當前位置: 首頁>>代碼示例>>Java>>正文


Java ThreadFactoryBuilder類代碼示例

本文整理匯總了Java中com.google.common.util.concurrent.ThreadFactoryBuilder的典型用法代碼示例。如果您正苦於以下問題:Java ThreadFactoryBuilder類的具體用法?Java ThreadFactoryBuilder怎麽用?Java ThreadFactoryBuilder使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ThreadFactoryBuilder類屬於com.google.common.util.concurrent包,在下文中一共展示了ThreadFactoryBuilder類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ResourceLocalizationService

import com.google.common.util.concurrent.ThreadFactoryBuilder; //導入依賴的package包/類
public ResourceLocalizationService(Dispatcher dispatcher,
    ContainerExecutor exec, DeletionService delService,
    LocalDirsHandlerService dirsHandler, Context context) {

  super(ResourceLocalizationService.class.getName());
  this.exec = exec;
  this.dispatcher = dispatcher;
  this.delService = delService;
  this.dirsHandler = dirsHandler;

  this.cacheCleanup = new ScheduledThreadPoolExecutor(1,
      new ThreadFactoryBuilder()
        .setNameFormat("ResourceLocalizationService Cache Cleanup")
        .build());
  this.stateStore = context.getNMStateStore();
  this.nmContext = context;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:18,代碼來源:ResourceLocalizationService.java

示例2: serviceStart

import com.google.common.util.concurrent.ThreadFactoryBuilder; //導入依賴的package包/類
@Override
protected void serviceStart() throws Exception {
  hsManager.start();
  if (storage instanceof Service) {
    ((Service) storage).start();
  }

  scheduledExecutor = new ScheduledThreadPoolExecutor(2,
      new ThreadFactoryBuilder().setNameFormat("Log Scanner/Cleaner #%d")
          .build());

  scheduledExecutor.scheduleAtFixedRate(new MoveIntermediateToDoneRunnable(),
      moveThreadInterval, moveThreadInterval, TimeUnit.MILLISECONDS);

  // Start historyCleaner
  scheduleHistoryCleaner();
  super.serviceStart();
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:19,代碼來源:JobHistory.java

示例3: serviceInit

import com.google.common.util.concurrent.ThreadFactoryBuilder; //導入依賴的package包/類
/**
 * The in-memory store bootstraps itself from the shared cache entries that
 * exist in HDFS.
 */
@Override
protected void serviceInit(Configuration conf) throws Exception {

  this.startTime = System.currentTimeMillis();
  this.initialDelayMin = getInitialDelay(conf);
  this.checkPeriodMin = getCheckPeriod(conf);
  this.stalenessMinutes = getStalenessPeriod(conf);

  bootstrap(conf);

  ThreadFactory tf =
      new ThreadFactoryBuilder().setNameFormat("InMemorySCMStore")
          .build();
  scheduler = Executors.newSingleThreadScheduledExecutor(tf);

  super.serviceInit(conf);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:22,代碼來源:InMemorySCMStore.java

示例4: PeerConnectionTester

import com.google.common.util.concurrent.ThreadFactoryBuilder; //導入依賴的package包/類
@Autowired
public PeerConnectionTester(final SystemProperties config) {
    this.config = config;
    ConnectThreads = config.peerDiscoveryWorkers();
    ReconnectPeriod = config.peerDiscoveryTouchPeriod() * 1000;
    ReconnectMaxPeers = config.peerDiscoveryTouchMaxNodes();
    peerConnectionPool = new ThreadPoolExecutor(ConnectThreads,
            ConnectThreads, 0L, TimeUnit.SECONDS,
            new MutablePriorityQueue<Runnable, ConnectTask>(new Comparator<ConnectTask>() {
                @Override
                public int compare(ConnectTask h1, ConnectTask h2) {
                    return h2.nodeHandler.getNodeStatistics().getReputation() -
                            h1.nodeHandler.getNodeStatistics().getReputation();
                }
            }), new ThreadFactoryBuilder().setDaemon(true).setNameFormat("discovery-tester-%d").build());
}
 
開發者ID:Aptoide,項目名稱:AppCoins-ethereumj,代碼行數:17,代碼來源:PeerConnectionTester.java

示例5: doStart

import com.google.common.util.concurrent.ThreadFactoryBuilder; //導入依賴的package包/類
@Override
protected void doStart() {
    if (config.isEnable()) {
        this.scheduler = Executors.newSingleThreadScheduledExecutor(
                new ThreadFactoryBuilder()
                        .setDaemon(true)
                        .setNameFormat("memory-reporter-thread")
                        .setUncaughtExceptionHandler((t, e) ->
                                log.error("Problem in memory reporter", e))
                        .build());

        this.scheduledJob = this.scheduler.scheduleAtFixedRate(() -> {
            reportGC();
            reportMemoryPool();
            reportMemoryUsage();
        }, config.getInterval(), config.getInterval(), TimeUnit.MILLISECONDS);
    }

    notifyStarted();
}
 
開發者ID:DevOpsStudio,項目名稱:Re-Collector,代碼行數:21,代碼來源:MemoryReporterService.java

示例6: ChunkReaderScheduler

import com.google.common.util.concurrent.ThreadFactoryBuilder; //導入依賴的package包/類
public ChunkReaderScheduler(final Input input,
                            final ArrayBlockingQueue<FileChunk> chunkQueue,
                            final int readerBufferSize,
                            final long readerInterval,
                            final FileInput.InitialReadPosition initialReadPosition) {
    this.input = input;
    this.chunkQueue = chunkQueue;
    this.readerBufferSize = readerBufferSize;
    this.readerInterval = readerInterval;
    this.initialReadPosition = initialReadPosition;

    // TODO Make the thread size configurable.
    this.scheduler = Executors.newSingleThreadScheduledExecutor(
            new ThreadFactoryBuilder()
                    .setDaemon(false)
                    .setNameFormat("chunkreader-scheduler-thread-" + input.getId() + "-%d")
                    .build());
}
 
開發者ID:DevOpsStudio,項目名稱:Re-Collector,代碼行數:19,代碼來源:ChunkReaderScheduler.java

示例7: KMSAudit

import com.google.common.util.concurrent.ThreadFactoryBuilder; //導入依賴的package包/類
/**
 * Create a new KMSAudit.
 *
 * @param windowMs Duplicate events within the aggregation window are quashed
 *                 to reduce log traffic. A single message for aggregated
 *                 events is printed at the end of the window, along with a
 *                 count of the number of aggregated events.
 */
KMSAudit(long windowMs) {
  cache = CacheBuilder.newBuilder()
      .expireAfterWrite(windowMs, TimeUnit.MILLISECONDS)
      .removalListener(
          new RemovalListener<String, AuditEvent>() {
            @Override
            public void onRemoval(
                RemovalNotification<String, AuditEvent> entry) {
              AuditEvent event = entry.getValue();
              if (event.getAccessCount().get() > 0) {
                KMSAudit.this.logEvent(event);
                event.getAccessCount().set(0);
                KMSAudit.this.cache.put(entry.getKey(), event);
              }
            }
          }).build();
  executor = Executors.newScheduledThreadPool(1, new ThreadFactoryBuilder()
      .setDaemon(true).setNameFormat(KMS_LOGGER_NAME + "_thread").build());
  executor.scheduleAtFixedRate(new Runnable() {
    @Override
    public void run() {
      cache.cleanUp();
    }
  }, windowMs / 10, windowMs / 10, TimeUnit.MILLISECONDS);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:34,代碼來源:KMSAudit.java

示例8: RENAudit

import com.google.common.util.concurrent.ThreadFactoryBuilder; //導入依賴的package包/類
/**
 * Create a new KMSAudit.
 *
 * @param windowMs Duplicate events within the aggregation window are quashed
 *                 to reduce log traffic. A single message for aggregated
 *                 events is printed at the end of the window, along with a
 *                 count of the number of aggregated events.
 */
RENAudit(long windowMs) {
  cache = CacheBuilder.newBuilder()
      .expireAfterWrite(windowMs, TimeUnit.MILLISECONDS)
      .removalListener(
          new RemovalListener<String, AuditEvent>() {
            @Override
            public void onRemoval(
                RemovalNotification<String, AuditEvent> entry) {
              AuditEvent event = entry.getValue();
              if (event.getAccessCount().get() > 0) {
                RENAudit.this.logEvent(event);
                event.getAccessCount().set(0);
                RENAudit.this.cache.put(entry.getKey(), event);
              }
            }
          }).build();
  executor = Executors.newScheduledThreadPool(1, new ThreadFactoryBuilder()
      .setDaemon(true).setNameFormat(REN_LOGGER_NAME + "_thread").build());
  executor.scheduleAtFixedRate(new Runnable() {
    @Override
    public void run() {
      cache.cleanUp();
    }
  }, windowMs / 10, windowMs / 10, TimeUnit.MILLISECONDS);
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:34,代碼來源:RENAudit.java

示例9: LocatedFileStatusFetcher

import com.google.common.util.concurrent.ThreadFactoryBuilder; //導入依賴的package包/類
/**
 * @param conf configuration for the job
 * @param dirs the initial list of paths
 * @param recursive whether to traverse the patchs recursively
 * @param inputFilter inputFilter to apply to the resulting paths
 * @param newApi whether using the mapred or mapreduce API
 * @throws InterruptedException
 * @throws IOException
 */
public LocatedFileStatusFetcher(Configuration conf, Path[] dirs,
    boolean recursive, PathFilter inputFilter, boolean newApi) throws InterruptedException,
    IOException {
  int numThreads = conf.getInt(FileInputFormat.LIST_STATUS_NUM_THREADS,
      FileInputFormat.DEFAULT_LIST_STATUS_NUM_THREADS);
  rawExec = Executors.newFixedThreadPool(
      numThreads,
      new ThreadFactoryBuilder().setDaemon(true)
          .setNameFormat("GetFileInfo #%d").build());
  exec = MoreExecutors.listeningDecorator(rawExec);
  resultQueue = new LinkedBlockingQueue<List<FileStatus>>();
  this.conf = conf;
  this.inputDirs = dirs;
  this.recursive = recursive;
  this.inputFilter = inputFilter;
  this.newApi = newApi;
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:27,代碼來源:LocatedFileStatusFetcher.java

示例10: MessagingEngine

import com.google.common.util.concurrent.ThreadFactoryBuilder; //導入依賴的package包/類
MessagingEngine(DataSource dataSource) throws BrokerException {
    DaoFactory daoFactory = new DaoFactory(dataSource);
    QueueDao queueDao = daoFactory.createQueueDao();
    ExchangeDao exchangeDao = daoFactory.createExchangeDao();
    BindingDao bindingDao = daoFactory.createBindingDao();
    MessageDao messageDao = daoFactory.createMessageDao();
    exchangeRegistry = new ExchangeRegistry(exchangeDao, bindingDao);
    // TODO: get the buffer sizes from configs
    sharedMessageStore = new SharedMessageStore(messageDao, 32768, 1024);
    queueRegistry = new QueueRegistry(queueDao, sharedMessageStore);
    exchangeRegistry.retrieveFromStore(queueRegistry);

    ThreadFactory threadFactory = new ThreadFactoryBuilder()
            .setNameFormat("MessageDeliveryTaskThreadPool-%d").build();
    deliveryTaskService = new TaskExecutorService<>(WORKER_COUNT, IDLE_TASK_DELAY_MILLIS, threadFactory);
    messageIdGenerator = new MessageIdGenerator();

    initDefaultDeadLetterQueue();
}
 
開發者ID:wso2,項目名稱:message-broker,代碼行數:20,代碼來源:MessagingEngine.java

示例11: serviceInit

import com.google.common.util.concurrent.ThreadFactoryBuilder; //導入依賴的package包/類
@Override
protected void serviceInit(Configuration conf) throws Exception {
  enabled = conf.getBoolean(YarnConfiguration.SHARED_CACHE_ENABLED,
      YarnConfiguration.DEFAULT_SHARED_CACHE_ENABLED);
  if (enabled) {
    int threadCount =
        conf.getInt(YarnConfiguration.SHARED_CACHE_NM_UPLOADER_THREAD_COUNT,
            YarnConfiguration.DEFAULT_SHARED_CACHE_NM_UPLOADER_THREAD_COUNT);
    uploaderPool = Executors.newFixedThreadPool(threadCount,
        new ThreadFactoryBuilder().
          setNameFormat("Shared cache uploader #%d").
          build());
    scmClient = createSCMClient(conf);
    try {
      fs = FileSystem.get(conf);
      localFs = FileSystem.getLocal(conf);
    } catch (IOException e) {
      LOG.error("Unexpected exception in getting the filesystem", e);
      throw new RuntimeException(e);
    }
  }
  super.serviceInit(conf);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:24,代碼來源:SharedCacheUploadService.java

示例12: TBoundedThreadPoolServer

import com.google.common.util.concurrent.ThreadFactoryBuilder; //導入依賴的package包/類
public TBoundedThreadPoolServer(Args options, ThriftMetrics metrics) {
  super(options);

  if (options.maxQueuedRequests > 0) {
    this.callQueue = new CallQueue(
        new LinkedBlockingQueue<Call>(options.maxQueuedRequests), metrics);
  } else {
    this.callQueue = new CallQueue(new SynchronousQueue<Call>(), metrics);
  }

  ThreadFactoryBuilder tfb = new ThreadFactoryBuilder();
  tfb.setDaemon(true);
  tfb.setNameFormat("thrift-worker-%d");
  executorService =
      new ThreadPoolExecutor(options.minWorkerThreads,
          options.maxWorkerThreads, options.threadKeepAliveTimeSec,
          TimeUnit.SECONDS, this.callQueue, tfb.build());
  serverOptions = options;
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:20,代碼來源:TBoundedThreadPoolServer.java

示例13: DbleServer

import com.google.common.util.concurrent.ThreadFactoryBuilder; //導入依賴的package包/類
private DbleServer() {
    this.config = new ServerConfig();
    scheduler = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder().setNameFormat("TimerScheduler-%d").build());

    /*
     * | offline | Change Server status to OFF |
     * | online | Change Server status to ON |
     */
    this.isOnline = new AtomicBoolean(true);


    // load data node active index from properties
    dnIndexProperties = DnPropertyUtil.loadDnIndexProps();

    this.startupTime = TimeUtil.currentTimeMillis();
    if (isUseZkSwitch()) {
        dnIndexLock = new InterProcessMutex(ZKUtils.getConnection(), KVPathUtil.getDnIndexLockPath());
    }
    xaSessionCheck = new XASessionCheck();
}
 
開發者ID:actiontech,項目名稱:dble,代碼行數:21,代碼來源:DbleServer.java

示例14: serviceInit

import com.google.common.util.concurrent.ThreadFactoryBuilder; //導入依賴的package包/類
@Override
protected void serviceInit(Configuration conf) throws Exception {
  ThreadFactory tf = new ThreadFactoryBuilder()
    .setNameFormat("DeletionService #%d")
    .build();
  if (conf != null) {
    sched = new DelServiceSchedThreadPoolExecutor(
        conf.getInt(YarnConfiguration.NM_DELETE_THREAD_COUNT,
        YarnConfiguration.DEFAULT_NM_DELETE_THREAD_COUNT), tf);
    debugDelay = conf.getInt(YarnConfiguration.DEBUG_NM_DELETE_DELAY_SEC, 0);
  } else {
    sched = new DelServiceSchedThreadPoolExecutor(
        YarnConfiguration.DEFAULT_NM_DELETE_THREAD_COUNT, tf);
  }
  sched.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
  sched.setKeepAliveTime(60L, SECONDS);
  if (stateStore.canRecover()) {
    recover(stateStore.loadDeletionServiceState());
  }
  super.serviceInit(conf);
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:22,代碼來源:DeletionService.java

示例15: HTableMultiplexer

import com.google.common.util.concurrent.ThreadFactoryBuilder; //導入依賴的package包/類
/**
 * @param conn The HBase connection.
 * @param conf The HBase configuration
 * @param perRegionServerBufferQueueSize determines the max number of the buffered Put ops for
 *          each region server before dropping the request.
 */
public HTableMultiplexer(Connection conn, Configuration conf,
    int perRegionServerBufferQueueSize) {
  this.conn = (ClusterConnection) conn;
  this.pool = HTable.getDefaultExecutor(conf);
  this.retryNum = conf.getInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER,
      HConstants.DEFAULT_HBASE_CLIENT_RETRIES_NUMBER);
  this.perRegionServerBufferQueueSize = perRegionServerBufferQueueSize;
  this.maxKeyValueSize = HTable.getMaxKeyValueSize(conf);
  this.flushPeriod = conf.getLong(TABLE_MULTIPLEXER_FLUSH_PERIOD_MS, 100);
  int initThreads = conf.getInt(TABLE_MULTIPLEXER_INIT_THREADS, 10);
  this.executor =
      Executors.newScheduledThreadPool(initThreads,
        new ThreadFactoryBuilder().setDaemon(true).setNameFormat("HTableFlushWorker-%d").build());

  this.workerConf = HBaseConfiguration.create(conf);
  // We do not do the retry because we need to reassign puts to different queues if regions are
  // moved.
  this.workerConf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 0);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:26,代碼來源:HTableMultiplexer.java


注:本文中的com.google.common.util.concurrent.ThreadFactoryBuilder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。