Module org.elasticsearch.server
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
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionRoutingAllocation
(AllocationDeciders deciders, ClusterState clusterState, ClusterInfo clusterInfo, SnapshotShardSizeInfo shardSizeInfo, long currentNanoTime) RoutingAllocation
(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) boolean
boolean
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 copiesReturns a map of target node name to replacement shutdownGet 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.void
setSimulatedClusterInfo
(ClusterInfo clusterInfo) 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.long
unaccountedSearchableSnapshotSize
(RoutingNode routingNode) Returns an approximation of the size (in bytes) of the unaccounted searchable snapshots before the allocationupdateMetadataWithRoutingChanges
(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 nodesSet theisReconciling
flag, and return aReleasable
which clears it again.
-
Constructor Details
-
RoutingAllocation
public RoutingAllocation(AllocationDeciders deciders, ClusterState clusterState, ClusterInfo clusterInfo, SnapshotShardSizeInfo shardSizeInfo, long currentNanoTime) -
RoutingAllocation
public RoutingAllocation(AllocationDeciders deciders, @Nullable RoutingNodes routingNodes, ClusterState clusterState, @Nullable 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 cluster ornull
if using those in the given cluster stateclusterState
- cluster state before reroutingclusterInfo
- information about node disk usage and shard disk usageshardSizeInfo
- information about snapshot shard sizescurrentNanoTime
- 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
-
getClusterState
-
clusterInfo
-
snapshotShardSizeInfo
-
desiredNodes
-
replacementTargetShutdowns
Returns a map of target node name to replacement shutdown -
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. -
unaccountedSearchableSnapshotSize
Returns an approximation of the size (in bytes) of the unaccounted searchable snapshots before the allocation -
isSimulating
public boolean isSimulating()- Returns:
true
if this allocation computation is trying to simulate the final allocation and therefore "transient" allocation blockers should be ignored.
-
isReconciling
public boolean isReconciling()- Returns:
true
if this allocation computation is trying to reconcile towards a previously-computed allocation and therefore path-dependent allocation blockers should be ignored.
-
withReconcilingFlag
Set theisReconciling
flag, and return aReleasable
which clears it again. -
setSimulatedClusterInfo
-
immutableClone
-
mutableCloneForSimulation
-