Skip to content

Commit

Permalink
Merge pull request #2897 from chrisdennis/ensure-close-on-reconnect
Browse files Browse the repository at this point in the history
Ensure previous connection is fully closed before starting reconnection
  • Loading branch information
cljohnso authored Apr 16, 2021
2 parents b699114 + c12108a commit bc0050c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ public void initClusterConnection(Executor asyncWorker) {
private void reconnect() {
while (true) {
try {
try {
//Ensure full closure of existing connection
clusterConnection.close();
} catch (IOException | ConnectionClosedException | IllegalStateException e) {
LOGGER.debug("Exception closing previous cluster connection", e);
}
connect();
LOGGER.info("New connection to server is established, reconnect count is {}", reconnectCounter.incrementAndGet());
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,11 @@ private interface TimeoutExceptionFunction<U, V> {
V apply(U u) throws TimeoutException;
}

private static class ReconnectInProgressProxy extends LockingServerStoreProxyImpl {
private static class ReconnectInProgressProxy implements LockingServerStoreProxy {

private final String cacheId;

ReconnectInProgressProxy(String cacheId) {
super(null, null);
this.cacheId = cacheId;
}

Expand Down Expand Up @@ -206,6 +205,11 @@ public ChainEntry lock(long key) {
public void unlock(long key, boolean localonly) {
throw new ReconnectInProgressException();
}

@Override
public void enableEvents(boolean enable) {
throw new ReconnectInProgressException();
}
}

private LockingServerStoreProxy unsupportedLocking(ServerStoreProxy serverStoreProxy) {
Expand Down

0 comments on commit bc0050c

Please sign in to comment.