improve join process in cluster, fetch the cluster meta-data on join and handle new meta data

This commit is contained in:
kimchy 2010-07-14 10:34:22 +03:00
parent 141506afc5
commit 2704ab3d69
1 changed files with 6 additions and 3 deletions

View File

@ -437,16 +437,19 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
} }
} }
private void handleJoinRequest(final DiscoveryNode node) { private ClusterState handleJoinRequest(final DiscoveryNode node) {
if (!master) { if (!master) {
throw new ElasticSearchIllegalStateException("Node [" + localNode + "] not master for join request from [" + node + "]"); throw new ElasticSearchIllegalStateException("Node [" + localNode + "] not master for join request from [" + node + "]");
} }
ClusterState state = clusterService.state();
if (!transportService.addressSupported(node.address().getClass())) { if (!transportService.addressSupported(node.address().getClass())) {
// TODO, what should we do now? Maybe inform that node that its crap? // TODO, what should we do now? Maybe inform that node that its crap?
logger.warn("received a wrong address type from [{}], ignoring...", node); logger.warn("received a wrong address type from [{}], ignoring...", node);
} else { } else {
// try and connect to the node, if it fails, we can raise an exception back to the client... // try and connect to the node, if it fails, we can raise an exception back to the client...
transportService.connectToNode(node); transportService.connectToNode(node);
state = clusterService.state();
clusterService.submitStateUpdateTask("zen-disco-receive(from node[" + node + "])", new ClusterStateUpdateTask() { clusterService.submitStateUpdateTask("zen-disco-receive(from node[" + node + "])", new ClusterStateUpdateTask() {
@Override public ClusterState execute(ClusterState currentState) { @Override public ClusterState execute(ClusterState currentState) {
@ -459,6 +462,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
} }
}); });
} }
return state;
} }
private DiscoveryNode findMaster() { private DiscoveryNode findMaster() {
@ -516,8 +520,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
private class MembershipListener implements MembershipAction.MembershipListener { private class MembershipListener implements MembershipAction.MembershipListener {
@Override public ClusterState onJoin(DiscoveryNode node) { @Override public ClusterState onJoin(DiscoveryNode node) {
handleJoinRequest(node); return handleJoinRequest(node);
return clusterService.state();
} }
@Override public void onLeave(DiscoveryNode node) { @Override public void onLeave(DiscoveryNode node) {