Class RoutingAllocation
java.lang.Object
org.elasticsearch.cluster.routing.allocation.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.-
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, SnapshotShardSizeInfo shardSizeInfo, 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.SnapshotShardSizeInfo
snapshotShardSizeInfo()
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 nodesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
RoutingAllocation
public RoutingAllocation(AllocationDeciders deciders, RoutingNodes routingNodes, ClusterState clusterState, ClusterInfo clusterInfo, SnapshotShardSizeInfo shardSizeInfo, 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 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
GetAllocationDeciders
used for allocation- Returns:
AllocationDeciders
used for allocation
-
routingTable
Get routing table of current nodes- Returns:
- current routing table
-
routingNodes
Get current routing nodes- Returns:
- routing nodes
-
metadata
Get metadata of routing nodes- Returns:
- Metadata of routing nodes
-
nodes
Get discovery nodes in current routing- Returns:
- discovery nodes
-
clusterInfo
-
snapshotShardSizeInfo
-
custom
-
getCustoms
-
ignoreDisable
public void ignoreDisable(boolean ignoreDisable) -
ignoreDisable
public boolean ignoreDisable() -
setDebugMode
-
debugDecision
public void debugDecision(boolean debug) -
debugDecision
public boolean debugDecision() -
getDebugMode
-
addIgnoreShardForNode
-
shouldIgnoreShardForNode
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
-
removeAllocationId
Remove the allocation id of the provided shard from the set of in-sync shard copies -
changes
Returns observer to use for changes made to the routing nodes -
updateMetadataWithRoutingChanges
Returns updatedMetadata
based on the changes that were made to the routing nodes -
updateRestoreInfoWithRoutingChanges
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.
-