Search in sources :

Example 1 with FutureTask

use of org.apache.cassandra.concurrent.FutureTask in project cassandra by apache.

the class Gossiper method runInGossipStageBlocking.

public static void runInGossipStageBlocking(Runnable runnable) {
    // run immediately if we're already in the gossip stage
    if (isInGossipStage()) {
        runnable.run();
        return;
    }
    FutureTask<?> task = new FutureTask<>(runnable);
    Stage.GOSSIP.execute(task);
    try {
        task.get();
    } catch (InterruptedException e) {
        throw new UncheckedInterruptedException(e);
    } catch (ExecutionException e) {
        throw new AssertionError(e);
    }
}
Also used : FutureTask(org.apache.cassandra.concurrent.FutureTask) UncheckedInterruptedException(org.apache.cassandra.utils.concurrent.UncheckedInterruptedException) ExecutionException(java.util.concurrent.ExecutionException) UncheckedInterruptedException(org.apache.cassandra.utils.concurrent.UncheckedInterruptedException)

Example 2 with FutureTask

use of org.apache.cassandra.concurrent.FutureTask in project cassandra by apache.

the class PendingAntiCompaction method run.

public Future<List<Void>> run() {
    List<FutureTask<AcquireResult>> tasks = new ArrayList<>(tables.size());
    for (ColumnFamilyStore cfs : tables) {
        cfs.forceBlockingFlush();
        FutureTask<AcquireResult> task = new FutureTask<>(getAcquisitionCallable(cfs, tokenRanges.ranges(), prsId, acquireRetrySeconds, acquireSleepMillis));
        executor.submit(task);
        tasks.add(task);
    }
    Future<List<AcquireResult>> acquisitionResults = FutureCombiner.successfulOf(tasks);
    return acquisitionResults.flatMap(getAcquisitionCallback(prsId, tokenRanges));
}
Also used : FutureTask(org.apache.cassandra.concurrent.FutureTask) ArrayList(java.util.ArrayList) ColumnFamilyStore(org.apache.cassandra.db.ColumnFamilyStore) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

FutureTask (org.apache.cassandra.concurrent.FutureTask)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)1 UncheckedInterruptedException (org.apache.cassandra.utils.concurrent.UncheckedInterruptedException)1