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 -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ClusterInfoprotected final ClusterStateprotected final longprotected final AllocationDecidersprotected final SnapshotShardSizeInfo -
Method Summary
Modifier and TypeMethodDescriptionvoidaddIgnoreShardForNode(ShardId shardId, String nodeId) abstract RoutingChangesObserverchanges()Returns observer to use for changes made to the routing nodesbooleanvoiddebugDecision(boolean debug) deciders()GetAllocationDecidersused for allocationCreate a routing decision, including the reason if the debug flag is turned on.longreturns the nano time captured at the beginning of the allocation.getIgnoreNodes(ShardId shardId) booleanReturnstrueiff the current allocation run has not processed all of the in-flight or available shard or store fetches.abstract booleanabstract voidignoreDisable(boolean ignoreDisable) static RoutingAllocationimmutable(AllocationDeciders deciders, ClusterState clusterState, ClusterInfo clusterInfo, SnapshotShardSizeInfo shardSizeInfo, long currentNanoTime) Deprecated.abstract booleanabstract booleanmetadata()Get metadata of routing nodesnodes()Get discovery nodes in current routingabstract voidremoveAllocationId(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 nodesabstract booleanReturns true iff changes were made to the routing nodesDeprecated.routingTable(ProjectId projectId) voidvoidSets a flag that signals that current allocation run has not processed all of the in-flight or available shard or store fetches.abstract voidsetSimulatedClusterInfo(ClusterInfo clusterInfo) booleanshouldIgnoreShardForNode(ShardId shardId, String nodeId) Returns whether the given node id should be ignored from consideration whenAllocationDecidersis deciding whether to allocate the specified shard id to that node.longunaccountedSearchableSnapshotSize(RoutingNode routingNode) Returns an approximation of the size (in bytes) of the unaccounted searchable snapshots before the allocationabstract MetadataupdateMetadataWithRoutingChanges(GlobalRoutingTable newRoutingTable) Returns updatedMetadatabased on the changes that were made to the routing nodesabstract RestoreInProgressupdateRestoreInfoWithRoutingChanges(RestoreInProgress restoreInProgress) Returns updatedRestoreInProgressbased on the changes that were made to the routing nodesabstract ReleasableSet theisReconciling()flag, and return aReleasablewhich clears it again.
-
Field Details
-
deciders
-
clusterState
-
clusterInfo
-
shardSizeInfo
-
currentNanoTime
protected final long currentNanoTime
-
-
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
GetAllocationDecidersused for allocation- Returns:
AllocationDecidersused for allocation
-
routingTable
Deprecated.Get routing table of current nodes- Returns:
- current routing table
-
globalRoutingTable
-
routingTable
-
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 -
ignoreDisable
public abstract void ignoreDisable(boolean ignoreDisable) -
ignoreDisable
public abstract 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 whenAllocationDecidersis 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 updatedMetadatabased on the changes that were made to the routing nodes -
updateRestoreInfoWithRoutingChanges
public abstract RestoreInProgress updateRestoreInfoWithRoutingChanges(RestoreInProgress restoreInProgress) Returns updatedRestoreInProgressbased on the changes that were made to the routing nodes -
routingNodesChanged
public abstract 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. This is useful to avoid constructing a newDecisioninstance directly in the common case on the hot path where the explanation isn't needed and thus it's best to avoid allocating a new object.- Parameters:
decision- decision whether to allow/deny allocation, typically a global constant such asDecision.YES,Decision.NOetc. to avoid unnecessary allocations.deciderLabel- a human-readable label for the AllocationDeciderreason- a format string explanation of the decisionparams- format string parameters. Note that these parameters are all evaluated before this method checksdebugDecisionand therefore they must be cheap to compute and ideally involve no extra allocations. To construct an explanation message with an expensive-to-compute parameter, checkdebugDecision()yourself first to ensure the computation is needed.
-
hasPendingAsyncFetch
public boolean hasPendingAsyncFetch()Returnstrueiff 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 abstract boolean isSimulating()- Returns:
trueif this allocation computation is trying to simulate the final allocation and therefore "transient" allocation blockers should be ignored.
-
isReconciling
public abstract boolean isReconciling()- Returns:
trueif 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 aReleasablewhich clears it again. -
setSimulatedClusterInfo
-
immutableClone
-
mutableCloneForSimulation
-
immutable
@Deprecated public static RoutingAllocation immutable(AllocationDeciders deciders, ClusterState clusterState, ClusterInfo clusterInfo, SnapshotShardSizeInfo shardSizeInfo, long currentNanoTime) Deprecated.Create an immutable routing allocationUse of this is only to support legacy applications
-