Class UnassignedInfo

All Implemented Interfaces:
Writeable, ToXContent, ToXContentFragment

public final class UnassignedInfo extends Object implements ToXContentFragment, Writeable
Holds additional information as to why the shard is in unassigned state.
  • Field Details


      public static final DateFormatter DATE_TIME_FORMATTER

      public static final Setting<TimeValue> INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING
  • Constructor Details

    • UnassignedInfo

      public UnassignedInfo(UnassignedInfo.Reason reason, String message)
      creates an UnassignedInfo object based on **current** time
      reason - the cause for making this shard unassigned. See UnassignedInfo.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)
      reason - the cause for making this shard unassigned. See UnassignedInfo.Reason for more information.
      message - more information about cause.
      failure - the shard level failure that caused this shard to be unassigned, if exists.
      unassignedTimeNanos - the time to use as the base for any delayed re-assignment calculation
      unassignedTimeMillis - the time of unassignment used to display to in our reporting.
      delayed - if allocation of this shard is delayed due to INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.
      lastAllocationStatus - the result of the last allocation attempt for this shard
      failedNodeIds - a set of nodeIds that failed to complete allocations for this shard
      lastAllocatedNodeId - the ID of the node this shard was last allocated to
    • UnassignedInfo

      public UnassignedInfo(StreamInput in) throws IOException
  • Method Details

    • writeTo

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

      public int getNumFailedAllocations()
      Returns the number of previously failed allocations of this shard.
    • isDelayed

      public boolean isDelayed()
      Returns true if allocation of this shard is delayed due to INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING
    • getReason

      public UnassignedInfo.Reason getReason()
      The reason why the shard is unassigned.
    • getUnassignedTimeInMillis

      public long getUnassignedTimeInMillis()
      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.
    • getUnassignedTimeInNanos

      public long getUnassignedTimeInNanos()
      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!
    • getMessage

      @Nullable public String getMessage()
      Returns optional details explaining the reasons.
    • getFailure

      @Nullable public Exception getFailure()
      Returns additional failure exception details if exists.
    • getDetails

      @Nullable public String getDetails()
      Builds a string representation of the message and the failure if exists.
    • getLastAllocatedNodeId

      @Nullable public String getLastAllocatedNodeId()
      Gets the ID of the node this shard was last allocated to, or null if unavailable.
    • getLastAllocationStatus

      public UnassignedInfo.AllocationStatus getLastAllocationStatus()
      Get the status for the last allocation attempt for this shard.
    • getFailedNodeIds

      public Set<String> getFailedNodeIds()
      A set of nodeIds that failed to complete allocations for this shard. ReplicaShardAllocator uses this set 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.
      See Also:
    • getRemainingDelay

      public long getRemainingDelay(long nanoTimeNow, Settings indexSettings, Map<String,SingleNodeShutdownMetadata> nodesShutdownMap)
      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 isDelayed()) Returns 0 if delay is negative
      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()
      toString in class Object
    • toXContent

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

      public boolean equals(Object o)
      equals in class Object
    • hashCode

      public int hashCode()
      hashCode in class Object