Search in sources :

Example 6 with ExecutorPlus

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

the class PendingAntiCompactionTest method antiCompactionException.

/**
 * Makes sure that PendingAntiCompaction fails when anticompaction throws exception
 */
@Test
public void antiCompactionException() {
    cfs.disableAutoCompaction();
    makeSSTables(2);
    UUID prsid = UUID.randomUUID();
    ExecutorPlus es = ImmediateExecutor.INSTANCE;
    PendingAntiCompaction pac = new PendingAntiCompaction(prsid, Collections.singleton(cfs), atEndpoint(FULL_RANGE, NO_RANGES), es, () -> false) {

        @Override
        protected AcquisitionCallback getAcquisitionCallback(UUID prsId, RangesAtEndpoint tokenRanges) {
            return new AcquisitionCallback(prsid, tokenRanges, () -> false) {

                @Override
                Future submitPendingAntiCompaction(AcquireResult result) {
                    Runnable r = new WrappedRunnable() {

                        protected void runMayThrow() {
                            throw new CompactionInterruptedException("antiCompactionExceptionTest");
                        }
                    };
                    return es.submit(r);
                }
            };
        }
    };
    ListenableFuture<?> fut = pac.run();
    try {
        fut.get();
        fail("Should throw exception");
    } catch (Throwable t) {
    }
}
Also used : RangesAtEndpoint(org.apache.cassandra.locator.RangesAtEndpoint) WrappedRunnable(org.apache.cassandra.utils.WrappedRunnable) ExecutorPlus(org.apache.cassandra.concurrent.ExecutorPlus) WrappedRunnable(org.apache.cassandra.utils.WrappedRunnable) CompactionInterruptedException(org.apache.cassandra.db.compaction.CompactionInterruptedException) UUID(java.util.UUID) AbstractPendingRepairTest(org.apache.cassandra.db.compaction.AbstractPendingRepairTest) Test(org.junit.Test)

Example 7 with ExecutorPlus

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

the class SSTableReader method openAll.

public static Collection<SSTableReader> openAll(Set<Map.Entry<Descriptor, Set<Component>>> entries, final TableMetadataRef metadata) {
    final Collection<SSTableReader> sstables = newBlockingQueue();
    ExecutorPlus executor = executorFactory().pooled("SSTableBatchOpen", FBUtilities.getAvailableProcessors());
    try {
        for (final Map.Entry<Descriptor, Set<Component>> entry : entries) {
            Runnable runnable = new Runnable() {

                public void run() {
                    SSTableReader sstable;
                    try {
                        sstable = open(entry.getKey(), entry.getValue(), metadata);
                    } catch (CorruptSSTableException ex) {
                        JVMStabilityInspector.inspectThrowable(ex);
                        logger.error("Corrupt sstable {}; skipping table", entry, ex);
                        return;
                    } catch (FSError ex) {
                        JVMStabilityInspector.inspectThrowable(ex);
                        logger.error("Cannot read sstable {}; file system error, skipping table", entry, ex);
                        return;
                    }
                    sstables.add(sstable);
                }
            };
            executor.submit(runnable);
        }
    } finally {
        executor.shutdown();
    }
    try {
        executor.awaitTermination(7, TimeUnit.DAYS);
    } catch (InterruptedException e) {
        throw new UncheckedInterruptedException(e);
    }
    return sstables;
}
Also used : FSError(org.apache.cassandra.io.FSError) ExecutorPlus(org.apache.cassandra.concurrent.ExecutorPlus) ScheduledExecutorPlus(org.apache.cassandra.concurrent.ScheduledExecutorPlus) DatabaseDescriptor(org.apache.cassandra.config.DatabaseDescriptor)

Aggregations

ExecutorPlus (org.apache.cassandra.concurrent.ExecutorPlus)7 Test (org.junit.Test)4 AbstractPendingRepairTest (org.apache.cassandra.db.compaction.AbstractPendingRepairTest)3 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 ColumnFamilyStore (org.apache.cassandra.db.ColumnFamilyStore)2 CompactionInfo (org.apache.cassandra.db.compaction.CompactionInfo)2 SSTableReader (org.apache.cassandra.io.sstable.format.SSTableReader)2 Future (org.apache.cassandra.utils.concurrent.Future)2 UUID (java.util.UUID)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ScheduledExecutorPlus (org.apache.cassandra.concurrent.ScheduledExecutorPlus)1 DatabaseDescriptor (org.apache.cassandra.config.DatabaseDescriptor)1 CompactionInterruptedException (org.apache.cassandra.db.compaction.CompactionInterruptedException)1 FSError (org.apache.cassandra.io.FSError)1 RangesAtEndpoint (org.apache.cassandra.locator.RangesAtEndpoint)1 WrappedRunnable (org.apache.cassandra.utils.WrappedRunnable)1