当前位置: 首页>>代码示例>>Java>>正文


Java NamedThreadFactory类代码示例

本文整理汇总了Java中org.apache.drill.exec.rpc.NamedThreadFactory的典型用法代码示例。如果您正苦于以下问题:Java NamedThreadFactory类的具体用法?Java NamedThreadFactory怎么用?Java NamedThreadFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NamedThreadFactory类属于org.apache.drill.exec.rpc包,在下文中一共展示了NamedThreadFactory类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: WorkManager

import org.apache.drill.exec.rpc.NamedThreadFactory; //导入依赖的package包/类
public WorkManager(final BootStrapContext context) {
  this.bContext = context;
  bee = new WorkerBee(); // TODO should this just be an interface?
  workBus = new WorkEventBus(); // TODO should this just be an interface?

  /*
   * TODO
   * This executor isn't bounded in any way and could create an arbitrarily large number of
   * threads, possibly choking the machine. We should really put an upper bound on the number of
   * threads that can be created. Ideally, this might be computed based on the number of cores or
   * some similar metric; ThreadPoolExecutor can impose an upper bound, and might be a better choice.
   */
  executor = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(),
      new NamedThreadFactory("WorkManager-")) {
          @Override
          protected void afterExecute(final Runnable r, final Throwable t) {
            if(t != null){
              logger.error("{}.run() leaked an exception.", r.getClass().getName(), t);
            }
            super.afterExecute(r, t);
          }
    };


  // TODO references to this escape here (via WorkerBee) before construction is done
  controlMessageWorker = new ControlMessageHandler(bee); // TODO getFragmentRunner(), getForemanForQueryId()
  userWorker = new UserWorker(bee); // TODO should just be an interface? addNewForeman(), getForemanForQueryId()
  statusThread = new StatusThread();
  dataHandler = new DataResponseHandlerImpl(bee); // TODO only uses startFragmentPendingRemote()
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:31,代码来源:WorkManager.java

示例2: BootStrapContext

import org.apache.drill.exec.rpc.NamedThreadFactory; //导入依赖的package包/类
public BootStrapContext(DrillConfig config, CaseInsensitiveMap<OptionDefinition> definitions,
                        ScanResult classpathScan) throws DrillbitStartupException {
  this.config = config;
  this.definitions = definitions;
  this.classpathScan = classpathScan;
  this.hostName = getCanonicalHostName();
  login(config);
  this.authProvider = new AuthenticatorProviderImpl(config, classpathScan);
  this.loop = TransportCheck.createEventLoopGroup(config.getInt(ExecConstants.BIT_SERVER_RPC_THREADS), "BitServer-");
  this.loop2 = TransportCheck.createEventLoopGroup(config.getInt(ExecConstants.BIT_SERVER_RPC_THREADS), "BitClient-");
  // Note that metrics are stored in a static instance
  this.metrics = DrillMetrics.getRegistry();
  this.allocator = RootAllocatorFactory.newRoot(config);
  this.executor = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS,
      new SynchronousQueue<Runnable>(),
      new NamedThreadFactory("drill-executor-")) {
    @Override
    protected void afterExecute(final Runnable r, final Throwable t) {
      if (t != null) {
        logger.error("{}.run() leaked an exception.", r.getClass().getName(), t);
      }
      super.afterExecute(r, t);
    }
  };
  // Setup two threadpools one for reading raw data from disk and another for decoding the data
  // A good guideline is to have the number threads in the scan pool to be a multiple (fractional
  // numbers are ok) of the number of disks.
  // A good guideline is to have the number threads in the decode pool to be a small multiple (fractional
  // numbers are ok) of the number of cores.
  final int numCores = Runtime.getRuntime().availableProcessors();
  final int numScanThreads = (int) (config.getDouble(ExecConstants.SCAN_THREADPOOL_SIZE));
  final int numScanDecodeThreads = (int) config.getDouble(ExecConstants.SCAN_DECODE_THREADPOOL_SIZE);
  final int scanThreadPoolSize =
      MIN_SCAN_THREADPOOL_SIZE > numScanThreads ? MIN_SCAN_THREADPOOL_SIZE : numScanThreads;
  final int scanDecodeThreadPoolSize =
      (numCores + 1) / 2 > numScanDecodeThreads ? (numCores + 1) / 2 : numScanDecodeThreads;
  this.scanExecutor = Executors.newFixedThreadPool(scanThreadPoolSize, new NamedThreadFactory("scan-"));
  this.scanDecodeExecutor =
      Executors.newFixedThreadPool(scanDecodeThreadPoolSize, new NamedThreadFactory("scan-decode-"));
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:41,代码来源:BootStrapContext.java


注:本文中的org.apache.drill.exec.rpc.NamedThreadFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。