Module org.elasticsearch.server
Class ShardAllocationDecision
java.lang.Object
org.elasticsearch.cluster.routing.allocation.ShardAllocationDecision
- All Implemented Interfaces:
Writeable
,ChunkedToXContent
,ChunkedToXContentObject
public final class ShardAllocationDecision
extends Object
implements ChunkedToXContentObject, Writeable
Represents the decision taken for the allocation of a single shard. If
the shard is unassigned,
getAllocateDecision()
will return an
object containing the decision and its explanation, and getMoveDecision()
will return an object for which MoveDecision.isDecisionTaken()
returns
false
. If the shard is in the started state, then getMoveDecision()
will return an object containing the decision to move/rebalance the shard, and
getAllocateDecision()
will return an object for which
AllocateUnassignedDecision.isDecisionTaken()
returns false
. If
the shard is neither unassigned nor started (i.e. it is initializing or relocating),
then both getAllocateDecision()
and getMoveDecision()
will return
objects whose isDecisionTaken()
method returns false
.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
FieldsFields inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContent
EMPTY
-
Constructor Summary
ConstructorsConstructorDescriptionShardAllocationDecision
(AllocateUnassignedDecision allocateDecision, MoveDecision moveDecision) -
Method Summary
Modifier and TypeMethodDescriptionGets the unassigned allocation decision for the shard.Gets the move decision for the shard.boolean
Returnstrue
if either an allocation decision or a move decision was taken for the shard.Iterator
<? extends ToXContent> toXContentChunked
(ToXContent.Params params) Create an iterator ofToXContent
chunks for a REST response.void
writeTo
(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContent
toXContentChunked, toXContentChunkedV8
Methods inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContentObject
isFragment
-
Field Details
-
NOT_TAKEN
-
-
Constructor Details
-
ShardAllocationDecision
public ShardAllocationDecision(AllocateUnassignedDecision allocateDecision, MoveDecision moveDecision) -
ShardAllocationDecision
- Throws:
IOException
-
-
Method Details
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
isDecisionTaken
public boolean isDecisionTaken()Returnstrue
if either an allocation decision or a move decision was taken for the shard. If no decision was taken, as in the case of initializing or relocating shards, then this method returnsfalse
. -
getAllocateDecision
Gets the unassigned allocation decision for the shard. If the shard was not in the unassigned state, the instance ofAllocateUnassignedDecision
that is returned will haveAllocateUnassignedDecision.isDecisionTaken()
returnfalse
. -
getMoveDecision
Gets the move decision for the shard. If the shard was not in the started state, the instance ofMoveDecision
that is returned will haveMoveDecision.isDecisionTaken()
returnfalse
. -
toXContentChunked
Description copied from interface:ChunkedToXContent
Create an iterator ofToXContent
chunks for a REST response. Each chunk is serialized with the sameXContentBuilder
andToXContent.Params
, which is also the same as theToXContent.Params
passed as theparams
argument. For best results, all chunks should beO(1)
size. The last chunk in the iterator must always yield at least one byte of output. See alsoChunkedToXContentHelper
for some handy utilities.Note that chunked response bodies cannot send deprecation warning headers once transmission has started, so implementations must check for deprecated feature use before returning.
- Specified by:
toXContentChunked
in interfaceChunkedToXContent
- Returns:
- iterator over chunks of
ToXContent
-