use of org.redisson.connection.NodeSource in project redisson by redisson.
the class CommandAsyncService method readAsync.
public <T, R> RFuture<R> readAsync(Integer slot, Codec codec, RedisCommand<T> command, Object... params) {
RPromise<R> mainPromise = connectionManager.newPromise();
async(true, new NodeSource(slot), codec, command, params, mainPromise, 0);
return mainPromise;
}
use of org.redisson.connection.NodeSource in project redisson by redisson.
the class CommandAsyncService method retryReadRandomAsync.
private <R, T> void retryReadRandomAsync(final RedisCommand<T> command, final RPromise<R> mainPromise, final List<MasterSlaveEntry> nodes, final Object... params) {
final RPromise<R> attemptPromise = connectionManager.newPromise();
attemptPromise.addListener(new FutureListener<R>() {
@Override
public void operationComplete(Future<R> future) throws Exception {
if (future.isSuccess()) {
if (future.getNow() == null) {
if (nodes.isEmpty()) {
mainPromise.trySuccess(null);
} else {
retryReadRandomAsync(command, mainPromise, nodes, params);
}
} else {
mainPromise.trySuccess(future.getNow());
}
} else {
mainPromise.tryFailure(future.cause());
}
}
});
MasterSlaveEntry entry = nodes.remove(0);
async(true, new NodeSource(entry), connectionManager.getCodec(), command, params, attemptPromise, 0);
}
Aggregations