Skip to content

Commit

Permalink
Simplify ClientConnectionManagerImpl
Browse files Browse the repository at this point in the history
This commit simplifies the concurrency and state machine logic of
ClientConnectionManagerImpl.

First, a simple mutex is defined and used for the management of connections and
client state and races are prevented during state updates.

Second, the possible client states and their transitions are clarified.
On bootstrap, a client starts with the INITIAL state and moves to
the INITIALIZED_ON_CLUSTER state once it makes its first connection to any
member. Then, whenever this client drops all its connections to the current
cluster and connects to a totally new cluster, it moves to
the CONNECTED_TO_CLUSTER state. Then, the client moves back to
the INITIALIZED_ON_CLUSTER state once it propagates its local state to
the new cluster.

Fixes hazelcast#16288
  • Loading branch information
metanet committed Dec 26, 2019
1 parent f9a0ec3 commit 3d897c2
Show file tree
Hide file tree
Showing 7 changed files with 491 additions and 506 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public void start() {
}
ClientConnectionStrategyConfig connectionStrategyConfig = config.getConnectionStrategyConfig();
if (!connectionStrategyConfig.isAsyncStart()) {
connectionManager.tryOpenConnectionToAllMembers();
connectionManager.connectToAllClusterMembers();
waitForInitialMembershipEvents();
}
loadBalancer.init(getCluster(), config);
Expand Down Expand Up @@ -838,7 +838,7 @@ public void onClusterChange() {

public void onClusterRestart() {
ILogger logger = loggingService.getLogger(HazelcastInstance.class);
logger.info("Clearing local state of the client, because of a cluster restart ");
logger.info("Clearing local state of the client, because of a cluster restart");

dispose(onClusterChangeDisposables);
//clear the member list version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void close(String reason, Throwable cause) {
logger.warning("Exception while closing connection" + e.getMessage());
}

connectionManager.onClose(this);
connectionManager.onConnectionClose(this);
}

private void logClose() {
Expand Down
Loading

0 comments on commit 3d897c2

Please sign in to comment.