Only apply the initialReconnectDelay on the first reconnection attempt
after a connected transport has failed.
This commit is contained in:
Timothy Bish 2016-04-15 12:49:49 -04:00
parent 1ffac14f6e
commit c8af70f094
1 changed files with 10 additions and 16 deletions

View File

@ -999,19 +999,15 @@ public class FailoverTransport implements CompositeTransport {
} }
} }
// Sleep for the reconnectDelay if there's no backup and we aren't trying // When there was no backup and we are reconnecting for the first time
// for the first time, or we were disposed for some reason. // we honor the initialReconnectDelay before trying a new connection, after
if (transport == null && !firstConnection && (reconnectDelay > 0) && !disposed) { // this normal reconnect delay happens following a failed attempt.
synchronized (sleepMutex) { if (transport == null && !firstConnection && connectFailures == 0 && initialReconnectDelay > 0 && !disposed) {
if (LOG.isDebugEnabled()) { // reconnectDelay will be equal to initialReconnectDelay since we are on
LOG.debug("Waiting " + reconnectDelay + " ms before attempting connection. "); // the first connect attempt after we had a working connection, doDelay
} // will apply updates to move to the next reconnectDelay value based on
try { // configuration.
sleepMutex.wait(reconnectDelay); doDelay();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
} }
Iterator<URI> iter = connectList.iterator(); Iterator<URI> iter = connectList.iterator();
@ -1137,9 +1133,7 @@ public class FailoverTransport implements CompositeTransport {
private void doDelay() { private void doDelay() {
if (reconnectDelay > 0) { if (reconnectDelay > 0) {
synchronized (sleepMutex) { synchronized (sleepMutex) {
if (LOG.isDebugEnabled()) { LOG.debug("Waiting {} ms before attempting connection", reconnectDelay);
LOG.debug("Waiting " + reconnectDelay + " ms before attempting connection");
}
try { try {
sleepMutex.wait(reconnectDelay); sleepMutex.wait(reconnectDelay);
} catch (InterruptedException e) { } catch (InterruptedException e) {