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 istrue
).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 to0.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 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 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 istrue
).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 istrue
).String
toString()
-
-
-
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 istrue
).useProcs
- Flag indicating whether to divide each node's CPU load by the number of processors on that node (default istrue
).
-
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 istrue
).useProcs
- Flag indicating whether to divide each node's CPU load by the number of processors on that node (default istrue
).procCoefficient
- Coefficient of every CPU processor (default value is1
).
-
-
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 istrue
.- 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 istrue
).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 istrue
).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 istrue
).
-
getProcessorCoefficient
public double getProcessorCoefficient()
Gets coefficient of every CPU processor. By default it is1
, 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 to0.75
.This value is ignored if
isUseProcessors()
is set tofalse
.- Returns:
- Coefficient of every CPU processor.
-
setProcessorCoefficient
public void setProcessorCoefficient(double procCoefficient)
Sets coefficient of every CPU processor. By default it is1
, 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 to0.75
.This value is ignored if
isUseProcessors()
is set tofalse
.- 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 byClusterNode.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 are0
), then a value of1
will be used.- Specified by:
getLoad
in interfaceAdaptiveLoadProbe
- 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).
-
-