dremio CommandPool简单说明

CommandPool 实际上是一个线程池的处理,官方实现了好几种线程池

主要作用

  • 限制并行请求以以及job 的运行
  • 定义优先级任务

特点

  • 任务基于优先级以及提交时间进行自然排序
  • 当线程空闲的是否任务会尽快的执行
  • 在其他任务需要运行的是否,比较忙碌的线程必须先完成
  • CommandPool 的注册是由CommandPoolFactory处理的

实现类

 

 


实际具体实现可以参考不同实现的源码

创建

上边也说了,是由CommandPoolFactory 创建的,参加处理
参考代码

 
public CommandPool newPool(final DremioConfig config, final Tracer tracer) {
    if (config.getBoolean(RELEASABLE_COMMAND_POOL_ENABLED)) {
      final int poolSize = getPoolSize(config);
      logger.info("Starting releasable bound command pool of size {}", poolSize);
      return new ReleasableBoundCommandPool(poolSize, tracer);
    }
 
    if (config.getBoolean(COMMAND_POOL_ENABLED)) {
      final int poolSize = getPoolSize(config);
      logger.info("Starting bound command pool of size {}", poolSize);
      return new BoundCommandPool(poolSize, tracer);
    }
 
    logger.info("Starting unbound command pool");
    // We don't bother decorating the same thread pool.
    // The tracing context doesn't have to move.
    return new SameThreadCommandPool();
  }
 // 实际的cpu 处理器个数
  private int getPoolSize(final DremioConfig config) {
    int poolSize = config.getInt(POOL_SIZE);
    poolSize = poolSize > 0 ? poolSize : VM.availableProcessors() - 1; // make sure we don't use all cores by default
    return Math.max(1, poolSize); // in the unlikely case where the cpu has a single core
  }

说明

CommandPool 在好多任务执行的地方都是需要依赖的,但是主要是AttemptManager 进行操作,由源头ForemenWorkManager 依赖,并传递到依赖的服务中

参考资料

services/command-pool/src/main/java/com/dremio/service/commandpool/CommandPool.java

posted on 2022-12-14 19:34  荣锋亮  阅读(37)  评论(0编辑  收藏  举报

导航