Class RoutingTable
java.lang.Object
org.elasticsearch.cluster.routing.RoutingTable
- All Implemented Interfaces:
java.lang.Iterable<IndexRoutingTable>,Diffable<RoutingTable>,Writeable
public class RoutingTable extends java.lang.Object implements java.lang.Iterable<IndexRoutingTable>, Diffable<RoutingTable>
Represents a global cluster-wide routing table for all indices including the
version of the current routing state.
- See Also:
IndexRoutingTable
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRoutingTable.BuilderBuilder for the routing table.Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
Fields Modifier and Type Field Description static RoutingTableEMPTY_ROUTING_TABLE -
Method Summary
Modifier and Type Method Description GroupShardsIterator<ShardIterator>activePrimaryShardsGrouped(java.lang.String[] indices, boolean includeEmpty)All the *active* primary shards for the provided indices grouped (each group is a single element, consisting of the primary shard).GroupShardsIterator<ShardIterator>allActiveShardsGrouped(java.lang.String[] indices, boolean includeEmpty)Return GroupShardsIterator where each active shard routing has it's own shard iterator.GroupShardsIterator<ShardIterator>allAssignedShardsGrouped(java.lang.String[] indices, boolean includeEmpty)Return GroupShardsIterator where each assigned shard routing has it's own shard iterator.java.util.List<ShardRouting>allShards()All the shards (replicas) for all indices in this routing table.java.util.List<ShardRouting>allShards(java.lang.String index)All the shards (replicas) for the provided index.ShardsIteratorallShards(java.lang.String[] indices)ShardsIteratorallShardsIncludingRelocationTargets(java.lang.String[] indices)static RoutingTable.Builderbuilder()static RoutingTable.Builderbuilder(RoutingTable routingTable)Diff<RoutingTable>diff(RoutingTable previousState)Returns serializable object representing differences between this and previousStateShardRoutinggetByAllocationId(ShardId shardId, java.lang.String allocationId)ImmutableOpenMap<java.lang.String,IndexRoutingTable>getIndicesRouting()booleanhasIndex(java.lang.String index)booleanhasIndex(Index index)IndexRoutingTableindex(java.lang.String index)IndexRoutingTableindex(Index index)ImmutableOpenMap<java.lang.String,IndexRoutingTable>indicesRouting()java.util.Iterator<IndexRoutingTable>iterator()static Diff<RoutingTable>readDiffFrom(StreamInput in)static RoutingTablereadFrom(StreamInput in)IndexShardRoutingTableshardRoutingTable(java.lang.String index, int shardId)All shards for the provided index and shard idstatic IndexShardRoutingTableshardRoutingTable(IndexRoutingTable indexRouting, int shardId)Get's theIndexShardRoutingTablefor the given shard id from the givenIndexRoutingTableor throws aShardNotFoundExceptionif no shard by the given id is found in the IndexRoutingTable.IndexShardRoutingTableshardRoutingTable(ShardId shardId)All shards for the providedShardIdjava.util.List<ShardRouting>shardsWithState(ShardRoutingState state)java.lang.StringtoString()booleanvalidate(Metadata metadata)longversion()Returns the version of theRoutingTable.voidwriteTo(StreamOutput out)Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
EMPTY_ROUTING_TABLE
-
-
Method Details
-
shardRoutingTable
public static IndexShardRoutingTable shardRoutingTable(IndexRoutingTable indexRouting, int shardId)Get's theIndexShardRoutingTablefor the given shard id from the givenIndexRoutingTableor throws aShardNotFoundExceptionif no shard by the given id is found in the IndexRoutingTable.- Parameters:
indexRouting- IndexRoutingTableshardId- ShardId- Returns:
- IndexShardRoutingTable
-
version
public long version()Returns the version of theRoutingTable.- Returns:
- version of the
RoutingTable
-
iterator
- Specified by:
iteratorin interfacejava.lang.Iterable<IndexRoutingTable>
-
hasIndex
public boolean hasIndex(java.lang.String index) -
hasIndex
-
index
-
index
-
indicesRouting
-
getIndicesRouting
-
shardRoutingTable
All shards for the provided index and shard id- Returns:
- All the shard routing entries for the given index and shard id
- Throws:
IndexNotFoundException- if provided index does not existShardNotFoundException- if provided shard id is unknown
-
shardRoutingTable
All shards for the providedShardId- Returns:
- All the shard routing entries for the given index and shard id
- Throws:
IndexNotFoundException- if provided index does not existShardNotFoundException- if provided shard id is unknown
-
getByAllocationId
-
validate
-
shardsWithState
-
allShards
All the shards (replicas) for all indices in this routing table.- Returns:
- All the shards
-
allShards
All the shards (replicas) for the provided index.- Parameters:
index- The index to return all the shards (replicas).- Returns:
- All the shards matching the specific index
- Throws:
IndexNotFoundException- If the index passed does not exists
-
allActiveShardsGrouped
public GroupShardsIterator<ShardIterator> allActiveShardsGrouped(java.lang.String[] indices, boolean includeEmpty)Return GroupShardsIterator where each active shard routing has it's own shard iterator.- Parameters:
includeEmpty- if true, a shard iterator will be added for non-assigned shards as well
-
allAssignedShardsGrouped
public GroupShardsIterator<ShardIterator> allAssignedShardsGrouped(java.lang.String[] indices, boolean includeEmpty)Return GroupShardsIterator where each assigned shard routing has it's own shard iterator.- Parameters:
includeEmpty- if true, a shard iterator will be added for non-assigned shards as well
-
allShards
-
allShardsIncludingRelocationTargets
-
activePrimaryShardsGrouped
public GroupShardsIterator<ShardIterator> activePrimaryShardsGrouped(java.lang.String[] indices, boolean includeEmpty)All the *active* primary shards for the provided indices grouped (each group is a single element, consisting of the primary shard). This is handy for components that expect to get group iterators, but still want in some cases to iterate over all primary shards (and not just one shard in replication group).- Parameters:
indices- The indices to return all the shards (replicas)- Returns:
- All the primary shards grouped into a single shard element group each
- Throws:
IndexNotFoundException- If an index passed does not exists
-
diff
Description copied from interface:DiffableReturns serializable object representing differences between this and previousState- Specified by:
diffin interfaceDiffable<RoutingTable>
-
readDiffFrom
- Throws:
java.io.IOException
-
readFrom
- Throws:
java.io.IOException
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput. -
builder
-
builder
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-