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 Jul 2, 2018
1 parent d3caf82 commit 1509b28
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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 @@ -117,6 +117,7 @@ void initialClusterState(ClusterState initialState, Version version) {
}
// no need to validate again
logger.fine("Setting initial cluster state: " + initialState + " and version: " + version);
validateNodeCompatibleWith(version);
setClusterStateAndVersion(initialState, version, true);
} finally {
clusterServiceLock.unlock();
Expand Down

0 comments on commit 1509b28

Please sign in to comment.