Class AbstractAllocateAllocationCommand
- java.lang.Object
-
- org.elasticsearch.cluster.routing.allocation.command.AbstractAllocateAllocationCommand
-
- All Implemented Interfaces:
AllocationCommand,NamedWriteable,Writeable,ToXContent,ToXContentObject
- Direct Known Subclasses:
AllocateReplicaAllocationCommand,BasePrimaryAllocationCommand
public abstract class AbstractAllocateAllocationCommand extends java.lang.Object implements AllocationCommand
Abstract base class for allocating an unassigned shard to a node
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractAllocateAllocationCommand.Builder<T extends AbstractAllocateAllocationCommand>Works around ObjectParser not supporting constructor arguments.-
Nested classes/interfaces inherited from interface org.elasticsearch.cluster.routing.allocation.command.AllocationCommand
AllocationCommand.Parser<T extends AllocationCommand>
-
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.lang.Stringindexprotected java.lang.Stringnodeprotected intshardId-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractAllocateAllocationCommand(java.lang.String index, int shardId, java.lang.String node)protectedAbstractAllocateAllocationCommand(StreamInput in)Read from a stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static <T extends AbstractAllocateAllocationCommand.Builder<?>>
ObjectParser<T,java.lang.Void>createAllocateParser(java.lang.String command)booleanequals(java.lang.Object obj)protected RerouteExplanationexplainOrThrowMissingRoutingNode(RoutingAllocation allocation, boolean explain, DiscoveryNode discoNode)Handle case where a disco node cannot be found in the routing table.protected RerouteExplanationexplainOrThrowRejectedCommand(boolean explain, RoutingAllocation allocation, java.lang.RuntimeException rte)Utility method for rejecting the current allocation command based on provided exceptionprotected RerouteExplanationexplainOrThrowRejectedCommand(boolean explain, RoutingAllocation allocation, java.lang.String reason)Utility method for rejecting the current allocation command based on provided reasonprotected voidextraXContent(XContentBuilder builder)inthashCode()java.lang.Stringindex()Get the index nameprotected voidinitializeUnassignedShard(RoutingAllocation allocation, RoutingNodes routingNodes, RoutingNode routingNode, ShardRouting shardRouting)Initializes an unassigned shard on a node and removes it from the unassignedprotected voidinitializeUnassignedShard(RoutingAllocation allocation, RoutingNodes routingNodes, RoutingNode routingNode, ShardRouting shardRouting, UnassignedInfo unassignedInfo, RecoverySource recoverySource)Initializes an unassigned shard on a node and removes it from the unassignedjava.lang.Stringnode()Get the id of the nodeintshardId()Get the shard idXContentBuildertoXContent(XContentBuilder builder, ToXContent.Params params)voidwriteTo(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.cluster.routing.allocation.command.AllocationCommand
execute, getMessage, getWriteableName, name
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
-
-
-
Constructor Detail
-
AbstractAllocateAllocationCommand
protected AbstractAllocateAllocationCommand(java.lang.String index, int shardId, java.lang.String node)
-
AbstractAllocateAllocationCommand
protected AbstractAllocateAllocationCommand(StreamInput in) throws java.io.IOException
Read from a stream.- Throws:
java.io.IOException
-
-
Method Detail
-
createAllocateParser
protected static <T extends AbstractAllocateAllocationCommand.Builder<?>> ObjectParser<T,java.lang.Void> createAllocateParser(java.lang.String command)
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:WriteableWrite this into the StreamOutput.
-
index
public java.lang.String index()
Get the index name- Returns:
- name of the index
-
shardId
public int shardId()
Get the shard id- Returns:
- id of the shard
-
node
public java.lang.String node()
Get the id of the node- Returns:
- id of the node
-
explainOrThrowMissingRoutingNode
protected RerouteExplanation explainOrThrowMissingRoutingNode(RoutingAllocation allocation, boolean explain, DiscoveryNode discoNode)
Handle case where a disco node cannot be found in the routing table. Usually means that it's not a data node.
-
explainOrThrowRejectedCommand
protected RerouteExplanation explainOrThrowRejectedCommand(boolean explain, RoutingAllocation allocation, java.lang.String reason)
Utility method for rejecting the current allocation command based on provided reason
-
explainOrThrowRejectedCommand
protected RerouteExplanation explainOrThrowRejectedCommand(boolean explain, RoutingAllocation allocation, java.lang.RuntimeException rte)
Utility method for rejecting the current allocation command based on provided exception
-
initializeUnassignedShard
protected void initializeUnassignedShard(RoutingAllocation allocation, RoutingNodes routingNodes, RoutingNode routingNode, ShardRouting shardRouting)
Initializes an unassigned shard on a node and removes it from the unassigned- Parameters:
allocation- the allocationroutingNodes- the routing nodesroutingNode- the node to initialize it toshardRouting- the shard routing that is to be matched in unassigned shards
-
initializeUnassignedShard
protected void initializeUnassignedShard(RoutingAllocation allocation, RoutingNodes routingNodes, RoutingNode routingNode, ShardRouting shardRouting, @Nullable UnassignedInfo unassignedInfo, @Nullable RecoverySource recoverySource)
Initializes an unassigned shard on a node and removes it from the unassigned- Parameters:
allocation- the allocationroutingNodes- the routing nodesroutingNode- the node to initialize it toshardRouting- the shard routing that is to be matched in unassigned shardsunassignedInfo- unassigned info to overriderecoverySource- recovery source to override
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
toXContentin interfaceToXContent- Throws:
java.io.IOException
-
extraXContent
protected void extraXContent(XContentBuilder builder) throws java.io.IOException
- Throws:
java.io.IOException
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-