refactoring

pull/1821/head
Nikita 6 years ago
parent 0e78d16f82
commit 7d934dc1dd

@ -747,14 +747,6 @@ public class CommandAsyncService implements CommandAsyncExecutor {
TimerTask timeoutTask = new TimerTask() {
@Override
public void run(Timeout timeout) throws Exception {
MasterSlaveEntry entry = connectionManager.getEntry(connection.getRedisClient());
if (entry != null) {
ClientConnectionsEntry ee = entry.getEntry(connection.getRedisClient());
if (ee != null && ee.getNodeType() == NodeType.SLAVE) {
ee.trySetupFistFail();
}
}
details.getAttemptPromise().tryFailure(
new RedisResponseTimeoutException("Redis server response timeout (" + timeoutAmount + " ms) occured for command: " + details.getCommand()
+ " with params: " + LogHelper.toString(details.getParams()) + " channel: " + connection.getChannel()));
@ -910,16 +902,6 @@ public class CommandAsyncService implements CommandAsyncExecutor {
free(details.getParams());
if (!(future.cause() instanceof RedisTimeoutException) && details.getConnectionFuture().getNow() != null) {
MasterSlaveEntry entry = connectionManager.getEntry(details.getConnectionFuture().getNow().getRedisClient());
if (entry != null) {
ClientConnectionsEntry ee = entry.getEntry(details.getConnectionFuture().getNow().getRedisClient());
if (ee != null && ee.getNodeType() == NodeType.SLAVE) {
ee.resetFirstFail();
}
}
}
if (future.isSuccess()) {
R res = future.getNow();
if (res instanceof ScanResult) {

@ -271,11 +271,10 @@ abstract class ConnectionPool<T extends RedisConnection> {
}
T conn = poll(entry);
if (conn != null) {
if (!conn.isActive()) {
promiseFailure(entry, promise, conn);
return;
}
if (!conn.isActive() && entry.getNodeType() == NodeType.SLAVE) {
entry.trySetupFistFail();
}
connectedSuccessful(entry, promise, conn);
return;
}
@ -305,6 +304,10 @@ abstract class ConnectionPool<T extends RedisConnection> {
}
private void connectedSuccessful(ClientConnectionsEntry entry, RPromise<T> promise, T conn) {
if (conn.isActive() && entry.getNodeType() == NodeType.SLAVE) {
entry.resetFirstFail();
}
if (!promise.trySuccess(conn)) {
releaseConnection(entry, conn);
releaseConnection(entry);

Loading…
Cancel
Save