primary
public boolean primary()
Returns
true
iff this shard is a primary.Writeable
, org.elasticsearch.common.xcontent.ToXContent
, org.elasticsearch.common.xcontent.ToXContentObject
public final class ShardRouting extends java.lang.Object implements Writeable, org.elasticsearch.common.xcontent.ToXContentObject
ShardRouting
immutably encapsulates information about shard
indexRoutings like id, state, version, etc.org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params
Writeable.Reader<V>, Writeable.Writer<V>
Modifier and Type | Field | Description |
---|---|---|
static long |
UNAVAILABLE_EXPECTED_SHARD_SIZE |
Used if shard size is not available
|
EMPTY_PARAMS
Constructor | Description |
---|---|
ShardRouting(StreamInput in) |
|
ShardRouting(ShardId shardId,
StreamInput in) |
Modifier and Type | Method | Description |
---|---|---|
boolean |
active() |
|
AllocationId |
allocationId() |
An id that uniquely identifies an allocation.
|
boolean |
assignedToNode() |
Returns
true iff this shard is assigned to a node ie. |
ShardRouting |
cancelRelocation() |
Cancel relocation of a 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., 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.
|
ShardRouting |
getTargetRelocatingShard() |
Returns a shard routing representing the target shard.
|
int |
hashCode() |
|
int |
id() |
The shard id.
|
Index |
index() |
|
ShardRouting |
initialize(java.lang.String nodeId,
java.lang.String existingAllocationId,
long expectedShardSize) |
Initializes an unassigned shard on a node.
|
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 initializeTargetRelocatingShard() |
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.
|
ShardRouting |
moveActiveReplicaToPrimary() |
Make the active shard primary unless it's not primary
|
ShardRouting |
moveToStarted() |
Set the shards state to
STARTED . |
ShardRouting |
moveToUnassigned(UnassignedInfo unassignedInfo) |
Moves the shard to unassigned state.
|
ShardRouting |
moveUnassignedFromPrimary() |
Set the unassigned primary shard to non-primary
|
static ShardRouting |
newUnassigned(ShardId shardId,
boolean primary,
RecoverySource recoverySource,
UnassignedInfo unassignedInfo) |
Creates a new unassigned shard.
|
boolean |
primary() |
Returns
true iff this shard is a primary. |
RecoverySource |
recoverySource() |
Returns recovery source for the given shard.
|
ShardRouting |
reinitializeReplicaShard() |
Reinitializes a replica shard, giving it a fresh allocation id
|
ShardRouting |
relocate(java.lang.String relocatingNodeId,
long expectedShardSize) |
Relocate the shard to another node.
|
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.
|
ShardRouting |
removeRelocationSource() |
Removes relocation source of a non-primary shard.
|
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() |
|
org.elasticsearch.common.xcontent.XContentBuilder |
toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder,
org.elasticsearch.common.xcontent.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.
|
ShardRouting |
updateUnassigned(UnassignedInfo unassignedInfo,
RecoverySource recoverySource) |
|
void |
writeTo(StreamOutput out) |
Write this into the StreamOutput.
|
void |
writeToThin(StreamOutput out) |
Writes shard information to
StreamOutput without writing index name and shard id |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isFragment
java.io.IOException
java.io.IOException
true
iff the this shard is currently relocating to
another node. Otherwise false
ShardRoutingState.RELOCATING
true
iff this shard is a primary.StreamOutput
without writing index name and shard idout
- StreamOutput
to write shard information tojava.io.IOException
- if something happens during writeWriteable
existingAllocationId
- allocation id to use. If null, a fresh allocation id is generated.relocatingNodeId
- id of the node to relocate the shardRELOCATING
.INITIALIZING
.
This allows the non-primary shard to continue recovery from the primary even though its non-primary
relocation source has failed.STARTED
. The shards state must be
INITIALIZING
or RELOCATING
. Any relocation will be
canceled.IllegalShardRoutingStateException
- if shard is already a primaryIllegalShardRoutingStateException
- if shard is already a replica
Note: if both shard routing has a null as their allocationId()
, this method returns false as the routing describe
no allocation at all..
true
if this shard is a relocation target for another shard
(i.e., was created with initializeTargetRelocatingShard()
equals
in class java.lang.Object
hashCode
in class java.lang.Object
toString
in class java.lang.Object
toXContent
in interface org.elasticsearch.common.xcontent.ToXContent
java.io.IOException
ShardRoutingState.RELOCATING
and ShardRoutingState.INITIALIZING
shards. If it's size is not available -1L will be returned.RecoverySource.PeerRecoverySource
.active()