Class RoutingTable

org.elasticsearch.cluster.routing.RoutingTable
All Implemented Interfaces:
<IndexRoutingTable>, Diffable<RoutingTable>, Writeable

public class RoutingTable extends implements <IndexRoutingTable>, Diffable<RoutingTable>
Represents a global cluster-wide routing table for all indices including the version of the current routing state.
See Also:
IndexRoutingTable
  • Field Details

    • EMPTY_ROUTING_TABLE

      public static final RoutingTable EMPTY_ROUTING_TABLE
  • Method Details

    • shardRoutingTable

      public static IndexShardRoutingTable shardRoutingTable(IndexRoutingTable indexRouting, int shardId)
      Get's the IndexShardRoutingTable for the given shard id from the given IndexRoutingTable or throws a ShardNotFoundException if no shard by the given id is found in the IndexRoutingTable.
      Parameters:
      indexRouting - IndexRoutingTable
      shardId - ShardId
      Returns:
      IndexShardRoutingTable
    • version

      public long version()
      Returns the version of the RoutingTable.
      Returns:
      version of the RoutingTable
    • iterator

      public <IndexRoutingTable> iterator()
      Specified by:
       in interface <IndexRoutingTable>
    • hasIndex

      public boolean hasIndex( index)
    • hasIndex

      public boolean hasIndex(Index index)
    • index

      public  index)
    • index

      public IndexRoutingTable index(Index index)
    • indicesRouting

      public ,​IndexRoutingTable> indicesRouting()
    • getIndicesRouting

      public ,​IndexRoutingTable> getIndicesRouting()
    • shardRoutingTable

      public  index, int shardId)
      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 exist
      ShardNotFoundException - if provided shard id is unknown
    • shardRoutingTable

      public IndexShardRoutingTable shardRoutingTable(ShardId shardId)
      All shards for the provided ShardId
      Returns:
      All the shard routing entries for the given index and shard id
      Throws:
      IndexNotFoundException - if provided index does not exist
      ShardNotFoundException - if provided shard id is unknown
    • getByAllocationId

      @Nullable public ShardRouting getByAllocationId(ShardId shardId,  allocationId)
    • validate

      public boolean validate(Metadata metadata)
    • shardsWithState

      public <ShardRouting> shardsWithState(ShardRoutingState state)
    • allShards

      public <ShardRouting> allShards()
      All the shards (replicas) for all indices in this routing table.
      Returns:
      All the shards
    • allShards

      public < index)
      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 [] 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 [] 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

      public [] indices)
    • allShardsIncludingRelocationTargets

      public [] indices)
    • activePrimaryShardsGrouped

      public [] 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

      public Diff<RoutingTable> diff(RoutingTable previousState)
      Description copied from interface: Diffable
      Returns serializable object representing differences between this and previousState
      Specified by:
      diff in interface Diffable<RoutingTable>
    • readDiffFrom

      public static Diff<RoutingTable> readDiffFrom(StreamInput in) throws
      Throws:
    • readFrom

      public static RoutingTable readFrom(StreamInput in) throws
      Throws:
    • writeTo

      public void writeTo(StreamOutput out) throws
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
    • builder

      public static RoutingTable.Builder builder()
    • builder

      public static RoutingTable.Builder builder(RoutingTable routingTable)
    • toString

      public  toString()
      Overrides:
       in class