Class AbstractAllocationDecision

All Implemented Interfaces:
Writeable, ToXContent, ToXContentFragment
Direct Known Subclasses:
AllocateUnassignedDecision, MoveDecision

public abstract class AbstractAllocationDecision extends Object implements ToXContentFragment, Writeable
An abstract class for representing various types of allocation decisions.
  • Field Details

  • Constructor Details

  • Method Details

    • isDecisionTaken

      public abstract boolean isDecisionTaken()
      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.
    • getTargetNode

      @Nullable public DiscoveryNode getTargetNode()
      Get the node that the allocator will assign the shard to, returning null if there is no node to which the shard will be assigned or moved. If isDecisionTaken() returns false, then invoking this method will throw an IllegalStateException.
    • getNodeDecisions

      @Nullable public List<NodeAllocationResult> getNodeDecisions()
      Gets the sorted list of individual node-level decisions that went into making the ultimate decision whether to allocate or move the shard. If isDecisionTaken() returns false, then invoking this method will throw an IllegalStateException.
    • getExplanation

      public abstract String getExplanation()
      Gets the explanation for the decision. If isDecisionTaken() returns false, then invoking this method will throw an IllegalStateException.
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
    • checkDecisionState

      protected void checkDecisionState()
    • discoveryNodeToXContent

      public static XContentBuilder discoveryNodeToXContent(DiscoveryNode node, boolean outerObjectWritten, XContentBuilder builder) throws IOException
      Generates X-Content for a DiscoveryNode that leaves off some of the non-critical fields.
    • sortNodeDecisions

      public List<NodeAllocationResult> sortNodeDecisions(List<NodeAllocationResult> nodeDecisions)
      Sorts a list of node level decisions by the decision type, then by weight ranking, and finally by node id.
    • nodeDecisionsToXContent

      public XContentBuilder nodeDecisionsToXContent(List<NodeAllocationResult> nodeDecisions, XContentBuilder builder, ToXContent.Params params) throws IOException
      Generates X-Content for the node-level decisions, creating the outer "node_decisions" object in which they are serialized.
    • atLeastOneNodeWithYesDecision

      protected boolean atLeastOneNodeWithYesDecision()
      Returns true if there is at least one node that returned a Decision.Type.YES decision for allocating this shard.
    • equals

      public boolean equals(Object other)
      equals in class Object
    • hashCode

      public int hashCode()
      hashCode in class Object