Fixed - Node.ping should return false if node is unreachable

pull/1705/head
Nikita Koksharov 6 years ago
parent c4762a34a4
commit 9dd8b52922

@ -27,6 +27,11 @@ import org.redisson.client.codec.StringCodec;
import org.redisson.client.protocol.RedisCommands;
import org.redisson.client.protocol.Time;
import org.redisson.command.CommandSyncService;
import org.redisson.misc.RPromise;
import org.redisson.misc.RedissonPromise;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.FutureListener;
/**
*
@ -61,7 +66,20 @@ public class RedisClientEntry implements ClusterNode {
}
public RFuture<Boolean> pingAsync() {
return commandExecutor.readAsync(client, null, RedisCommands.PING_BOOL);
RPromise<Boolean> result = new RedissonPromise<Boolean>();
RFuture<Boolean> f = commandExecutor.readAsync(client, null, RedisCommands.PING_BOOL);
f.addListener(new FutureListener<Boolean>() {
@Override
public void operationComplete(Future<Boolean> future) throws Exception {
if (!future.isSuccess()) {
result.trySuccess(false);
return;
}
result.trySuccess(future.getNow());
}
});
return result;
}
@Override
@ -149,9 +167,4 @@ public class RedisClientEntry implements ClusterNode {
throw new IllegalStateException();
}
@Override
public Map<String, String> info() {
return clusterInfo();
}
}

Loading…
Cancel
Save