Search in sources :

Example 16 with NodeSource

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;
}
Also used : NodeSource(org.redisson.connection.NodeSource)

Example 17 with NodeSource

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);
}
Also used : NodeSource(org.redisson.connection.NodeSource) MasterSlaveEntry(org.redisson.connection.MasterSlaveEntry) RedisAskException(org.redisson.client.RedisAskException) RedisLoadingException(org.redisson.client.RedisLoadingException) RedisTimeoutException(org.redisson.client.RedisTimeoutException) RedisException(org.redisson.client.RedisException) RedisMovedException(org.redisson.client.RedisMovedException) WriteRedisConnectionException(org.redisson.client.WriteRedisConnectionException) RedisTryAgainException(org.redisson.client.RedisTryAgainException) RedissonShutdownException(org.redisson.RedissonShutdownException)

Aggregations

NodeSource (org.redisson.connection.NodeSource)17 MasterSlaveEntry (org.redisson.connection.MasterSlaveEntry)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 RedisAskException (org.redisson.client.RedisAskException)5 RedisLoadingException (org.redisson.client.RedisLoadingException)5 RedisMovedException (org.redisson.client.RedisMovedException)5 RedisTimeoutException (org.redisson.client.RedisTimeoutException)5 RedisTryAgainException (org.redisson.client.RedisTryAgainException)5 WriteRedisConnectionException (org.redisson.client.WriteRedisConnectionException)5 ChannelFuture (io.netty.channel.ChannelFuture)4 ChannelFutureListener (io.netty.channel.ChannelFutureListener)3 Future (io.netty.util.concurrent.Future)3 FutureListener (io.netty.util.concurrent.FutureListener)3 ArrayList (java.util.ArrayList)3 RFuture (org.redisson.api.RFuture)3 Timeout (io.netty.util.Timeout)2 TimerTask (io.netty.util.TimerTask)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 RedissonShutdownException (org.redisson.RedissonShutdownException)2 RedisException (org.redisson.client.RedisException)2