Module org.elasticsearch.server
Interface ShardsAllocator
- All Known Implementing Classes:
BalancedShardsAllocator,DesiredBalanceShardsAllocator
public interface ShardsAllocator
A ShardsAllocator is the main entry point for shard allocation on nodes in the cluster.
The allocator makes basic decision where a shard instance will be allocated, if already allocated instances
need to relocate to other nodes due to node failures or due to rebalancing decisions.
-
Method Summary
Modifier and TypeMethodDescriptionvoidallocate(RoutingAllocation allocation) Allocates shards to nodes in the cluster.default voidallocate(RoutingAllocation allocation, ActionListener<Void> listener) Allocates shards to nodes in the cluster.default RoutingExplanationsexecute(RoutingAllocation allocation, AllocationCommands commands, boolean explain, boolean retryFailed) Execute allocation commandsexplainShardAllocation(ShardRouting shard, RoutingAllocation allocation) Returns the decision for where a shard should reside in the cluster.default Function<ShardRouting, ShardAllocationDecision> explainShardAllocationFunction(RoutingAllocation allocation) Similar to explainShardAllocation, but returns a Function that is more efficient for explaining many shards in a bulk circumstance.
-
Method Details
-
allocate
Allocates 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- Parameters:
allocation- current node allocation
-
allocate
Allocates 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- Parameters:
allocation- current node allocationlistener- listener to be executed once async allocation is completed
-
execute
default RoutingExplanations execute(RoutingAllocation allocation, AllocationCommands commands, boolean explain, boolean retryFailed) Execute allocation commands -
explainShardAllocation
Returns 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. 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. -
explainShardAllocationFunction
default Function<ShardRouting,ShardAllocationDecision> explainShardAllocationFunction(RoutingAllocation allocation) Similar to explainShardAllocation, but returns a Function that is more efficient for explaining many shards in a bulk circumstance. Internally, an allocator builds up internal data structures for simulating its balancing algorithm. In some implementations, such as the BalancedShardsAllocator (also used within the DesiredBalanceAllocator), this internal context is computationally expensive. When run over many shards, it can be Order(shards * nodes). Instead of taking a shard and explaining it, explainShardAllocationFunction returns a Function that can be called repeatedly to explain multiple shards while reusing the context in the Function's closure. This reduces the computational cost of explain.
-