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) {
}
}
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;
}
Aggregations