Check failedAttempts value in tryAcquireConnection. #262

pull/297/head
Nikita 9 years ago
parent 28205954de
commit a8d0614d5c

@ -429,7 +429,7 @@ public class CommandExecutorService implements CommandExecutor {
return;
}
if (attempt == connectionManager.getConfig().getRetryAttempts()) {
attemptPromise.setFailure(ex.get());
attemptPromise.tryFailure(ex.get());
return;
}
if (!attemptPromise.cancel(false)) {

@ -64,6 +64,10 @@ public class ConnectionEntry {
failedAttempts.set(0);
}
public int getFailedAttempts() {
return failedAttempts.get();
}
public int incFailedAttempts() {
return failedAttempts.incrementAndGet();
}

@ -102,7 +102,7 @@ public class ConnectionPool<T extends RedisConnection> {
}
protected boolean tryAcquireConnection(SubscribesConnectionEntry entry) {
return entry.tryAcquireConnection();
return entry.getFailedAttempts() < config.getSlaveFailedAttempts() && entry.tryAcquireConnection();
}
protected T poll(SubscribesConnectionEntry entry) {
@ -168,8 +168,8 @@ public class ConnectionPool<T extends RedisConnection> {
private void promiseFailure(SubscribesConnectionEntry entry, Promise<T> promise, T conn) {
int attempts = entry.incFailedAttempts();
if (entry.getNodeType() == NodeType.SLAVE) {
int attempts = entry.incFailedAttempts();
if (attempts == config.getSlaveFailedAttempts()) {
connectionManager.slaveDown(masterSlaveEntry, entry.getClient().getAddr().getHostName(),
entry.getClient().getAddr().getPort(), FreezeReason.RECONNECT);

Loading…
Cancel
Save