Class AllocateUnassignedDecision
java.lang.Object
org.elasticsearch.cluster.routing.allocation.AbstractAllocationDecision
org.elasticsearch.cluster.routing.allocation.AllocateUnassignedDecision
- All Implemented Interfaces:
Writeable,ToXContent,ToXContentFragment
public class AllocateUnassignedDecision extends AbstractAllocationDecision
Represents the allocation decision by an allocator for an unassigned shard.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested 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 static AllocateUnassignedDecisionNOT_TAKENa constant representing a shard decision where no decision was takenFields inherited from class org.elasticsearch.cluster.routing.allocation.AbstractAllocationDecision
nodeDecisions, targetNode -
Constructor Summary
Constructors Constructor Description AllocateUnassignedDecision(StreamInput in) -
Method Summary
Modifier and Type Method Description static AllocateUnassignedDecisiondelayed(long remainingDelay, long totalDelay, java.util.List<NodeAllocationResult> decisions)Returns a NO decision for a delayed shard allocation on a replica shard, with the individual node-level decisions that comprised the final NO decision, if in explain mode.booleanequals(java.lang.Object other)static AllocateUnassignedDecisionfromDecision(Decision decision, DiscoveryNode assignedNode, java.util.List<NodeAllocationResult> nodeDecisions)Creates aAllocateUnassignedDecisionfrom the givenDecisionand the assigned node, if any.AllocationDecisiongetAllocationDecision()Returns theAllocationDecisiondenoting the result of an allocation attempt.java.lang.StringgetAllocationId()Gets the allocation id for the existing shard copy that the allocator is assigning the shard to.UnassignedInfo.AllocationStatusgetAllocationStatus()Returns the status of an unsuccessful allocation attempt.longgetConfiguredDelayInMillis()Gets the total configured delay for allocating the replica shard when a node holding the replica left the cluster and the deciders are waiting to see if the node returns before allocating the replica elsewhere.java.lang.StringgetExplanation()Gets the explanation for the decision.longgetRemainingDelayInMillis()Gets the remaining delay for allocating the replica shard when a node holding the replica left the cluster and the deciders are waiting to see if the node returns before allocating the replica elsewhere.inthashCode()booleanisDecisionTaken()Returnstrueif a decision was taken by the allocator,falseotherwise.static AllocateUnassignedDecisionno(UnassignedInfo.AllocationStatus allocationStatus, java.util.List<NodeAllocationResult> decisions)Returns a NO decision with the givenUnassignedInfo.AllocationStatus, and the individual node-level decisions that comprised the final NO decision if in explain mode.static AllocateUnassignedDecisionno(UnassignedInfo.AllocationStatus allocationStatus, java.util.List<NodeAllocationResult> decisions, boolean reuseStore)Returns a NO decision with the givenUnassignedInfo.AllocationStatus, and the individual node-level decisions that comprised the final NO decision if in explain mode.static AllocateUnassignedDecisionthrottle(java.util.List<NodeAllocationResult> decisions)Returns a THROTTLE decision, with the individual node-level decisions that comprised the final THROTTLE decision if in explain mode.XContentBuildertoXContent(XContentBuilder builder, ToXContent.Params params)voidwriteTo(StreamOutput out)Write this into the StreamOutput.static AllocateUnassignedDecisionyes(DiscoveryNode assignedNode, java.lang.String allocationId, java.util.List<NodeAllocationResult> decisions, boolean reuseStore)Creates a YES decision with the given individual node-level decisions that comprised the final YES decision, along with the node id to which the shard is assigned and the allocation id for the shard, if available.Methods inherited from class org.elasticsearch.cluster.routing.allocation.AbstractAllocationDecision
atLeastOneNodeWithYesDecision, checkDecisionState, discoveryNodeToXContent, getNodeDecisions, getTargetNode, nodeDecisionsToXContent, sortNodeDecisions
-
Field Details
-
NOT_TAKEN
a constant representing a shard decision where no decision was taken
-
-
Constructor Details
-
AllocateUnassignedDecision
- Throws:
java.io.IOException
-
-
Method Details
-
no
public static AllocateUnassignedDecision no(UnassignedInfo.AllocationStatus allocationStatus, @Nullable java.util.List<NodeAllocationResult> decisions)Returns a NO decision with the givenUnassignedInfo.AllocationStatus, and the individual node-level decisions that comprised the final NO decision if in explain mode. -
delayed
public static AllocateUnassignedDecision delayed(long remainingDelay, long totalDelay, @Nullable java.util.List<NodeAllocationResult> decisions)Returns a NO decision for a delayed shard allocation on a replica shard, with the individual node-level decisions that comprised the final NO decision, if in explain mode. Instances created with this method will returnUnassignedInfo.AllocationStatus.DELAYED_ALLOCATIONforgetAllocationStatus(). -
no
public static AllocateUnassignedDecision no(UnassignedInfo.AllocationStatus allocationStatus, @Nullable java.util.List<NodeAllocationResult> decisions, boolean reuseStore)Returns a NO decision with the givenUnassignedInfo.AllocationStatus, and the individual node-level decisions that comprised the final NO decision if in explain mode. -
throttle
public static AllocateUnassignedDecision throttle(@Nullable java.util.List<NodeAllocationResult> decisions)Returns a THROTTLE decision, with the individual node-level decisions that comprised the final THROTTLE decision if in explain mode. -
yes
public static AllocateUnassignedDecision yes(DiscoveryNode assignedNode, @Nullable java.lang.String allocationId, @Nullable java.util.List<NodeAllocationResult> decisions, boolean reuseStore)Creates a YES decision with the given individual node-level decisions that comprised the final YES decision, along with the node id to which the shard is assigned and the allocation id for the shard, if available. -
fromDecision
public static AllocateUnassignedDecision fromDecision(Decision decision, @Nullable DiscoveryNode assignedNode, @Nullable java.util.List<NodeAllocationResult> nodeDecisions)Creates aAllocateUnassignedDecisionfrom the givenDecisionand the assigned node, if any. -
isDecisionTaken
public boolean isDecisionTaken()Description copied from class:AbstractAllocationDecisionReturnstrueif a decision was taken by the allocator,falseotherwise. If no decision was taken, then the rest of the fields in this object cannot be accessed and will throw anIllegalStateException.- Specified by:
isDecisionTakenin classAbstractAllocationDecision
-
getAllocationDecision
Returns theAllocationDecisiondenoting the result of an allocation attempt. IfisDecisionTaken()returnsfalse, then invoking this method will throw anIllegalStateException. -
getAllocationStatus
Returns the status of an unsuccessful allocation attempt. This value will benullif no decision was taken or if the decision wasDecision.Type.YES. IfisDecisionTaken()returnsfalse, then invoking this method will throw anIllegalStateException. -
getAllocationId
Gets the allocation id for the existing shard copy that the allocator is assigning the shard to. This method returns a non-null value iffAbstractAllocationDecision.getTargetNode()returns a non-null value and the node on which the shard is assigned already has a shard copy with an in-sync allocation id that we can re-use. IfisDecisionTaken()returnsfalse, then invoking this method will throw anIllegalStateException. -
getRemainingDelayInMillis
public long getRemainingDelayInMillis()Gets the remaining delay for allocating the replica shard when a node holding the replica left the cluster and the deciders are waiting to see if the node returns before allocating the replica elsewhere. Only returns a meaningful positive value ifgetAllocationStatus()returnsUnassignedInfo.AllocationStatus.DELAYED_ALLOCATION. IfisDecisionTaken()returnsfalse, then invoking this method will throw anIllegalStateException. -
getConfiguredDelayInMillis
public long getConfiguredDelayInMillis()Gets the total configured delay for allocating the replica shard when a node holding the replica left the cluster and the deciders are waiting to see if the node returns before allocating the replica elsewhere. Only returns a meaningful positive value ifgetAllocationStatus()returnsUnassignedInfo.AllocationStatus.DELAYED_ALLOCATION. IfisDecisionTaken()returnsfalse, then invoking this method will throw anIllegalStateException. -
getExplanation
public java.lang.String getExplanation()Description copied from class:AbstractAllocationDecisionGets the explanation for the decision. IfAbstractAllocationDecision.isDecisionTaken()returnsfalse, then invoking this method will throw anIllegalStateException.- Specified by:
getExplanationin classAbstractAllocationDecision
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException- Throws:
java.io.IOException
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Overrides:
writeToin classAbstractAllocationDecision- Throws:
java.io.IOException
-
equals
public boolean equals(java.lang.Object other)- Overrides:
equalsin classAbstractAllocationDecision
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractAllocationDecision
-