Class RoutingTable
java.lang.Object
org.elasticsearch.cluster.routing.RoutingTable
- All Implemented Interfaces:
Iterable<IndexRoutingTable>
,Diffable<RoutingTable>
,Writeable
public class RoutingTable
extends Object
implements 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
Modifier and TypeClassDescriptionstatic class
Builder for the routing table.Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionactivePrimaryShardsGrouped(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).allActiveShardsGrouped(String[] indices, boolean includeEmpty)
Return GroupShardsIterator where each active shard routing has it's own shard iterator.allAssignedShardsGrouped(String[] indices, boolean includeEmpty)
Return GroupShardsIterator where each assigned shard routing has it's own shard iterator.All the shards (replicas) for all indices in this routing table.All the shards (replicas) for the provided index.allShardsIncludingRelocationTargets(String[] indices)
static RoutingTable.Builder
builder()
static RoutingTable.Builder
builder(RoutingTable routingTable)
diff(RoutingTable previousState)
Returns serializable object representing differences between this and previousStategetByAllocationId(ShardId shardId, String allocationId)
boolean
boolean
iterator()
static Diff<RoutingTable>
static RoutingTable
readFrom(StreamInput in)
shardRoutingTable(String index, int shardId)
All shards for the provided index and shard idstatic IndexShardRoutingTable
shardRoutingTable(IndexRoutingTable indexRouting, int shardId)
Get's theIndexShardRoutingTable
for the given shard id from the givenIndexRoutingTable
or throws aShardNotFoundException
if no shard by the given id is found in the IndexRoutingTable.shardRoutingTable(ShardId shardId)
All shards for the providedShardId
shardsWithState(ShardRoutingState state)
toString()
boolean
long
version()
Returns the version of theRoutingTable
.void
writeTo(StreamOutput out)
Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
EMPTY_ROUTING_TABLE
-
-
Method Details
-
shardRoutingTable
Get's theIndexShardRoutingTable
for the given shard id from the givenIndexRoutingTable
or throws aShardNotFoundException
if 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:
iterator
in interfaceIterable<IndexRoutingTable>
-
hasIndex
-
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(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(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(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:Diffable
Returns serializable object representing differences between this and previousState- Specified by:
diff
in interfaceDiffable<RoutingTable>
-
readDiffFrom
- Throws:
IOException
-
readFrom
- Throws:
IOException
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
builder
-
builder
-
toString
-