664行 CliDriver main启动

public static void main(String[] args) throws Exception {
int ret = new CliDriver().run(args);
System.exit(ret);
}

646行

public int run(String[] args) throws Exception {

OptionsProcessor oproc = new OptionsProcessor();
if (!oproc.process_stage1(args)) {
return 1;
}

OptionsProcessor oproc = new OptionsProcessor();

OptionsProcessor 初始化  所有options

解析 options  args
if (!oproc.process_stage1(args)) {

在new CliDriver()

  public CliDriver() {
SessionState ss = SessionState.get();
conf = (ss != null) ? ss.getConf() : new Configuration();
Logger LOG = LoggerFactory.getLogger("CliDriver");
if (LOG.isDebugEnabled()) {
LOG.debug("CliDriver inited with classpath {}", System.getProperty("java.class.path"));
}
console = new LogHelper(LOG);
}
SessionState.get();
看 SessionState.get
public static SessionState get() {
return tss.get().state;
}

tss.是threadlocal  ,threadlocal我想大家都知道,解决多线程共享问题。 threadlocal 包装了一个hashmap 其中key 是this 当前线程。

  private static ThreadLocal<SessionStates> tss = new ThreadLocal<SessionStates>() {
@Override
protected SessionStates initialValue() {
return new SessionStates();
}
};
重新 initialValue 当值不存在 new 一个

看看SessionStates
  private static class SessionStates {
private SessionState state;
private HiveConf conf;
private void attach(SessionState state) {
this.state = state;
attach(state.getConf());
}
private void attach(HiveConf conf) {
this.conf = conf; ClassLoader classLoader = conf.getClassLoader();
if (classLoader != null) {
Thread.currentThread().setContextClassLoader(classLoader);
}
}
}

看到

SessionStates 大家明白了
SessionStates 包含两部分
HiveConf 
SessionState 
看看
SessionState 代码
private static final Logger LOG = LoggerFactory.getLogger(SessionState.class);

  private static final String TMP_PREFIX = "_tmp_space.db";
private static final String LOCAL_SESSION_PATH_KEY = "_hive.local.session.path";
private static final String HDFS_SESSION_PATH_KEY = "_hive.hdfs.session.path";
private static final String TMP_TABLE_SPACE_KEY = "_hive.tmp_table_space";
static final String LOCK_FILE_NAME = "inuse.lck";
static final String INFO_FILE_NAME = "inuse.info"; private final Map<String, Map<String, Table>> tempTables = new HashMap<String, Map<String, Table>>();
private final Map<String, Map<String, ColumnStatisticsObj>> tempTableColStats =
new HashMap<String, Map<String, ColumnStatisticsObj>>(); protected ClassLoader parentLoader; // Session-scope compile lock.
private final ReentrantLock compileLock = new ReentrantLock(); /**
* current configuration.
*/
private final HiveConf sessionConf; /**
* silent mode.
*/
protected boolean isSilent; /**
* verbose mode
*/
protected boolean isVerbose; /**
* The flag to indicate if the session serves the queries from HiveServer2 or not.
*/
private boolean isHiveServerQuery = false; /**
* The flag to indicate if the session using thrift jdbc binary serde or not.
*/
private boolean isUsingThriftJDBCBinarySerDe = false; /**
* The flag to indicate if the session already started so we can skip the init
*/
private boolean isStarted = false;
/*
* HiveHistory Object
*/
protected HiveHistory hiveHist; /**
* Streams to read/write from.
*/
public InputStream in;
public PrintStream out;
public PrintStream info;
public PrintStream err;

上面部分代码 可以看出部分命令行的

的值。

 
 

hive CliDriver 源码分析的更多相关文章

  1. YARN DistributedShell源码分析与修改

    YARN DistributedShell源码分析与修改 YARN版本:2.6.0 转载请注明出处:http://www.cnblogs.com/BYRans/ 1 概述 2 YARN Distrib ...

  2. 《深入理解Spark:核心思想与源码分析》(前言及第1章)

    自己牺牲了7个月的周末和下班空闲时间,通过研究Spark源码和原理,总结整理的<深入理解Spark:核心思想与源码分析>一书现在已经正式出版上市,目前亚马逊.京东.当当.天猫等网站均有销售 ...

  3. 《深入理解Spark:核心思想与源码分析》(第2章)

    <深入理解Spark:核心思想与源码分析>一书前言的内容请看链接<深入理解SPARK:核心思想与源码分析>一书正式出版上市 <深入理解Spark:核心思想与源码分析> ...

  4. 《深入理解Spark:核心思想与源码分析》一书正式出版上市

    自己牺牲了7个月的周末和下班空闲时间,通过研究Spark源码和原理,总结整理的<深入理解Spark:核心思想与源码分析>一书现在已经正式出版上市,目前亚马逊.京东.当当.天猫等网站均有销售 ...

  5. 《深入理解Spark:核心思想与源码分析》正式出版上市

    自己牺牲了7个月的周末和下班空闲时间,通过研究Spark源码和原理,总结整理的<深入理解Spark:核心思想与源码分析>一书现在已经正式出版上市,目前亚马逊.京东.当当.天猫等网站均有销售 ...

  6. Hadoop RCFile存储格式详解(源码分析、代码示例)

    RCFile   RCFile全称Record Columnar File,列式记录文件,是一种类似于SequenceFile的键值对(Key/Value Pairs)数据文件.   关键词:Reco ...

  7. Hadoop之HDFS原理及文件上传下载源码分析(下)

    上篇Hadoop之HDFS原理及文件上传下载源码分析(上)楼主主要介绍了hdfs原理及FileSystem的初始化源码解析, Client如何与NameNode建立RPC通信.本篇将继续介绍hdfs文 ...

  8. SparkThriftServer 源码分析

    目录 版本 起点 客户端--Beeline 服务端 Hive-jdbc TCLIService.Iface客户端请求 流程 SparkThrift 主函数HiveThriftServer2 Thrif ...

  9. 第十篇:Spark SQL 源码分析之 In-Memory Columnar Storage源码分析之 query

    /** Spark SQL源码分析系列文章*/ 前面讲到了Spark SQL In-Memory Columnar Storage的存储结构是基于列存储的. 那么基于以上存储结构,我们查询cache在 ...

随机推荐

  1. zf-关于注册码全部错误的解决方法

    之所以错误,是因为这里的用户名称是石首市政务服务中心. 在数据库里把这个字段改成 上海卓繁 就可以了 一般都是在 SYS_INFO 这张表里面改

  2. 我也谈javascript正则匹配

    一.javascript 正则全局匹配 g 慎用test()方法 来个例子: var a = /^[a-z]+/gi; a.test('bb123'); //true a.lastIndex ; // ...

  3. 网络通信TCP编程实例代码

    Makefile: all: gcc -o server server.c -lpthread gcc -o client client.c clean: rm server client serve ...

  4. <meta http-equiv="refresh" content="0; url=">

    原文:http://www.cnblogs.com/net2/archive/2010/11/29/1890874.html 页面定期刷新,如果加url的,则会重新定向到指定的网页,content后面 ...

  5. c语言基本数据类型short、int、long、char、float、double

    C 语言包含的数据类型如下图所示: 一.数据类型与“模子”short.int.long.char.float.double 这六个关键字代表C 语言里的六种基本数据类型. 怎么去理解它们呢? 举个例子 ...

  6. 搭建git服务器及利用git hook自动布署代码

    注意:服务器:Ubuntu Server 14.04,我的项目比较小,所有操作都使用root,建议最好新建一个用户(需要有管理员权限,否则在后面使用hooks自动部署代码时会出现各种权限问题,很蛋疼的 ...

  7. 设计 无状态的类,而不是 stateful

    0down votefavorite   I have created a Database Abstraction Layer over PDO to refrain from creating m ...

  8. MySQL查询in操作 查询结果按in集合顺序显示_Mysql_脚本之家

    body { font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI ...

  9. CollapsingToolbarLayout学习笔记

    CollapsingToolbarLayout包裹 Toolbar 的时候提供一个可折叠的 Toolbar,一般作为AppbarLayout的子视图使用. <?xml version=" ...

  10. utf8_unicode_ci与utf8_general_ci

    下面摘录一下Mysql 5.1中文手册中关于utf8_unicode_ci与utf8_general_ci的说明: 当前,utf8_unicode_ci校对规则仅部分支持Unicode校对规则算法.一 ...