diff options
Diffstat (limited to 'core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java')
-rw-r--r-- | core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java b/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java index 3a2567e3f4..6a6373f977 100644 --- a/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java +++ b/core/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java @@ -28,6 +28,7 @@ import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.Randomness; import org.elasticsearch.common.collect.ImmutableOpenMap; +import org.elasticsearch.index.Index; import org.elasticsearch.index.shard.ShardId; import java.util.ArrayList; @@ -169,7 +170,7 @@ public class RoutingNodes implements Iterable<RoutingNode> { } else if (routing.primary() == false) { // primary without relocationID is initial recovery ShardRouting primary = findPrimary(routing); if (primary == null && initializing) { - primary = routingTable.index(routing.index()).shard(routing.shardId().id()).primary; + primary = routingTable.index(routing.index().getName()).shard(routing.shardId().id()).primary; } else if (primary == null) { throw new IllegalStateException("replica is initializing but primary is unassigned"); } @@ -348,7 +349,7 @@ public class RoutingNodes implements Iterable<RoutingNode> { */ public boolean allReplicasActive(ShardRouting shardRouting) { final List<ShardRouting> shards = assignedShards(shardRouting.shardId()); - if (shards.isEmpty() || shards.size() < this.routingTable.index(shardRouting.index()).shard(shardRouting.id()).size()) { + if (shards.isEmpty() || shards.size() < this.routingTable.index(shardRouting.index().getName()).shard(shardRouting.id()).size()) { return false; // if we are empty nothing is active if we have less than total at least one is unassigned } for (ShardRouting shard : shards) { @@ -778,7 +779,7 @@ public class RoutingNodes implements Iterable<RoutingNode> { int inactivePrimaryCount = 0; int inactiveShardCount = 0; int relocating = 0; - Map<String, Integer> indicesAndShards = new HashMap<>(); + Map<Index, Integer> indicesAndShards = new HashMap<>(); for (RoutingNode node : routingNodes) { for (ShardRouting shard : node) { if (!shard.active() && shard.relocatingNodeId() == null) { @@ -800,10 +801,10 @@ public class RoutingNodes implements Iterable<RoutingNode> { } } // Assert that the active shard routing are identical. - Set<Map.Entry<String, Integer>> entries = indicesAndShards.entrySet(); + Set<Map.Entry<Index, Integer>> entries = indicesAndShards.entrySet(); final List<ShardRouting> shards = new ArrayList<>(); - for (Map.Entry<String, Integer> e : entries) { - String index = e.getKey(); + for (Map.Entry<Index, Integer> e : entries) { + Index index = e.getKey(); for (int i = 0; i < e.getValue(); i++) { for (RoutingNode routingNode : routingNodes) { for (ShardRouting shardRouting : routingNode) { |