diff --git a/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java b/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java index 4728169fb7116..872f6b6a55b38 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 @@ */ 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 DiscoveryNode node() { } public String nodeId() { - return this.node.id(); + return this.nodeId; } public List shards() { @@ -140,7 +143,7 @@ public int numberOfOwningShards() { 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 cf147fcc5e5ad..e01fb698da98b 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 RoutingNodes(ClusterState clusterState) { } 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 c9301ff90f992..3af0cc04e1ace 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 @@ private boolean electPrimaries(RoutingNodes routingNodes) { 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); } }