Module org.elasticsearch.server
Class MoveDecision
java.lang.Object
org.elasticsearch.cluster.routing.allocation.AbstractAllocationDecision
org.elasticsearch.cluster.routing.allocation.MoveDecision
- All Implemented Interfaces:
- Writeable,- ToXContent,- ToXContentFragment
Represents a decision to move a started shard, either because it is no longer allowed to remain on its current node
 or because moving it to another node will form a better cluster balance.
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContentToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.WriteableWriteable.Reader<V>, Writeable.Writer<V>
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final MoveDecisiona constant representing no decision takenFields inherited from class org.elasticsearch.cluster.routing.allocation.AbstractAllocationDecisionnodeDecisions, targetNodeFields inherited from interface org.elasticsearch.xcontent.ToXContentEMPTY_PARAMS
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic MoveDecisioncannotRebalance(Decision canRebalanceDecision, AllocationDecision allocationDecision, int currentNodeRanking, List<NodeAllocationResult> nodeDecisions) Creates a move decision for when rebalancing the shard is not allowed.static MoveDecisioncannotRemain(Decision canRemainDecision, AllocationDecision allocationDecision, DiscoveryNode assignedNode, List<NodeAllocationResult> nodeDecisions) Creates a move decision for the shard not being allowed to remain on its current node.booleanReturnstrueif the shard is allowed to be rebalanced to another node in the cluster, returnsfalseotherwise.booleanReturnstrueif the shard can remain on its current node, returnsfalseotherwise.booleanbooleanReturnstrueif the shard cannot remain on its current node and can be moved, returnsfalseotherwise.Returns theAllocationDecisionfor moving this shard to another node.Returns the decision for the shard being allowed to remain on its current node.Returns the decision for being allowed to rebalance the shard.intGets the current ranking of the node to which the shard is currently assigned, relative to the other nodes in the cluster as reported inNodeAllocationResult.getWeightRanking().Gets the explanation for the decision.inthashCode()booleanReturnstrueif a decision was taken by the allocator,falseotherwise.static MoveDecisionrebalance(Decision canRebalanceDecision, AllocationDecision allocationDecision, DiscoveryNode assignedNode, int currentNodeRanking, List<NodeAllocationResult> nodeDecisions) Creates a decision for whether to move the shard to a different node to form a better cluster balance.static MoveDecisionCreates a move decision for the shard being able to remain on its current node, so the shard won't be forced to move to another node.toXContent(XContentBuilder builder, ToXContent.Params params) withRemainDecision(Decision canRemainDecision) Creates a new move decision from this decision, plus adding a remain decision.voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class org.elasticsearch.cluster.routing.allocation.AbstractAllocationDecisionatLeastOneNodeWithYesDecision, checkDecisionState, discoveryNodeToXContent, getNodeDecisions, getTargetNode, nodeDecisionsToXContent, sortNodeDecisionsMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.xcontent.ToXContentFragmentisFragment
- 
Field Details- 
NOT_TAKENa constant representing no decision taken
 
- 
- 
Constructor Details- 
MoveDecision- Throws:
- IOException
 
 
- 
- 
Method Details- 
writeToDescription copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
- writeToin interface- Writeable
- Overrides:
- writeToin class- AbstractAllocationDecision
- Throws:
- IOException
 
- 
stayCreates a move decision for the shard being able to remain on its current node, so the shard won't be forced to move to another node.
- 
cannotRemainpublic static MoveDecision cannotRemain(Decision canRemainDecision, AllocationDecision allocationDecision, DiscoveryNode assignedNode, List<NodeAllocationResult> nodeDecisions) Creates a move decision for the shard not being allowed to remain on its current node.- Parameters:
- canRemainDecision- the decision for whether the shard is allowed to remain on its current node
- allocationDecision- the- AllocationDecisionfor moving the shard to another node
- assignedNode- the node where the shard should move to
- nodeDecisions- the node-level decisions that comprised the final decision, non-null iff explain is true
- Returns:
- the MoveDecisionfor moving the shard to another node
 
- 
cannotRebalancepublic static MoveDecision cannotRebalance(Decision canRebalanceDecision, AllocationDecision allocationDecision, int currentNodeRanking, List<NodeAllocationResult> nodeDecisions) Creates a move decision for when rebalancing the shard is not allowed.
- 
rebalancepublic static MoveDecision rebalance(Decision canRebalanceDecision, AllocationDecision allocationDecision, @Nullable DiscoveryNode assignedNode, int currentNodeRanking, List<NodeAllocationResult> nodeDecisions) Creates a decision for whether to move the shard to a different node to form a better cluster balance.
- 
isDecisionTakenpublic boolean isDecisionTaken()Description copied from class:AbstractAllocationDecisionReturnstrueif a decision was taken by the allocator,falseotherwise. If no decision was taken, then the rest of the fields in this object cannot be accessed and will throw anIllegalStateException.- Specified by:
- isDecisionTakenin class- AbstractAllocationDecision
 
- 
withRemainDecisionCreates a new move decision from this decision, plus adding a remain decision.
- 
forceMovepublic boolean forceMove()Returnstrueif the shard cannot remain on its current node and can be moved, returnsfalseotherwise. IfisDecisionTaken()returnsfalse, then invoking this method will throw anIllegalStateException.
- 
canRemainpublic boolean canRemain()Returnstrueif the shard can remain on its current node, returnsfalseotherwise. IfisDecisionTaken()returnsfalse, then invoking this method will throw anIllegalStateException.
- 
getCanRemainDecisionReturns the decision for the shard being allowed to remain on its current node. IfisDecisionTaken()returnsfalse, then invoking this method will throw anIllegalStateException.
- 
canRebalanceClusterpublic boolean canRebalanceCluster()Returnstrueif the shard is allowed to be rebalanced to another node in the cluster, returnsfalseotherwise. IfgetClusterRebalanceDecision()returnsnull, then the result of this method is meaningless, as no rebalance decision was taken. IfisDecisionTaken()returnsfalse, then invoking this method will throw anIllegalStateException.
- 
getClusterRebalanceDecisionReturns the decision for being allowed to rebalance the shard. Invoking this method will returnnullifcanRemain()()} returnsfalse, which means the node is not allowed to remain on its current node, so the cluster is forced to attempt to move the shard to a different node, as opposed to attempting to rebalance the shard if a better cluster balance is possible by moving it. IfisDecisionTaken()returnsfalse, then invoking this method will throw anIllegalStateException.
- 
getAllocationDecisionReturns theAllocationDecisionfor moving this shard to another node. IfisDecisionTaken()returnsfalse, then invoking this method will throw anIllegalStateException.
- 
getCurrentNodeRankingpublic int getCurrentNodeRanking()Gets the current ranking of the node to which the shard is currently assigned, relative to the other nodes in the cluster as reported inNodeAllocationResult.getWeightRanking(). The ranking will only return a meaningful positive integer ifgetClusterRebalanceDecision()returns a non-null value; otherwise, 0 will be returned. IfisDecisionTaken()returnsfalse, then invoking this method will throw anIllegalStateException.
- 
getExplanationDescription copied from class:AbstractAllocationDecisionGets the explanation for the decision. IfAbstractAllocationDecision.isDecisionTaken()returnsfalse, then invoking this method will throw anIllegalStateException.- Specified by:
- getExplanationin class- AbstractAllocationDecision
 
- 
toXContentpublic XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Throws:
- IOException
 
- 
equals- Overrides:
- equalsin class- AbstractAllocationDecision
 
- 
hashCodepublic int hashCode()- Overrides:
- hashCodein class- AbstractAllocationDecision
 
 
-