Class RoutingAllocation
- java.lang.Object
-
- org.elasticsearch.cluster.routing.allocation.RoutingAllocation
-
public class RoutingAllocation extends java.lang.Object
TheRoutingAllocation
keep the state of the current allocation of shards and holds theAllocationDeciders
which are responsible for the current routing state.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RoutingAllocation.DebugMode
-
Constructor Summary
Constructors Constructor Description RoutingAllocation(AllocationDeciders deciders, RoutingNodes routingNodes, ClusterState clusterState, ClusterInfo clusterInfo, long currentNanoTime)
Creates a newRoutingAllocation
-
Method Summary
Modifier and Type Method Description void
addIgnoreShardForNode(ShardId shardId, java.lang.String nodeId)
RoutingChangesObserver
changes()
Returns observer to use for changes made to the routing nodesClusterInfo
clusterInfo()
<T extends ClusterState.Custom>
Tcustom(java.lang.String key)
boolean
debugDecision()
void
debugDecision(boolean debug)
AllocationDeciders
deciders()
GetAllocationDeciders
used for allocationDecision
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 onlong
getCurrentNanoTime()
returns the nano time captured at the beginning of the allocation.ImmutableOpenMap<java.lang.String,ClusterState.Custom>
getCustoms()
RoutingAllocation.DebugMode
getDebugMode()
java.util.Set<java.lang.String>
getIgnoreNodes(ShardId shardId)
boolean
hasPendingAsyncFetch()
Returnstrue
iff the current allocation run has not processed all of the in-flight or available shard or store fetches.boolean
ignoreDisable()
void
ignoreDisable(boolean ignoreDisable)
MetaData
metaData()
Get metadata of routing nodesDiscoveryNodes
nodes()
Get discovery nodes in current routingvoid
removeAllocationId(ShardRouting shardRouting)
Remove the allocation id of the provided shard from the set of in-sync shard copiesRoutingNodes
routingNodes()
Get current routing nodesboolean
routingNodesChanged()
Returns true iff changes were made to the routing nodesRoutingTable
routingTable()
Get routing table of current nodesvoid
setDebugMode(RoutingAllocation.DebugMode debug)
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.boolean
shouldIgnoreShardForNode(ShardId shardId, java.lang.String nodeId)
Returns whether the given node id should be ignored from consideration whenAllocationDeciders
is deciding whether to allocate the specified shard id to that node.MetaData
updateMetaDataWithRoutingChanges(RoutingTable newRoutingTable)
Returns updatedMetaData
based on the changes that were made to the routing nodesRestoreInProgress
updateRestoreInfoWithRoutingChanges(RestoreInProgress restoreInProgress)
Returns updatedRestoreInProgress
based on the changes that were made to the routing nodes
-
-
-
Constructor Detail
-
RoutingAllocation
public RoutingAllocation(AllocationDeciders deciders, RoutingNodes routingNodes, ClusterState clusterState, ClusterInfo clusterInfo, long currentNanoTime)
Creates a newRoutingAllocation
- Parameters:
deciders
-AllocationDeciders
to used to make decisions for routing allocationsroutingNodes
- Routing nodes in the current clusterclusterState
- cluster state before reroutingcurrentNanoTime
- the nano time to use for all delay allocation calculation (typicallySystem.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
-
deciders
public AllocationDeciders deciders()
GetAllocationDeciders
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()
-
custom
public <T extends ClusterState.Custom> T custom(java.lang.String key)
-
getCustoms
public ImmutableOpenMap<java.lang.String,ClusterState.Custom> 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, 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 whenAllocationDeciders
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 allocatednodeId
- 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 updatedMetaData
based on the changes that were made to the routing nodes
-
updateRestoreInfoWithRoutingChanges
public RestoreInProgress updateRestoreInfoWithRoutingChanges(RestoreInProgress restoreInProgress)
Returns updatedRestoreInProgress
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 allocationdeciderLabel
- a human readable label for the AllocationDeciderreason
- a format string explanation of the decisionparams
- format string parameters
-
hasPendingAsyncFetch
public boolean hasPendingAsyncFetch()
Returnstrue
iff the current allocation run has not processed all of the in-flight or available shard or store fetches. Otherwisetrue
-
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.
-
-