Class MoveDecision

  • All Implemented Interfaces:
    Writeable, ToXContent, ToXContentFragment

    public final class MoveDecision
    extends AbstractAllocationDecision
    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.
    • Field Detail

      • NOT_TAKEN

        public static final MoveDecision NOT_TAKEN
        a constant representing no decision taken
    • Constructor Detail

      • MoveDecision

        public MoveDecision​(StreamInput in)
                     throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • stay

        public 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.
      • cannotRemain

        public 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.
        Parameters:
        canRemainDecision - the decision for whether the shard is allowed to remain on its current node
        allocationDecision - the AllocationDecision for 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 MoveDecision for moving the shard to another node
      • isDecisionTaken

        public boolean isDecisionTaken()
        Description copied from class: AbstractAllocationDecision
        Returns 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.
        Specified by:
        isDecisionTaken in class AbstractAllocationDecision
      • withRemainDecision

        public MoveDecision withRemainDecision​(Decision canRemainDecision)
        Creates a new move decision from this decision, plus adding a remain decision.
      • forceMove

        public boolean forceMove()
        Returns 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.
      • canRemain

        public boolean canRemain()
        Returns 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.
      • getCanRemainDecision

        public Decision getCanRemainDecision()
        Returns the decision for the shard being allowed to remain on its current node. If isDecisionTaken() returns false, then invoking this method will throw an IllegalStateException.
      • canRebalanceCluster

        public boolean canRebalanceCluster()
        Returns 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.
      • getClusterRebalanceDecision

        @Nullable
        public Decision getClusterRebalanceDecision()
        Returns the decision for being allowed to rebalance the shard. Invoking this method will return 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.
      • 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 in 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.