Package org.elasticsearch.gateway
Class BaseGatewayShardAllocator
java.lang.Object
org.elasticsearch.gateway.BaseGatewayShardAllocator
- Direct Known Subclasses:
PrimaryShardAllocator
,ReplicaShardAllocator
An abstract class that implements basic functionality for allocating
shards to nodes based on shard copies that already exist in the cluster.
Individual implementations of this class are responsible for providing
the logic to determine to which nodes (if any) those shards are allocated.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
allocateUnassigned(ShardRouting shardRouting, RoutingAllocation allocation, ExistingShardsAllocator.UnassignedAllocationHandler unassignedAllocationHandler)
Allocate an unassigned shard to nodes (if any) where valid copies of the shard already exist.protected static List<NodeAllocationResult>
buildDecisionsForAllNodes(ShardRouting shard, RoutingAllocation allocation)
Builds decisions for all nodes in the cluster, so that the explain API can provide information on allocation decisions for each node, while still waiting to allocate the shard (e.g.protected long
getExpectedShardSize(ShardRouting shardRouting, RoutingAllocation allocation)
abstract AllocateUnassignedDecision
makeAllocationDecision(ShardRouting unassignedShard, RoutingAllocation allocation, org.apache.logging.log4j.Logger logger)
Make a decision on the allocation of an unassigned shard.
-
Field Details
-
logger
protected final org.apache.logging.log4j.Logger logger
-
-
Constructor Details
-
BaseGatewayShardAllocator
public BaseGatewayShardAllocator()
-
-
Method Details
-
allocateUnassigned
public void allocateUnassigned(ShardRouting shardRouting, RoutingAllocation allocation, ExistingShardsAllocator.UnassignedAllocationHandler unassignedAllocationHandler)Allocate an unassigned shard to nodes (if any) where valid copies of the shard already exist. It is up to the individual implementations ofmakeAllocationDecision(ShardRouting, RoutingAllocation, Logger)
to make decisions on assigning shards to nodes.- Parameters:
shardRouting
- the shard to allocateallocation
- the allocation state container objectunassignedAllocationHandler
- handles the allocation of the current shard
-
getExpectedShardSize
-
makeAllocationDecision
public abstract AllocateUnassignedDecision makeAllocationDecision(ShardRouting unassignedShard, RoutingAllocation allocation, org.apache.logging.log4j.Logger logger)Make a decision on the allocation of an unassigned shard. This method is used byallocateUnassigned(ShardRouting, RoutingAllocation, ExistingShardsAllocator.UnassignedAllocationHandler)
to make decisions about whether or not the shard can be allocated by this allocator and if so, to which node it will be allocated.- Parameters:
unassignedShard
- the unassigned shard to allocateallocation
- the current routing statelogger
- the logger- Returns:
- an
AllocateUnassignedDecision
with the final decision of whether to allocate and details of the decision
-
buildDecisionsForAllNodes
protected static List<NodeAllocationResult> buildDecisionsForAllNodes(ShardRouting shard, RoutingAllocation allocation)Builds decisions for all nodes in the cluster, so that the explain API can provide information on allocation decisions for each node, while still waiting to allocate the shard (e.g. due to fetching shard data).
-