public List<RoutingNode> nodesToShardsSorted(Comparator<RoutingNode> comparator) { List<RoutingNode> nodes = new ArrayList<RoutingNode>(nodesToShards.values()); if (comparator != null) { Collections.sort(nodes, comparator); } return nodes; }
public MutableShardRouting findPrimaryForBackup(MutableShardRouting shard) { assert !shard.primary(); for (RoutingNode routingNode : nodesToShards.values()) { for (MutableShardRouting shardRouting : routingNode) { if (shardRouting.shardId().equals(shard.shardId()) && shardRouting.primary()) { return shardRouting; } } } return null; }
@Override public Iterator<RoutingNode> iterator() { return nodesToShards.values().iterator(); }
public RoutingNode node(String nodeId) { return nodesToShards.get(nodeId); }
public int requiredAverageNumberOfShardsPerNode() { return metaData.totalNumberOfShards() / nodesToShards.size(); }