public class IndexRoutingTable extends AbstractDiffable<IndexRoutingTable> implements java.lang.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 related classes, replicas are
represented as ShardRouting
.
Modifier and Type | Class and Description |
---|---|
static class |
IndexRoutingTable.Builder |
Writeable.Reader<V>, Writeable.Writer<V>
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(Index index) |
boolean |
equals(java.lang.Object o) |
Index |
getIndex()
Return the index id
|
ImmutableOpenIntMap<IndexShardRoutingTable> |
getShards() |
int |
hashCode() |
java.util.Iterator<IndexShardRoutingTable> |
iterator() |
int |
numberOfNodesShardsAreAllocatedOn(java.lang.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. |
java.lang.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).
|
static Diff<IndexRoutingTable> |
readDiffFrom(StreamInput in) |
static IndexRoutingTable |
readFrom(StreamInput in) |
IndexShardRoutingTable |
shard(int shardId) |
ImmutableOpenIntMap<IndexShardRoutingTable> |
shards() |
java.util.List<ShardRouting> |
shardsWithState(ShardRoutingState state)
Returns a
List of shards that match one of the states listed in states |
void |
writeTo(StreamOutput out)
Write this into the StreamOutput.
|
diff, get, readDiffFrom
public Index getIndex()
public java.util.Iterator<IndexShardRoutingTable> iterator()
iterator
in interface java.lang.Iterable<IndexShardRoutingTable>
public int numberOfNodesShardsAreAllocatedOn(java.lang.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 java.util.List<ShardRouting> shardsWithState(ShardRoutingState state)
List
of shards that match one of the states listed in states
state
- ShardRoutingState
to retrieveList
of shards that match one of the given states
public ShardsIterator randomAllActiveShardsIt()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public static IndexRoutingTable readFrom(StreamInput in) throws java.io.IOException
java.io.IOException
public static Diff<IndexRoutingTable> readDiffFrom(StreamInput in) throws java.io.IOException
java.io.IOException
public void writeTo(StreamOutput out) throws java.io.IOException
Writeable
public static IndexRoutingTable.Builder builder(Index index)
public java.lang.String prettyPrint()