Module org.elasticsearch.server
Record Class DesiredBalance
java.lang.Object
java.lang.Record
org.elasticsearch.cluster.routing.allocation.allocator.DesiredBalance
- Record Components:
lastConvergedIndex- Identifies what input data the balancer computation round used to produce thisDesiredBalance. SeeDesiredBalanceInput.index()for details. Each reroute request in the same master term is assigned a strictly increasing sequence number. A new master term restarts the index values from zero. The balancer, which runs async to reroute, uses the latest request's data to compute the desired balance.assignments- a set of the (persistent) node IDs to which eachShardIdshould be allocatedweightsPerNode- The node weights calculated based onWeightFunction.calculateNodeWeight(int, float, double, double, double, double)
public record DesiredBalance(long lastConvergedIndex, Map<ShardId,ShardAssignment> assignments, Map<DiscoveryNode,DesiredBalanceMetrics.NodeWeightStats> weightsPerNode, org.elasticsearch.cluster.routing.allocation.allocator.DesiredBalance.ComputationFinishReason finishReason)
extends Record
The desired balance of the cluster, indicating which nodes should hold a copy of each shard.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DesiredBalanceThe starting value forDesiredBalancewhen the node becomes the master.static final DesiredBalanceThe placeholder value forDesiredBalancewhen the node stands down as master. -
Constructor Summary
ConstructorsConstructorDescriptionDesiredBalance(long lastConvergedIndex, Map<ShardId, ShardAssignment> assignments) DesiredBalance(long lastConvergedIndex, Map<ShardId, ShardAssignment> assignments, Map<DiscoveryNode, DesiredBalanceMetrics.NodeWeightStats> weightsPerNode, org.elasticsearch.cluster.routing.allocation.allocator.DesiredBalance.ComputationFinishReason finishReason) Creates an instance of aDesiredBalancerecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theassignmentsrecord component.final booleanIndicates whether some other object is "equal to" this one.org.elasticsearch.cluster.routing.allocation.allocator.DesiredBalance.ComputationFinishReasonReturns the value of thefinishReasonrecord component.getAssignment(ShardId shardId) static booleanfinal inthashCode()Returns a hash code value for this object.static StringhumanReadableDiff(DesiredBalance old, DesiredBalance updated) longReturns the value of thelastConvergedIndexrecord component.static intshardMovements(DesiredBalance old, DesiredBalance updated) Returns the sum of shard movements needed to reach the new desired balance.final StringtoString()Returns a string representation of this record class.Returns the value of theweightsPerNoderecord component.
-
Field Details
-
NOT_MASTER
The placeholder value forDesiredBalancewhen the node stands down as master. -
BECOME_MASTER_INITIAL
The starting value forDesiredBalancewhen the node becomes the master.
-
-
Constructor Details
-
DesiredBalance
-
DesiredBalance
public DesiredBalance(long lastConvergedIndex, Map<ShardId, ShardAssignment> assignments, Map<DiscoveryNode, DesiredBalanceMetrics.NodeWeightStats> weightsPerNode, org.elasticsearch.cluster.routing.allocation.allocator.DesiredBalance.ComputationFinishReason finishReason) Creates an instance of aDesiredBalancerecord class.- Parameters:
lastConvergedIndex- the value for thelastConvergedIndexrecord componentassignments- the value for theassignmentsrecord componentweightsPerNode- the value for theweightsPerNoderecord componentfinishReason- the value for thefinishReasonrecord component
-
-
Method Details
-
getAssignment
-
hasChanges
-
shardMovements
Returns the sum of shard movements needed to reach the new desired balance. Doesn't count new shard copies as a move, nor removal or unassignment of a shard copy. -
humanReadableDiff
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
lastConvergedIndex
public long lastConvergedIndex()Returns the value of thelastConvergedIndexrecord component.- Returns:
- the value of the
lastConvergedIndexrecord component
-
assignments
Returns the value of theassignmentsrecord component.- Returns:
- the value of the
assignmentsrecord component
-
weightsPerNode
Returns the value of theweightsPerNoderecord component.- Returns:
- the value of the
weightsPerNoderecord component
-
finishReason
public org.elasticsearch.cluster.routing.allocation.allocator.DesiredBalance.ComputationFinishReason finishReason()Returns the value of thefinishReasonrecord component.- Returns:
- the value of the
finishReasonrecord component
-