Class AbstractAllocateAllocationCommand
java.lang.Object
org.opensearch.cluster.routing.allocation.command.AbstractAllocateAllocationCommand
- All Implemented Interfaces:
AllocationCommand
,org.opensearch.core.common.io.stream.NamedWriteable
,org.opensearch.core.common.io.stream.Writeable
,org.opensearch.core.xcontent.ToXContent
,org.opensearch.core.xcontent.ToXContentObject
- Direct Known Subclasses:
AllocateReplicaAllocationCommand
,BasePrimaryAllocationCommand
Abstract base class for allocating an unassigned shard to a node
- Opensearch.internal:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Works around ObjectParser not supporting constructor arguments.Nested classes/interfaces inherited from interface org.opensearch.core.xcontent.ToXContent
org.opensearch.core.xcontent.ToXContent.DelegatingMapParams, org.opensearch.core.xcontent.ToXContent.MapParams, org.opensearch.core.xcontent.ToXContent.Params
Nested classes/interfaces inherited from interface org.opensearch.core.common.io.stream.Writeable
org.opensearch.core.common.io.stream.Writeable.Reader<V>, org.opensearch.core.common.io.stream.Writeable.WriteableRegistry, org.opensearch.core.common.io.stream.Writeable.Writer<V>
-
Field Summary
Modifier and TypeFieldDescriptionprotected final String
protected final String
protected final int
Fields inherited from interface org.opensearch.core.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractAllocateAllocationCommand
(String index, int shardId, String node) protected
AbstractAllocateAllocationCommand
(org.opensearch.core.common.io.stream.StreamInput in) Read from a stream. -
Method Summary
Modifier and TypeMethodDescriptionprotected static <T extends AbstractAllocateAllocationCommand.Builder<?>>
org.opensearch.core.xcontent.ObjectParser<T, Void> createAllocateParser
(String command) boolean
protected RerouteExplanation
explainOrThrowMissingRoutingNode
(RoutingAllocation allocation, boolean explain, DiscoveryNode discoNode) Handle case where a disco node cannot be found in the routing table.protected RerouteExplanation
explainOrThrowRejectedCommand
(boolean explain, RoutingAllocation allocation, RuntimeException rte) Utility method for rejecting the current allocation command based on provided exceptionprotected RerouteExplanation
explainOrThrowRejectedCommand
(boolean explain, RoutingAllocation allocation, String reason) Utility method for rejecting the current allocation command based on provided reasonprotected void
extraXContent
(org.opensearch.core.xcontent.XContentBuilder builder) int
hashCode()
index()
Get the index nameprotected void
initializeUnassignedShard
(RoutingAllocation allocation, RoutingNodes routingNodes, RoutingNode routingNode, ShardRouting shardRouting) Initializes an unassigned shard on a node and removes it from the unassignedprotected void
initializeUnassignedShard
(RoutingAllocation allocation, RoutingNodes routingNodes, RoutingNode routingNode, ShardRouting shardRouting, UnassignedInfo unassignedInfo, RecoverySource recoverySource) Initializes an unassigned shard on a node and removes it from the unassignednode()
Get the id of the nodeint
shardId()
Get the shard idorg.opensearch.core.xcontent.XContentBuilder
toXContent
(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) void
writeTo
(org.opensearch.core.common.io.stream.StreamOutput out) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opensearch.cluster.routing.allocation.command.AllocationCommand
execute, getMessage, getWriteableName, name
Methods inherited from interface org.opensearch.core.xcontent.ToXContentObject
isFragment
-
Field Details
-
index
-
shardId
protected final int shardId -
node
-
-
Constructor Details
-
AbstractAllocateAllocationCommand
-
AbstractAllocateAllocationCommand
protected AbstractAllocateAllocationCommand(org.opensearch.core.common.io.stream.StreamInput in) throws IOException Read from a stream.- Throws:
IOException
-
-
Method Details
-
createAllocateParser
protected static <T extends AbstractAllocateAllocationCommand.Builder<?>> org.opensearch.core.xcontent.ObjectParser<T,Void> createAllocateParser(String command) -
writeTo
- Specified by:
writeTo
in interfaceorg.opensearch.core.common.io.stream.Writeable
- Throws:
IOException
-
index
Get the index name- Returns:
- name of the index
-
shardId
public int shardId()Get the shard id- Returns:
- id of the shard
-
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, String reason) Utility method for rejecting the current allocation command based on provided reason -
explainOrThrowRejectedCommand
protected RerouteExplanation explainOrThrowRejectedCommand(boolean explain, RoutingAllocation allocation, 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 org.opensearch.core.xcontent.XContentBuilder toXContent(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) throws IOException - Specified by:
toXContent
in interfaceorg.opensearch.core.xcontent.ToXContent
- Throws:
IOException
-
extraXContent
protected void extraXContent(org.opensearch.core.xcontent.XContentBuilder builder) throws IOException - Throws:
IOException
-
equals
-
hashCode
public int hashCode()
-