Example usage for com.google.common.util.concurrent ThreadFactoryBuilder ThreadFactoryBuilder

List of usage examples for com.google.common.util.concurrent ThreadFactoryBuilder ThreadFactoryBuilder

Introduction

In this page you can find the example usage for com.google.common.util.concurrent ThreadFactoryBuilder ThreadFactoryBuilder.

Prototype

public ThreadFactoryBuilder() 

Source Link

Document

Creates a new ThreadFactory builder.

Usage

From source file:org.apache.pulsar.functions.worker.ClusterServiceCoordinator.java

public ClusterServiceCoordinator(String workerId, MembershipManager membershipManager) {
    this.workerId = workerId;
    this.membershipManager = membershipManager;
    this.executor = Executors.newSingleThreadScheduledExecutor(
            new ThreadFactoryBuilder().setNameFormat("cluster-service-coordinator-timer").build());
}

From source file:com.baidu.cc.ConfigChangedListener.java

/**
 * start listener thread//from  w w w  . java 2  s .  c  o m
 */
public synchronized void start() {
    if (es == null) {
        ThreadFactoryBuilder tfbuilder = new ThreadFactoryBuilder();
        tfbuilder.setNameFormat("ConfigChangedListener-Thread");
        es = Executors.newSingleThreadExecutor(tfbuilder.build());
    }
    stop = false;
    es.execute(this);
}

From source file:net.myrrix.client.async.AsyncRecommenderUpdater.java

/**
 * @param delegate underlying recommender to wrap
 *//* w w w.j a v  a  2 s.c  o m*/
public AsyncRecommenderUpdater(MyrrixRecommender delegate) {
    Preconditions.checkNotNull(delegate);
    this.delegate = delegate;
    this.executor = Executors.newCachedThreadPool(
            new ThreadFactoryBuilder().setNameFormat("AsyncRecommenderUpdater-%s").build());
}

From source file:com.seyren.core.service.live.server.PickleHandlerFactory.java

@PostConstruct
public void initialize() {
    if (seyrenConfig.getGraphiteCarbonPickleEnable()) {
        executor = new ThreadPoolExecutor(2, 8, 500, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(1000),
                new ThreadFactoryBuilder().setNameFormat("seyren.check-live-%s").build());
        executor.prestartCoreThread();/*www  .ja  v a  2s. c o m*/
    } else {
        LOGGER.info("Carbon Pickle Listener disabled.");
    }
}

From source file:com.netflix.astyanax.util.MutationBatchExecutorWithQueue.java

public MutationBatchExecutorWithQueue(AckingQueue queue, int nThreads) {
    this.executor = Executors.newFixedThreadPool(nThreads, new ThreadFactoryBuilder().setDaemon(true).build());
    this.queue = queue;
    this.nThreads = nThreads;
}

From source file:org.locationtech.geogig.rest.AsyncContext.java

private AsyncContext() {
    int nThreads = Math.max(2, Runtime.getRuntime().availableProcessors());
    ThreadFactory threadFactory = new ThreadFactoryBuilder().setDaemon(true)
            .setNameFormat("GeoGIG async tasks-%d").build();
    this.commandExecutor = Executors.newScheduledThreadPool(nThreads, threadFactory);
    this.commandExecutor.scheduleAtFixedRate(new PruneTask(), 0, 10, TimeUnit.MINUTES);
}

From source file:org.graylog.plugins.beats.BeatsTransport.java

private static Executor executorService(final String executorName, final String threadNameFormat,
        final MetricRegistry metricRegistry) {
    final ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat(threadNameFormat).build();
    return new InstrumentedExecutorService(Executors.newCachedThreadPool(threadFactory), metricRegistry,
            name(BeatsTransport.class, executorName, "executor-service"));
}

From source file:org.graylog2.radio.inputs.udp.UDPInput.java

@Override
public void run() {
    this.startedAt = Tools.getUTCTimestamp();

    final ExecutorService workerThreadPool = Executors
            .newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("input-udp-%d").build());

    final ConnectionlessBootstrap bootstrap = new ConnectionlessBootstrap(
            new NioDatagramChannelFactory(workerThreadPool));

    bootstrap.setOption("receiveBufferSizePredictorFactory",
            new FixedReceiveBufferSizePredictorFactory(radio.getConfiguration().getUdpRecvBufferSizes()));
    bootstrap.setPipelineFactory(new UDPPipelineFactory(radio, config));

    try {/*from  ww w .j a v a2  s. co  m*/
        bootstrap.bind(config.getAddress());
    } catch (ChannelException e) {
        LOG.error("Could not bind UDP input {}", config.getAddress(), e);
    }
}

From source file:com.kolich.havalo.io.managers.RepositoryMetaWriter.java

public RepositoryMetaWriter(final MetaStore metaStore, final int poolSize) {
    metaStore_ = metaStore;/*from w ww  .j a va  2  s . c  om*/
    writerPool_ = newFixedThreadPool(poolSize, new ThreadFactoryBuilder().setDaemon(true)
            .setNameFormat("havalo-meta-writer-%s").setPriority(Thread.MAX_PRIORITY).build());
}

From source file:com.google.gerrit.server.project.ProjectCacheWarmer.java

@Override
public void start() {
    int cpus = Runtime.getRuntime().availableProcessors();
    if (config.getBoolean("cache", "projects", "loadOnStartup", false)) {
        ThreadPoolExecutor pool = new ScheduledThreadPoolExecutor(
                config.getInt("cache", "projects", "loadThreads", cpus),
                new ThreadFactoryBuilder().setNameFormat("ProjectCacheLoader-%d").build());
        ExecutorService scheduler = Executors.newFixedThreadPool(1);

        log.info("Loading project cache");
        scheduler.execute(() -> {//from www . j a v a  2s . c om
            for (final Project.NameKey name : cache.all()) {
                pool.execute(() -> {
                    cache.get(name);
                });
            }
            pool.shutdown();
            try {
                pool.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
                log.info("Finished loading project cache");
            } catch (InterruptedException e) {
                log.warn("Interrupted while waiting for project cache to load");
            }
        });
    }
}