Package org.elasticsearch.gateway
Class BaseGatewayShardAllocator
- java.lang.Object
-
- org.elasticsearch.gateway.BaseGatewayShardAllocator
-
- Direct Known Subclasses:
PrimaryShardAllocator
,ReplicaShardAllocator
public abstract class BaseGatewayShardAllocator extends java.lang.Object
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
Fields Modifier and Type Field Description protected org.apache.logging.log4j.Logger
logger
-
Constructor Summary
Constructors Constructor Description BaseGatewayShardAllocator()
-
Method Summary
Modifier and Type Method Description void
allocateUnassigned(RoutingAllocation allocation)
Allocate unassigned shards to nodes (if any) where valid copies of the shard already exist.protected java.util.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.abstract AllocateUnassignedDecision
makeAllocationDecision(ShardRouting unassignedShard, RoutingAllocation allocation, org.apache.logging.log4j.Logger logger)
Make a decision on the allocation of an unassigned shard.
-
-
-
Method Detail
-
allocateUnassigned
public void allocateUnassigned(RoutingAllocation allocation)
Allocate unassigned shards 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:
allocation
- the allocation state container object
-
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(RoutingAllocation)
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 java.util.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).
-
-