Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PUBDEV-6662] H2O client should be able to connect to a new cluster if the previous was stopped #3672

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 16 additions & 1 deletion h2o-core/src/main/java/water/Paxos.java
Expand Up @@ -32,7 +32,7 @@ public abstract class Paxos {
public static volatile boolean _cloudLocked = false;

public static final NonBlockingHashMap<H2Okey,H2ONode> PROPOSED = new NonBlockingHashMap<>();

// ---
// This is a packet announcing what Cloud this Node thinks is the current
// Cloud, plus other status bits
Expand Down Expand Up @@ -64,6 +64,14 @@ static synchronized int doHeartbeat( H2ONode h2o ) {
return 0;
}

// Because of previous check we can be sure that the nodes are with the same cluster names
// I am client and non-client node is trying to talk to me
//
// Check if cloud hashes are equal. If not, we need to drop the state for previous cloud hash and connect to the
// new cloud. We are doing this only in case cloud is locked to allow normal clouding behaviour
if (_cloudLocked && H2O.ARGS.client && !h2o._heartbeat._client && H2O.SELF._heartbeat._cloud_hash != h2o._heartbeat._cloud_hash) {
resetState();
}

// Update manual flatfile in case of flatfile is enabled
if (H2O.isFlatfileEnabled()) {
Expand Down Expand Up @@ -134,6 +142,13 @@ static synchronized int doHeartbeat( H2ONode h2o ) {
return 0;
}

private static void resetState() {
PROPOSED.clear();
_cloudLocked = false;
_commonKnowledge = false;
H2O.SELF._heartbeat._cloud_hash = 0;
}

static private int doHash() {
int hash = 0;
for( H2ONode h2o : PROPOSED.values() )
Expand Down