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>
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
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, 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 aListof active shardsbooleanallShardsStarted()Returnstrueiff all shards in the routing table are started otherwisefalsejava.util.List<ShardRouting>assignedShards()Returns aListof assigned shardsbooleanequals(java.lang.Object o)java.util.List<ShardRouting>getActiveShards()Returns aListof active shardsjava.util.Set<java.lang.String>getAllAllocationIds()java.util.List<ShardRouting>getAllInitializingShards()Returns aListof all initializing shards, including target shards of relocationsjava.util.List<ShardRouting>getAssignedShards()Returns aListof assigned shardsShardRoutinggetByAllocationId(java.lang.String allocationId)ShardIdgetShardId()Returns the shards idjava.util.List<ShardRouting>getShards()Returns aListof shardsintgetSize()Returns the number of this shards instances.inthashCode()java.util.Iterator<ShardRouting>iterator()ShardIteratoronlyNodeActiveInitializingShardsIt(java.lang.String nodeId)ShardIteratoronlyNodeSelectorActiveInitializingShardsIt(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 APIShardIteratoronlyNodeSelectorActiveInitializingShardsIt(java.lang.String nodeAttributes, DiscoveryNodes discoveryNodes)ShardIteratorpreferAttributesActiveInitializingShardsIt(java.util.List<java.lang.String> attributes, DiscoveryNodes nodes)ShardIteratorpreferAttributesActiveInitializingShardsIt(java.util.List<java.lang.String> attributes, DiscoveryNodes nodes, int seed)ShardIteratorpreferNodeActiveInitializingShardsIt(java.util.Set<java.lang.String> nodeIds)ShardIteratorprimaryActiveInitializingShardIt()ShardIteratorprimaryFirstActiveInitializingShardsIt()ShardRoutingprimaryShard()ShardIteratorprimaryShardIt()Returns an iterator only on the primary shard.ShardIteratorreplicaActiveInitializingShardIt()ShardIteratorreplicaFirstActiveInitializingShardsIt()java.util.List<ShardRouting>replicaShards()java.util.List<ShardRouting>replicaShardsWithState(ShardRoutingState... states)ShardIdshardId()Returns the shards idjava.util.List<ShardRouting>shards()Returns aListof shardsShardIteratorshardsIt()ShardIteratorshardsIt(int seed)ShardIteratorshardsRandomIt()java.util.List<ShardRouting>shardsWithState(ShardRoutingState state)intsize()Returns the number of this shards instances.java.lang.StringtoString()
-
-
-
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 java.util.Iterator<ShardRouting> iterator()
- Specified by:
iteratorin 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
public java.util.List<ShardRouting> shards()
Returns aListof shards- Returns:
- a
Listof shards
-
getShards
public java.util.List<ShardRouting> getShards()
Returns aListof shards- Returns:
- a
Listof shards
-
activeShards
public java.util.List<ShardRouting> activeShards()
Returns aListof active shards- Returns:
- a
Listof shards
-
getAllInitializingShards
public java.util.List<ShardRouting> getAllInitializingShards()
Returns aListof all initializing shards, including target shards of relocations- Returns:
- a
Listof shards
-
getActiveShards
public java.util.List<ShardRouting> getActiveShards()
Returns aListof active shards- Returns:
- a
Listof shards
-
assignedShards
public java.util.List<ShardRouting> assignedShards()
Returns aListof assigned shards- Returns:
- a
Listof shards
-
getAssignedShards
public java.util.List<ShardRouting> getAssignedShards()
Returns aListof assigned shards- 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 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
public ShardIterator primaryShardIt()
Returns an iterator only on the primary shard.
-
primaryActiveInitializingShardIt
public ShardIterator primaryActiveInitializingShardIt()
-
primaryFirstActiveInitializingShardsIt
public ShardIterator primaryFirstActiveInitializingShardsIt()
-
replicaActiveInitializingShardIt
public ShardIterator replicaActiveInitializingShardIt()
-
replicaFirstActiveInitializingShardsIt
public ShardIterator replicaFirstActiveInitializingShardsIt()
-
onlyNodeActiveInitializingShardsIt
public ShardIterator onlyNodeActiveInitializingShardsIt(java.lang.String nodeId)
-
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
public ShardIterator preferNodeActiveInitializingShardsIt(java.util.Set<java.lang.String> nodeIds)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
allShardsStarted
public boolean allShardsStarted()
Returnstrueiff all shards in the routing table are started otherwisefalse
-
getByAllocationId
@Nullable public ShardRouting getByAllocationId(java.lang.String allocationId)
-
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
public ShardRouting primaryShard()
-
replicaShards
public java.util.List<ShardRouting> replicaShards()
-
replicaShardsWithState
public java.util.List<ShardRouting> replicaShardsWithState(ShardRoutingState... states)
-
shardsWithState
public java.util.List<ShardRouting> shardsWithState(ShardRoutingState state)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-