@Override public void onSuccess(Object obj) { flowController.release(batch); retFuture.set(null); }
private static <T> BatchingFlowController<T> getDisabledBatchingFlowController() { return new BatchingFlowController<>( getDisabledFlowController(), new ElementCounter<T>() { @Override public long count(T t) { return 1; } }, new ElementCounter<T>() { @Override public long count(T t) { return 1; } }); }
flowController.reserve(e); lock.lock(); try {
private ThresholdBatcher<Batch<RequestT, ResponseT>> createBatcher(PartitionKey partitionKey) { BatchExecutor<RequestT, ResponseT> processor = new BatchExecutor<>(batchingDescriptor, partitionKey); BatchingFlowController<Batch<RequestT, ResponseT>> batchingFlowController = new BatchingFlowController<>( flowController, new BatchElementCounter<>(batchingDescriptor), new BatchByteCounter<RequestT, ResponseT>()); return ThresholdBatcher.<Batch<RequestT, ResponseT>>newBuilder() .setThresholds(getThresholds(batchingSettings)) .setExecutor(executor) .setMaxDelay(batchingSettings.getDelayThreshold()) .setReceiver(processor) .setFlowController(batchingFlowController) .setBatchMerger(new BatchMergerImpl<RequestT, ResponseT>()) .build(); }
flowController.reserve(e); lock.lock(); try {
private static BatchingFlowController<SimpleBatch> getTrackedIntegerBatchingFlowController( Long elementCount, Long byteCount, LimitExceededBehavior limitExceededBehaviour) { trackedFlowController = new TrackedFlowController( FlowControlSettings.newBuilder() .setMaxOutstandingElementCount(elementCount) .setMaxOutstandingRequestBytes(byteCount) .setLimitExceededBehavior(limitExceededBehaviour) .build()); return new BatchingFlowController<>( trackedFlowController, new ElementCounter<SimpleBatch>() { @Override public long count(SimpleBatch t) { return t.getIntegers().size(); } }, new ElementCounter<SimpleBatch>() { @Override public long count(SimpleBatch t) { long counter = 0; for (Integer i : t.integers) { counter += i; } return counter; } }); }
@Override public void onFailure(Throwable t) { flowController.release(batch); retFuture.setException(t); } },
private ThresholdBatcher<Batch<RequestT, ResponseT>> createBatcher(PartitionKey partitionKey) { BatchExecutor<RequestT, ResponseT> processor = new BatchExecutor<>(batchingDescriptor, partitionKey); BatchingFlowController<Batch<RequestT, ResponseT>> batchingFlowController = new BatchingFlowController<>( flowController, new BatchElementCounter<>(batchingDescriptor), new BatchByteCounter<RequestT, ResponseT>()); return ThresholdBatcher.<Batch<RequestT, ResponseT>>newBuilder() .setThresholds(getThresholds(batchingSettings)) .setExecutor(executor) .setMaxDelay(batchingSettings.getDelayThreshold()) .setReceiver(processor) .setFlowController(batchingFlowController) .setBatchMerger(new BatchMergerImpl<RequestT, ResponseT>()) .build(); }
@Override public void onSuccess(Object obj) { flowController.release(batch); retFuture.set(null); }
@Override public void onFailure(Throwable t) { flowController.release(batch); retFuture.setException(t); } },