Skip to content

Commit

Permalink
Removing a node with TRACE logging enabled causes cluster state not t…
Browse files Browse the repository at this point in the history
…o be properly updated, closes #1626.
  • Loading branch information
kimchy committed Jan 19, 2012
1 parent 2eeb609 commit a1a3022
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java
Expand Up @@ -31,15 +31,18 @@
*/
public class RoutingNode implements Iterable<MutableShardRouting> {

private final String nodeId;

private final DiscoveryNode node;

private final List<MutableShardRouting> shards;

public RoutingNode(DiscoveryNode node) {
this(node, new ArrayList<MutableShardRouting>());
public RoutingNode(String nodeId, DiscoveryNode node) {
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.shards = shards;
}
Expand All @@ -54,7 +57,7 @@ public DiscoveryNode node() {
}

public String nodeId() {
return this.node.id();
return this.nodeId;
}

public List<MutableShardRouting> shards() {
Expand Down Expand Up @@ -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');
}
Expand Down
Expand Up @@ -86,7 +86,7 @@ public RoutingNodes(ClusterState clusterState) {
}
for (Map.Entry<String, List<MutableShardRouting>> 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()));
}
}

Expand Down
Expand Up @@ -246,7 +246,7 @@ private boolean electPrimaries(RoutingNodes routingNodes) {
private void applyNewNodes(RoutingNodes routingNodes, Iterable<DiscoveryNode> 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);
}
}
Expand Down

0 comments on commit a1a3022

Please sign in to comment.