diff --git a/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java b/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java index 4728169fb71..872f6b6a55b 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java +++ b/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java @@ -31,15 +31,18 @@ import static com.google.common.collect.Lists.newArrayList; */ public class RoutingNode implements Iterable { + private final String nodeId; + private final DiscoveryNode node; private final List shards; - public RoutingNode(DiscoveryNode node) { - this(node, new ArrayList()); + public RoutingNode(String nodeId, DiscoveryNode node) { + this(nodeId, node, new ArrayList()); } - public RoutingNode(DiscoveryNode node, List shards) { + public RoutingNode(String nodeId, DiscoveryNode node, List shards) { + this.nodeId = nodeId; this.node = node; this.shards = shards; } @@ -54,7 +57,7 @@ public class RoutingNode implements Iterable { } public String nodeId() { - return this.node.id(); + return this.nodeId; } public List shards() { @@ -140,7 +143,7 @@ public class RoutingNode implements Iterable { public String prettyPrint() { StringBuilder sb = new StringBuilder(); - sb.append("-----node_id[").append(node.id()).append("]\n"); + sb.append("-----node_id[").append(nodeId).append("][" + (node == null ? "X" : "V") + "]\n"); for (MutableShardRouting entry : shards) { sb.append("--------").append(entry.shortSummary()).append('\n'); } diff --git a/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java b/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java index cf147fcc5e5..e01fb698da9 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java +++ b/src/main/java/org/elasticsearch/cluster/routing/RoutingNodes.java @@ -86,7 +86,7 @@ public class RoutingNodes implements Iterable { } for (Map.Entry> entry : nodesToShards.entrySet()) { String nodeId = entry.getKey(); - this.nodesToShards.put(nodeId, new RoutingNode(clusterState.nodes().get(nodeId), entry.getValue())); + this.nodesToShards.put(nodeId, new RoutingNode(nodeId, clusterState.nodes().get(nodeId), entry.getValue())); } } diff --git a/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java b/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java index c9301ff90f9..3af0cc04e1a 100644 --- a/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java +++ b/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java @@ -246,7 +246,7 @@ public class AllocationService extends AbstractComponent { private void applyNewNodes(RoutingNodes routingNodes, Iterable liveNodes) { for (DiscoveryNode node : liveNodes) { if (!routingNodes.nodesToShards().containsKey(node.id())) { - RoutingNode routingNode = new RoutingNode(node); + RoutingNode routingNode = new RoutingNode(node.id(), node); routingNodes.nodesToShards().put(node.id(), routingNode); } }