zoukankan      html  css  js  c++  java
  • CliDriver续

    cliDriver 调用

     processCmd(String cmd) 
    public int processCmd(String cmd) {
    CliSessionState ss = (CliSessionState) SessionState.get();
    ss.setLastCommand(cmd);
    
    ss.updateThreadName();

    在这个方法里

         try {
            CommandProcessor proc = CommandProcessorFactory.get(tokens, (HiveConf) conf);
            ret = processLocalCmd(cmd, proc, ss);
          } catch (SQLException e) {
            console.printError("Failed processing command " + tokens[0] + " " + e.getLocalizedMessage(),
              org.apache.hadoop.util.StringUtils.stringifyException(e));
            ret = 1;
          }

    其中首先看

    CommandProcessor  是什么?

    public static CommandProcessor get(String[] cmd, HiveConf conf)
          throws SQLException {
        CommandProcessor result = getForHiveCommand(cmd, conf);
        if (result != null) {
          return result;
        }
        if (isBlank(cmd[0])) {
          return null;
        } else {
          if (conf == null) {
            return new Driver();
          }
          Driver drv = mapDrivers.get(conf);
    这这里可以判断
    Driver
    if (drv == null) { drv = new Driver(); mapDrivers.put(conf, drv); } else { drv.resetQueryState(); } drv.init(); return drv; } }
    processLocalCmd 这个方法
    首先判断是否是接口是是否 Driver 如果是调用Driver.run

    hive不管CliDirver 所有客户端最终都会调用 Diver.run方法。


      int processLocalCmd(String cmd, CommandProcessor proc, CliSessionState ss) {
        int tryCount = 0;
        boolean needRetry;
        int ret = 0;
    
        do {
          try {
            needRetry = false;
            if (proc != null) {
              if (proc instanceof Driver) {
                Driver qp = (Driver) proc;
                PrintStream out = ss.out;
                long start = System.currentTimeMillis();
                if (ss.getIsVerbose()) {
                  out.println(cmd);
                }
    
                qp.setTryCount(tryCount);
                ret = qp.run(cmd).getResponseCode();
                if (ret != 0) {
                  qp.close();
                  return ret;
                }
     
  • 相关阅读:
    WEBAPI 增加身份验证
    C# Image与Base64编码互转函数
    WebApi 接口传参接参
    Spring.Net依赖注入(属性注入)学习笔记
    ASP.NET MVC5+EF6+EasyUI 后台管理系统(30)-本地化(多语言)
    文件各种上传,离不开的表单
    linux下yum命令出现Loaded plugins: fastestmirror
    linux系统快速安装宝塔
    微信小程序实现watch属性监听数据变化
    chrome调试微信
  • 原文地址:https://www.cnblogs.com/itxuexiwang/p/6292558.html
Copyright © 2011-2022 走看看