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 |
---|---|
class |
RoutingNodes.RoutingNodeIterator |
class |
RoutingNodes.RoutingNodesIterator |
static class |
RoutingNodes.UnassignedShards |
Constructor and Description |
---|
RoutingNodes(ClusterState clusterState) |
RoutingNodes(ClusterState clusterState,
boolean readOnly) |
Modifier and Type | Method and Description |
---|---|
ShardRouting |
activePrimary(ShardRouting shard)
Returns the active primary shard for the given ShardRouting or
null if
no primary is found or the primary is not active. |
ShardRouting |
activeReplica(ShardRouting shard)
Returns one active replica shard for the given ShardRouting shard ID or
null if
no active replica is found. |
void |
addInitialRecovery(ShardRouting routing) |
void |
addNode(DiscoveryNode node) |
boolean |
allReplicasActive(ShardRouting shardRouting)
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.lang.Iterable<ShardRouting> |
assignedShards(ShardRouting shard)
Returns all shards that are not in the state UNASSIGNED with the same shard
ID as the given shard.
|
ClusterBlocks |
blocks() |
void |
cancelRelocation(ShardRouting shard)
Cancels a relocation of a shard that shard must relocating.
|
<T extends ClusterState.Custom> |
custom(java.lang.String type) |
ImmutableOpenMap<java.lang.String,ClusterState.Custom> |
customs() |
ClusterBlocks |
getBlocks() |
int |
getIncomingRecoveries(java.lang.String nodeId) |
MetaData |
getMetaData() |
int |
getOutgoingRecoveries(java.lang.String nodeId) |
int |
getRelocatingShardCount() |
RoutingTable |
getRoutingTable() |
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. |
void |
initialize(ShardRouting shard,
java.lang.String nodeId,
java.lang.String existingAllocationId,
long expectedSize)
Moves a shard from unassigned to initialize state
|
boolean |
isKnown(DiscoveryNode node) |
java.util.Iterator<RoutingNode> |
iterator() |
MetaData |
metaData() |
RoutingNode |
node(java.lang.String nodeId) |
RoutingNodes.RoutingNodesIterator |
nodes() |
com.carrotsearch.hppc.ObjectIntHashMap<java.lang.String> |
nodesPerAttributesCounts(java.lang.String attributeName) |
java.lang.String |
prettyPrint() |
void |
reinitShadowPrimary(ShardRouting candidate) |
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.
|
RoutingNodes.RoutingNodeIterator |
routingNodeIter(java.lang.String nodeId) |
RoutingTable |
routingTable() |
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
|
void |
started(ShardRouting shard)
Mark a shard as started and adjusts internal statistics.
|
void |
swapPrimaryFlag(ShardRouting... shards)
swaps the status of a shard, making replicas primary and vice versa.
|
RoutingNode[] |
toArray() |
RoutingNodes.UnassignedShards |
unassigned() |
public RoutingNodes(ClusterState clusterState)
public RoutingNodes(ClusterState clusterState, boolean readOnly)
public void addInitialRecovery(ShardRouting routing)
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 RoutingTable routingTable()
public RoutingTable getRoutingTable()
public MetaData metaData()
public MetaData getMetaData()
public ClusterBlocks blocks()
public ClusterBlocks getBlocks()
public ImmutableOpenMap<java.lang.String,ClusterState.Custom> customs()
public <T extends ClusterState.Custom> T custom(java.lang.String type)
public RoutingNodes.UnassignedShards unassigned()
public RoutingNodes.RoutingNodesIterator nodes()
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 ShardRouting activePrimary(ShardRouting shard)
null
if
no primary is found or the primary is not active.public ShardRouting activeReplica(ShardRouting shard)
null
if
no active replica is found.public java.lang.Iterable<ShardRouting> assignedShards(ShardRouting shard)
public boolean allReplicasActive(ShardRouting shardRouting)
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 void 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 ShardRouting relocate(ShardRouting shard, java.lang.String nodeId, long expectedShardSize)
public void started(ShardRouting shard)
public void cancelRelocation(ShardRouting shard)
public void swapPrimaryFlag(ShardRouting... shards)
shards
- the shard to have its primary status swapped.public boolean isKnown(DiscoveryNode node)
public void addNode(DiscoveryNode node)
public RoutingNodes.RoutingNodeIterator routingNodeIter(java.lang.String nodeId)
public RoutingNode[] toArray()
public void reinitShadowPrimary(ShardRouting candidate)
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.