public class RoutingNodes extends java.lang.Object implements java.lang.Iterable<RoutingNode>
RoutingNodes
represents a copy the routing information contained in
the cluster state
.Modifier and Type | Class and Description |
---|---|
static class |
RoutingNodes.UnassignedShards |
Constructor and Description |
---|
RoutingNodes(ClusterState clusterState) |
RoutingNodes(ClusterState clusterState,
boolean readOnly) |
Modifier and Type | Method and Description |
---|---|
ShardRouting |
activePrimary(ShardId shardId)
Returns the active primary shard for the given shard id or
null if
no primary is found or the primary is not active. |
ShardRouting |
activeReplica(ShardId shardId)
Returns one active replica shard for the given shard id or
null if
no active replica is found. |
boolean |
allReplicasActive(ShardId shardId,
MetaData metaData)
Returns
true iff all replicas are active for the given shard routing. |
static boolean |
assertShardStats(RoutingNodes routingNodes)
Calculates RoutingNodes statistics by iterating over all
ShardRouting s
in the cluster to ensure the book-keeping is correct. |
java.util.List<ShardRouting> |
assignedShards(ShardId shardId)
Returns all shards that are not in the state UNASSIGNED with the same shard
ID as the given shard.
|
ShardRouting |
cancelRelocation(ShardRouting shard)
Cancels a relocation of a shard that shard must relocating.
|
int |
getIncomingRecoveries(java.lang.String nodeId) |
int |
getOutgoingRecoveries(java.lang.String nodeId) |
int |
getRelocatingShardCount() |
boolean |
hasInactivePrimaries() |
boolean |
hasInactiveShards() |
boolean |
hasUnassignedPrimaries()
Returns
true iff this RoutingNodes instance has any unassigned primaries even if the
primaries are marked as temporarily ignored. |
boolean |
hasUnassignedShards()
Returns
true iff this RoutingNodes instance has any unassigned shards even if the
shards are marked as temporarily ignored. |
ShardRouting |
initialize(ShardRouting shard,
java.lang.String nodeId,
java.lang.String existingAllocationId,
long expectedSize)
Moves a shard from unassigned to initialize state
|
java.util.Iterator<RoutingNode> |
iterator() |
ShardRouting |
moveToUnassigned(ShardRouting shard,
UnassignedInfo unassignedInfo) |
java.util.Iterator<RoutingNode> |
mutableIterator() |
RoutingNode |
node(java.lang.String nodeId) |
java.util.Iterator<ShardRouting> |
nodeInterleavedShardIterator()
Creates an iterator over shards interleaving between nodes: The iterator returns the first shard from
the first node, then the first shard of the second node, etc.
|
com.carrotsearch.hppc.ObjectIntHashMap<java.lang.String> |
nodesPerAttributesCounts(java.lang.String attributeName) |
java.lang.String |
prettyPrint() |
ShardRouting |
promoteAssignedReplicaShardToPrimary(ShardRouting replicaShard)
moves the assigned replica shard to primary.
|
ShardRouting |
reinitShadowPrimary(ShardRouting candidate) |
Tuple<ShardRouting,ShardRouting> |
relocate(ShardRouting shard,
java.lang.String nodeId,
long expectedShardSize)
Relocate a shard to another node, adding the target initializing
shard as well as assigning it.
|
void |
remove(ShardRouting shard)
Cancels the give shard from the Routing nodes internal statistics and cancels
the relocation if the shard is relocating.
|
ShardRouting |
removeRelocationSource(ShardRouting shard)
Removes relocation source of an initializing non-primary shard.
|
java.util.List<ShardRouting> |
shards(java.util.function.Predicate<ShardRouting> predicate) |
java.util.List<ShardRouting> |
shardsWithState(ShardRoutingState... state) |
java.util.List<ShardRouting> |
shardsWithState(java.lang.String index,
ShardRoutingState... state) |
int |
size()
Returns the number of routing nodes
|
ShardRouting |
started(ShardRouting shard)
Mark a shard as started and adjusts internal statistics.
|
RoutingNodes.UnassignedShards |
unassigned() |
public RoutingNodes(ClusterState clusterState)
public RoutingNodes(ClusterState clusterState, boolean readOnly)
public int getIncomingRecoveries(java.lang.String nodeId)
public int getOutgoingRecoveries(java.lang.String nodeId)
public java.util.Iterator<RoutingNode> iterator()
iterator
in interface java.lang.Iterable<RoutingNode>
public java.util.Iterator<RoutingNode> mutableIterator()
public RoutingNodes.UnassignedShards unassigned()
public RoutingNode node(java.lang.String nodeId)
public com.carrotsearch.hppc.ObjectIntHashMap<java.lang.String> nodesPerAttributesCounts(java.lang.String attributeName)
public boolean hasUnassignedPrimaries()
true
iff this RoutingNodes
instance has any unassigned primaries even if the
primaries are marked as temporarily ignored.public boolean hasUnassignedShards()
true
iff this RoutingNodes
instance has any unassigned shards even if the
shards are marked as temporarily ignored.public boolean hasInactivePrimaries()
public boolean hasInactiveShards()
public int getRelocatingShardCount()
public java.util.List<ShardRouting> assignedShards(ShardId shardId)
public ShardRouting activePrimary(ShardId shardId)
null
if
no primary is found or the primary is not active.public ShardRouting activeReplica(ShardId shardId)
null
if
no active replica is found.public boolean allReplicasActive(ShardId shardId, MetaData metaData)
true
iff all replicas are active for the given shard routing. Otherwise false
public java.util.List<ShardRouting> shards(java.util.function.Predicate<ShardRouting> predicate)
public java.util.List<ShardRouting> shardsWithState(ShardRoutingState... state)
public java.util.List<ShardRouting> shardsWithState(java.lang.String index, ShardRoutingState... state)
public java.lang.String prettyPrint()
public ShardRouting initialize(ShardRouting shard, java.lang.String nodeId, @Nullable java.lang.String existingAllocationId, long expectedSize)
existingAllocationId
- allocation id to use. If null, a fresh allocation id is generated.public Tuple<ShardRouting,ShardRouting> relocate(ShardRouting shard, java.lang.String nodeId, long expectedShardSize)
public ShardRouting started(ShardRouting shard)
public ShardRouting cancelRelocation(ShardRouting shard)
public ShardRouting promoteAssignedReplicaShardToPrimary(ShardRouting replicaShard)
replicaShard
- the replica shard to be promoted to primarypublic void remove(ShardRouting shard)
public ShardRouting removeRelocationSource(ShardRouting shard)
public ShardRouting reinitShadowPrimary(ShardRouting candidate)
public ShardRouting moveToUnassigned(ShardRouting shard, UnassignedInfo unassignedInfo)
public int size()
public static boolean assertShardStats(RoutingNodes routingNodes)
ShardRouting
s
in the cluster to ensure the book-keeping is correct.
For performance reasons, this should only be called from assertstrue
or throws an assertion error. If assertion are not enabled
this method does nothing.public java.util.Iterator<ShardRouting> nodeInterleavedShardIterator()