Class AbstractAllocationDecision
- java.lang.Object
-
- org.elasticsearch.cluster.routing.allocation.AbstractAllocationDecision
-
- All Implemented Interfaces:
Writeable
,ToXContent
,ToXContentFragment
- Direct Known Subclasses:
AllocateUnassignedDecision
,MoveDecision
public abstract class AbstractAllocationDecision extends java.lang.Object implements ToXContentFragment, Writeable
An abstract class for representing various types of allocation decisions.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<NodeAllocationResult>
nodeDecisions
protected DiscoveryNode
targetNode
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractAllocationDecision(DiscoveryNode targetNode, java.util.List<NodeAllocationResult> nodeDecisions)
protected
AbstractAllocationDecision(StreamInput in)
-
Method Summary
Modifier and Type Method Description protected boolean
atLeastOneNodeWithYesDecision()
Returnstrue
if there is at least one node that returned aDecision.Type.YES
decision for allocating this shard.protected void
checkDecisionState()
static XContentBuilder
discoveryNodeToXContent(DiscoveryNode node, boolean outerObjectWritten, XContentBuilder builder)
Generates X-Content for aDiscoveryNode
that leaves off some of the non-critical fields.boolean
equals(java.lang.Object other)
abstract java.lang.String
getExplanation()
Gets the explanation for the decision.java.util.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.DiscoveryNode
getTargetNode()
Get the node that the allocator will assign the shard to, returningnull
if there is no node to which the shard will be assigned or moved.int
hashCode()
abstract boolean
isDecisionTaken()
Returnstrue
if a decision was taken by the allocator,false
otherwise.XContentBuilder
nodeDecisionsToXContent(java.util.List<NodeAllocationResult> nodeDecisions, XContentBuilder builder, ToXContent.Params params)
Generates X-Content for the node-level decisions, creating the outer "node_decisions" object in which they are serialized.java.util.List<NodeAllocationResult>
sortNodeDecisions(java.util.List<NodeAllocationResult> nodeDecisions)
Sorts a list of node level decisions by the decision type, then by weight ranking, and finally by node id.void
writeTo(StreamOutput out)
Write this into the StreamOutput.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContent
toXContent
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
-
-
-
Field Detail
-
targetNode
@Nullable protected final DiscoveryNode targetNode
-
nodeDecisions
@Nullable protected final java.util.List<NodeAllocationResult> nodeDecisions
-
-
Constructor Detail
-
AbstractAllocationDecision
protected AbstractAllocationDecision(@Nullable DiscoveryNode targetNode, @Nullable java.util.List<NodeAllocationResult> nodeDecisions)
-
AbstractAllocationDecision
protected AbstractAllocationDecision(StreamInput in) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
isDecisionTaken
public abstract boolean isDecisionTaken()
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
.
-
getTargetNode
@Nullable public DiscoveryNode getTargetNode()
Get the node that the allocator will assign the shard to, returningnull
if there is no node to which the shard will be assigned or moved. IfisDecisionTaken()
returnsfalse
, then invoking this method will throw anIllegalStateException
.
-
getNodeDecisions
@Nullable public java.util.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. IfisDecisionTaken()
returnsfalse
, then invoking this method will throw anIllegalStateException
.
-
getExplanation
public abstract java.lang.String getExplanation()
Gets the explanation for the decision. IfisDecisionTaken()
returnsfalse
, then invoking this method will throw anIllegalStateException
.
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:Writeable
Write this into the StreamOutput.
-
checkDecisionState
protected void checkDecisionState()
-
discoveryNodeToXContent
public static XContentBuilder discoveryNodeToXContent(DiscoveryNode node, boolean outerObjectWritten, XContentBuilder builder) throws java.io.IOException
Generates X-Content for aDiscoveryNode
that leaves off some of the non-critical fields.- Throws:
java.io.IOException
-
sortNodeDecisions
public java.util.List<NodeAllocationResult> sortNodeDecisions(java.util.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(java.util.List<NodeAllocationResult> nodeDecisions, XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
Generates X-Content for the node-level decisions, creating the outer "node_decisions" object in which they are serialized.- Throws:
java.io.IOException
-
atLeastOneNodeWithYesDecision
protected boolean atLeastOneNodeWithYesDecision()
Returnstrue
if there is at least one node that returned aDecision.Type.YES
decision for allocating this shard.
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-