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 class
RoutingTable.Builder
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
Fields Modifier and Type Field Description static RoutingTable
EMPTY_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.ShardsIterator
allShards(java.lang.String[] indices)
ShardsIterator
allShardsIncludingRelocationTargets(java.lang.String[] indices)
static RoutingTable.Builder
builder()
static RoutingTable.Builder
builder(RoutingTable routingTable)
Diff<RoutingTable>
diff(RoutingTable previousState)
Returns serializable object representing differences between this and previousStateShardRouting
getByAllocationId(ShardId shardId, java.lang.String allocationId)
ImmutableOpenMap<java.lang.String,IndexRoutingTable>
getIndicesRouting()
boolean
hasIndex(java.lang.String index)
boolean
hasIndex(Index index)
IndexRoutingTable
index(java.lang.String index)
IndexRoutingTable
index(Index index)
ImmutableOpenMap<java.lang.String,IndexRoutingTable>
indicesRouting()
java.util.Iterator<IndexRoutingTable>
iterator()
static Diff<RoutingTable>
readDiffFrom(StreamInput in)
static RoutingTable
readFrom(StreamInput in)
IndexShardRoutingTable
shardRoutingTable(java.lang.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.IndexShardRoutingTable
shardRoutingTable(ShardId shardId)
All shards for the providedShardId
java.util.List<ShardRouting>
shardsWithState(ShardRoutingState state)
java.lang.String
toString()
boolean
validate(MetaData metaData)
long
version()
Returns the version of theRoutingTable
.void
writeTo(StreamOutput out)
Write this into the StreamOutput.
-
Field Details
-
Method Details
-
shardRoutingTable
public static 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.- 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 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:Diffable
Returns serializable object representing differences between this and previousState- Specified by:
diff
in interfaceDiffable<RoutingTable>
-
readDiffFrom
- Throws:
java.io.IOException
-
readFrom
- Throws:
java.io.IOException
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput. -
builder
-
builder
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-