Class 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  
    • Field Detail

      • logger

        protected final org.apache.logging.log4j.Logger logger
    • Constructor Detail

      • BaseGatewayShardAllocator

        public BaseGatewayShardAllocator()
    • 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 of makeAllocationDecision(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 by allocateUnassigned(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 allocate
        allocation - the current routing state
        logger - 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).