当前位置: 首页>>代码示例>>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;未经允许,请勿转载。