Class IndexShardRoutingTable
- java.lang.Object
-
- org.elasticsearch.cluster.routing.IndexShardRoutingTable
-
- All Implemented Interfaces:
Iterable<ShardRouting>
public class IndexShardRoutingTable extends Object implements Iterable<ShardRouting>
IndexShardRoutingTableencapsulates 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIndexShardRoutingTable.Builder
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ShardIteratoractiveInitializingShardsIt(int seed)Returns an iterator over active and initializing shards.ShardIteratoractiveInitializingShardsRandomIt()Returns an iterator over active and initializing shards.ShardIteratoractiveInitializingShardsRankedIt(ResponseCollectorService collector, Map<String,Long> nodeSearchCounts)Returns an iterator over active and initializing shards, ordered by the adaptive replica selection formula.List<ShardRouting>activeShards()Returns aListof active shardsbooleanallShardsStarted()Returnstrueiff all shards in the routing table are started otherwisefalseList<ShardRouting>assignedShards()Returns aListof assigned shards, including relocation targetsbooleanequals(Object o)List<ShardRouting>getActiveShards()Returns aListof active shardsSet<String>getAllAllocationIds()List<ShardRouting>getAllInitializingShards()Returns aListof all initializing shards, including target shards of relocationsShardRoutinggetByAllocationId(String allocationId)ShardIdgetShardId()Returns the shards idList<ShardRouting>getShards()Returns aListof shardsintgetSize()Returns the number of this shards instances.inthashCode()Iterator<ShardRouting>iterator()ShardIteratoronlyNodeActiveInitializingShardsIt(String nodeId)ShardIteratoronlyNodeSelectorActiveInitializingShardsIt(String[] nodeAttributes, DiscoveryNodes discoveryNodes)Returns shards based on nodeAttributes given such as node name , node attribute, node IP Supports node specifications in cluster APIShardIteratoronlyNodeSelectorActiveInitializingShardsIt(String nodeAttributes, DiscoveryNodes discoveryNodes)ShardIteratorpreferAttributesActiveInitializingShardsIt(List<String> attributes, DiscoveryNodes nodes)ShardIteratorpreferAttributesActiveInitializingShardsIt(List<String> attributes, DiscoveryNodes nodes, int seed)ShardIteratorpreferNodeActiveInitializingShardsIt(Set<String> nodeIds)ShardRoutingprimaryShard()ShardIteratorprimaryShardIt()Returns an iterator only on the primary shard.List<ShardRouting>replicaShards()List<ShardRouting>replicaShardsWithState(ShardRoutingState... states)ShardIdshardId()Returns the shards idList<ShardRouting>shards()Returns aListof shardsShardIteratorshardsIt()ShardIteratorshardsIt(int seed)ShardIteratorshardsRandomIt()List<ShardRouting>shardsWithState(ShardRoutingState state)intsize()Returns the number of this shards instances.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
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:
iteratorin interfaceIterable<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 aListof shards- Returns:
- a
Listof shards
-
getShards
public List<ShardRouting> getShards()
Returns aListof shards- Returns:
- a
Listof shards
-
activeShards
public List<ShardRouting> activeShards()
Returns aListof active shards- Returns:
- a
Listof shards
-
getAllInitializingShards
public List<ShardRouting> getAllInitializingShards()
Returns aListof all initializing shards, including target shards of relocations- Returns:
- a
Listof shards
-
getActiveShards
public List<ShardRouting> getActiveShards()
Returns aListof active shards- Returns:
- a
Listof shards
-
assignedShards
public List<ShardRouting> assignedShards()
Returns aListof assigned shards, including relocation targets- Returns:
- a
Listof 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)
-
allShardsStarted
public boolean allShardsStarted()
Returnstrueiff all shards in the routing table are started otherwisefalse
-
getByAllocationId
@Nullable public ShardRouting getByAllocationId(String allocationId)
-
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)
-
-