public final class MoveDecision extends AbstractAllocationDecision
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Writeable.Reader<V>, Writeable.Writer<V>
Modifier and Type | Field and Description |
---|---|
static MoveDecision |
NOT_TAKEN
a constant representing no decision taken
|
nodeDecisions, targetNode
EMPTY_PARAMS
Constructor and Description |
---|
MoveDecision(StreamInput in) |
Modifier and Type | Method and Description |
---|---|
static MoveDecision |
cannotRebalance(Decision canRebalanceDecision,
AllocationDecision allocationDecision,
int currentNodeRanking,
java.util.List<NodeAllocationResult> nodeDecisions)
Creates a move decision for when rebalancing the shard is not allowed.
|
static MoveDecision |
cannotRemain(Decision canRemainDecision,
AllocationDecision allocationDecision,
DiscoveryNode assignedNode,
java.util.List<NodeAllocationResult> nodeDecisions)
Creates a move decision for the shard not being allowed to remain on its current node.
|
boolean |
canRebalanceCluster()
Returns
true if the shard is allowed to be rebalanced to another node in the cluster,
returns false otherwise. |
boolean |
canRemain()
Returns
true if the shard can remain on its current node, returns false otherwise. |
boolean |
equals(java.lang.Object other) |
boolean |
forceMove()
Returns
true if the shard cannot remain on its current node and can be moved,
returns false otherwise. |
AllocationDecision |
getAllocationDecision()
Returns the
AllocationDecision for moving this shard to another node. |
Decision |
getCanRemainDecision()
Returns the decision for the shard being allowed to remain on its current node.
|
Decision |
getClusterRebalanceDecision()
Returns the decision for being allowed to rebalance the shard.
|
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 in
NodeAllocationResult.getWeightRanking() . |
java.lang.String |
getExplanation()
Gets the explanation for the decision.
|
int |
hashCode() |
boolean |
isDecisionTaken()
Returns
true if a decision was taken by the allocator, false otherwise. |
static MoveDecision |
rebalance(Decision canRebalanceDecision,
AllocationDecision allocationDecision,
DiscoveryNode assignedNode,
int currentNodeRanking,
java.util.List<NodeAllocationResult> nodeDecisions)
Creates a decision for whether to move the shard to a different node to form a better cluster balance.
|
static MoveDecision |
stay(Decision canRemainDecision)
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.
|
XContentBuilder |
toXContent(XContentBuilder builder,
ToXContent.Params params) |
MoveDecision |
withRemainDecision(Decision canRemainDecision)
Creates a new move decision from this decision, plus adding a remain decision.
|
void |
writeTo(StreamOutput out)
Write this into the StreamOutput.
|
atLeastOneNodeWithYesDecision, checkDecisionState, discoveryNodeToXContent, getNodeDecisions, getTargetNode, nodeDecisionsToXContent, sortNodeDecisions
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
isFragment
public static final MoveDecision NOT_TAKEN
public MoveDecision(StreamInput in) throws java.io.IOException
java.io.IOException
public void writeTo(StreamOutput out) throws java.io.IOException
Writeable
writeTo
in interface Writeable
writeTo
in class AbstractAllocationDecision
java.io.IOException
public static MoveDecision stay(Decision canRemainDecision)
public static MoveDecision cannotRemain(Decision canRemainDecision, AllocationDecision allocationDecision, DiscoveryNode assignedNode, java.util.List<NodeAllocationResult> nodeDecisions)
canRemainDecision
- the decision for whether the shard is allowed to remain on its current nodeallocationDecision
- the AllocationDecision
for moving the shard to another nodeassignedNode
- the node where the shard should move tonodeDecisions
- the node-level decisions that comprised the final decision, non-null iff explain is trueMoveDecision
for moving the shard to another nodepublic static MoveDecision cannotRebalance(Decision canRebalanceDecision, AllocationDecision allocationDecision, int currentNodeRanking, java.util.List<NodeAllocationResult> nodeDecisions)
public static MoveDecision rebalance(Decision canRebalanceDecision, AllocationDecision allocationDecision, @Nullable DiscoveryNode assignedNode, int currentNodeRanking, java.util.List<NodeAllocationResult> nodeDecisions)
public boolean isDecisionTaken()
AbstractAllocationDecision
true
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 an IllegalStateException
.isDecisionTaken
in class AbstractAllocationDecision
public MoveDecision withRemainDecision(Decision canRemainDecision)
public boolean forceMove()
true
if the shard cannot remain on its current node and can be moved,
returns false
otherwise. If isDecisionTaken()
returns false
,
then invoking this method will throw an IllegalStateException
.public boolean canRemain()
true
if the shard can remain on its current node, returns false
otherwise.
If isDecisionTaken()
returns false
, then invoking this method will throw an IllegalStateException
.public Decision getCanRemainDecision()
isDecisionTaken()
returns false
, then invoking this method will throw an IllegalStateException
.public boolean canRebalanceCluster()
true
if the shard is allowed to be rebalanced to another node in the cluster,
returns false
otherwise. If getClusterRebalanceDecision()
returns null
, then
the result of this method is meaningless, as no rebalance decision was taken. If isDecisionTaken()
returns false
, then invoking this method will throw an IllegalStateException
.@Nullable public Decision getClusterRebalanceDecision()
null
if canRemain()
()} returns false
, 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.
If isDecisionTaken()
returns false
, then invoking this method will throw an
IllegalStateException
.@Nullable public AllocationDecision getAllocationDecision()
AllocationDecision
for moving this shard to another node. If isDecisionTaken()
returns
false
, then invoking this method will throw an IllegalStateException
.public int getCurrentNodeRanking()
NodeAllocationResult.getWeightRanking()
. The
ranking will only return a meaningful positive integer if getClusterRebalanceDecision()
returns
a non-null value; otherwise, 0 will be returned. If isDecisionTaken()
returns
false
, then invoking this method will throw an IllegalStateException
.public java.lang.String getExplanation()
AbstractAllocationDecision
AbstractAllocationDecision.isDecisionTaken()
returns false
, then invoking
this method will throw an IllegalStateException
.getExplanation
in class AbstractAllocationDecision
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
java.io.IOException
public boolean equals(java.lang.Object other)
equals
in class AbstractAllocationDecision
public int hashCode()
hashCode
in class AbstractAllocationDecision