Package com.google.common.util.concurrent

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


        installTransport(mapBinder, "syslog-tcp", SyslogTcpTransport.class);

        // TODO Add instrumentation to ExecutorService and ThreadFactory
        bind(Executor.class)
                .annotatedWith(Names.named("bossPool"))
                .toInstance(Executors.newCachedThreadPool(new ThreadFactoryBuilder()
                                                                  .setNameFormat("transport-boss-%d")
                                                                  .build()));

        // TODO Add instrumentation to ExecutorService and ThreadFactory
        bind(Executor.class)
View Full Code Here


  /**
   * Start the asynchronous packet sender.
   */
  public synchronized void initializeScheduler() {
    if (asynchronousSender == null) {
      ThreadFactory factory = new ThreadFactoryBuilder().
        setDaemon(true).
        setNameFormat("ProtocolLib-AsyncSender %s").
        build();
      asynchronousSender = Executors.newSingleThreadExecutor(factory);
    }
View Full Code Here

   * Uses the default {@link #THREAD_FORMAT} to name worker threads.
   * @param loader - class loader from Bukkit.
   * @param reporter - current error reporter.
   */
  public BackgroundCompiler(ClassLoader loader, ErrorReporter reporter) {
    ThreadFactory factory = new ThreadFactoryBuilder().
      setDaemon(true).
      setNameFormat(THREAD_FORMAT).
      build();
    initializeCompiler(loader, reporter, Executors.newSingleThreadExecutor(factory));
  }
View Full Code Here

  @Singleton
  protected RobotConnection provideRobotConnection() {
    HttpClient httpClient = new HttpClient(new MultiThreadedHttpConnectionManager());

    ThreadFactory threadFactory =
        new ThreadFactoryBuilder().setNameFormat("RobotConnection").build();
    return new HttpRobotConnection(
        httpClient, Executors.newFixedThreadPool(NUMBER_OF_THREADS, threadFactory));
  }
View Full Code Here

  @Provides
  @Singleton
  @Named("GatewayExecutor")
  protected Executor provideGatewayExecutor() {
    ThreadFactory threadFactory =
        new ThreadFactoryBuilder().setNameFormat("PassiveRobotRunner").build();
    return Executors.newFixedThreadPool(NUMBER_OF_THREADS, threadFactory);
  }
View Full Code Here

  private Executor provideThreadPoolExecutor(Provider<RequestScopeExecutor> executorProvider,
      int threadCount, String name) {
    if (threadCount == 0) {
      return MoreExecutors.sameThreadExecutor();
    }
    ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat(name).build();
    ExecutorService executor;
    if (threadCount < 0) {
      executor = Executors.newCachedThreadPool(threadFactory);
    } else if (threadCount == 1) {
      executor = Executors.newSingleThreadExecutor(threadFactory);
View Full Code Here

    return scopeExecutor;
  }

  private ScheduledExecutorService provideScheduledThreadPoolExecutor(
      Provider<ScheduledRequestScopeExecutor> executorProvider, int threadCount, String name) {
    ThreadFactory threadFactory = new ThreadFactoryBuilder().setNameFormat(name).build();
    ScheduledExecutorService executor;
    if (threadCount == 1) {
      executor = Executors.newSingleThreadScheduledExecutor(threadFactory);
    } else {
      executor = Executors.newScheduledThreadPool(threadCount, threadFactory);
View Full Code Here

        // - failures are logged
        // - when storage queue is full, we throttle backwards to the serialization threadpool
        // - when serialization queue is full, we abort execution for new entries
        // - fetching uses a synchronous queue and therefore is a blocking operation, with a timeout

        ThreadFactory storageThreadFactory = new ThreadFactoryBuilder().setNameFormat("Checkpointing-storage-%d")
                .setUncaughtExceptionHandler(new UncaughtExceptionLogger("storage")).build();
        storageThreadPool = new ThreadPoolExecutor(1, storageMaxThreads, storageThreadKeepAliveSeconds,
                TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(storageMaxOutstandingRequests),
                storageThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy());
        storageThreadPool.allowCoreThreadTimeOut(true);

        ThreadFactory serializationThreadFactory = new ThreadFactoryBuilder()
                .setNameFormat("Checkpointing-serialization-%d")
                .setUncaughtExceptionHandler(new UncaughtExceptionLogger("serialization")).build();
        serializationThreadPool = new ThreadPoolExecutor(1, serializationMaxThreads,
                serializationThreadKeepAliveSeconds, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(
                        serializationMaxOutstandingRequests), serializationThreadFactory,
                new ThreadPoolExecutor.AbortPolicy());
        serializationThreadPool.allowCoreThreadTimeOut(true);

        ThreadFactory fetchingThreadFactory = new ThreadFactoryBuilder().setNameFormat("Checkpointing-fetching-%d")
                .setUncaughtExceptionHandler(new UncaughtExceptionLogger("fetching")).build();
        fetchingThreadPool = new ThreadPoolExecutor(0, fetchingMaxThreads, fetchingThreadKeepAliveSeconds,
                TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(fetchingQueueSize), fetchingThreadFactory);
        fetchingThreadPool.allowCoreThreadTimeOut(true);
View Full Code Here

        if (interval == 0) {
            return this;
        }

        ThreadFactory threadFactory = new ThreadFactoryBuilder().setDaemon(true)
                .setUncaughtExceptionHandler(new UncaughtExceptionHandler() {

                    @Override
                    public void uncaughtException(Thread t, Throwable e) {
                        logger.error("Expection from timer thread", e);
View Full Code Here

            logger.debug("Started timer for PE prototype [{}], ID [{}] with interval [{}].", new String[] {
                    this.getClass().getName(), id, String.valueOf(timerIntervalInMilliseconds) });
        }

        if (checkpointingConfig.mode == CheckpointingMode.TIME) {
            ThreadFactory threadFactory = new ThreadFactoryBuilder().setDaemon(true)
                    .setUncaughtExceptionHandler(new UncaughtExceptionHandler() {

                        @Override
                        public void uncaughtException(Thread t, Throwable e) {
                            logger.error("Expection from checkpointing thread", e);
View Full Code Here

TOP

Related Classes of com.google.common.util.concurrent.ThreadFactoryBuilder

Copyright © 2018 www.massapicom. 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.