Class AllocateUnassignedDecision
java.lang.Object
org.elasticsearch.cluster.routing.allocation.AbstractAllocationDecision
org.elasticsearch.cluster.routing.allocation.AllocateUnassignedDecision
- All Implemented Interfaces:
Writeable
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentFragment
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
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Modifier and TypeFieldDescriptionstatic AllocateUnassignedDecision
a constant representing a shard decision where no decision was takenFields inherited from class org.elasticsearch.cluster.routing.allocation.AbstractAllocationDecision
nodeDecisions, targetNode
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic AllocateUnassignedDecision
delayed(long remainingDelay, long totalDelay, 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
static AllocateUnassignedDecision
fromDecision(Decision decision, DiscoveryNode assignedNode, List<NodeAllocationResult> nodeDecisions)
Creates aAllocateUnassignedDecision
from the givenDecision
and the assigned node, if any.Returns theAllocationDecision
denoting the result of an allocation attempt.Gets the allocation id for the existing shard copy that the allocator is assigning the shard to.Returns the status of an unsuccessful allocation attempt.long
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.Gets the explanation for the decision.long
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
Returnstrue
if a decision was taken by the allocator,false
otherwise.static AllocateUnassignedDecision
no(UnassignedInfo.AllocationStatus allocationStatus, 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, 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(List<NodeAllocationResult> decisions)
Returns a THROTTLE decision, with the individual node-level decisions that comprised the final THROTTLE decision if in explain mode.org.elasticsearch.common.xcontent.XContentBuilder
toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
void
writeTo(StreamOutput out)
Write this into the StreamOutput.static AllocateUnassignedDecision
yes(DiscoveryNode assignedNode, String allocationId, 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 Details
-
NOT_TAKEN
a constant representing a shard decision where no decision was taken
-
-
Constructor Details
-
AllocateUnassignedDecision
- Throws:
IOException
-
-
Method Details
-
no
public static AllocateUnassignedDecision no(UnassignedInfo.AllocationStatus allocationStatus, @Nullable 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 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 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
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 String allocationId, @Nullable 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 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
Returns theAllocationDecision
denoting 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 benull
if 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
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 org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException- Throws:
IOException
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Overrides:
writeTo
in classAbstractAllocationDecision
- Throws:
IOException
-
equals
- Overrides:
equals
in classAbstractAllocationDecision
-
hashCode
public int hashCode()- Overrides:
hashCode
in classAbstractAllocationDecision
-