public final class ShardRouting extends 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) |
ShardRouting(ShardRouting copy,
long version) |
Modifier and Type | Method and Description |
---|---|
boolean |
active()
|
boolean |
allocatedPostIndexCreate() |
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.
|
String |
currentNodeId()
The current node id the shard is allocated on.
|
boolean |
equals(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.
|
String |
getIndex()
The index name.
|
int |
hashCode() |
int |
id()
The shard id.
|
String |
index()
The index name.
|
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(String 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) |
void |
readFrom(StreamInput in,
String index,
int shardId) |
void |
readFromThin(StreamInput in) |
static ShardRouting |
readShardRoutingEntry(StreamInput in) |
static ShardRouting |
readShardRoutingEntry(StreamInput in,
String index,
int shardId) |
boolean |
relocating()
Returns
true iff the this shard is currently relocating to
another node. |
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.
|
String |
shortSummary()
A short description of the shard.
|
boolean |
started()
The shard is in started mode.
|
ShardRoutingState |
state()
The shard state.
|
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) |
long |
version()
The routing version associated with the shard.
|
void |
writeTo(StreamOutput out) |
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 ShardRouting(ShardRouting copy, long version)
public static ShardRouting newUnassigned(String index, int shardId, RestoreSource restoreSource, boolean primary, UnassignedInfo unassignedInfo)
public String index()
public String getIndex()
public int id()
public int getId()
public long version()
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 String currentNodeId()
public 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()
public ShardIterator shardsIt()
public static ShardRouting readShardRoutingEntry(StreamInput in) throws IOException
IOException
public static ShardRouting readShardRoutingEntry(StreamInput in, String index, int shardId) throws IOException
IOException
public void readFrom(StreamInput in, String index, int shardId) throws IOException
IOException
public void readFromThin(StreamInput in) throws IOException
IOException
public void readFrom(StreamInput in) throws IOException
readFrom
in interface Streamable
IOException
public void writeToThin(StreamOutput out) throws IOException
StreamOutput
without writing index name and shard idout
- StreamOutput
to write shard information toIOException
- if something happens during writepublic void writeTo(StreamOutput out) throws IOException
writeTo
in interface Streamable
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 String shortSummary()
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
toXContent
in interface ToXContent
IOException
public long getExpectedShardSize()
ShardRoutingState.RELOCATING
and ShardRoutingState.INITIALIZING
shards. If it's size is not available -1L will be returned.Copyright © 2009–2017. All rights reserved.