From a1a30226caaef4667cb7d85a4702ecf6a6bb0703 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Thu, 19 Jan 2012 15:42:23 +0200 Subject: [PATCH] Removing a node with TRACE logging enabled causes cluster state not to be properly updated, closes #1626. --- .../elasticsearch/cluster/routing/RoutingNode.java | 13 ++++++++----- .../elasticsearch/cluster/routing/RoutingNodes.java | 2 +- .../routing/allocation/AllocationService.java | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) 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); } }