@Override public <T, R> RFuture<Collection<R>> readAllAsync(Codec codec, RedisCommand<T> command, Object... params) { List<R> results = new ArrayList<R>(); return readAllAsync(results, codec, command, params); }
@Override public Integer clusterGetSlotForKey(byte[] key) { RFuture<Integer> f = executorService.readAsync((String)null, StringCodec.INSTANCE, RedisCommands.KEYSLOT, key); return syncFuture(f); }
@Override public <T> RFuture<Void> writeAllAsync(RedisCommand<T> command, Object... params) { return writeAllAsync(command, null, params); }
@Override public <T, R> RFuture<R> readAsync(String key, Codec codec, RedisCommand<T> command, Object... params) { RPromise<R> mainPromise = createPromise(); NodeSource source = getNodeSource(key); async(true, source, codec, command, params, mainPromise, 0, false); return mainPromise; }
public <T, R> RFuture<R> readAsync(MasterSlaveEntry entry, Codec codec, RedisCommand<T> command, Object... params) { RPromise<R> mainPromise = createPromise(); async(true, new NodeSource(entry), codec, command, params, mainPromise, 0, false); return mainPromise; }
@Override public void watch(byte[]... keys) { if (isQueueing()) { throw new UnsupportedOperationException(); } syncFuture(executorService.writeAsync(null, RedisCommands.WATCH, keys)); }
@Override public Long clusterCountKeysInSlot(int slot) { RedisClusterNode node = clusterGetNodeForSlot(slot); MasterSlaveEntry entry = executorService.getConnectionManager().getEntry(new InetSocketAddress(node.getHost(), node.getPort())); RFuture<Long> f = executorService.readAsync(entry, StringCodec.INSTANCE, RedisCommands.CLUSTER_COUNTKEYSINSLOT, slot); return syncFuture(f); }
private RFuture<Long> executeAsync(RedisStrictCommand<Long> command, byte[] ... keys) { if (!executorService.getConnectionManager().isClusterMode()) { return executorService.writeAsync(null, command, Arrays.asList(keys).toArray()); int slot = executorService.getConnectionManager().calcSlot(key); MasterSlaveEntry entry = executorService.getConnectionManager().getEntry(slot); List<byte[]> list = range2key.get(entry); if (list == null) { CommandBatchService es = new CommandBatchService(executorService.getConnectionManager()); for (byte[] key : entry.getValue()) { es.writeAsync(entry.getKey(), null, command, key);
@Override public RedisClusterNode clusterGetNodeForKey(byte[] key) { int slot = executorService.getConnectionManager().calcSlot(key); return clusterGetNodeForSlot(slot); }
@Override public byte[] randomKey(RedisClusterNode node) { MasterSlaveEntry entry = getEntry(node); RFuture<byte[]> f = executorService.readRandomAsync(entry, ByteArrayCodec.INSTANCE, RedisCommands.RANDOM_KEY); return syncFuture(f); }
<V> V syncFuture(RFuture<V> future) { try { return executorService.get(future); } catch (Exception ex) { throw transform(ex); } }
@Override public <R, T> RFuture<R> writeAllAsync(Codec codec, RedisCommand<T> command, SlotCallback<T, R> callback, Object... params) { return allAsync(false, codec, command, callback, params); }
@Override public void run(Timeout timeout) throws Exception { async(details.isReadOnlyMode(), source, details.getCodec(), details.getCommand(), details.getParams(), details.getMainPromise(), details.getAttempt(), ignoreRedirect); } }, 1, TimeUnit.SECONDS);
@Override public void watch(byte[]... keys) { if (isQueueing()) { throw new UnsupportedOperationException(); } syncFuture(executorService.writeAsync(null, RedisCommands.WATCH, keys)); }
@Override public Long clusterCountKeysInSlot(int slot) { RedisClusterNode node = clusterGetNodeForSlot(slot); MasterSlaveEntry entry = executorService.getConnectionManager().getEntry(new InetSocketAddress(node.getHost(), node.getPort())); RFuture<Long> f = executorService.readAsync(entry, StringCodec.INSTANCE, RedisCommands.CLUSTER_COUNTKEYSINSLOT, slot); return syncFuture(f); }
private RFuture<Long> executeAsync(RedisStrictCommand<Long> command, byte[] ... keys) { if (!executorService.getConnectionManager().isClusterMode()) { return executorService.writeAsync(null, command, Arrays.asList(keys).toArray()); int slot = executorService.getConnectionManager().calcSlot(key); MasterSlaveEntry entry = executorService.getConnectionManager().getEntry(slot); List<byte[]> list = range2key.get(entry); if (list == null) { CommandBatchService es = new CommandBatchService(executorService.getConnectionManager()); for (byte[] key : entry.getValue()) { es.writeAsync(entry.getKey(), null, command, key);
@Override public RedisClusterNode clusterGetNodeForKey(byte[] key) { int slot = executorService.getConnectionManager().calcSlot(key); return clusterGetNodeForSlot(slot); }
@Override public <T, R> RFuture<R> readAsync(byte[] key, Codec codec, RedisCommand<T> command, Object... params) { RPromise<R> mainPromise = createPromise(); NodeSource source = getNodeSource(key); async(true, source, codec, command, params, mainPromise, 0, false); return mainPromise; }
@Override public byte[] randomKey(RedisClusterNode node) { MasterSlaveEntry entry = getEntry(node); RFuture<byte[]> f = executorService.readRandomAsync(entry, ByteArrayCodec.INSTANCE, RedisCommands.RANDOM_KEY); return syncFuture(f); }
@Override public <T, R> RFuture<R> writeAsync(MasterSlaveEntry entry, Codec codec, RedisCommand<T> command, Object... params) { RPromise<R> mainPromise = createPromise(); async(false, new NodeSource(entry), codec, command, params, mainPromise, 0, false); return mainPromise; }