public class AdaptiveCpuLoadProbe extends Object implements AdaptiveLoadProbe
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 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.
|
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() |
public AdaptiveCpuLoadProbe()
public AdaptiveCpuLoadProbe(boolean useAvg, boolean useProcs)
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.
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
).public AdaptiveCpuLoadProbe(boolean useAvg, boolean useProcs, double procCoefficient)
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
.
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
).public boolean isUseAverage()
public void setUseAverage(boolean useAvg)
true
.useAvg
- Flag indicating whether to use average CPU load vs. current.public boolean isUseProcessors()
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.
true
).public void setUseProcessors(boolean useProcs)
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
.
useProcs
- Flag indicating whether to divide each node's CPU load
by the number of processors on that node (default is true
).public double getProcessorCoefficient()
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
.
public void setProcessorCoefficient(double procCoefficient)
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
.
procCoefficient
- Coefficient of every CPU processor.public double getLoad(ClusterNode node, int jobsSentSinceLastUpdate)
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.
getLoad
in interface AdaptiveLoadProbe
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.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.16.0 Release Date : December 15 2023