Module org.elasticsearch.server
Class DesiredBalanceShardsAllocator
java.lang.Object
org.elasticsearch.cluster.routing.allocation.allocator.DesiredBalanceShardsAllocator
- All Implemented Interfaces:
ShardsAllocator
A
ShardsAllocator which asynchronously refreshes the desired balance held by the DesiredBalanceComputer and then takes
steps towards the desired balance using the DesiredBalanceReconciler.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CounterMetricprotected final CounterMetricprotected final CounterMetricprotected final MeanMetricprotected final CounterMetricprotected final CounterMetric -
Constructor Summary
ConstructorsConstructorDescriptionDesiredBalanceShardsAllocator(ShardsAllocator delegateAllocator, ThreadPool threadPool, ClusterService clusterService, DesiredBalanceComputer desiredBalanceComputer, DesiredBalanceShardsAllocator.DesiredBalanceReconcilerAction reconciler, TelemetryProvider telemetryProvider, NodeAllocationStatsAndWeightsCalculator nodeAllocationStatsAndWeightsCalculator) DesiredBalanceShardsAllocator(ClusterSettings clusterSettings, ShardsAllocator delegateAllocator, ThreadPool threadPool, ClusterService clusterService, DesiredBalanceShardsAllocator.DesiredBalanceReconcilerAction reconciler, TelemetryProvider telemetryProvider, NodeAllocationStatsAndWeightsCalculator nodeAllocationStatsAndWeightsCalculator) -
Method Summary
Modifier and TypeMethodDescriptionvoidallocate(RoutingAllocation allocation) Allocates shards to nodes in the cluster.voidallocate(RoutingAllocation allocation, ActionListener<Void> listener) Allocates shards to nodes in the cluster.protected final voiddecideShardAllocation(ShardRouting shard, RoutingAllocation allocation) Returns the decision for where a shard should reside in the cluster.execute(RoutingAllocation allocation, AllocationCommands commands, boolean explain, boolean retryFailed) Execute allocation commandsgetStats()protected voidreconcile(DesiredBalance desiredBalance, RoutingAllocation allocation) voidprotected voidsubmitReconcileTask(DesiredBalance desiredBalance) Submits the desired balance to be reconciled (applies the desired changes to the routing table) and creates and publishes a new cluster state.
-
Field Details
-
computationsSubmitted
-
computationsExecuted
-
computationsConverged
-
computedShardMovements
-
cumulativeComputationTime
-
cumulativeReconciliationTime
-
-
Constructor Details
-
DesiredBalanceShardsAllocator
public DesiredBalanceShardsAllocator(ClusterSettings clusterSettings, ShardsAllocator delegateAllocator, ThreadPool threadPool, ClusterService clusterService, DesiredBalanceShardsAllocator.DesiredBalanceReconcilerAction reconciler, TelemetryProvider telemetryProvider, NodeAllocationStatsAndWeightsCalculator nodeAllocationStatsAndWeightsCalculator) -
DesiredBalanceShardsAllocator
public DesiredBalanceShardsAllocator(ShardsAllocator delegateAllocator, ThreadPool threadPool, ClusterService clusterService, DesiredBalanceComputer desiredBalanceComputer, DesiredBalanceShardsAllocator.DesiredBalanceReconcilerAction reconciler, TelemetryProvider telemetryProvider, NodeAllocationStatsAndWeightsCalculator nodeAllocationStatsAndWeightsCalculator)
-
-
Method Details
-
decideShardAllocation
public ShardAllocationDecision decideShardAllocation(ShardRouting shard, RoutingAllocation allocation) Description copied from interface:ShardsAllocatorReturns the decision for where a shard should reside in the cluster. If the shard is unassigned, then theAllocateUnassignedDecisionwill be non-null. If the shard is not in the unassigned state, then theMoveDecisionwill be non-null. This method is primarily used by the cluster allocation explain API to provide detailed explanations for the allocation of a single shard. Implementations of theShardsAllocator.allocate(RoutingAllocation)method may use the results of this method implementation to decide on allocating shards in the routing table to the cluster. If an implementation of this interface does not support explaining decisions for a single shard through the cluster explain API, then this method should throw aUnsupportedOperationException.- Specified by:
decideShardAllocationin interfaceShardsAllocator
-
allocate
Description copied from interface:ShardsAllocatorAllocates shards to nodes in the cluster. An implementation of this method should: - assign unassigned shards - relocate shards that cannot stay on a node anymore - relocate shards to find a good shard balance in the cluster- Specified by:
allocatein interfaceShardsAllocator- Parameters:
allocation- current node allocation
-
allocate
Description copied from interface:ShardsAllocatorAllocates shards to nodes in the cluster. An implementation of this method should: - assign unassigned shards - relocate shards that cannot stay on a node anymore - relocate shards to find a good shard balance in the cluster- Specified by:
allocatein interfaceShardsAllocator- Parameters:
allocation- current node allocationlistener- listener to be executed once async allocation is completed
-
execute
public RoutingExplanations execute(RoutingAllocation allocation, AllocationCommands commands, boolean explain, boolean retryFailed) Description copied from interface:ShardsAllocatorExecute allocation commands- Specified by:
executein interfaceShardsAllocator
-
submitReconcileTask
Submits the desired balance to be reconciled (applies the desired changes to the routing table) and creates and publishes a new cluster state. The data nodes will receive and apply the new cluster state to start/move/remove shards. -
reconcile
-
getDesiredBalance
-
resetDesiredBalance
public void resetDesiredBalance() -
getStats
-
completeToLastConvergedIndex
protected final void completeToLastConvergedIndex()
-