2、Impala源代码分析

參考链接:http://www.sizeofvoid.net/wp-content/uploads/ImpalaIntroduction2.pdf

本章開始进入源代码分析阶段,參考链接是一篇很好的impala实现、执行流程介绍的文档,感谢作者。

2.1 Impala内部架构

Impala内部架构图例如以下:

图2-1 Impala内部架构

从图中能够看出,Impala三个部分:client、Impalad、StateStore的关系。

组件

说明

Client

图中能够看到有三种,是Thriftclient,用来提交查询,连接到Impalad的21000port

Impalad

有frontEnd和backEnd两部分,包含三个Thrift Server(beeswax-server、hs2-server、be-server)

StateStore

各个impalad向其注冊,然后它向各个impalad更新集群中其它节点的状态

以下介绍一下Impalad组件的各个port,例如以下表:

属性

说明

 

Impalad组件port

Impala 后台程序后端port 

be_port

22000

默认值

ImpalaBackendService 导出的port。

Impala Daemon Beeswax port 

beeswax_port

21000

默认值

Impala Daemon 向 Beeswaxclient请求提供服务所使用的port。

Impala Daemon HiveServer2 port 

hs2_port

21050

默认值

Impala Daemon 向 HiveServer2client请求提供服务所使用的port。

StateStoreSubscriber 服务port 

state_store_subscriber_port

23000

默认值

StateStoreSubscriberService 执行的port。

StateStore组件port

StateStore 服务port 

state_store_port

24000

默认值

StateStoreService 导出的port。

StateStore HTTP serverport 

webserver_port

25010

默认值

StateStore 调试站点server执行的port。

当中beeswax_port=21000是用来给Beeswaxclient提供服务的port,比方图中的Hueclient、JDBC、Impala-shell三种client都会使用这个port;hs2_port=21050是用来给HiveServer2client提供服务的;be_port=22000是用来与内部的其它Impalad进程交互的port;state_store_subscriber_port=23000是用来向StateStated进程注冊自己和更新状态用的port;而StateStore组件里的24000port正是用来与Impalad的23000port进行交互的,其它port不太重要,不做介绍。

总体的代码文件结构例如以下:

2.2 Impalad代码分析

2.2.1 Impalad-main.cc


   16 // This file contains the main() function for the impala daemon process,
17 // which exports the Thrift services ImpalaService and ImpalaInternalService.
18
19 #include <unistd.h>
20 #include <jni.h>
21
22 #include "common/logging.h"
23 #include "common/init.h"
24 #include "exec/hbase-table-scanner.h"
25 #include "exec/hbase-table-writer.h"
26 #include "runtime/hbase-table-factory.h"
27 #include "codegen/llvm-codegen.h"
28 #include "common/status.h"
29 #include "runtime/coordinator.h"
30 #include "runtime/exec-env.h"
31 #include "util/jni-util.h"
32 #include "util/network-util.h"
33 #include "rpc/thrift-util.h"
34 #include "rpc/thrift-server.h"
35 #include "rpc/rpc-trace.h"
36 #include "service/impala-server.h"
37 #include "service/fe-support.h"
38 #include "gen-cpp/ImpalaService.h"
39 #include "gen-cpp/ImpalaInternalService.h"
40 #include "util/impalad-metrics.h"
41 #include "util/thread.h"
42
43 using namespace impala;
44 using namespace std;
45
46 DECLARE_string(classpath);
47 DECLARE_bool(use_statestore);
48 DECLARE_int32(beeswax_port);
49 DECLARE_int32(hs2_port);
50 DECLARE_int32(be_port);
51 DECLARE_string(principal);
52
53 int main(int argc, char** argv) {
54 InitCommonRuntime(argc, argv, true); //參数解析,开启日志,基于Google gflags和glog
55
56 LlvmCodeGen::InitializeLlvm();
57 JniUtil::InitLibhdfs(); //初始化JNI,由于Fe部分是java开发的
58 EXIT_IF_ERROR(HBaseTableScanner::Init());
59 EXIT_IF_ERROR(HBaseTableFactory::Init());
60 EXIT_IF_ERROR(HBaseTableWriter::InitJNI());
61 InitFeSupport();
62
63 // start backend service for the coordinator on be_port
64 ExecEnv exec_env; //ExecEnv是query/paln-fragment的运行环境
65 StartThreadInstrumentation(exec_env.metrics(), exec_env.webserver());
66 InitRpcEventTracing(exec_env.webserver());
67
68 ThriftServer* beeswax_server = NULL;
69 ThriftServer* hs2_server = NULL;
70 ThriftServer* be_server = NULL; //这是三个ThriftServer,原来服务client和其它impalad backend
71 ImpalaServer* server = NULL; //此server将上面三个ThriftServer包装起来对外提供服务
72 EXIT_IF_ERROR(CreateImpalaServer(&exec_env, FLAGS_beeswax_port, FLAGS_hs2_port,
73 FLAGS_be_port, &beeswax_server, &hs2_server, &be_server, &server)); //创建ImpalaServer
74
75 EXIT_IF_ERROR(be_server->Start()); //启动be_server
76
77 Status status = exec_env.StartServices(); //启动service,包含statestore_subscriber (用来向statestod进程注冊)
78 if (!status.ok()) {
79 LOG(ERROR) << "Impalad services did not start correctly, exiting. Error: "
80 << status.GetErrorMsg();
81 ShutdownLogging();
82 exit(1);
83 }
84
85 // this blocks until the beeswax and hs2 servers terminate
86 EXIT_IF_ERROR(beeswax_server->Start());
87 EXIT_IF_ERROR(hs2_server->Start());
88 ImpaladMetrics::IMPALA_SERVER_READY->Update(true);
89 LOG(INFO) << "Impala has started.";
90 beeswax_server->Join(); //堵塞等待beeswax-server退出才运行后面的语句
91 hs2_server->Join(); //堵塞等待hs2-server退出才继续运行后面语句
92
93 delete be_server;
94 delete beeswax_server;
95 delete hs2_server;
96 }

