Search in sources :

Example 1 with BlockingWorkerPool

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();
}
Also used : BlockingWorkerPool(com.palantir.common.concurrent.BlockingWorkerPool)

Example 2 with BlockingWorkerPool

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);
    }
}
Also used : TokenBackedBasicResultsPage(com.palantir.util.paging.TokenBackedBasicResultsPage) RangeRequest(com.palantir.atlasdb.keyvalue.api.RangeRequest) Value(com.palantir.atlasdb.keyvalue.api.Value) BlockingWorkerPool(com.palantir.common.concurrent.BlockingWorkerPool)

Aggregations

BlockingWorkerPool (com.palantir.common.concurrent.BlockingWorkerPool)2 RangeRequest (com.palantir.atlasdb.keyvalue.api.RangeRequest)1 Value (com.palantir.atlasdb.keyvalue.api.Value)1 TokenBackedBasicResultsPage (com.palantir.util.paging.TokenBackedBasicResultsPage)1