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. postgres 错误duplicate key value violates unique constraint 解决方案

    SELECT setval('tablename_id_seq', (SELECT MAX(id) FROM tablename)+1) 主要是:serial key其实是由sequence实现的,当 ...

  2. 转: 两个 Shell 网站: explainshell 和 shellcheck

    今天向大家介绍两个有意思的 Shell 网站,一个是 explainshell.com,另一个是 shellcheck.net. explainshell 先说 explainshell.explai ...

  3. js判断是否是正整数,js判断是否是数字

    //判断字符串是否为数字 function checkRate(input) { var re = /^[0-9]+.?[0-9]*$/; if (!re.test(input.rate.value) ...

  4. drawRect & layoutSubviews 调用时间

    首先两个方法都是异步执行.layoutSubviews方便数据计算,drawRect方便视图重绘.   layoutSubviews在以下情况下会被调用: 1.init初始化不会触发layoutSub ...

  5. Android 联网监控抓包工具的制作(tcpdump的使用)

    最近做一个Android联网抓包的工具 自己在网上搜索了好久 发现还是没有头绪 于是考虑在linux层上下功夫 于是采用linux的tcpdump来实现了抓包的功能 用简单的话来定义tcpdump,就 ...

  6. DataGridView很详细的用法

    DataGridiew用法总结 一.DataGridView 取得或者修改当前单元格的内容: 当前单元格指的是 DataGridView 焦点所在的单元格,它可以通过 DataGridView 对象的 ...

  7. learn from 德国老师

    最近在跟踪德国来的一个老师学android,感触比较深的一点就是他对细节的理解,一个源代码他可以从第一行解释到最后一行,知道每一行的意思和用法,这可能就是德国人对细节的追求. 刚才想了一下写代码确实应 ...

  8. UVA 11255 Necklace

    带颜色数限制的polya计数. 其实感觉一样了... #include<iostream> #include<cstdio> #include<cstring> # ...

  9. 将Web项目访问的URL项目名设置为"/"

    工具:Eclipse 步骤: 1.鼠标右键项目名--->properties--->Web Project Setting--->Context root. 将Context roo ...

  10. linux下利用curl监控web应用状态

    监控机器列表文件: server.list     建立监控脚本:  webstatus.sh     #!/bin/sh monitor_dir=/home/admin/monitor/ #Log记 ...