From d74eac94f228a1b9f819cff79660d86d9faf1fb3 Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Fri, 3 Jul 2015 12:33:46 +0200 Subject: [PATCH] ZenDiscovery: #11960 failed to remove eager reroute from node join It is removed now :) Closes #12019 --- .../elasticsearch/discovery/zen/ZenDiscovery.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java index baf6a4a7fdb..57dbcb98a68 100644 --- a/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/core/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -30,6 +30,7 @@ import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; +import org.elasticsearch.cluster.routing.RoutingNode; import org.elasticsearch.cluster.routing.RoutingService; import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; import org.elasticsearch.cluster.service.InternalClusterService; @@ -939,14 +940,15 @@ public class ZenDiscovery extends AbstractLifecycleComponent implemen } } - ClusterState.Builder stateBuilder = ClusterState.builder(currentState); + + // we must return a new cluster state instance to force publishing. This is important + // for the joining node to finalize it's join and set us as a master + final ClusterState.Builder newState = ClusterState.builder(currentState); if (nodeAdded) { - stateBuilder.nodes(nodesBuilder); + newState.nodes(nodesBuilder); } - currentState = stateBuilder.build(); - // eagerly run reroute to apply the node addition - RoutingAllocation.Result result = routingService.getAllocationService().reroute(currentState); - return ClusterState.builder(currentState).routingResult(result).build(); + + return newState.build(); } @Override