Class IndexShardRoutingTable

java.lang.Object
org.elasticsearch.cluster.routing.IndexShardRoutingTable
All Implemented Interfaces:
Iterable<ShardRouting>

public class IndexShardRoutingTable extends Object implements Iterable<ShardRouting>
IndexShardRoutingTable encapsulates all instances of a single shard. Each Elasticsearch index consists of multiple shards, each shard encapsulates a disjoint set of the index data and each shard has one or more instances referred to as replicas of a shard. Given that, this class encapsulates all replicas (instances) for a single index shard.
  • Method Details

    • shardId

      public ShardId shardId()
      Returns the shards id
      Returns:
      id of the shard
    • getShardId

      public ShardId getShardId()
      Returns the shards id
      Returns:
      id of the shard
    • iterator

      public Iterator<ShardRouting> iterator()
      Specified by:
      iterator in interface Iterable<ShardRouting>
    • size

      public int size()
      Returns the number of this shards instances.
    • getSize

      public int getSize()
      Returns the number of this shards instances.
    • shards

      public List<ShardRouting> shards()
      Returns a List of shards
      Returns:
      a List of shards
    • getShards

      public List<ShardRouting> getShards()
      Returns a List of shards
      Returns:
      a List of shards
    • activeShards

      public List<ShardRouting> activeShards()
      Returns a List of active shards
      Returns:
      a List of shards
    • getAllInitializingShards

      public List<ShardRouting> getAllInitializingShards()
      Returns a List of all initializing shards, including target shards of relocations
      Returns:
      a List of shards
    • getActiveShards

      public List<ShardRouting> getActiveShards()
      Returns a List of active shards
      Returns:
      a List of shards
    • assignedShards

      public List<ShardRouting> assignedShards()
      Returns a List of assigned shards, including relocation targets
      Returns:
      a List of shards
    • shardsRandomIt

      public ShardIterator shardsRandomIt()
    • shardsIt

      public ShardIterator shardsIt()
    • shardsIt

      public ShardIterator shardsIt(int seed)
    • activeInitializingShardsRandomIt

      public ShardIterator activeInitializingShardsRandomIt()
      Returns an iterator over active and initializing shards. Making sure though that its random within the active shards, and initializing shards are the last to iterate through.
    • activeInitializingShardsIt

      public ShardIterator activeInitializingShardsIt(int seed)
      Returns an iterator over active and initializing shards. Making sure though that its random within the active shards, and initializing shards are the last to iterate through.
    • activeInitializingShardsRankedIt

      public ShardIterator activeInitializingShardsRankedIt(@Nullable ResponseCollectorService collector, @Nullable Map<String,​Long> nodeSearchCounts)
      Returns an iterator over active and initializing shards, ordered by the adaptive replica selection formula. Making sure though that its random within the active shards of the same (or missing) rank, and initializing shards are the last to iterate through.
    • primaryShardIt

      public ShardIterator primaryShardIt()
      Returns an iterator only on the primary shard.
    • onlyNodeActiveInitializingShardsIt

      public ShardIterator onlyNodeActiveInitializingShardsIt(String nodeId)
    • onlyNodeSelectorActiveInitializingShardsIt

      public ShardIterator onlyNodeSelectorActiveInitializingShardsIt(String nodeAttributes, DiscoveryNodes discoveryNodes)
    • onlyNodeSelectorActiveInitializingShardsIt

      public ShardIterator onlyNodeSelectorActiveInitializingShardsIt(String[] nodeAttributes, DiscoveryNodes discoveryNodes)
      Returns shards based on nodeAttributes given such as node name , node attribute, node IP Supports node specifications in cluster API
    • preferNodeActiveInitializingShardsIt

      public ShardIterator preferNodeActiveInitializingShardsIt(Set<String> nodeIds)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • allShardsStarted

      public boolean allShardsStarted()
      Returns true iff all shards in the routing table are started otherwise false
    • getByAllocationId

      @Nullable public ShardRouting getByAllocationId(String allocationId)
    • getAllAllocationIds

      public Set<String> getAllAllocationIds()
    • preferAttributesActiveInitializingShardsIt

      public ShardIterator preferAttributesActiveInitializingShardsIt(List<String> attributes, DiscoveryNodes nodes)
    • preferAttributesActiveInitializingShardsIt

      public ShardIterator preferAttributesActiveInitializingShardsIt(List<String> attributes, DiscoveryNodes nodes, int seed)
    • primaryShard

      public ShardRouting primaryShard()
    • replicaShards

      public List<ShardRouting> replicaShards()
    • replicaShardsWithState

      public List<ShardRouting> replicaShardsWithState(ShardRoutingState... states)
    • shardsWithState

      public List<ShardRouting> shardsWithState(ShardRoutingState state)
    • toString

      public String toString()
      Overrides:
      toString in class Object