public class IndexRoutingTable extends AbstractDiffable<IndexRoutingTable> implements Iterable<IndexShardRoutingTable>
IndexRoutingTable
represents routing information for a single
index. The routing table maintains a list of all shards in the index. A
single shard in this context has one more instances namely exactly one
primary
and 1 or more replicas. In other
words, each instance of a shard is considered a replica while only one
replica per shard is a primary replica. The primary replica
can be seen as the "leader" of the shard acting as the primary entry point
for operations on a specific shard.
Note: The term replica is not directly
reflected in the routing table or in releated classes, replicas are
represented as ShardRouting
.
Modifier and Type | Class and Description |
---|---|
static class |
IndexRoutingTable.Builder |
Modifier and Type | Field and Description |
---|---|
static IndexRoutingTable |
PROTO |
Modifier and Type | Method and Description |
---|---|
boolean |
allPrimaryShardsActive()
Returns
true if all shards are primary and active. |
boolean |
allPrimaryShardsUnassigned()
Returns
true if all primary shards are in
ShardRoutingState.UNASSIGNED state. |
static IndexRoutingTable.Builder |
builder(String index) |
boolean |
equals(Object o) |
String |
getIndex()
Return the index id
|
ImmutableOpenIntMap<IndexShardRoutingTable> |
getShards() |
GroupShardsIterator |
groupByAllIt()
A groups shards iterator where each groups is a single
ShardRouting and a group
is created for each shard routing. |
GroupShardsIterator |
groupByShardsIt()
A group shards iterator where each group (
ShardIterator
is an iterator across shard replication group. |
int |
hashCode() |
String |
index()
Return the index id
|
com.google.common.collect.UnmodifiableIterator<IndexShardRoutingTable> |
iterator() |
IndexRoutingTable |
normalizeVersions()
creates a new
IndexRoutingTable with all shard versions normalized |
int |
numberOfNodesShardsAreAllocatedOn(String... excludedNodes)
Calculates the number of nodes that hold one or more shards of this index
IndexRoutingTable excluding the nodes with the node ids give as
the excludedNodes parameter. |
String |
prettyPrint() |
int |
primaryShardsActive()
Calculates the number of primary shards in active state in routing table
|
int |
primaryShardsUnassigned()
Calculates the number of primary shards in the routing table the are in
ShardRoutingState.UNASSIGNED state. |
ShardsIterator |
randomAllActiveShardsIt()
Returns an unordered iterator over all active shards (including replicas).
|
IndexRoutingTable |
readFrom(StreamInput in)
Reads a copy of an object with the same type form the stream input
The caller object remains unchanged.
|
IndexShardRoutingTable |
shard(int shardId) |
ImmutableOpenIntMap<IndexShardRoutingTable> |
shards() |
List<ShardRouting> |
shardsWithState(ShardRoutingState state)
|
void |
validate() |
List<String> |
validate(IndexMetaData indexMetaData)
validate based on a meta data, returning failures found
|
void |
validate(RoutingTableValidation validation,
MetaData metaData) |
void |
writeTo(StreamOutput out)
Writes the current object into the output stream out
|
diff, get, readDiffFrom, readDiffFrom
public static final IndexRoutingTable PROTO
public String index()
public String getIndex()
public IndexRoutingTable normalizeVersions()
IndexRoutingTable
with all shard versions normalizedIndexRoutingTable
public void validate(RoutingTableValidation validation, MetaData metaData)
public List<String> validate(IndexMetaData indexMetaData)
public com.google.common.collect.UnmodifiableIterator<IndexShardRoutingTable> iterator()
iterator
in interface Iterable<IndexShardRoutingTable>
public int numberOfNodesShardsAreAllocatedOn(String... excludedNodes)
IndexRoutingTable
excluding the nodes with the node ids give as
the excludedNodes
parameter.excludedNodes
- id of nodes that will be excludedpublic ImmutableOpenIntMap<IndexShardRoutingTable> shards()
public ImmutableOpenIntMap<IndexShardRoutingTable> getShards()
public IndexShardRoutingTable shard(int shardId)
public boolean allPrimaryShardsActive()
true
if all shards are primary and active. Otherwise false
.public int primaryShardsActive()
public boolean allPrimaryShardsUnassigned()
public int primaryShardsUnassigned()
ShardRoutingState.UNASSIGNED
state.public List<ShardRouting> shardsWithState(ShardRoutingState state)
state
- ShardRoutingState
to retrieveList
of shards that match one of the given states
public ShardsIterator randomAllActiveShardsIt()
public GroupShardsIterator groupByShardsIt()
ShardIterator
is an iterator across shard replication group.public GroupShardsIterator groupByAllIt()
ShardRouting
and a group
is created for each shard routing.
This basically means that components that use the GroupShardsIterator
will iterate
over *all* the shards (all the replicas) within the index.
public void validate() throws RoutingValidationException
RoutingValidationException
public IndexRoutingTable readFrom(StreamInput in) throws IOException
StreamableReader
readFrom
in interface StreamableReader<IndexRoutingTable>
IOException
public void writeTo(StreamOutput out) throws IOException
Writeable
writeTo
in interface Writeable<IndexRoutingTable>
IOException
public static IndexRoutingTable.Builder builder(String index)
public String prettyPrint()
Copyright © 2009–2017. All rights reserved.