@Override public RFuture<Void> setAsync(long fromIndex, long toIndex, boolean value) { CommandBatchService executorService = new CommandBatchService(commandExecutor.getConnectionManager()); for (long i = fromIndex; i < toIndex; i++) { executorService.writeAsync(getName(), LongCodec.INSTANCE, RedisCommands.SETBIT_VOID, getName(), i, value ? 1 : 0); } return executorService.executeAsyncVoid(); }
public List<Boolean> executeAdd() { return (List<Boolean>) batchCommandService.execute(); }
public RFuture<List<Boolean>> executeAddAsync() { return (RFuture<List<Boolean>>)(Object)batchCommandService.executeAsync(); }
public BatchResult<?> execute(BatchOptions options) { RFuture<BatchResult<?>> f = executeAsync(options); return get(f); }
CommandBatchService es = new CommandBatchService(executorService.getConnectionManager()); for (byte[] key : entry.getValue()) { es.writeAsync(entry.getKey(), null, command, key); RFuture<List<?>> future = es.executeAsync(); future.addListener(listener);
CommandBatchService executorService = new CommandBatchService(commandExecutor.getConnectionManager()); executorService.evalReadAsync(configName, codec, RedisCommands.EVAL_VOID, "local size = redis.call('hget', KEYS[1], 'size');" + "local hashIterations = redis.call('hget', KEYS[1], 'hashIterations');" + "assert(size == false and hashIterations == false, 'Bloom filter config has been changed')", Arrays.<Object>asList(configName), size, hashIterations); executorService.writeAsync(configName, StringCodec.INSTANCE, new RedisCommand<Void>("HMSET", new VoidReplayConvertor()), configName, "size", size, "hashIterations", hashIterations, "expectedInsertions", expectedInsertions, "falseProbability", BigDecimal.valueOf(falseProbability).toPlainString()); try { executorService.execute(); } catch (RedisException e) { if (!e.getMessage().contains("Bloom filter config has been changed")) {
public void rollback(List<TransactionalOperation> operations) { checkState(); CommandBatchService executorService = new CommandBatchService(commandExecutor.getConnectionManager()); for (TransactionalOperation transactionalOperation : operations) { transactionalOperation.rollback(executorService); } try { executorService.execute(); } catch (Exception e) { throw new TransactionException("Unable to rollback transaction", e); } operations.clear(); executed.set(true); }
public RedissonBatch(EvictionScheduler evictionScheduler, ConnectionManager connectionManager, BatchOptions options) { this.executorService = new CommandBatchService(connectionManager, options); this.evictionScheduler = evictionScheduler; this.options = options; }
@Override public long count() { CommandBatchService executorService = new CommandBatchService(commandExecutor.getConnectionManager()); RFuture<Map<String, String>> configFuture = executorService.readAsync(configName, StringCodec.INSTANCE, new RedisCommand<Map<Object, Object>>("HGETALL", new ObjectMapReplayDecoder()), configName); RBitSetAsync bs = createBitSet(executorService); RFuture<Long> cardinalityFuture = bs.cardinalityAsync(); executorService.execute(); readConfig(configFuture.getNow()); return Math.round(-size / ((double) hashIterations) * Math.log(1 - cardinalityFuture.getNow() / ((double) size))); }
@Override public RFuture<Void> rollbackAsync() { checkState(); CommandBatchService executorService = new CommandBatchService(commandExecutor.getConnectionManager()); for (TransactionalOperation transactionalOperation : operations) { transactionalOperation.rollback(executorService); } final RPromise<Void> result = new RedissonPromise<Void>(); RFuture<List<?>> future = executorService.executeAsync(); future.addListener(new FutureListener<Object>() { @Override public void operationComplete(Future<Object> future) throws Exception { if (!future.isSuccess()) { result.tryFailure(new TransactionException("Unable to rollback transaction", future.cause())); return; } operations.clear(); executed.set(true); result.trySuccess(null); } }); return result; }
@Override public boolean isPipelined() { if (executorService instanceof CommandBatchService) { CommandBatchService es = (CommandBatchService) executorService; return es.getOptions().getExecutionMode() == ExecutionMode.IN_MEMORY || es.getOptions().getExecutionMode() == ExecutionMode.IN_MEMORY_ATOMIC; } return false; }
details.setException(convertException(connFuture)); return; releaseConnection(source, connFuture, details.isReadOnlyMode(), attemptPromise, details); return; if (c.getPromise().isSuccess() && !isWaitCommand(c) && !isAtomic) { releaseConnection(source, connFuture, entry.isReadOnlyMode(), attemptPromise, details);
@Override public <V, R> void async(boolean readOnlyMode, NodeSource nodeSource, Codec codec, RedisCommand<V> command, Object[] params, RPromise<R> mainPromise, int attempt, boolean ignoreRedirect) { batchService.async(readOnlyMode, nodeSource, codec, command, params, mainPromise, attempt, ignoreRedirect); }
protected void enableRedissonReferenceSupport(Redisson redisson) { this.executorService.enableRedissonReferenceSupport(redisson); }
private void addConfigCheck(int hashIterations, long size, CommandBatchService executorService) { executorService.evalReadAsync(configName, codec, RedisCommands.EVAL_VOID, "local size = redis.call('hget', KEYS[1], 'size');" + "local hashIterations = redis.call('hget', KEYS[1], 'hashIterations');" + "assert(size == ARGV[1] and hashIterations == ARGV[2], 'Bloom filter config has been changed')", Arrays.<Object>asList(configName), size, hashIterations); }
CommandBatchService es = new CommandBatchService(executorService.getConnectionManager()); for (byte[] key : entry.getValue()) { es.writeAsync(entry.getKey(), null, command, key); RFuture<List<?>> future = es.executeAsync(); future.addListener(listener);
CommandBatchService executorService = new CommandBatchService(commandExecutor.getConnectionManager()); executorService.evalReadAsync(configName, codec, RedisCommands.EVAL_VOID, "local size = redis.call('hget', KEYS[1], 'size');" + "local hashIterations = redis.call('hget', KEYS[1], 'hashIterations');" + "assert(size == false and hashIterations == false, 'Bloom filter config has been changed')", Arrays.<Object>asList(configName), size, hashIterations); executorService.writeAsync(configName, StringCodec.INSTANCE, new RedisCommand<Void>("HMSET", new VoidReplayConvertor()), configName, "size", size, "hashIterations", hashIterations, "expectedInsertions", expectedInsertions, "falseProbability", BigDecimal.valueOf(falseProbability).toPlainString()); try { executorService.execute(); } catch (RedisException e) { if (!e.getMessage().contains("Bloom filter config has been changed")) {
public void rollback(List<TransactionalOperation> operations) { checkState(); CommandBatchService executorService = new CommandBatchService(commandExecutor.getConnectionManager()); for (TransactionalOperation transactionalOperation : operations) { transactionalOperation.rollback(executorService); } try { executorService.execute(); } catch (Exception e) { throw new TransactionException("Unable to rollback transaction", e); } operations.clear(); executed.set(true); }
public RedissonBatch(EvictionScheduler evictionScheduler, ConnectionManager connectionManager, BatchOptions options) { this.executorService = new CommandBatchService(connectionManager, options); this.evictionScheduler = evictionScheduler; this.options = options; }
@Override public long count() { CommandBatchService executorService = new CommandBatchService(commandExecutor.getConnectionManager()); RFuture<Map<String, String>> configFuture = executorService.readAsync(configName, StringCodec.INSTANCE, new RedisCommand<Map<Object, Object>>("HGETALL", new ObjectMapReplayDecoder()), configName); RBitSetAsync bs = createBitSet(executorService); RFuture<Long> cardinalityFuture = bs.cardinalityAsync(); executorService.execute(); readConfig(configFuture.getNow()); return Math.round(-size / ((double) hashIterations) * Math.log(1 - cardinalityFuture.getNow() / ((double) size))); }