Class RoutingAllocation

java.lang.Object
org.elasticsearch.cluster.routing.allocation.RoutingAllocation

public class RoutingAllocation extends 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 Details

  • Method Details

    • 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
    • deciders

      public AllocationDeciders deciders()
      Get AllocationDeciders used for allocation
      Returns:
      AllocationDeciders used for allocation
    • 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
    • clusterInfo

      public ClusterInfo clusterInfo()
    • snapshotShardSizeInfo

      public SnapshotShardSizeInfo snapshotShardSizeInfo()
    • nodeShutdowns

      public Map<String,SingleNodeShutdownMetadata> nodeShutdowns()
      Returns the map of node id to shutdown metadata currently in the cluster
    • replacementTargetShutdowns

      public Map<String,SingleNodeShutdownMetadata> replacementTargetShutdowns()
      Returns a map of target node name to replacement shutdown
    • custom

      public <T extends ClusterState.Custom> T custom(String key)
    • getCustoms

    • ignoreDisable

      public void ignoreDisable(boolean ignoreDisable)
    • ignoreDisable

      public boolean ignoreDisable()
    • setDebugMode

      public void setDebugMode(RoutingAllocation.DebugMode debug)
    • debugDecision

      public void debugDecision(boolean debug)
    • debugDecision

      public boolean debugDecision()
    • getDebugMode

      public RoutingAllocation.DebugMode getDebugMode()
    • addIgnoreShardForNode

      public void addIgnoreShardForNode(ShardId shardId, String nodeId)
    • shouldIgnoreShardForNode

      public boolean shouldIgnoreShardForNode(ShardId shardId, 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 Set<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
    • updateRestoreInfoWithRoutingChanges

      public RestoreInProgress updateRestoreInfoWithRoutingChanges(RestoreInProgress restoreInProgress)
      Returns updated RestoreInProgress 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, String deciderLabel, String reason, 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.