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.delayed
- true if allocation of this shard is delayed due toINDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING
.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.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!lastAllocationStatus
- status for the last allocation attempt for this shard.failedNodeIds
- A set of nodeIds that failed to complete allocations for this shard.ReplicaShardAllocator
uses 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Captures the status of an unsuccessful allocation attempt for the shard, causing it to remain in the unassigned state.static enum
Reason why the shard is in unassigned state.Nested classes/interfaces inherited from interface org.elasticsearch.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
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 aUnassignedInfo
record class. -
Method Summary
Modifier and TypeMethodDescriptionboolean
delayed()
Returns the value of thedelayed
record component.details()
Builds a string representation of the message and the failure if exists.boolean
Indicates whether some other object is "equal to" this one.int
Returns the value of thefailedAllocations
record component.Returns the value of thefailedNodeIds
record component.failure()
Returns the value of thefailure
record component.static long
findNextDelayedAllocation
(long currentNanoTime, ClusterState state) Finds the next (closest) delay expiration of an delayed shard in nanoseconds based on current time.static UnassignedInfo
static int
Returns the number of shards that are unassigned and currently being delayed.int
hashCode()
Returns a hash code value for this object.Returns the value of thelastAllocatedNodeId
record component.Returns the value of thelastAllocationStatus
record component.message()
Returns the value of themessage
record component.reason()
Returns the value of thereason
record component.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.toString()
Returns a string representation of this record class.toXContent
(XContentBuilder builder, ToXContent.Params params) long
Returns the value of theunassignedTimeMillis
record component.long
Returns the value of theunassignedTimeNanos
record component.void
writeTo
(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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.Reason
for 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 aUnassignedInfo
record class.- Parameters:
reason
- the value for thereason
record componentmessage
- the value for themessage
record componentfailure
- the value for thefailure
record componentfailedAllocations
- the value for thefailedAllocations
record componentunassignedTimeNanos
- the value for theunassignedTimeNanos
record componentunassignedTimeMillis
- the value for theunassignedTimeMillis
record componentdelayed
- the value for thedelayed
record componentlastAllocationStatus
- the value for thelastAllocationStatus
record componentfailedNodeIds
- the value for thefailedNodeIds
record componentlastAllocatedNodeId
- the value for thelastAllocatedNodeId
record component
-
-
Method Details
-
fromStreamInput
- Throws:
IOException
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in 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:
toXContent
in 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 thereason
record component.- Returns:
- the value of the
reason
record component
-
message
Returns the value of themessage
record component.- Returns:
- the value of the
message
record component
-
failure
Returns the value of thefailure
record component.- Returns:
- the value of the
failure
record component
-
failedAllocations
public int failedAllocations()Returns the value of thefailedAllocations
record component.- Returns:
- the value of the
failedAllocations
record component
-
unassignedTimeNanos
public long unassignedTimeNanos()Returns the value of theunassignedTimeNanos
record component.- Returns:
- the value of the
unassignedTimeNanos
record component
-
unassignedTimeMillis
public long unassignedTimeMillis()Returns the value of theunassignedTimeMillis
record component.- Returns:
- the value of the
unassignedTimeMillis
record component
-
delayed
public boolean delayed()Returns the value of thedelayed
record component.- Returns:
- the value of the
delayed
record component
-
lastAllocationStatus
Returns the value of thelastAllocationStatus
record component.- Returns:
- the value of the
lastAllocationStatus
record component
-
failedNodeIds
Returns the value of thefailedNodeIds
record component.- Returns:
- the value of the
failedNodeIds
record component
-
lastAllocatedNodeId
Returns the value of thelastAllocatedNodeId
record component.- Returns:
- the value of the
lastAllocatedNodeId
record component
-