Removing a node with TRACE logging enabled causes cluster state not to be properly updated, closes #1626.

This commit is contained in:
Shay Banon 2012-01-19 15:42:23 +02:00
parent 2eeb609353
commit a1a30226ca
3 changed files with 10 additions and 7 deletions

View File

@ -31,15 +31,18 @@ import static com.google.common.collect.Lists.newArrayList;
*/ */
public class RoutingNode implements Iterable<MutableShardRouting> { public class RoutingNode implements Iterable<MutableShardRouting> {
private final String nodeId;
private final DiscoveryNode node; private final DiscoveryNode node;
private final List<MutableShardRouting> shards; private final List<MutableShardRouting> shards;
public RoutingNode(DiscoveryNode node) { public RoutingNode(String nodeId, DiscoveryNode node) {
this(node, new ArrayList<MutableShardRouting>()); this(nodeId, node, new ArrayList<MutableShardRouting>());
} }
public RoutingNode(DiscoveryNode node, List<MutableShardRouting> shards) { public RoutingNode(String nodeId, DiscoveryNode node, List<MutableShardRouting> shards) {
this.nodeId = nodeId;
this.node = node; this.node = node;
this.shards = shards; this.shards = shards;
} }
@ -54,7 +57,7 @@ public class RoutingNode implements Iterable<MutableShardRouting> {
} }
public String nodeId() { public String nodeId() {
return this.node.id(); return this.nodeId;
} }
public List<MutableShardRouting> shards() { public List<MutableShardRouting> shards() {
@ -140,7 +143,7 @@ public class RoutingNode implements Iterable<MutableShardRouting> {
public String prettyPrint() { public String prettyPrint() {
StringBuilder sb = new StringBuilder(); 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) { for (MutableShardRouting entry : shards) {
sb.append("--------").append(entry.shortSummary()).append('\n'); sb.append("--------").append(entry.shortSummary()).append('\n');
} }

View File

@ -86,7 +86,7 @@ public class RoutingNodes implements Iterable<RoutingNode> {
} }
for (Map.Entry<String, List<MutableShardRouting>> entry : nodesToShards.entrySet()) { for (Map.Entry<String, List<MutableShardRouting>> entry : nodesToShards.entrySet()) {
String nodeId = entry.getKey(); 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()));
} }
} }

View File

@ -246,7 +246,7 @@ public class AllocationService extends AbstractComponent {
private void applyNewNodes(RoutingNodes routingNodes, Iterable<DiscoveryNode> liveNodes) { private void applyNewNodes(RoutingNodes routingNodes, Iterable<DiscoveryNode> liveNodes) {
for (DiscoveryNode node : liveNodes) { for (DiscoveryNode node : liveNodes) {
if (!routingNodes.nodesToShards().containsKey(node.id())) { if (!routingNodes.nodesToShards().containsKey(node.id())) {
RoutingNode routingNode = new RoutingNode(node); RoutingNode routingNode = new RoutingNode(node.id(), node);
routingNodes.nodesToShards().put(node.id(), routingNode); routingNodes.nodesToShards().put(node.id(), routingNode);
} }
} }