public final class ShardRouting extends java.lang.Object implements Streamable, ToXContent
ShardRouting
immutably encapsulates information about shard
routings like id, state, version, etc.ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Modifier and Type | Field and Description |
---|---|
static long |
UNAVAILABLE_EXPECTED_SHARD_SIZE
Used if shard size is not available
|
EMPTY_PARAMS
Constructor and Description |
---|
ShardRouting(ShardRouting copy) |
Modifier and Type | Method and Description |
---|---|
boolean |
active()
|
boolean |
allocatedPostIndexCreate(IndexMetaData indexMetaData) |
AllocationId |
allocationId()
An id that uniquely identifies an allocation.
|
boolean |
assignedToNode()
Returns
true iff this shard is assigned to a node ie. |
ShardRouting |
buildTargetRelocatingShard()
Creates a shard routing representing the target shard.
|
java.lang.String |
currentNodeId()
The current node id the shard is allocated on.
|
boolean |
equals(java.lang.Object o) |
boolean |
equalsIgnoringMetaData(ShardRouting other)
returns true if the current routing is identical to the other routing in all but meta fields, i.e., version and unassigned info
|
long |
getExpectedShardSize()
Returns the expected shard size for
ShardRoutingState.RELOCATING and ShardRoutingState.INITIALIZING
shards. |
int |
getId()
The shard id.
|
java.lang.String |
getIndexName()
The index name.
|
int |
hashCode() |
int |
id()
The shard id.
|
Index |
index() |
boolean |
initializing()
The shard is initializing (usually recovering either from peer shard
or from gateway).
|
boolean |
isRelocationSourceOf(ShardRouting other)
returns true if the routing is the relocation source for the given routing
|
boolean |
isRelocationTarget()
Returns
true if this shard is a relocation target for another shard (i.e., was created with buildTargetRelocatingShard() |
boolean |
isRelocationTargetOf(ShardRouting other)
returns true if the routing is the relocation target of the given routing
|
boolean |
isSameAllocation(ShardRouting other)
returns true if this routing has the same allocation ID as another.
|
boolean |
isSameShard(ShardRouting other)
returns true if this routing has the same shardId as another
|
static ShardRouting |
newUnassigned(Index index,
int shardId,
RestoreSource restoreSource,
boolean primary,
UnassignedInfo unassignedInfo)
Creates a new unassigned shard.
|
boolean |
primary()
Returns
true iff this shard is a primary. |
void |
readFrom(StreamInput in)
Set this object's fields from a StreamInput.
|
void |
readFrom(StreamInput in,
Index index,
int shardId) |
void |
readFromThin(StreamInput in) |
static ShardRouting |
readShardRoutingEntry(StreamInput in) |
static ShardRouting |
readShardRoutingEntry(StreamInput in,
Index index,
int shardId) |
boolean |
relocating()
Returns
true iff the this shard is currently relocating to
another node. |
java.lang.String |
relocatingNodeId()
The relocating node id the shard is either relocating to or relocating from.
|
RestoreSource |
restoreSource()
Snapshot id and repository where this shard is being restored from
|
ShardId |
shardId()
The shard id.
|
ShardIterator |
shardsIt()
A shard iterator with just this shard in it.
|
java.lang.String |
shortSummary()
A short description of the shard.
|
boolean |
started()
The shard is in started mode.
|
ShardRoutingState |
state()
The shard state.
|
java.lang.String |
toString() |
XContentBuilder |
toXContent(XContentBuilder builder,
ToXContent.Params params) |
boolean |
unassigned()
The shard is unassigned (not allocated to any node).
|
UnassignedInfo |
unassignedInfo()
Additional metadata on why the shard is/was unassigned.
|
void |
updateUnassignedInfo(UnassignedInfo unassignedInfo) |
void |
writeTo(StreamOutput out)
Write this object's fields to a StreamOutput.
|
void |
writeToThin(StreamOutput out)
Writes shard information to
StreamOutput without writing index name and shard id |
public static final long UNAVAILABLE_EXPECTED_SHARD_SIZE
public ShardRouting(ShardRouting copy)
public static ShardRouting newUnassigned(Index index, int shardId, RestoreSource restoreSource, boolean primary, UnassignedInfo unassignedInfo)
public Index index()
public java.lang.String getIndexName()
public int id()
public int getId()
public boolean unassigned()
public boolean initializing()
public boolean active()
public boolean started()
public boolean relocating()
true
iff the this shard is currently relocating to
another node. Otherwise false
ShardRoutingState.RELOCATING
public boolean assignedToNode()
public java.lang.String currentNodeId()
public java.lang.String relocatingNodeId()
public ShardRouting buildTargetRelocatingShard()
public RestoreSource restoreSource()
@Nullable public UnassignedInfo unassignedInfo()
@Nullable public AllocationId allocationId()
public boolean primary()
true
iff this shard is a primary.public ShardRoutingState state()
public ShardId shardId()
public boolean allocatedPostIndexCreate(IndexMetaData indexMetaData)
public ShardIterator shardsIt()
public static ShardRouting readShardRoutingEntry(StreamInput in) throws java.io.IOException
java.io.IOException
public static ShardRouting readShardRoutingEntry(StreamInput in, Index index, int shardId) throws java.io.IOException
java.io.IOException
public void readFrom(StreamInput in, Index index, int shardId) throws java.io.IOException
java.io.IOException
public void readFromThin(StreamInput in) throws java.io.IOException
java.io.IOException
public void readFrom(StreamInput in) throws java.io.IOException
Streamable
readFrom
in interface Streamable
java.io.IOException
public void writeToThin(StreamOutput out) throws java.io.IOException
StreamOutput
without writing index name and shard idout
- StreamOutput
to write shard information tojava.io.IOException
- if something happens during writepublic void writeTo(StreamOutput out) throws java.io.IOException
Streamable
writeTo
in interface Streamable
java.io.IOException
public void updateUnassignedInfo(UnassignedInfo unassignedInfo)
public boolean isSameShard(ShardRouting other)
public boolean isSameAllocation(ShardRouting other)
Note: if both shard routing has a null as their allocationId()
, this method returns false as the routing describe
no allocation at all..
public boolean isRelocationTarget()
true
if this shard is a relocation target for another shard (i.e., was created with buildTargetRelocatingShard()
public boolean isRelocationTargetOf(ShardRouting other)
public boolean isRelocationSourceOf(ShardRouting other)
public boolean equalsIgnoringMetaData(ShardRouting other)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String shortSummary()
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
toXContent
in interface ToXContent
java.io.IOException
public long getExpectedShardSize()
ShardRoutingState.RELOCATING
and ShardRoutingState.INITIALIZING
shards. If it's size is not available -1L will be returned.