待续。。。


Impala源代码分析---1的更多相关文章

  1. android-plugmgr源代码分析

    android-plugmgr是一个Android插件加载框架,它最大的特点就是对插件不需要进行任何约束.关于这个类库的介绍见作者博客,市面上也有一些插件加载框架,但是感觉没有这个好.在这篇文章中,我 ...

  2. Twitter Storm源代码分析之ZooKeeper中的目录结构

    徐明明博客:Twitter Storm源代码分析之ZooKeeper中的目录结构 我们知道Twitter Storm的所有的状态信息都是保存在Zookeeper里面,nimbus通过在zookeepe ...

  3. 转:SDL2源代码分析

    1:初始化(SDL_Init()) SDL简介 有关SDL的简介在<最简单的视音频播放示例7:SDL2播放RGB/YUV>以及<最简单的视音频播放示例9:SDL2播放PCM>中 ...

  4. 转:RTMPDump源代码分析

    0: 主要函数调用分析 rtmpdump 是一个用来处理 RTMP 流媒体的开源工具包,支持 rtmp://, rtmpt://, rtmpe://, rtmpte://, and rtmps://. ...

  5. 转:ffdshow 源代码分析

    ffdshow神奇的功能:视频播放时显示运动矢量和QP FFDShow可以称得上是全能的解码.编码器.最初FFDShow只是mpeg视频解码器,不过现在他能做到的远不止于此.它能够解码的视频格式已经远 ...

  6. UiAutomator源代码分析之UiAutomatorBridge框架

    上一篇文章<UIAutomator源代码分析之启动和执行>我们描写叙述了uitautomator从命令行执行到载入測试用例执行測试的整个流程.过程中我们也描写叙述了UiAutomatorB ...

  7. MyBatis架构设计及源代码分析系列(一):MyBatis架构

    如果不太熟悉MyBatis使用的请先参见MyBatis官方文档,这对理解其架构设计和源码分析有很大好处. 一.概述 MyBatis并不是一个完整的ORM框架,其官方首页是这么介绍自己 The MyBa ...

  8. hostapd源代码分析(三):管理帧的收发和处理

    hostapd源代码分析(三):管理帧的收发和处理 原文链接:http://blog.csdn.net/qq_21949217/article/details/46004379 这篇文章我来讲解一下h ...

  9. hostapd源代码分析(二):hostapd的工作机制

    [转]hostapd源代码分析(二):hostapd的工作机制 原文链接:http://blog.csdn.net/qq_21949217/article/details/46004433 在我的上一 ...

随机推荐

  1. MysqL的root用户不允许远程连接

    原文:MysqL的root用户不允许远程连接 今天程序报了异常:java.sql.SQLException: Access denied for user 'root'@'RJB-Z' (using ...

  2. Java TCP/UDP网络通信编程

    本文转自:http://www.cnblogs.com/cdtarena/archive/2013/04/10/3012282.html 网络应用中基本上都是TCP(Transmission Cont ...

  3. ruby 删除文件夹(包括文件夹中的文件夹和文件)

    def deleteDirectory(dirPath) if File.directory?(dirPath) puts "是文件夹"; Dir.foreach(dirPath) ...

  4. 使用Inno Setup 打包jdk、mysql、tomcat、webapp等为一个exe安装包(转)

    之前一直都没涉及到打包安装方面的东西,都是另一个同事负责的,使用的工具(installshield)也比较高大上一点,可是后来他离职以后接受的同事也只能是在这个基础上做个简单的配置,然后打包,可是现在 ...

  5. mount命令使用具体解释(Linux)

    linux是一个优秀的开放源代码的操作系统,能够执行在大到巨型小到掌上型各类计算机系统上,随着 linux系统的日渐成熟和稳定以及它开放源代码特有的优越性,linux在全世界得到了越来越广泛的应用. ...

  6. Oracle 数据库 JOB 失败后解密法重试

    因为官方文档上没有找到相关的说明,所以这里进行了例如以下測试,为了找到oracle数据库中 job 失败后重试时间的规律. 数据库版本号:11.2.0.3 測试说明:这里创建了一个日志表以及一个执行时 ...

  7. Sql示例说明如何分组后求中间值--【叶子】

    原文:Sql示例说明如何分组后求中间值--[叶子] 这里所谓的分组后求中间值是个什么概念呢? 我举个例子来说明一下: 假设我们现在有下面这样一个表: type        name price -- ...

  8. BI—脚不一样的感觉

    在这个网络智能的时代,假设生活和智能挂不上边那就太落后啦!尤其IT行业更是如此,前不久还在用微软的office做报表,这几天就吵吵着换成BI,那么BI是什么?有什么用?怎么用?等等带着这一系列的问题来 ...

  9. Spark1.0.0 学习路径

          2014-05-30 Spark1.0.0 Relaease 经过11次RC后最终公布.尽管还有不少bug,还是非常令人振奋. 作为一个骨灰级的老IT,经过非常成一段时间的消沉,再次被点燃 ...

  10. WAP页面点击与hover延迟解决之道

    最近一直在WAP端页面的开发,一直都知道wap端点击相关问题存在延迟.之前做的网页大部分使用a链接进行,一直未入此坑. 最近做的一个WAP网站,各种点击,hover事件,如果使用PC端网页的做法,直接 ...