Module org.elasticsearch.server
Record Class UnassignedInfo
java.lang.Object
java.lang.Record
org.elasticsearch.cluster.routing.UnassignedInfo
- Record Components:
reason- why the shard is unassigned.message- optional details explaining the reasons.failure- additional failure exception details if exists.failedAllocations- number of previously failed allocations of this shard.unassignedTimeNanos- The timestamp in nanoseconds when the shard became unassigned, based on System.nanoTime(). Used to calculate the delay for delayed shard allocation. ONLY EXPOSED FOR TESTS!unassignedTimeMillis- The timestamp in milliseconds when the shard became unassigned, based on System.currentTimeMillis(). Note, we use timestamp here since we want to make sure its preserved across node serializations.delayed- true if allocation of this shard is delayed due toINDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.lastAllocationStatus- status for the last allocation attempt for this shard.failedNodeIds- A set of nodeIds that failed to complete allocations for this shard.ReplicaShardAllocatoruses this bset to avoid repeatedly canceling ongoing recoveries for copies on those nodes, although they can perform noop recoveries. This set will be discarded when a shard moves to started. And if a shard is failed while started (i.e., from started to unassigned), the currently assigned node won't be added to this set.lastAllocatedNodeId- ID of the node this shard was last allocated to, or null if unavailable.
- All Implemented Interfaces:
Writeable,ToXContent,ToXContentFragment
public record UnassignedInfo(UnassignedInfo.Reason reason, String message, Exception failure, int failedAllocations, long unassignedTimeNanos, long unassignedTimeMillis, boolean delayed, UnassignedInfo.AllocationStatus lastAllocationStatus, Set<String> failedNodeIds, String lastAllocatedNodeId)
extends Record
implements ToXContentFragment, Writeable
Holds additional information as to why the shard is in an unassigned state.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumCaptures the status of an unsuccessful allocation attempt for the shard, causing it to remain in the unassigned state.static enumReason why the shard is in unassigned state.Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested 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.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
ConstructorsConstructorDescriptionUnassignedInfo(UnassignedInfo.Reason reason, String message) creates an UnassignedInfo object based on **current** timeUnassignedInfo(UnassignedInfo.Reason reason, String message, Exception failure, int failedAllocations, long unassignedTimeNanos, long unassignedTimeMillis, boolean delayed, UnassignedInfo.AllocationStatus lastAllocationStatus, Set<String> failedNodeIds, String lastAllocatedNodeId) Creates an instance of aUnassignedInforecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleandelayed()Returns the value of thedelayedrecord component.details()Builds a string representation of the message and the failure if exists.booleanIndicates whether some other object is "equal to" this one.intReturns the value of thefailedAllocationsrecord component.Returns the value of thefailedNodeIdsrecord component.failure()Returns the value of thefailurerecord component.static longfindNextDelayedAllocation(long currentNanoTime, ClusterState state) Finds the next (closest) delay expiration of an delayed shard in nanoseconds based on current time.static UnassignedInfostatic intReturns the number of shards that are unassigned and currently being delayed.inthashCode()Returns a hash code value for this object.Returns the value of thelastAllocatedNodeIdrecord component.Returns the value of thelastAllocationStatusrecord component.message()Returns the value of themessagerecord component.reason()Returns the value of thereasonrecord component.longremainingDelay(long nanoTimeNow, Settings indexSettings, NodesShutdownMetadata nodesShutdownMetadata) Calculates the delay left based on current time (in nanoseconds) and the delay defined by the index settings.toString()Returns a string representation of this record class.toXContent(XContentBuilder builder, ToXContent.Params params) longReturns the value of theunassignedTimeMillisrecord component.longReturns the value of theunassignedTimeNanosrecord component.voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.xcontent.ToXContentFragment
isFragment
-
Field Details
-
DATE_TIME_FORMATTER
-
INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING
-
-
Constructor Details
-
UnassignedInfo
creates an UnassignedInfo object based on **current** time- Parameters:
reason- the cause for making this shard unassigned. SeeUnassignedInfo.Reasonfor more information.message- more information about cause.
-
UnassignedInfo
public UnassignedInfo(UnassignedInfo.Reason reason, @Nullable String message, @Nullable Exception failure, int failedAllocations, long unassignedTimeNanos, long unassignedTimeMillis, boolean delayed, UnassignedInfo.AllocationStatus lastAllocationStatus, Set<String> failedNodeIds, @Nullable String lastAllocatedNodeId) Creates an instance of aUnassignedInforecord class.- Parameters:
reason- the value for thereasonrecord componentmessage- the value for themessagerecord componentfailure- the value for thefailurerecord componentfailedAllocations- the value for thefailedAllocationsrecord componentunassignedTimeNanos- the value for theunassignedTimeNanosrecord componentunassignedTimeMillis- the value for theunassignedTimeMillisrecord componentdelayed- the value for thedelayedrecord componentlastAllocationStatus- the value for thelastAllocationStatusrecord componentfailedNodeIds- the value for thefailedNodeIdsrecord componentlastAllocatedNodeId- the value for thelastAllocatedNodeIdrecord component
-
-
Method Details
-
fromStreamInput
- Throws:
IOException
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
details
Builds a string representation of the message and the failure if exists. -
remainingDelay
public long remainingDelay(long nanoTimeNow, Settings indexSettings, NodesShutdownMetadata nodesShutdownMetadata) Calculates the delay left based on current time (in nanoseconds) and the delay defined by the index settings. Only relevant if shard is effectively delayed (seedelayed()) Returns 0 if delay is negative- Returns:
- calculated delay in nanoseconds
-
getNumberOfDelayedUnassigned
Returns the number of shards that are unassigned and currently being delayed. -
findNextDelayedAllocation
Finds the next (closest) delay expiration of an delayed shard in nanoseconds based on current time. Returns 0 if delay is negative. Returns -1 if no delayed shard is found. -
shortSummary
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
hashCode
public int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
reason
Returns the value of thereasonrecord component.- Returns:
- the value of the
reasonrecord component
-
message
Returns the value of themessagerecord component.- Returns:
- the value of the
messagerecord component
-
failure
Returns the value of thefailurerecord component.- Returns:
- the value of the
failurerecord component
-
failedAllocations
public int failedAllocations()Returns the value of thefailedAllocationsrecord component.- Returns:
- the value of the
failedAllocationsrecord component
-
unassignedTimeNanos
public long unassignedTimeNanos()Returns the value of theunassignedTimeNanosrecord component.- Returns:
- the value of the
unassignedTimeNanosrecord component
-
unassignedTimeMillis
public long unassignedTimeMillis()Returns the value of theunassignedTimeMillisrecord component.- Returns:
- the value of the
unassignedTimeMillisrecord component
-
delayed
public boolean delayed()Returns the value of thedelayedrecord component.- Returns:
- the value of the
delayedrecord component
-
lastAllocationStatus
Returns the value of thelastAllocationStatusrecord component.- Returns:
- the value of the
lastAllocationStatusrecord component
-
failedNodeIds
Returns the value of thefailedNodeIdsrecord component.- Returns:
- the value of the
failedNodeIdsrecord component
-
lastAllocatedNodeId
Returns the value of thelastAllocatedNodeIdrecord component.- Returns:
- the value of the
lastAllocatedNodeIdrecord component
-