Class UnassignedInfo
java.lang.Object
org.elasticsearch.cluster.routing.UnassignedInfo
- All Implemented Interfaces:
Writeable
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentFragment
public final class UnassignedInfo
extends Object
implements org.elasticsearch.common.xcontent.ToXContentFragment, Writeable
Holds additional information as to why the shard is in unassigned state.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Captures the status of an unsuccessful allocation attempt for the shard, causing it to remain in the unassigned state.static class
Reason why the shard is in unassigned state.Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Modifier and TypeFieldDescriptionstatic DateFormatter
static Setting<org.elasticsearch.core.TimeValue>
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ConstructorDescriptionUnassignedInfo(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)
-
Method Summary
Modifier and TypeMethodDescriptionboolean
static long
findNextDelayedAllocation(long currentNanoTime, ClusterState state)
Finds the next (closest) delay expiration of an delayed shard in nanoseconds based on current time.Builds a string representation of the message and the failure if exists.A set of nodeIds that failed to complete allocations for this shard.Returns additional failure exception details if exists.Get the status for the last allocation attempt for this shard.Returns optional details explaining the reasons.static int
Returns the number of shards that are unassigned and currently being delayed.int
Returns the number of previously failed allocations of this shard.The reason why the shard is unassigned.long
getRemainingDelay(long nanoTimeNow, Settings indexSettings)
Calculates the delay left based on current time (in nanoseconds) and the delay defined by the index settings.long
The timestamp in milliseconds when the shard became unassigned, based on System.currentTimeMillis().long
The timestamp in nanoseconds when the shard became unassigned, based on System.nanoTime().int
hashCode()
boolean
Returns true if allocation of this shard is delayed due toINDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING
toString()
org.elasticsearch.common.xcontent.XContentBuilder
toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
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.common.xcontent.ToXContentFragment
isFragment
-
Field Details
-
DATE_TIME_FORMATTER
-
INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING
public static final Setting<org.elasticsearch.core.TimeValue> 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)- Parameters:
reason
- the cause for making this shard unassigned. SeeUnassignedInfo.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 calculationunassignedTimeMillis
- 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 shardfailedNodeIds
- a set of nodeIds that failed to complete allocations for this shard
-
UnassignedInfo
- Throws:
IOException
-
-
Method Details
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
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 toINDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING
-
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
Returns optional details explaining the reasons. -
getFailure
Returns additional failure exception details if exists. -
getDetails
Builds a string representation of the message and the failure if exists. -
getLastAllocationStatus
Get the status for the last allocation attempt for this shard. -
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. -
getRemainingDelay
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 (seeisDelayed()
) 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
-
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException- Specified by:
toXContent
in interfaceorg.elasticsearch.common.xcontent.ToXContent
- Throws:
IOException
-
equals
-
hashCode
public int hashCode()
-