コード例 #1
0
 public List<RoutingNode> nodesToShardsSorted(Comparator<RoutingNode> comparator) {
   List<RoutingNode> nodes = new ArrayList<RoutingNode>(nodesToShards.values());
   if (comparator != null) {
     Collections.sort(nodes, comparator);
   }
   return nodes;
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 @Override
 public Iterator<RoutingNode> iterator() {
   return nodesToShards.values().iterator();
 }
コード例 #4
0
 public RoutingNode node(String nodeId) {
   return nodesToShards.get(nodeId);
 }
コード例 #5
0
 public int requiredAverageNumberOfShardsPerNode() {
   return metaData.totalNumberOfShards() / nodesToShards.size();
 }