Skip to content

Commit

Permalink
Shutdown joining member when initial cluster version is not valid
Browse files Browse the repository at this point in the history
The local member should be validating the initial cluster version
as is already done each time cluster version changes.
  • Loading branch information
vbekiaris committed Sep 10, 2018
1 parent af34a2c commit 54b54ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Expand Up @@ -81,6 +81,7 @@
import static com.hazelcast.util.Preconditions.checkFalse;
import static com.hazelcast.util.Preconditions.checkNotNull;
import static com.hazelcast.util.Preconditions.checkTrue;
import static java.lang.String.format;

@SuppressWarnings({"checkstyle:methodcount", "checkstyle:classdataabstractioncoupling", "checkstyle:classfanoutcomplexity"})
public class ClusterServiceImpl implements ClusterService, ConnectionListener, ManagedService,
Expand Down Expand Up @@ -378,7 +379,15 @@ public boolean finalizeJoin(MembersView membersView, Address callerAddress, Stri

checkMemberUpdateContainsLocalMember(membersView, targetUuid);

initialClusterState(clusterState, clusterVersion);
try {
initialClusterState(clusterState, clusterVersion);
} catch (VersionMismatchException e) {
// node should shutdown since it cannot handle the cluster version
// it is safe to do so here because no operations have been executed yet
logger.severe(format("This member will shutdown because it cannot join the cluster: %s", e.getMessage()));
node.shutdown(true);
return false;
}
setClusterId(clusterId);
ClusterClockImpl clusterClock = getClusterClock();
clusterClock.setClusterStartTime(clusterStartTime);
Expand Down
Expand Up @@ -115,7 +115,7 @@ void initialClusterState(ClusterState initialState, Version version) {
+ initialState);
return;
}
// no need to validate again
validateNodeCompatibleWith(version);
logger.fine("Setting initial cluster state: " + initialState + " and version: " + version);
setClusterStateAndVersion(initialState, version, true);
} finally {
Expand Down

0 comments on commit 54b54ba

Please sign in to comment.