Skip to content

Commit c639da5

Browse files
Merge pull request #1277 from myronkscott/backup_wait
backoff wait times what servers are down
2 parents da1b98d + 78303a1 commit c639da5

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

tc-client/src/main/java/com/tc/object/DistributedObjectClient.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -379,23 +379,25 @@ private boolean waitForConnection(long timeout, TimeUnit units) throws Interrupt
379379
}
380380

381381
private void openChannel(ClientMessageChannel channel) throws InterruptedException {
382+
long waitTime = 0;
382383
while (!clientStopped.isSet()) {
383384
try {
385+
waitTime = Math.min(Math.max(Math.round(waitTime * 1.5), 1_000L), 30_000L);
384386
DSO_LOGGER.debug("Trying to open channel....");
385387
channel.open(serverAddresses);
386388
DSO_LOGGER.debug("Channel open");
387389
break;
388390
} catch (final TCTimeoutException tcte) {
389-
DSO_LOGGER.debug("Unable to connect to server/s {} ...sleeping for 1 sec.", serverAddresses);
391+
DSO_LOGGER.info("Unable to connect to server/s {} ...sleeping for {} sec.", serverAddresses, TimeUnit.MILLISECONDS.toSeconds(waitTime));
390392
DSO_LOGGER.debug("Timeout connecting to server/s: {} {}", serverAddresses, tcte.getMessage());
391393
synchronized(clientStopped) {
392-
clientStopped.wait(1000);
394+
clientStopped.wait(waitTime);
393395
}
394396
} catch (final ConnectException e) {
395-
DSO_LOGGER.debug("Unable to connect to server/s {} ...sleeping for 1 sec.", serverAddresses);
397+
DSO_LOGGER.info("Unable to connect to server/s {} ...sleeping for {} sec.", serverAddresses, TimeUnit.MILLISECONDS.toSeconds(waitTime));
396398
DSO_LOGGER.debug("Connection refused from server/s: {} {}", serverAddresses, e.getMessage());
397399
synchronized(clientStopped) {
398-
clientStopped.wait(1000);
400+
clientStopped.wait(waitTime);
399401
}
400402
} catch (final MaxConnectionsExceededException e) {
401403
DSO_LOGGER.error(e.getMessage());
@@ -407,15 +409,15 @@ private void openChannel(ClientMessageChannel channel) throws InterruptedExcepti
407409
DSO_LOGGER.error(handshake.getMessage());
408410
throw new IllegalStateException(handshake.getMessage(), handshake);
409411
} catch (final IOException ioe) {
410-
DSO_LOGGER.debug("Unable to connect to server/s {} ...sleeping for 1 sec.", serverAddresses);
412+
DSO_LOGGER.info("Unable to connect to server/s {} ...sleeping for {} sec.", serverAddresses, TimeUnit.MILLISECONDS.toSeconds(waitTime));
411413
DSO_LOGGER.debug("IOException connecting to server/s: {} {}", serverAddresses, ioe.getMessage());
412414
synchronized(clientStopped) {
413-
clientStopped.wait(1000);
415+
clientStopped.wait(waitTime);
414416
}
415417
}
416418
}
417419
}
418-
420+
419421
private void waitForHandshake(ClientMessageChannel channel) {
420422
this.clientHandshakeManager.waitForHandshake();
421423
ClientMessageChannel cmc = this.getClientMessageChannel();

0 commit comments

Comments
 (0)