Class IndexRoutingTable
- java.lang.Object
-
- org.elasticsearch.cluster.AbstractDiffable<IndexRoutingTable>
-
- org.elasticsearch.cluster.routing.IndexRoutingTable
-
- All Implemented Interfaces:
java.lang.Iterable<IndexShardRoutingTable>,Diffable<IndexRoutingTable>,Writeable
public class IndexRoutingTable extends AbstractDiffable<IndexRoutingTable> implements java.lang.Iterable<IndexShardRoutingTable>
TheIndexRoutingTablerepresents 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 oneprimaryand 1 or more replicas. In other words, each instance of a shard is considered a replica while only one replica per shard is aprimaryreplica. Theprimaryreplica 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIndexRoutingTable.Builder-
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallPrimaryShardsActive()Returnstrueif all shards are primary and active.booleanallPrimaryShardsUnassigned()Returnstrueif all primary shards are inShardRoutingState.UNASSIGNEDstate.static IndexRoutingTable.Builderbuilder(Index index)booleanequals(java.lang.Object o)IndexgetIndex()Return the index idImmutableOpenIntMap<IndexShardRoutingTable>getShards()inthashCode()java.util.Iterator<IndexShardRoutingTable>iterator()intnumberOfNodesShardsAreAllocatedOn(java.lang.String... excludedNodes)Calculates the number of nodes that hold one or more shards of this indexIndexRoutingTableexcluding the nodes with the node ids give as theexcludedNodesparameter.java.lang.StringprettyPrint()intprimaryShardsActive()Calculates the number of primary shards in active state in routing tableintprimaryShardsUnassigned()Calculates the number of primary shards in the routing table the are inShardRoutingState.UNASSIGNEDstate.ShardsIteratorrandomAllActiveShardsIt()Returns an unordered iterator over all active shards (including replicas).static Diff<IndexRoutingTable>readDiffFrom(StreamInput in)static IndexRoutingTablereadFrom(StreamInput in)IndexShardRoutingTableshard(int shardId)ImmutableOpenIntMap<IndexShardRoutingTable>shards()java.util.List<ShardRouting>shardsWithState(ShardRoutingState state)Returns aListof shards that match one of the states listed instatesvoidwriteTo(StreamOutput out)Write this into the StreamOutput.-
Methods inherited from class org.elasticsearch.cluster.AbstractDiffable
diff, get, readDiffFrom
-
-
-
-
Method Detail
-
getIndex
public Index getIndex()
Return the index id- Returns:
- id of the index
-
iterator
public java.util.Iterator<IndexShardRoutingTable> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<IndexShardRoutingTable>
-
numberOfNodesShardsAreAllocatedOn
public int numberOfNodesShardsAreAllocatedOn(java.lang.String... excludedNodes)
Calculates the number of nodes that hold one or more shards of this indexIndexRoutingTableexcluding the nodes with the node ids give as theexcludedNodesparameter.- Parameters:
excludedNodes- id of nodes that will be excluded- Returns:
- number of distinct nodes this index has at least one shard allocated on
-
shards
public ImmutableOpenIntMap<IndexShardRoutingTable> shards()
-
getShards
public ImmutableOpenIntMap<IndexShardRoutingTable> getShards()
-
shard
public IndexShardRoutingTable shard(int shardId)
-
allPrimaryShardsActive
public boolean allPrimaryShardsActive()
Returnstrueif all shards are primary and active. Otherwisefalse.
-
primaryShardsActive
public int primaryShardsActive()
Calculates the number of primary shards in active state in routing table- Returns:
- number of active primary shards
-
allPrimaryShardsUnassigned
public boolean allPrimaryShardsUnassigned()
-
primaryShardsUnassigned
public int primaryShardsUnassigned()
Calculates the number of primary shards in the routing table the are inShardRoutingState.UNASSIGNEDstate.
-
shardsWithState
public java.util.List<ShardRouting> shardsWithState(ShardRoutingState state)
Returns aListof shards that match one of the states listed instates- Parameters:
state-ShardRoutingStateto retrieve- Returns:
- a
Listof shards that match one of the givenstates
-
randomAllActiveShardsIt
public ShardsIterator randomAllActiveShardsIt()
Returns an unordered iterator over all active shards (including replicas).
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
readFrom
public static IndexRoutingTable readFrom(StreamInput in) throws java.io.IOException
- Throws:
java.io.IOException
-
readDiffFrom
public static Diff<IndexRoutingTable> readDiffFrom(StreamInput in) throws java.io.IOException
- Throws:
java.io.IOException
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:WriteableWrite this into the StreamOutput.
-
builder
public static IndexRoutingTable.Builder builder(Index index)
-
prettyPrint
public java.lang.String prettyPrint()
-
-