use of com.palantir.common.concurrent.BlockingWorkerPool in project atlasdb by palantir.
the class RangeVisitor method visit.
public long visit(final Visitor visitor) throws InterruptedException {
BlockingWorkerPool pool = new BlockingWorkerPool(exec, threadCount);
for (final MutableRange range : getRanges()) {
pool.submitTask(() -> visitRange(visitor, range));
}
pool.waitForSubmittedTasks();
return counter.get();
}
use of com.palantir.common.concurrent.BlockingWorkerPool in project atlasdb by palantir.
the class KeyValueServices method getFirstBatchForRangesUsingGetRangeConcurrent.
@SuppressWarnings("checkstyle:LineLength")
public static Map<RangeRequest, TokenBackedBasicResultsPage<RowResult<Value>, byte[]>> getFirstBatchForRangesUsingGetRangeConcurrent(ExecutorService executor, final KeyValueService kv, final TableReference tableRef, Iterable<RangeRequest> rangeRequests, final long timestamp, int maxConcurrentRequests) {
final Map<RangeRequest, TokenBackedBasicResultsPage<RowResult<Value>, byte[]>> ret = Maps.newConcurrentMap();
BlockingWorkerPool pool = new BlockingWorkerPool(executor, maxConcurrentRequests);
try {
for (final RangeRequest request : rangeRequests) {
pool.submitTask(() -> getFirstBatchForRangeUsingGetRange(kv, tableRef, request, timestamp, ret));
}
pool.waitForSubmittedTasks();
return ret;
} catch (InterruptedException e) {
throw Throwables.rewrapAndThrowUncheckedException(e);
}
}
Aggregations