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) |
Modifier and Type | Method and Description |
---|---|
MutableShardRouting |
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. |
MutableShardRouting |
activeReplica(ShardRouting shard)
Returns one active replica shard for the given ShardRouting shard ID or
null if
no active replica is found. |
void |
addClearPostAllocationFlag(ShardId shardId)
Clears the post allocation flag for the provided shard id.
|
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
MutableShardRouting s
in the cluster to ensure the book-keeping is correct. |
void |
assign(MutableShardRouting shard,
String nodeId)
Assign a shard to a node.
|
Iterable<MutableShardRouting> |
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(MutableShardRouting shard)
Cancels a relocation of a shard that shard must relocating.
|
ClusterBlocks |
getBlocks() |
MetaData |
getMetaData() |
int |
getRelocatingShardCount() |
RoutingTable |
getRoutingTable() |
Iterable<ShardId> |
getShardsToClearPostAllocationFlag() |
boolean |
hasInactivePrimaries() |
boolean |
hasInactiveShards() |
boolean |
hasUnassigned() |
boolean |
hasUnassignedPrimaries() |
boolean |
hasUnassignedShards() |
List<MutableShardRouting> |
ignoredUnassigned() |
boolean |
isKnown(DiscoveryNode node) |
Iterator<RoutingNode> |
iterator() |
MetaData |
metaData() |
RoutingNode |
node(String nodeId) |
RoutingNodes.RoutingNodesIterator |
nodes() |
com.carrotsearch.hppc.ObjectIntOpenHashMap<String> |
nodesPerAttributesCounts(String attributeName) |
String |
prettyPrint() |
void |
reinitShadowPrimary(MutableShardRouting candidate) |
void |
relocate(MutableShardRouting shard,
String nodeId)
Relocate a shard to another node.
|
int |
requiredAverageNumberOfShardsPerNode() |
RoutingNodes.RoutingNodeIterator |
routingNodeIter(String nodeId) |
RoutingTable |
routingTable() |
List<MutableShardRouting> |
shards(com.google.common.base.Predicate<MutableShardRouting> predicate) |
List<MutableShardRouting> |
shardsWithState(ShardRoutingState... state) |
List<MutableShardRouting> |
shardsWithState(String index,
ShardRoutingState... state) |
void |
started(MutableShardRouting shard)
Mark a shard as started and adjusts internal statistics.
|
void |
swapPrimaryFlag(MutableShardRouting... shards)
swaps the status of a shard, making replicas primary and vice versa.
|
RoutingNode[] |
toArray() |
RoutingNodes.UnassignedShards |
unassigned() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public RoutingNodes(ClusterState clusterState)
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 int requiredAverageNumberOfShardsPerNode()
public boolean hasUnassigned()
public List<MutableShardRouting> ignoredUnassigned()
public RoutingNodes.UnassignedShards unassigned()
public RoutingNodes.RoutingNodesIterator nodes()
public void addClearPostAllocationFlag(ShardId shardId)
public RoutingNode node(String nodeId)
public com.carrotsearch.hppc.ObjectIntOpenHashMap<String> nodesPerAttributesCounts(String attributeName)
public boolean hasUnassignedPrimaries()
public boolean hasUnassignedShards()
public boolean hasInactivePrimaries()
public boolean hasInactiveShards()
public int getRelocatingShardCount()
public MutableShardRouting activePrimary(ShardRouting shard)
null
if
no primary is found or the primary is not active.public MutableShardRouting activeReplica(ShardRouting shard)
null
if
no active replica is found.public Iterable<MutableShardRouting> assignedShards(ShardRouting shard)
public boolean allReplicasActive(ShardRouting shardRouting)
true
iff all replicas are active for the given shard routing. Otherwise false
public List<MutableShardRouting> shards(com.google.common.base.Predicate<MutableShardRouting> predicate)
public List<MutableShardRouting> shardsWithState(ShardRoutingState... state)
public List<MutableShardRouting> shardsWithState(String index, ShardRoutingState... state)
public String prettyPrint()
public void assign(MutableShardRouting shard, String nodeId)
shard
- the shard to be assignednodeId
- the nodeId this shard should initialize on or relocate frompublic void relocate(MutableShardRouting shard, String nodeId)
public void started(MutableShardRouting shard)
public void cancelRelocation(MutableShardRouting shard)
public void swapPrimaryFlag(MutableShardRouting... 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(MutableShardRouting candidate)
public static boolean assertShardStats(RoutingNodes routingNodes)
MutableShardRouting
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–2015. All rights reserved.