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 to INDEX_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.
See Also:
  • Field Details

    • DATE_TIME_FORMATTER

      public static final DateFormatter DATE_TIME_FORMATTER
    • INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING

      public static final Setting<TimeValue> INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING
  • Constructor Details

  • Method Details

    • fromStreamInput

      public static UnassignedInfo fromStreamInput(StreamInput in) throws IOException
      Throws:
      IOException
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • details

      @Nullable public String 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 (see delayed()) Returns 0 if delay is negative
      Returns:
      calculated delay in nanoseconds
    • getNumberOfDelayedUnassigned

      public static int getNumberOfDelayedUnassigned(ClusterState state)
      Returns the number of shards that are unassigned and currently being delayed.
    • findNextDelayedAllocation

      public static long findNextDelayedAllocation(long currentNanoTime, ClusterState state)
      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

      public String shortSummary()
    • toString

      public String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • toXContent

      public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface ToXContent
      Throws:
      IOException
    • equals

      public boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • reason

      public UnassignedInfo.Reason reason()
      Returns the value of the reason record component.
      Returns:
      the value of the reason record component
    • message

      @Nullable public String message()
      Returns the value of the message record component.
      Returns:
      the value of the message record component
    • failure

      @Nullable public Exception failure()
      Returns the value of the failure record component.
      Returns:
      the value of the failure record component
    • failedAllocations

      public int failedAllocations()
      Returns the value of the failedAllocations record component.
      Returns:
      the value of the failedAllocations record component
    • unassignedTimeNanos

      public long unassignedTimeNanos()
      Returns the value of the unassignedTimeNanos record component.
      Returns:
      the value of the unassignedTimeNanos record component
    • unassignedTimeMillis

      public long unassignedTimeMillis()
      Returns the value of the unassignedTimeMillis record component.
      Returns:
      the value of the unassignedTimeMillis record component
    • delayed

      public boolean delayed()
      Returns the value of the delayed record component.
      Returns:
      the value of the delayed record component
    • lastAllocationStatus

      public UnassignedInfo.AllocationStatus lastAllocationStatus()
      Returns the value of the lastAllocationStatus record component.
      Returns:
      the value of the lastAllocationStatus record component
    • failedNodeIds

      public Set<String> failedNodeIds()
      Returns the value of the failedNodeIds record component.
      Returns:
      the value of the failedNodeIds record component
    • lastAllocatedNodeId

      @Nullable public String lastAllocatedNodeId()
      Returns the value of the lastAllocatedNodeId record component.
      Returns:
      the value of the lastAllocatedNodeId record component