Search in sources :

Example 1 with ThreadFactoryBuilder

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);
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) MetricsManager(com.datastax.oss.dsbulk.workflow.commons.metrics.MetricsManager) ThreadFactoryBuilder(com.datastax.oss.driver.shaded.guava.common.util.concurrent.ThreadFactoryBuilder)

Example 2 with ThreadFactoryBuilder

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");
        }
    }
}
Also used : ExecutorService(java.util.concurrent.ExecutorService) ThreadFactoryBuilder(com.datastax.oss.driver.shaded.guava.common.util.concurrent.ThreadFactoryBuilder) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 3 with ThreadFactoryBuilder

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);
}
Also used : ThreadFactory(java.util.concurrent.ThreadFactory) ThreadFactoryBuilder(com.datastax.oss.driver.shaded.guava.common.util.concurrent.ThreadFactoryBuilder) DefaultEventLoopGroup(io.netty.channel.DefaultEventLoopGroup)

Aggregations

ThreadFactoryBuilder (com.datastax.oss.driver.shaded.guava.common.util.concurrent.ThreadFactoryBuilder)3 ThreadFactory (java.util.concurrent.ThreadFactory)2 MetricsManager (com.datastax.oss.dsbulk.workflow.commons.metrics.MetricsManager)1 DefaultEventLoopGroup (io.netty.channel.DefaultEventLoopGroup)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)1 Test (org.junit.Test)1