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.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 static AllocateUnassignedDecision
NOT_TAKEN
a constant representing a shard decision where no decision was taken-
Fields inherited from class org.elasticsearch.cluster.routing.allocation.AbstractAllocationDecision
nodeDecisions, targetNode
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Constructor Description AllocateUnassignedDecision(StreamInput in)
-
Method Summary
Modifier and Type Method Description static AllocateUnassignedDecision
delayed(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.boolean
equals(java.lang.Object other)
static AllocateUnassignedDecision
fromDecision(Decision decision, DiscoveryNode assignedNode, java.util.List<NodeAllocationResult> nodeDecisions)
Creates aAllocateUnassignedDecision
from the givenDecision
and the assigned node, if any.AllocationDecision
getAllocationDecision()
Returns theAllocationDecision
denoting the result of an allocation attempt.java.lang.String
getAllocationId()
Gets the allocation id for the existing shard copy that the allocator is assigning the shard to.UnassignedInfo.AllocationStatus
getAllocationStatus()
Returns the status of an unsuccessful allocation attempt.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.java.lang.String
getExplanation()
Gets the explanation for the decision.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.int
hashCode()
boolean
isDecisionTaken()
Returnstrue
if a decision was taken by the allocator,false
otherwise.static AllocateUnassignedDecision
no(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 AllocateUnassignedDecision
no(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 AllocateUnassignedDecision
throttle(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.XContentBuilder
toXContent(XContentBuilder builder, ToXContent.Params params)
void
writeTo(StreamOutput out)
Write this into the StreamOutput.static AllocateUnassignedDecision
yes(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
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
-
-
-
Field Detail
-
NOT_TAKEN
public static final AllocateUnassignedDecision NOT_TAKEN
a constant representing a shard decision where no decision was taken
-
-
Constructor Detail
-
AllocateUnassignedDecision
public AllocateUnassignedDecision(StreamInput in) throws java.io.IOException
- Throws:
java.io.IOException
-
-
Method Detail
-
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_ALLOCATION
forgetAllocationStatus()
.
-
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 aAllocateUnassignedDecision
from the givenDecision
and the assigned node, if any.
-
isDecisionTaken
public boolean isDecisionTaken()
Description copied from class:AbstractAllocationDecision
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
.- Specified by:
isDecisionTaken
in classAbstractAllocationDecision
-
getAllocationDecision
public AllocationDecision getAllocationDecision()
Returns theAllocationDecision
denoting the result of an allocation attempt. IfisDecisionTaken()
returnsfalse
, then invoking this method will throw anIllegalStateException
.
-
getAllocationStatus
@Nullable public UnassignedInfo.AllocationStatus getAllocationStatus()
Returns the status of an unsuccessful allocation attempt. This value will benull
if no decision was taken or if the decision wasDecision.Type.YES
. IfisDecisionTaken()
returnsfalse
, then invoking this method will throw anIllegalStateException
.
-
getAllocationId
@Nullable public java.lang.String 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:AbstractAllocationDecision
Gets the explanation for the decision. IfAbstractAllocationDecision.isDecisionTaken()
returnsfalse
, then invoking this method will throw anIllegalStateException
.- Specified by:
getExplanation
in classAbstractAllocationDecision
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Throws:
java.io.IOException
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Overrides:
writeTo
in classAbstractAllocationDecision
- Throws:
java.io.IOException
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classAbstractAllocationDecision
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classAbstractAllocationDecision
-
-