Esempio n. 1
0
 public List<MutableShardRouting> shardsWithState(ShardRoutingState... state) {
   List<MutableShardRouting> shards = newArrayList();
   for (RoutingNode routingNode : this) {
     shards.addAll(routingNode.shardsWithState(state));
   }
   return shards;
 }
Esempio n. 2
0
 public RoutingNodes(MetaData metaData, RoutingTable routingTable) {
   this.metaData = metaData;
   this.routingTable = routingTable;
   Map<String, List<MutableShardRouting>> nodesToShards = newHashMap();
   for (IndexRoutingTable indexRoutingTable : routingTable.indicesRouting().values()) {
     for (IndexShardRoutingTable indexShard : indexRoutingTable) {
       for (ShardRouting shard : indexShard) {
         if (shard.assignedToNode()) {
           List<MutableShardRouting> entries = nodesToShards.get(shard.currentNodeId());
           if (entries == null) {
             entries = newArrayList();
             nodesToShards.put(shard.currentNodeId(), entries);
           }
           entries.add(new MutableShardRouting(shard));
           if (shard.relocating()) {
             entries = nodesToShards.get(shard.relocatingNodeId());
             if (entries == null) {
               entries = newArrayList();
               nodesToShards.put(shard.relocatingNodeId(), entries);
             }
             // add the counterpart shard with relocatingNodeId reflecting the source from which
             // it's relocating from.
             entries.add(
                 new MutableShardRouting(
                     shard.index(),
                     shard.id(),
                     shard.relocatingNodeId(),
                     shard.currentNodeId(),
                     shard.primary(),
                     ShardRoutingState.INITIALIZING));
           }
         } else {
           unassigned.add(new MutableShardRouting(shard));
         }
       }
     }
   }
   for (Map.Entry<String, List<MutableShardRouting>> entry : nodesToShards.entrySet()) {
     String nodeId = entry.getKey();
     this.nodesToShards.put(nodeId, new RoutingNode(nodeId, entry.getValue()));
   }
 }
Esempio n. 3
0
 public boolean hasUnassigned() {
   return !unassigned.isEmpty();
 }