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() { TimerTask timeoutTask = new TimerTask() {
@Override @Override
public void run(Timeout timeout) throws Exception { 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( details.getAttemptPromise().tryFailure(
new RedisResponseTimeoutException("Redis server response timeout (" + timeoutAmount + " ms) occured for command: " + details.getCommand() new RedisResponseTimeoutException("Redis server response timeout (" + timeoutAmount + " ms) occured for command: " + details.getCommand()
+ " with params: " + LogHelper.toString(details.getParams()) + " channel: " + connection.getChannel())); + " with params: " + LogHelper.toString(details.getParams()) + " channel: " + connection.getChannel()));
@ -910,16 +902,6 @@ public class CommandAsyncService implements CommandAsyncExecutor {
free(details.getParams()); 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()) { if (future.isSuccess()) {
R res = future.getNow(); R res = future.getNow();
if (res instanceof ScanResult) { if (res instanceof ScanResult) {

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

Loading…
Cancel
Save