Examples of ThreadFactoryBuilder


Examples of com.google.common.util.concurrent.ThreadFactoryBuilder

* after a specified amount of time has elapsed, causing the application to exit.
* @author elandau
*/
public class SelfDestructingTerminationEvent extends BlockingTerminationEvent {
    public SelfDestructingTerminationEvent(final long timeout, final TimeUnit units) {
        Executors.newScheduledThreadPool(1, new ThreadFactoryBuilder().setDaemon(true).build())
            .schedule(new Runnable() {
                @Override
                public void run() {
                    terminate();
                }
View Full Code Here

Examples of com.google.common.util.concurrent.ThreadFactoryBuilder

    this.backupCheckpointDir = backupCheckpointDir;
    this.logDirs = logDirs;
    this.fsyncPerTransaction = fsyncPerTransaction;
    this.fsyncInterval = fsyncInterval;
    logFiles = new AtomicReferenceArray<LogFile.Writer>(this.logDirs.length);
    workerExecutor = Executors.newSingleThreadScheduledExecutor(new
      ThreadFactoryBuilder().setNameFormat("Log-BackgroundWorker-" + name)
        .build());
    workerExecutor.scheduleWithFixedDelay(new BackgroundWorker(this),
        this.checkpointInterval, this.checkpointInterval,
        TimeUnit.MILLISECONDS);
View Full Code Here

Examples of com.google.common.util.concurrent.ThreadFactoryBuilder

              + " probably because the agent stopped while the channel was"
              + " checkpointing.");
    }
    if (shouldBackup) {
      checkpointBackUpExecutor = Executors.newSingleThreadExecutor(
        new ThreadFactoryBuilder().setNameFormat(
          getName() + " - CheckpointBackUpThread").build());
    } else {
      checkpointBackUpExecutor = null;
    }
  }
View Full Code Here

Examples of com.google.common.util.concurrent.ThreadFactoryBuilder

  @Override
  public void start() {
    String timeoutName = "hdfs-" + getName() + "-call-runner-%d";
    callTimeoutPool = Executors.newFixedThreadPool(threadsPoolSize,
            new ThreadFactoryBuilder().setNameFormat(timeoutName).build());

    String rollerName = "hdfs-" + getName() + "-roll-timer-%d";
    timedRollerPool = Executors.newScheduledThreadPool(rollTimerPoolSize,
            new ThreadFactoryBuilder().setNameFormat(rollerName).build());

    this.sfWriters = new WriterLinkedHashMap(maxOpenFiles);
    sinkCounter.start();
    super.start();
  }
View Full Code Here

Examples of com.google.common.util.concurrent.ThreadFactoryBuilder

        return new InstrumentedExecutorService(Executors.newFixedThreadPool(nThreads, threadFactory()), metricRegistry);
    }

    private ThreadFactory threadFactory() {
        return new InstrumentedThreadFactory(
                new ThreadFactoryBuilder().setDaemon(true).setNameFormat("eventbus-handler-%d").build(), metricRegistry);
    }
View Full Code Here

Examples of com.google.common.util.concurrent.ThreadFactoryBuilder

    @Override
    protected void configure() {
        // TODO Add instrumentation to ExecutorService and ThreadFactory
        final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(SCHEDULED_THREADS_POOL_SIZE,
                new ThreadFactoryBuilder()
                        .setNameFormat("scheduled-%d")
                        .setDaemon(false)
                        .setUncaughtExceptionHandler(new Tools.LogUncaughtExceptionHandler(LoggerFactory.getLogger("org.graylog2.scheduler.Scheduler")))
                        .build()
        );

        bind(ScheduledExecutorService.class).annotatedWith(Names.named("scheduler")).toInstance(scheduler);

        // TODO Add instrumentation to ExecutorService and ThreadFactory
        final ScheduledExecutorService daemonScheduler = Executors.newScheduledThreadPool(SCHEDULED_THREADS_POOL_SIZE,
                new ThreadFactoryBuilder()
                        .setNameFormat("scheduled-daemon-%d")
                        .setDaemon(true)
                        .setUncaughtExceptionHandler(new Tools.LogUncaughtExceptionHandler(LoggerFactory.getLogger("org.graylog2.scheduler.DaemonScheduler")))
                        .build()
        );
View Full Code Here

Examples of com.google.common.util.concurrent.ThreadFactoryBuilder

                Executors.newCachedThreadPool(threadFactory(nameFormat, metricRegistry)), metricRegistry);
    }

    private static ThreadFactory threadFactory(final String nameFormat, final MetricRegistry metricRegistry) {
        return new InstrumentedThreadFactory(
                new ThreadFactoryBuilder().setNameFormat(nameFormat).build(), metricRegistry);
    }
View Full Code Here

Examples of com.google.common.util.concurrent.ThreadFactoryBuilder

    private ServerNodesRefreshService(ApiClient api, ServerNodes serverNodes, Node.Factory nodeFactory) {
        this.api = api;
        this.serverNodes = serverNodes;
        this.nodeFactory = nodeFactory;
        executor = Executors.newSingleThreadScheduledExecutor(
                new ThreadFactoryBuilder()
                        .setNameFormat("servernodes-refresh-%d")
                        .setDaemon(true)
                        .build());
    }
View Full Code Here

Examples of com.google.common.util.concurrent.ThreadFactoryBuilder

                Executors.newSingleThreadScheduledExecutor(threadFactory()), metricRegistry);
    }

    private ThreadFactory threadFactory() {
        return new InstrumentedThreadFactory(
                new ThreadFactoryBuilder().setNameFormat("disk-journal-" + getDbFileName() + "-%d").build(),
                metricRegistry);
    }
View Full Code Here

Examples of com.google.common.util.concurrent.ThreadFactoryBuilder

                new LinkedBlockingQueue<Runnable>(), threadFactory(metricRegistry, nameFormat)), metricRegistry);
    }

    private ThreadFactory threadFactory(final MetricRegistry metricRegistry, final String nameFormat) {
        return new InstrumentedThreadFactory(
                new ThreadFactoryBuilder().setNameFormat(nameFormat).build(),
                metricRegistry);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.