org.apache.ignite.spi.loadbalancing.adaptive

## Class AdaptiveCpuLoadProbe

- java.lang.Object
- - org.apache.ignite.spi.loadbalancing.adaptive.AdaptiveCpuLoadProbe

- All Implemented Interfaces:
    AdaptiveLoadProbe

      public class AdaptiveCpuLoadProbe
      extends Object
      implements AdaptiveLoadProbe

  Implementation of node load probing based on CPU load.

  Based on `setUseAverage(boolean)` parameter, this implementation will either use average CPU load values or current (default is to use averages).

  Based on `setUseProcessors(boolean)` parameter, this implementation will either take number of processors on the node into account or not. Since CPU load on multi-processor boxes shows medium load of multiple CPU's it usually means that the remaining capacity is proportional to the number of CPU's (or cores) on the node. This configuration parameter indicates whether to divide each node's CPU load by the number of processors on that node (default is `true`).

  Also note that in some environments every processor may not be adding 100% of processing power. For example, if you are using multi-core CPU's, then addition of every core would probably result in about 75% of extra CPU power. To account for that, you should set `setProcessorCoefficient(double)` parameter to `0.75` .

  Below is an example of how CPU load probe would be configured in Ignite Spring configuration file:

       <property name="loadBalancingSpi">
           <bean class="org.apache.ignite.spi.loadBalancing.adaptive.GridAdaptiveLoadBalancingSpi">
               <property name="loadProbe">
                   <bean class="org.apache.ignite.spi.loadBalancing.adaptive.GridAdaptiveCpuLoadProbe">
                       <property name="useAverage" value="true"/>
                       <property name="useProcessors" value="true"/>
                       <property name="processorCoefficient" value="0.9"/>
                   </bean>
               </property>
           </bean>
       </property>

  This implementation is used by default by `AdaptiveLoadBalancingSpi` SPI.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AdaptiveCpuLoadProbe()` Initializes CPU load probe to use CPU load average by default.
    `AdaptiveCpuLoadProbe(boolean useAvg, boolean useProcs)` Specifies whether to use average CPU load vs. current and whether or not to take number of processors into account.
    `AdaptiveCpuLoadProbe(boolean useAvg, boolean useProcs, double procCoefficient)` Specifies whether to use average CPU load vs. current and whether or not to take number of processors into account.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `double` | `getLoad(ClusterNode node, int jobsSentSinceLastUpdate)` Calculates load value for a given node.
    `double` | `getProcessorCoefficient()` Gets coefficient of every CPU processor.
    `boolean` | `isUseAverage()` Gets flag indicating whether to use average CPU load vs. current.
    `boolean` | `isUseProcessors()` Gets flag indicating whether to use average CPU load vs. current (default is `true`).
    `void` | `setProcessorCoefficient(double procCoefficient)` Sets coefficient of every CPU processor.
    `void` | `setUseAverage(boolean useAvg)` Sets flag indicating whether to use average CPU load vs. current.
    `void` | `setUseProcessors(boolean useProcs)` Sets flag indicating whether to use average CPU load vs. current (default is `true`).
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### AdaptiveCpuLoadProbe

          public AdaptiveCpuLoadProbe()

      Initializes CPU load probe to use CPU load average by default.

    - #### AdaptiveCpuLoadProbe

          public AdaptiveCpuLoadProbe(boolean useAvg,
                                      boolean useProcs)

      Specifies whether to use average CPU load vs. current and whether or not to take number of processors into account.

      Since CPU load on multi-processor boxes shows medium load of multiple CPU's it usually means that the remaining capacity is proportional to the number of CPU's (or cores) on the node.

      Parameters:
        `useAvg` - Flag indicating whether to use average CPU load vs. current (default is `true`).
        `useProcs` - Flag indicating whether to divide each node's CPU load by the number of processors on that node (default is `true`).

    - #### AdaptiveCpuLoadProbe

          public AdaptiveCpuLoadProbe(boolean useAvg,
                                      boolean useProcs,
                                      double procCoefficient)

      Specifies whether to use average CPU load vs. current and whether or not to take number of processors into account. It also allows to specify the coefficient of addition power every CPU adds.

      Since CPU load on multi-processor boxes shows medium load of multiple CPU's it usually means that the remaining capacity is proportional to the number of CPU's (or cores) on the node.

      Also, in some environments every processor may not be adding 100% of processing power. For example, if you are using multi-core CPU's, then addition of every core would probably result in about 75% of extra CPU power, and hence you would set this coefficient to `0.75` .

      Parameters:
        `useAvg` - Flag indicating whether to use average CPU load vs. current (default is `true`).
        `useProcs` - Flag indicating whether to divide each node's CPU load by the number of processors on that node (default is `true`).
        `procCoefficient` - Coefficient of every CPU processor (default value is `1`).

  - ### Method Detail

    - #### isUseAverage

          public boolean isUseAverage()

      Gets flag indicating whether to use average CPU load vs. current.
      Returns:
        Flag indicating whether to use average CPU load vs. current.

    - #### setUseAverage

          public void setUseAverage(boolean useAvg)

      Sets flag indicating whether to use average CPU load vs. current. If not explicitly set, then default value is `true`.
      Parameters:
        `useAvg` - Flag indicating whether to use average CPU load vs. current.

    - #### isUseProcessors

          public boolean isUseProcessors()

      Gets flag indicating whether to use average CPU load vs. current (default is `true`).

      Since CPU load on multi-processor boxes shows medium load of multiple CPU's it usually means that the remaining capacity is proportional to the number of CPU's (or cores) on the node.

      Returns:
        Flag indicating whether to divide each node's CPU load by the number of processors on that node (default is `true`).

    - #### setUseProcessors

          public void setUseProcessors(boolean useProcs)

      Sets flag indicating whether to use average CPU load vs. current (default is `true`).

      Since CPU load on multi-processor boxes shows medium load of multiple CPU's it usually means that the remaining capacity is proportional to the number of CPU's (or cores) on the node.

      If not explicitly set, then default value is `true`.

      Parameters:
        `useProcs` - Flag indicating whether to divide each node's CPU load by the number of processors on that node (default is `true`).

    - #### getProcessorCoefficient

          public double getProcessorCoefficient()

      Gets coefficient of every CPU processor. By default it is `1`, but in some environments every processor may not be adding 100% of processing power. For example, if you are using multi-core CPU's, then addition of every core would probably result in about 75% of extra CPU power, and hence you would set this coefficient to `0.75` .

      This value is ignored if `isUseProcessors()` is set to `false`.

      Returns:
        Coefficient of every CPU processor.

    - #### setProcessorCoefficient

          public void setProcessorCoefficient(double procCoefficient)

      Sets coefficient of every CPU processor. By default it is `1`, but in some environments every processor may not be adding 100% of processing power. For example, if you are using multi-core CPU's, then addition of every core would probably result in about 75% of extra CPU power, and hence you would set this coefficient to `0.75` .

      This value is ignored if `isUseProcessors()` is set to `false`.

      Parameters:
        `procCoefficient` - Coefficient of every CPU processor.

    - #### getLoad

          public double getLoad(ClusterNode node,
                                int jobsSentSinceLastUpdate)

      Calculates load value for a given node. Specific implementations would usually take into account some of the values provided by `ClusterNode.metrics()` method. For example, load can be calculated based on job execution time or number of active jobs, or CPU/Heap utilization.

      Note that if this method returns a value of `0`, then implementation will assume that load value is simply not available and will try to calculate an average of load values for other nodes. If such average cannot be obtained (all node load values are `0`), then a value of `1` will be used.

      Specified by:
        `getLoad` in interface `AdaptiveLoadProbe`
      Parameters:
        `node` - Grid node to calculate load for.
        `jobsSentSinceLastUpdate` - Number of jobs sent to this node since last metrics update. This parameter may be useful when implementation takes into account the current job count on a node.
      Returns:
        Non-negative load value for the node (zero and above).

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

2021 Copyright © Apache Software Foundation
| Follow @ApacheIgnite
Ignite Database and Caching Platform | : ver. 2.11.0
Release Date | : September 11 2021