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:com.palantir.atlasdb.keyvalue.cassandra.jmx.CassandraJmxCompaction.java

public static Optional<CassandraJmxCompactionManager> createJmxCompactionManager(
        CassandraKeyValueServiceConfigManager configManager) {
    Preconditions.checkNotNull(configManager);
    CassandraKeyValueServiceConfig config = configManager.getConfig();
    CassandraJmxCompaction jmxCompaction = new CassandraJmxCompaction(config);

    Optional<CassandraJmxCompactionConfig> jmxConfig = config.jmx();
    // need to set the property before creating the JMX compaction client
    if (!jmxConfig.isPresent()) {
        log.info("Jmx compaction is not enabled.");
        return Optional.absent();
    }/*  ww  w .  j a  v a 2  s  .  c  o m*/

    jmxCompaction.setJmxSslProperty(jmxConfig.get());
    ImmutableSet<CassandraJmxCompactionClient> clients = jmxCompaction.createCompactionClients(jmxConfig.get());
    ExecutorService exec = Executors.newFixedThreadPool(clients.size(),
            new ThreadFactoryBuilder().setNameFormat("Cassandra-Jmx-Compaction-ThreadPool-%d").build());

    return Optional.of(CassandraJmxCompactionManager.create(clients, exec));
}

From source file:org.apache.hadoop.security.ssl.KeyManagersReloaderThreadPool.java

private KeyManagersReloaderThreadPool(boolean isForTesting) {
    this.isForTesting = isForTesting;
    scheduledTasks = new CopyOnWriteArrayList<>();
    scheduler = Executors.newScheduledThreadPool(THREAD_POOL_SIZE, new ThreadFactoryBuilder().setDaemon(true)
            .setNameFormat("Client certificate reloader Thread #%d").build());

    ShutdownHookManager.get().addShutdownHook(new ShutdownHook(), 5);
}

From source file:io.joynr.runtime.ClusterControllerRuntimeModule.java

@Override
protected void configure() {
    super.configure();
    install(new DiscoveryClientModule());
    install(new NoBackendMessagingModule());
    bind(RoutingProvider.class).to(RoutingProviderImpl.class);

    bind(PlatformSecurityManager.class).to(DummyPlatformSecurityManager.class);
    bind(Address.class).annotatedWith(Names.named(GLOBAL_ADDRESS)).toProvider(GlobalAddressProvider.class);

    ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
            .setNameFormat("joynr.scheduler.capabilities.freshness-%d").build();
    ScheduledExecutorService capabilitiesFreshnessUpdateExecutor = Executors
            .newSingleThreadScheduledExecutor(namedThreadFactory);
    bind(ScheduledExecutorService.class)
            .annotatedWith(Names.named(LocalCapabilitiesDirectory.JOYNR_SCHEDULER_CAPABILITIES_FRESHNESS))
            .toInstance(capabilitiesFreshnessUpdateExecutor);
}

From source file:azkaban.dag.DagService.java

@Inject
public DagService(final ExecutorServiceUtils executorServiceUtils) {
    // Give the thread a name to make debugging easier.
    this.executorServiceUtils = executorServiceUtils;
    final ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("Dag-service").build();
    this.executorService = Executors.newSingleThreadExecutor(namedThreadFactory);
}

From source file:de.craftolution.craftoplugin4.services.task.TaskThreadFactory.java

TaskThreadFactory() {
    this.innerFactory = new ThreadFactoryBuilder().setNameFormat("TaskService-Thread-%d")
            .setUncaughtExceptionHandler(this).setDaemon(true).build();
}

From source file:org.sonar.server.computation.taskprocessor.CeProcessingSchedulerExecutorServiceImpl.java

public CeProcessingSchedulerExecutorServiceImpl(CeConfiguration ceConfiguration) {
    super(MoreExecutors.listeningDecorator(
            Executors.newScheduledThreadPool(ceConfiguration.getWorkerCount(), new ThreadFactoryBuilder()
                    .setNameFormat(THREAD_NAME_PREFIX + "%d").setPriority(Thread.MIN_PRIORITY).build())));
}

From source file:co.paralleluniverse.fibers.FiberExecutorScheduler.java

/**
 * Creates a new fiber scheduler.//w  w  w .j  av a 2  s .  c o  m
 *
 * @param name         the scheuler's name. This name is used in naming the scheduler's threads.
 * @param executor     an {@link Executor} used to schedule the fibers;
 *                     may be {@code null} if the {@link #execute(Runnable)} method is overriden.
 * @param monitorType  the {@link MonitorType} type to use for the scheduler.
 * @param detailedInfo whether detailed information about the fibers is collected by the fibers monitor.
 */
public FiberExecutorScheduler(String name, Executor executor, MonitorType monitorType, boolean detailedInfo) {
    super(name, monitorType, detailedInfo);
    this.executor = executor;
    this.timer = new FiberTimedScheduler(this, new ThreadFactoryBuilder().setDaemon(true)
            .setNameFormat("FiberTimedScheduler-" + getName()).build(), getMonitor());
}

From source file:com.proofpoint.zookeeper.crossprocess.LeadershipNominatorImp.java

/**
 *
 * @param lockFactory zookeeper instance
 * @param groupName name of the leadership group. There will be one leader per group
 * @throws Exception errors//from w w  w .  jav a 2  s  . c  om
 */
public LeadershipNominatorImp(CrossProcessLockFactory lockFactory, String groupName) throws Exception {
    this.notifier = new AtomicReference<LeadershipNominatorNotifier>(null);
    this.groupName = groupName;

    lock = lockFactory.newLock(groupName);

    ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat("LeadershipNominator")
            // TODO: .setUncaughtExceptionHandler()
            .build();

    executor = Executors.newSingleThreadExecutor(factory);
}

From source file:org.eclipse.rdf4j.http.client.SharedHttpClientSessionManager.java

public SharedHttpClientSessionManager() {
    this.executor = Executors
            .newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("rdf4j-sesameclientimpl-%d").build());
}

From source file:qa.qcri.nadeef.core.pipeline.ViolationDetector.java

/**
 * Violation detector constructor./*from w ww  . j a  v a 2s . c  om*/
 */
public ViolationDetector(ExecutionContext context) {
    super(context);
    resultCollection = Lists.newArrayList();
    ThreadFactory factory = new ThreadFactoryBuilder().setNameFormat("detect-pool-%d").build();
    service = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(MAX_THREAD_NUM, factory));
}