use of com.datastax.oss.driver.shaded.guava.common.util.concurrent.ThreadFactoryBuilder in project dsbulk by datastax.
the class MonitoringSettings method newMetricsManager.
public MetricsManager newMetricsManager(boolean monitorWrites, boolean batchingEnabled, Path operationDirectory, Verbosity verbosity, ProtocolVersion protocolVersion, CodecRegistry codecRegistry, RowType rowType) {
ThreadFactory threadFactory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat("reporter-%d").setPriority(Thread.MIN_PRIORITY).build();
ScheduledThreadPoolExecutor scheduler = new ScheduledThreadPoolExecutor(1, threadFactory);
return new MetricsManager(registry, monitorWrites, executionId, scheduler, rateUnit, durationUnit, expectedWrites, expectedReads, trackBytes, jmx, csv, console, prometheus, operationDirectory, verbosity, reportRate, batchingEnabled, protocolVersion, codecRegistry, rowType);
}
use of com.datastax.oss.driver.shaded.guava.common.util.concurrent.ThreadFactoryBuilder in project java-driver by datastax.
the class CycleDetectorTest method should_detect_cycle_between_different_threads.
@Test
public void should_detect_cycle_between_different_threads() throws Throwable {
CycleDetector checker = new CycleDetector("Detected cycle", true);
CyclicContext context = new CyclicContext(checker, true);
ExecutorService executor = Executors.newFixedThreadPool(3, new ThreadFactoryBuilder().setNameFormat("thread%d").build());
Future<String> futureA = executor.submit(() -> context.a.get());
Future<String> futureB = executor.submit(() -> context.b.get());
Future<String> futureC = executor.submit(() -> context.c.get());
context.latchA.countDown();
context.latchB.countDown();
context.latchC.countDown();
for (Future<String> future : ImmutableList.of(futureA, futureB, futureC)) {
try {
Uninterruptibles.getUninterruptibly(future);
} catch (ExecutionException e) {
assertThat(e.getCause()).isInstanceOf(IllegalStateException.class).hasMessageContaining("Detected cycle");
}
}
}
use of com.datastax.oss.driver.shaded.guava.common.util.concurrent.ThreadFactoryBuilder in project stargate by stargate.
the class QueryTracingFetcher method createExecutor.
private static ScheduledExecutorService createExecutor() {
ThreadFactory safeFactory = new BlockingOperation.SafeThreadFactory();
ThreadFactory adminThreadFactory = new ThreadFactoryBuilder().setThreadFactory(safeFactory).setNameFormat("Query-tracing-fetcher-%d").setDaemon(false).build();
return new DefaultEventLoopGroup(2, adminThreadFactory);
}
Aggregations