首页 > 其他分享 >dremio CommandCreator 简单说明

dremio CommandCreator 简单说明

时间:2022-12-14 19:47:02浏览次数:56  
标签:dremio CommandCreator getExecutionControls queryContext command plan 简单 INJECTOR

CommandCreator 主要是基于不同业务规则进行conmandrunner 的生成,以下是一个简单说明

CommandCreator 的作用

  • 基于request 创建包装的command
  • 包装多种conmandrunner (基于用户请求类型,包装不同的commandrunner)
  • 构建后变任务处理需要的上下文信息(比如sqlConverter,sqlHandlerConfig)

参考类

 

 

CommandRunner 类

参考子类,后边会介绍下,jdbc 以及web 经常会用到HandlerToExec

 

 

调用

实际CommandCreator 的调用是由AttemptManager 的run 方法执行的,同时源头是ForemenWorkManager(和drill 一致)AttemptManager我以前简单介绍过,可以参考

  • run 部分处理
    对于CommandCreator 的依赖处理核心是使用了CommandPool
 
@Override
  public void run() {
    // rename the thread we're using for debugging purposes
    final Thread currentThread = Thread.currentThread();
    final String originalName = currentThread.getName();
    currentThread.setName(queryIdString + ":foreman");
   
    try {
      injector.injectChecked(queryContext.getExecutionControls(), INJECTOR_TRY_BEGINNING_ERROR,
        ForemanException.class);
 
      observer.beginState(AttemptObserver.toEvent(AttemptEvent.State.PENDING));
 
      observer.queryStarted(queryRequest, queryContext.getSession().getCredentials().getUserName());
 
      String ruleSetEngine = ruleBasedEngineSelector.resolveAndUpdateEngine(queryContext);
      ResourceSchedulingProperties resourceSchedulingProperties = new ResourceSchedulingProperties();
      resourceSchedulingProperties.setRoutingEngine(queryContext.getSession().getRoutingEngine());
      resourceSchedulingProperties.setRuleSetEngine(ruleSetEngine);
      final GroupResourceInformation groupResourceInformation =
        maestroService.getGroupResourceInformation(queryContext.getOptions(), resourceSchedulingProperties);
      queryContext.setGroupResourceInformation(groupResourceInformation);
 
      // Checks for Run Query privileges for the selected Engine
      checkRunQueryAccessPrivilege(groupResourceInformation);
 
      // planning is done in the command pool
      commandPool.submit(CommandPool.Priority.LOW, attemptId.toString() + ":foreman-planning",
        (waitInMillis) -> {
          observer.commandPoolWait(waitInMillis);
 
          injector.injectPause(queryContext.getExecutionControls(), INJECTOR_PENDING_PAUSE, logger);
          injector.injectChecked(queryContext.getExecutionControls(), INJECTOR_PENDING_ERROR,
            ForemanException.class);
 
          plan();
          injector.injectPause(queryContext.getExecutionControls(), INJECTOR_PLAN_PAUSE, logger);
          injector.injectChecked(queryContext.getExecutionControls(), INJECTOR_PLAN_ERROR,
            ForemanException.class);
          return null;
        }, runInSameThread).get(); // 等待plan()中的创建成功

plan 方法,会等待实际的CommandRunner plan 执行完成

private void plan() throws Exception {
    // query parsing and dataset retrieval (both from source and kvstore).
    observer.beginState(AttemptObserver.toEvent(AttemptEvent.State.METADATA_RETRIEVAL));
 
    CommandCreator creator = newCommandCreator(queryContext, observer, prepareId);
    command = creator.toCommand();
    logger.debug("Using command: {}.", command);
 
    injector.injectPause(queryContext.getExecutionControls(), INJECTOR_METADATA_RETRIEVAL_PAUSE, logger);
 
    switch (command.getCommandType()) {
      case ASYNC_QUERY:
        Preconditions.checkState(command instanceof AsyncCommand, "Asynchronous query must be an AsyncCommand");
        command.plan();
        break;
 
      case SYNC_QUERY:
      case SYNC_RESPONSE:
        moveToState(QueryState.STARTING, null);
        command.plan();
        extraResultData = command.execute();
        addToEventQueue(QueryState.COMPLETED, null);
        break;
 
      default:
        throw new IllegalStateException(
          String.format("command type %s not supported in plan()", command.getCommandType()));
    }
    profileTracker.setPrepareId(prepareId.value);
  }

参考资料

sabot/kernel/src/main/java/com/dremio/exec/planner/sql/handlers/commands/CommandCreator.java
https://www.cnblogs.com/rongfengliang/p/15987562.html
sabot/kernel/src/main/java/com/dremio/exec/work/foreman/AttemptManager.java

标签:dremio,CommandCreator,getExecutionControls,queryContext,command,plan,简单,INJECTOR
From: https://www.cnblogs.com/rongfengliang/p/16983353.html

相关文章

  • dremio CommandPool简单说明
    CommandPool实际上是一个线程池的处理,官方实现了好几种线程池主要作用限制并行请求以以及job的运行定义优先级任务特点任务基于优先级以及提交时间进行自然排序......
  • spring boot+ nginx 搭建简单的文件服务器,实现上传下载
    项目中用的文件服务的上传和下载访问的问题,由于疫情没有办法接入大的分布式是文件服务器中,自己就动手搭建一个文件服务器来nginx+springboot。实现的主要思路如下:springb......
  • omitjs简单使用
    欢迎关注前端早茶,与广东靓仔携手共同进阶​前端早茶专注前端,一起结伴同行,紧跟业界发展步伐~1、omitjs干什么用的返回一个没有列入排除key属性的对象。其中,参数object为JSON......
  • vuex的使用-简单存储
    在写新项目的时候,用input写了个搜索框,搜索之后获取到点击的数据,要将数据在tab中渲染出来,我思前想后,还是觉得vuex是最好的解决办法,记录一下vuex的基本用法首先是在store文......
  • 简单端口映射、转发、重定向工具之Rinetd
    ◆一、概述Rinetd是为在一个Unix和Linux操作系统中为重定向传输控制协议(TCP)连接的一个工具。将TCP连接从一个IP地址和端口重定向到另一个。它处理文件中/etc/rinetd......
  • 06-Go日志库Zap简单二次封装
    Go日志库Zap简单二次封装1.在项目根目录或者项目其他目录下创建二次封装代码存放目录zaplog,其他目录名称也可以2.新建config.go文件和zaplog文件,文件内容如下:config.g......
  • 正排索引和倒排索引简单介绍
    在搜索引擎中,数据被爬取后,就会建立index,方便检索。  在工作中经常会听到有人问,你这个index是正排的还是倒排的?那么什么是正排呢?什么又是倒排呢?下面是一些简单的介绍。 ......
  • stm32定时器引脚分布,定时器2~7、9~14基本配置,PWM波电机调速简单代码
    使用STM32MIN开发板操作,对电机进行PWM简单调速,使用通用定时器TIM3上,下图为MIN板定时器引脚分布图mian.c#include"delay.h"#include"usart.h"#include"motor.h"intmai......
  • python对m3u8文件的简单处理(一)
    前言:最近一直在看python方面的知识,突然对python对视频如何处理非常感兴趣,于是百度一下,看看网上的方法,根据兴趣,试着从网上下载一个m3u8的实例看看。本实例为个人学习使用,试着......
  • DoWhy - 因果推断 建模入门 简单样例学习与解读
    因为工作原因,需要进行因果推断的分析,在这里进行一个DoWhy工具的简单入门。分析入口:https://github.com/py-why/dowhy/blob/main/docs/source/example_notebooks/dowhy_exa......