Class RoutingAllocation


  • public class RoutingAllocation
    extends java.lang.Object
    The RoutingAllocation keep the state of the current allocation of shards and holds the AllocationDeciders which are responsible for the current routing state.
    • Constructor Detail

      • RoutingAllocation

        public RoutingAllocation​(AllocationDeciders deciders,
                                 RoutingNodes routingNodes,
                                 ClusterState clusterState,
                                 ClusterInfo clusterInfo,
                                 long currentNanoTime)
        Creates a new RoutingAllocation
        Parameters:
        deciders - AllocationDeciders to used to make decisions for routing allocations
        routingNodes - Routing nodes in the current cluster
        clusterState - cluster state before rerouting
        currentNanoTime - the nano time to use for all delay allocation calculation (typically System.nanoTime())
    • Method Detail

      • getCurrentNanoTime

        public long getCurrentNanoTime()
        returns the nano time captured at the beginning of the allocation. used to make sure all time based decisions are aligned
      • routingTable

        public RoutingTable routingTable()
        Get routing table of current nodes
        Returns:
        current routing table
      • routingNodes

        public RoutingNodes routingNodes()
        Get current routing nodes
        Returns:
        routing nodes
      • metaData

        public MetaData metaData()
        Get metadata of routing nodes
        Returns:
        Metadata of routing nodes
      • nodes

        public DiscoveryNodes nodes()
        Get discovery nodes in current routing
        Returns:
        discovery nodes
      • ignoreDisable

        public void ignoreDisable​(boolean ignoreDisable)
      • ignoreDisable

        public boolean ignoreDisable()
      • debugDecision

        public void debugDecision​(boolean debug)
      • debugDecision

        public boolean debugDecision()
      • addIgnoreShardForNode

        public void addIgnoreShardForNode​(ShardId shardId,
                                          java.lang.String nodeId)
      • shouldIgnoreShardForNode

        public boolean shouldIgnoreShardForNode​(ShardId shardId,
                                                java.lang.String nodeId)
        Returns whether the given node id should be ignored from consideration when AllocationDeciders is deciding whether to allocate the specified shard id to that node. The node will be ignored if the specified shard failed on that node, triggering the current round of allocation. Since the shard just failed on that node, we don't want to try to reassign it there, if the node is still a part of the cluster.
        Parameters:
        shardId - the shard id to be allocated
        nodeId - the node id to check against
        Returns:
        true if the node id should be ignored in allocation decisions, false otherwise
      • getIgnoreNodes

        public java.util.Set<java.lang.String> getIgnoreNodes​(ShardId shardId)
      • removeAllocationId

        public void removeAllocationId​(ShardRouting shardRouting)
        Remove the allocation id of the provided shard from the set of in-sync shard copies
      • changes

        public RoutingChangesObserver changes()
        Returns observer to use for changes made to the routing nodes
      • updateMetaDataWithRoutingChanges

        public MetaData updateMetaDataWithRoutingChanges​(RoutingTable newRoutingTable)
        Returns updated MetaData based on the changes that were made to the routing nodes
      • routingNodesChanged

        public boolean routingNodesChanged()
        Returns true iff changes were made to the routing nodes
      • decision

        public Decision decision​(Decision decision,
                                 java.lang.String deciderLabel,
                                 java.lang.String reason,
                                 java.lang.Object... params)
        Create a routing decision, including the reason if the debug flag is turned on
        Parameters:
        decision - decision whether to allow/deny allocation
        deciderLabel - a human readable label for the AllocationDecider
        reason - a format string explanation of the decision
        params - format string parameters
      • hasPendingAsyncFetch

        public boolean hasPendingAsyncFetch()
        Returns true iff the current allocation run has not processed all of the in-flight or available shard or store fetches. Otherwise true
      • setHasPendingAsyncFetch

        public void setHasPendingAsyncFetch()
        Sets a flag that signals that current allocation run has not processed all of the in-flight or available shard or store fetches. This state is anti-viral and can be reset in on allocation run.