Class IndexShardRoutingTable
java.lang.Object
org.elasticsearch.cluster.routing.IndexShardRoutingTable
- All Implemented Interfaces:
java.lang.Iterable<ShardRouting>
public class IndexShardRoutingTable extends java.lang.Object implements java.lang.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.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IndexShardRoutingTable.Builder
-
Method Summary
Modifier and Type Method Description ShardIterator
activeInitializingShardsIt(int seed)
Returns an iterator over active and initializing shards.ShardIterator
activeInitializingShardsRandomIt()
Returns an iterator over active and initializing shards.ShardIterator
activeInitializingShardsRankedIt(ResponseCollectorService collector, java.util.Map<java.lang.String,java.lang.Long> nodeSearchCounts)
Returns an iterator over active and initializing shards, ordered by the adaptive replica selection formula.java.util.List<ShardRouting>
activeShards()
Returns aList
of active shardsboolean
allShardsStarted()
Returnstrue
iff all shards in the routing table are started otherwisefalse
java.util.List<ShardRouting>
assignedShards()
Returns aList
of assigned shards, including relocation targetsboolean
equals(java.lang.Object o)
java.util.List<ShardRouting>
getActiveShards()
Returns aList
of active shardsjava.util.Set<java.lang.String>
getAllAllocationIds()
java.util.List<ShardRouting>
getAllInitializingShards()
Returns aList
of all initializing shards, including target shards of relocationsShardRouting
getByAllocationId(java.lang.String allocationId)
ShardId
getShardId()
Returns the shards idjava.util.List<ShardRouting>
getShards()
Returns aList
of shardsint
getSize()
Returns the number of this shards instances.int
hashCode()
java.util.Iterator<ShardRouting>
iterator()
ShardIterator
onlyNodeActiveInitializingShardsIt(java.lang.String nodeId)
ShardIterator
onlyNodeSelectorActiveInitializingShardsIt(java.lang.String[] nodeAttributes, DiscoveryNodes discoveryNodes)
Returns shards based on nodeAttributes given such as node name , node attribute, node IP Supports node specifications in cluster APIShardIterator
onlyNodeSelectorActiveInitializingShardsIt(java.lang.String nodeAttributes, DiscoveryNodes discoveryNodes)
ShardIterator
preferAttributesActiveInitializingShardsIt(java.util.List<java.lang.String> attributes, DiscoveryNodes nodes)
ShardIterator
preferAttributesActiveInitializingShardsIt(java.util.List<java.lang.String> attributes, DiscoveryNodes nodes, int seed)
ShardIterator
preferNodeActiveInitializingShardsIt(java.util.Set<java.lang.String> nodeIds)
ShardRouting
primaryShard()
ShardIterator
primaryShardIt()
Returns an iterator only on the primary shard.java.util.List<ShardRouting>
replicaShards()
java.util.List<ShardRouting>
replicaShardsWithState(ShardRoutingState... states)
ShardId
shardId()
Returns the shards idjava.util.List<ShardRouting>
shards()
Returns aList
of shardsShardIterator
shardsIt()
ShardIterator
shardsIt(int seed)
ShardIterator
shardsRandomIt()
java.util.List<ShardRouting>
shardsWithState(ShardRoutingState state)
int
size()
Returns the number of this shards instances.java.lang.String
toString()
-
Method Details
-
shardId
Returns the shards id- Returns:
- id of the shard
-
getShardId
Returns the shards id- Returns:
- id of the shard
-
iterator
- Specified by:
iterator
in interfacejava.lang.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
Returns aList
of shards- Returns:
- a
List
of shards
-
getShards
Returns aList
of shards- Returns:
- a
List
of shards
-
activeShards
Returns aList
of active shards- Returns:
- a
List
of shards
-
getAllInitializingShards
Returns aList
of all initializing shards, including target shards of relocations- Returns:
- a
List
of shards
-
getActiveShards
Returns aList
of active shards- Returns:
- a
List
of shards
-
assignedShards
Returns aList
of assigned shards, including relocation targets- Returns:
- a
List
of shards
-
shardsRandomIt
-
shardsIt
-
shardsIt
-
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
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 java.util.Map<java.lang.String,java.lang.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
Returns an iterator only on the primary shard. -
onlyNodeActiveInitializingShardsIt
-
onlyNodeSelectorActiveInitializingShardsIt
public ShardIterator onlyNodeSelectorActiveInitializingShardsIt(java.lang.String nodeAttributes, DiscoveryNodes discoveryNodes) -
onlyNodeSelectorActiveInitializingShardsIt
public ShardIterator onlyNodeSelectorActiveInitializingShardsIt(java.lang.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
-
equals
public boolean equals(java.lang.Object o)- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()- Overrides:
hashCode
in classjava.lang.Object
-
allShardsStarted
public boolean allShardsStarted()Returnstrue
iff all shards in the routing table are started otherwisefalse
-
getByAllocationId
-
getAllAllocationIds
public java.util.Set<java.lang.String> getAllAllocationIds() -
preferAttributesActiveInitializingShardsIt
public ShardIterator preferAttributesActiveInitializingShardsIt(java.util.List<java.lang.String> attributes, DiscoveryNodes nodes) -
preferAttributesActiveInitializingShardsIt
public ShardIterator preferAttributesActiveInitializingShardsIt(java.util.List<java.lang.String> attributes, DiscoveryNodes nodes, int seed) -
primaryShard
-
replicaShards
-
replicaShardsWithState
-
shardsWithState
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-