public class RoutingNodes extends Object implements 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 |
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. |
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(String type) |
ImmutableOpenMap<String,ClusterState.Custom> |
customs() |
ClusterBlocks |
getBlocks() |
MetaData |
getMetaData() |
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,
String nodeId,
long expectedSize)
Moves a shard from unassigned to initialize state
|
boolean |
isKnown(DiscoveryNode node) |
Iterator<RoutingNode> |
iterator() |
MetaData |
metaData() |
RoutingNode |
node(String nodeId) |
RoutingNodes.RoutingNodesIterator |
nodes() |
com.carrotsearch.hppc.ObjectIntHashMap<String> |
nodesPerAttributesCounts(String attributeName) |
String |
prettyPrint() |
void |
reinitShadowPrimary(ShardRouting candidate) |
ShardRouting |
relocate(ShardRouting shard,
String nodeId,
long expectedShardSize)
Relocate a shard to another node, adding the target initializing
shard as well as assigning it.
|
RoutingNodes.RoutingNodeIterator |
routingNodeIter(String nodeId) |
RoutingTable |
routingTable() |
List<ShardRouting> |
shards(com.google.common.base.Predicate<ShardRouting> predicate) |
List<ShardRouting> |
shardsWithState(ShardRoutingState... state) |
List<ShardRouting> |
shardsWithState(String index,
ShardRoutingState... state) |
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 Iterator<RoutingNode> iterator()
iterator
in interface Iterable<RoutingNode>
public RoutingTable routingTable()
public RoutingTable getRoutingTable()
public MetaData metaData()
public MetaData getMetaData()
public ClusterBlocks blocks()
public ClusterBlocks getBlocks()
public ImmutableOpenMap<String,ClusterState.Custom> customs()
public <T extends ClusterState.Custom> T custom(String type)
public RoutingNodes.UnassignedShards unassigned()
public RoutingNodes.RoutingNodesIterator nodes()
public RoutingNode node(String nodeId)
public com.carrotsearch.hppc.ObjectIntHashMap<String> nodesPerAttributesCounts(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 Iterable<ShardRouting> assignedShards(ShardRouting shard)
public boolean allReplicasActive(ShardRouting shardRouting)
true
iff all replicas are active for the given shard routing. Otherwise false
public List<ShardRouting> shards(com.google.common.base.Predicate<ShardRouting> predicate)
public List<ShardRouting> shardsWithState(ShardRoutingState... state)
public List<ShardRouting> shardsWithState(String index, ShardRoutingState... state)
public String prettyPrint()
public void initialize(ShardRouting shard, String nodeId, long expectedSize)
public ShardRouting relocate(ShardRouting shard, 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(String nodeId)
public RoutingNode[] toArray()
public void reinitShadowPrimary(ShardRouting candidate)
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.Copyright © 2009–2016. All rights reserved.