refactoring

pull/2323/head
Nikita Koksharov 5 years ago
parent 094274a465
commit eb962251f4

@ -226,17 +226,11 @@ public class RedisExecutor<V, R> {
} }
attempt++; attempt++;
Timeout timeout; scheduleRetryTimeout(connectionFuture, attemptPromise);
if (retryInterval > 0 && attempts > 0) {
timeout = connectionManager.newTimeout(this, retryInterval, TimeUnit.MILLISECONDS);
} else {
timeout = MasterSlaveConnectionManager.DUMMY_TIMEOUT;
}
RedisExecutor.this.timeout = timeout;
return; return;
} }
if (writeFuture.isDone() && writeFuture.isSuccess()) { if (writeFuture.isSuccess()) {
return; return;
} }
} }
@ -308,6 +302,10 @@ public class RedisExecutor<V, R> {
timeout.cancel(); timeout.cancel();
scheduleResponseTimeout(attemptPromise, connection);
}
private void scheduleResponseTimeout(RPromise<R> attemptPromise, RedisConnection connection) {
long timeoutTime = responseTimeout; long timeoutTime = responseTimeout;
if (command != null if (command != null
&& (RedisCommands.BLOCKING_COMMAND_NAMES.contains(command.getName()) && (RedisCommands.BLOCKING_COMMAND_NAMES.contains(command.getName())

@ -666,8 +666,8 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
result.awaitUninterruptibly(timeout, unit); result.awaitUninterruptibly(timeout, unit);
resolverGroup.close(); resolverGroup.close();
timer.stop();
shutdownLatch.close(); shutdownLatch.close();
timer.stop();
shutdownPromise.trySuccess(null); shutdownPromise.trySuccess(null);
shutdownLatch.awaitUninterruptibly(); shutdownLatch.awaitUninterruptibly();
@ -697,9 +697,12 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
try { try {
return timer.newTimeout(task, delay, unit); return timer.newTimeout(task, delay, unit);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
// timer is shutdown if (isShuttingDown()) {
return DUMMY_TIMEOUT; return DUMMY_TIMEOUT;
} }
throw e;
}
} }
@Override @Override

Loading…
Cancel
Save