ZenDiscovery: #11960 failed to remove eager reroute from node join

It is removed now :)

Closes #12019
This commit is contained in:
Boaz Leskes 2015-07-03 12:33:46 +02:00
parent 9495816cb7
commit d74eac94f2
1 changed files with 8 additions and 6 deletions

View File

@ -30,6 +30,7 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.cluster.node.DiscoveryNodes;
import org.elasticsearch.cluster.routing.RoutingNode;
import org.elasticsearch.cluster.routing.RoutingService; import org.elasticsearch.cluster.routing.RoutingService;
import org.elasticsearch.cluster.routing.allocation.RoutingAllocation; import org.elasticsearch.cluster.routing.allocation.RoutingAllocation;
import org.elasticsearch.cluster.service.InternalClusterService; import org.elasticsearch.cluster.service.InternalClusterService;
@ -939,14 +940,15 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> 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) { if (nodeAdded) {
stateBuilder.nodes(nodesBuilder); newState.nodes(nodesBuilder);
} }
currentState = stateBuilder.build();
// eagerly run reroute to apply the node addition return newState.build();
RoutingAllocation.Result result = routingService.getAllocationService().reroute(currentState);
return ClusterState.builder(currentState).routingResult(result).build();
} }
@Override @Override