Class RoutingAllocation
java.lang.Object
org.elasticsearch.cluster.routing.allocation.RoutingAllocation
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
-
Constructor Summary
ConstructorDescriptionRoutingAllocation(AllocationDeciders deciders, RoutingNodes routingNodes, ClusterState clusterState, ClusterInfo clusterInfo, SnapshotShardSizeInfo shardSizeInfo, long currentNanoTime)
Creates a newRoutingAllocation
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addIgnoreShardForNode(ShardId shardId, String nodeId)
changes()
Returns observer to use for changes made to the routing nodes<T extends ClusterState.Custom>
Tboolean
void
debugDecision(boolean debug)
deciders()
GetAllocationDeciders
used for allocationCreate a routing decision, including the reason if the debug flag is turned onlong
returns the nano time captured at the beginning of the allocation.getIgnoreNodes(ShardId shardId)
boolean
Returnstrue
iff the current allocation run has not processed all of the in-flight or available shard or store fetches.boolean
void
ignoreDisable(boolean ignoreDisable)
metadata()
Get metadata of routing nodesnodes()
Get discovery nodes in current routingvoid
removeAllocationId(ShardRouting shardRouting)
Remove the allocation id of the provided shard from the set of in-sync shard copiesGet current routing nodesboolean
Returns true iff changes were made to the routing nodesGet routing table of current nodesvoid
void
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, 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.updateMetadataWithRoutingChanges(RoutingTable newRoutingTable)
Returns updatedMetadata
based on the changes that were made to the routing nodesupdateRestoreInfoWithRoutingChanges(RestoreInProgress restoreInProgress)
Returns updatedRestoreInProgress
based on the changes that were made to the routing nodes
-
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
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.
-