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
,ChunkedToXContent
,ChunkedToXContentObject
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 Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MoveDecision
a constant representing no decision takenFields inherited from class org.elasticsearch.cluster.routing.allocation.AbstractAllocationDecision
nodeDecisions, targetNode
Fields inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContent
EMPTY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if the shard is allowed to be rebalanced to another node in the cluster, returnsfalse
otherwise.boolean
Returnstrue
if the shard can remain on its current node, returnsfalse
otherwise.boolean
boolean
Returnstrue
if the shard cannot remain on its current node and can be moved, returnsfalse
otherwise.Returns theAllocationDecision
for 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.int
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()
.Gets the explanation for the decision.int
hashCode()
boolean
Returnstrue
if a decision was taken by the allocator,false
otherwise.static MoveDecision
move
(Decision canRemainDecision, AllocationDecision moveDecision, DiscoveryNode targetNode, List<NodeAllocationResult> nodeDecisions) Creates a move decision for the shard.static MoveDecision
rebalance
(Decision canRemainDecision, Decision canRebalanceDecision, AllocationDecision canMoveDecision, DiscoveryNode targetNode, 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 MoveDecision
Creates 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.Iterator
<? extends ToXContent> toXContentChunked
(ToXContent.Params params) Create an iterator ofToXContent
chunks for a REST response.void
writeTo
(StreamOutput out) Write this into the StreamOutput.Methods inherited from class org.elasticsearch.cluster.routing.allocation.AbstractAllocationDecision
atLeastOneNodeWithYesDecision, checkDecisionState, discoveryNodeToXContent, getNodeDecisions, getTargetNode, nodeDecisionsToXContentChunked, sortNodeDecisions
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContent
toXContentChunkedV7
Methods inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContentObject
isFragment
-
Field Details
-
NOT_TAKEN
a constant representing no decision taken
-
-
Constructor Details
-
MoveDecision
- Throws:
IOException
-
-
Method Details
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Overrides:
writeTo
in classAbstractAllocationDecision
- Throws:
IOException
-
remain
Creates 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. -
move
public static MoveDecision move(Decision canRemainDecision, AllocationDecision moveDecision, @Nullable DiscoveryNode targetNode, @Nullable List<NodeAllocationResult> nodeDecisions) Creates a move decision for the shard.- Parameters:
canRemainDecision
- the decision for whether the shard is allowed to remain on its current nodemoveDecision
- theAllocationDecision
for moving the shard to another nodetargetNode
- the node where the shard should move tonodeDecisions
- the node-level decisions that comprised the final decision, non-null iff explain is true- Returns:
- the
MoveDecision
for moving the shard to another node
-
rebalance
public static MoveDecision rebalance(Decision canRemainDecision, Decision canRebalanceDecision, AllocationDecision canMoveDecision, @Nullable DiscoveryNode targetNode, int currentNodeRanking, List<NodeAllocationResult> nodeDecisions) Creates a decision for whether to move the shard to a different node to form a better cluster balance. -
isDecisionTaken
public boolean isDecisionTaken()Description copied from class:AbstractAllocationDecision
Returnstrue
if a decision was taken by the allocator,false
otherwise. If no decision was taken, then the rest of the fields in this object cannot be accessed and will throw anIllegalStateException
.- Specified by:
isDecisionTaken
in classAbstractAllocationDecision
-
forceMove
public boolean forceMove()Returnstrue
if the shard cannot remain on its current node and can be moved, returnsfalse
otherwise. IfisDecisionTaken()
returnsfalse
, then invoking this method will throw anIllegalStateException
. -
canRemain
public boolean canRemain()Returnstrue
if the shard can remain on its current node, returnsfalse
otherwise. IfisDecisionTaken()
returnsfalse
, then invoking this method will throw anIllegalStateException
. -
getCanRemainDecision
Returns the decision for the shard being allowed to remain on its current node. IfisDecisionTaken()
returnsfalse
, then invoking this method will throw anIllegalStateException
. -
canRebalanceCluster
public boolean canRebalanceCluster()Returnstrue
if the shard is allowed to be rebalanced to another node in the cluster, returnsfalse
otherwise. 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
. -
getClusterRebalanceDecision
Returns the decision for being allowed to rebalance the shard. Invoking this method will returnnull
ifcanRemain()
()} 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
. -
getAllocationDecision
Returns theAllocationDecision
for moving this shard to another node. IfisDecisionTaken()
returnsfalse
, then invoking this method will throw anIllegalStateException
. -
getCurrentNodeRanking
public 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
. -
getExplanation
Description copied from class:AbstractAllocationDecision
Gets the explanation for the decision. IfAbstractAllocationDecision.isDecisionTaken()
returnsfalse
, then invoking this method will throw anIllegalStateException
.- Specified by:
getExplanation
in classAbstractAllocationDecision
-
toXContentChunked
Description copied from interface:ChunkedToXContent
Create an iterator ofToXContent
chunks for a REST response. Each chunk is serialized with the sameXContentBuilder
andToXContent.Params
, which is also the same as theToXContent.Params
passed as theparams
argument. For best results, all chunks should beO(1)
size. The last chunk in the iterator must always yield at least one byte of output. See alsoChunkedToXContentHelper
for some handy utilities.Note that chunked response bodies cannot send deprecation warning headers once transmission has started, so implementations must check for deprecated feature use before returning.
- Returns:
- iterator over chunks of
ToXContent
-
equals
- Overrides:
equals
in classAbstractAllocationDecision
-
hashCode
public int hashCode()- Overrides:
hashCode
in classAbstractAllocationDecision
-