GridGain™ 2.0.3
Java API Specification

org.gridgain.grid.spi.loadbalancing.adaptive
Class GridAdaptiveCpuLoadProbe

java.lang.Object
  extended by org.gridgain.grid.spi.loadbalancing.adaptive.GridAdaptiveCpuLoadProbe
All Implemented Interfaces:
GridAdaptiveLoadProbe

public class GridAdaptiveCpuLoadProbe
extends Object
implements GridAdaptiveLoadProbe

Implementation of node load probing based on CPU load.

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

Based on GridAdaptiveCpuLoadProbe.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 GridAdaptiveCpuLoadProbe.setProcessorCoefficient(double) parameter to 0.75 .

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

 <property name="loadBalancingSpi">
     <bean class="org.gridgain.grid.spi.loadbalancing.adaptive.GridAdaptiveLoadBalancingSpi">
         <property name="loadProbe">
             <bean class="org.gridgain.grid.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 GridAdaptiveLoadBalancingSpi SPI.



See Also:

  Documentation
  Email Support
  Online Forums
  Issue Tracking

Author:   2005-2008 Copyright © GridGain Systems. All Rights Reserved. ver. 2.0.3

 

Constructor Summary
GridAdaptiveCpuLoadProbe()
          Initializes CPU load probe to use CPU load average by default.
GridAdaptiveCpuLoadProbe(boolean useAvg, boolean useProcs)
          Specifies whether to use average CPU load vs. current and whether or not to take number of processors into account.
GridAdaptiveCpuLoadProbe(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
 double getLoad(GridNode 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

GridAdaptiveCpuLoadProbe

public GridAdaptiveCpuLoadProbe()
Initializes CPU load probe to use CPU load average by default.


GridAdaptiveCpuLoadProbe

public GridAdaptiveCpuLoadProbe(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).

GridAdaptiveCpuLoadProbe

public GridAdaptiveCpuLoadProbe(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 GridAdaptiveCpuLoadProbe.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 GridAdaptiveCpuLoadProbe.isUseProcessors() is set to false.

Parameters:
procCoefficient - Coefficient of every CPU processor.

getLoad

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

Note that if GridAdaptiveLoadProbe.getLoad(GridNode, int) 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 GridAdaptiveLoadProbe
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

GridGain™ 2.0.3
Java API Specification

GridGain™ - Grid Computing Made Simple, ver. 2.0.3.20052008
2005-2008 Copyright © GridGain Systems. All Rights Reserved.