use of org.apache.accumulo.core.util.CancelFlagFuture in project accumulo by apache.
the class Gatherer method gather.
public Future<SummaryCollection> gather(ExecutorService es) {
int numFiles;
try {
numFiles = countFiles();
} catch (TableNotFoundException | AccumuloException | AccumuloSecurityException e) {
throw new RuntimeException(e);
}
log.debug("Gathering summaries from {} files", numFiles);
if (numFiles == 0) {
return CompletableFuture.completedFuture(new SummaryCollection());
}
// have each tablet server process ~100K files
int numRequest = Math.max(numFiles / 100_000, 1);
List<CompletableFuture<SummaryCollection>> futures = new ArrayList<>();
AtomicBoolean cancelFlag = new AtomicBoolean(false);
TInfo tinfo = Tracer.traceInfo();
for (int i = 0; i < numRequest; i++) {
futures.add(CompletableFuture.supplyAsync(new GatherRequest(tinfo, i, numRequest, cancelFlag), es));
}
Future<SummaryCollection> future = CompletableFutureUtil.merge(futures, (sc1, sc2) -> SummaryCollection.merge(sc1, sc2, factory), SummaryCollection::new);
return new CancelFlagFuture<>(future, cancelFlag);
}
Aggregations