public interface AdaptiveLoadProbe
AdaptiveLoadBalancingSpi
by setting AdaptiveLoadBalancingSpi.setLoadProbe(AdaptiveLoadProbe)
configuration parameter.
Note that if getLoad(org.apache.ignite.cluster.ClusterNode, 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.
By default, AdaptiveCpuLoadProbe
probing implementation is used.
public class FooBarLoadProbe implements GridAdaptiveLoadProbe { // Flag indicating whether to use average value or current. private int useAvg = true; public FooBarLoadProbe(boolean useAvg) { this.useAvg = useAvg; } // Calculate load based on number of active and waiting jobs. public double getLoad(ClusterNode node, int jobsSentSinceLastUpdate) { GridNodeMetrics metrics = node.getMetrics(); if (useAvg) { double load = metrics.getAverageActiveJobs() + metrics.getAverageWaitingJobs(); if (load > 0) { return load; } } return metrics.getCurrentActiveJobs() + metrics.getCurrentWaitingJobs(); } }Below is an example of how a probe shown above would be configured with
AdaptiveLoadBalancingSpi
SPI:
<property name="loadBalancingSpi"> <bean class="org.apache.ignite.spi.loadBalancing.adaptive.GridAdaptiveLoadBalancingSpi"> <property name="loadProbe"> <bean class="foo.bar.FooBarLoadProbe"> <constructor-arg value="true"/> </bean> </property> </bean> </property>
Modifier and Type | Method and Description |
---|---|
double |
getLoad(ClusterNode node,
int jobsSentSinceLastUpdate)
Calculates load value for a given node.
|
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.
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.
GridGain In-Memory Computing Platform : ver. 8.9.14 Release Date : November 5 2024