Impalaソース分析---1
5720 ワード
2、Impalaソース分析
参照リンク:http://www.sizeofvoid.net/wp-content/uploads/ImpalaIntroduction2.pdf
本章はソース分析段階に入り、参考リンクは非常に良いimpala実装、実行プロセス紹介のドキュメントであり、著者に感謝します.
2.1 Impala内部アーキテクチャ
Impalaの内部アーキテクチャ図は次のとおりです.
図2-1 Impala内部アーキテクチャ
図から分かるように、Impalaの3つの部分:client、Impalad、StateStoreの関係.
コンポーネント
説明
Client
図には、クエリをコミットし、Impaladの21000ポートに接続するThriftクライアントの3つが表示されます.
Impalad
3つのThrift Server(beeswax-server、hs 2-server、be-server)を含むfrontEndとbackEndの2つのセクションがあります.
StateStore
各impaladは登録され、各impaladにクラスタ内の他のノードの状態が更新されます.
次の表に、Impaladコンポーネントの各ポートについて説明します.
ツールバーの
値
説明
Impaladコンポーネントポート
Impalaバックグラウンドプログラムバックエンドポートbe_port
22000デフォルト
ImpalaBackendServiceがエクスポートしたポート.
Impala Daemon Beeswaxポートbeeswax_port
21000デフォルト
Impala Daemonは、サービスに使用されるポートの提供をBeeswaxクライアントに要求する.
Impala Daemon HiveServer 2ポートhs 2_port
21050デフォルト
Impala Daemonは、HiveServer 2クライアントにサービス提供に使用するポートを要求する.
StateStoreSubscriberサービスポートstate_store_subscriber_port
23000デフォルト
StateStoreSubscriberServiceが実行するポート.
StateStoreコンポーネントポート
StateStoreサービスポートstate_store_port
24000デフォルト
StateStoreServiceがエクスポートしたポート.
StateStore HTTPサーバーポートwebserver_port
25010デフォルト
StateStoreは、Webサーバが実行するポートをデバッグします.
ここでbeeswax_port=2000はBeeswaxクライアントにサービスを提供するためのポートであり、例えば図中のHueクライアント、JDBC、Impala-shellの3種類のclientがこのポートを使用する.hs2_port=2150は、HiveServer 2クライアントにサービスを提供するためのものです.be_port=2200は、内部の他のImpaladプロセスと対話するためのポートです.state_store_subscriber_port=2300は、StateStatedプロセスに自己登録とステータス更新用のポートである.StateStoreコンポーネントの24000ポートは、Impaladの23000ポートとインタラクティブに使用されています.他のポートはあまり重要ではありません.紹介しません.
全体のコードファイル構造は以下の通りです.
2.2 Impaladコード分析
2.2.1 Impalad-main.cc
続きます...
参照リンク:http://www.sizeofvoid.net/wp-content/uploads/ImpalaIntroduction2.pdf
本章はソース分析段階に入り、参考リンクは非常に良いimpala実装、実行プロセス紹介のドキュメントであり、著者に感謝します.
2.1 Impala内部アーキテクチャ
Impalaの内部アーキテクチャ図は次のとおりです.
図2-1 Impala内部アーキテクチャ
図から分かるように、Impalaの3つの部分:client、Impalad、StateStoreの関係.
コンポーネント
説明
Client
図には、クエリをコミットし、Impaladの21000ポートに接続するThriftクライアントの3つが表示されます.
Impalad
3つのThrift Server(beeswax-server、hs 2-server、be-server)を含むfrontEndとbackEndの2つのセクションがあります.
StateStore
各impaladは登録され、各impaladにクラスタ内の他のノードの状態が更新されます.
次の表に、Impaladコンポーネントの各ポートについて説明します.
ツールバーの
値
説明
Impaladコンポーネントポート
Impalaバックグラウンドプログラムバックエンドポートbe_port
22000デフォルト
ImpalaBackendServiceがエクスポートしたポート.
Impala Daemon Beeswaxポートbeeswax_port
21000デフォルト
Impala Daemonは、サービスに使用されるポートの提供をBeeswaxクライアントに要求する.
Impala Daemon HiveServer 2ポートhs 2_port
21050デフォルト
Impala Daemonは、HiveServer 2クライアントにサービス提供に使用するポートを要求する.
StateStoreSubscriberサービスポートstate_store_subscriber_port
23000デフォルト
StateStoreSubscriberServiceが実行するポート.
StateStoreコンポーネントポート
StateStoreサービスポートstate_store_port
24000デフォルト
StateStoreServiceがエクスポートしたポート.
StateStore HTTPサーバーポートwebserver_port
25010デフォルト
StateStoreは、Webサーバが実行するポートをデバッグします.
ここでbeeswax_port=2000はBeeswaxクライアントにサービスを提供するためのポートであり、例えば図中のHueクライアント、JDBC、Impala-shellの3種類のclientがこのポートを使用する.hs2_port=2150は、HiveServer 2クライアントにサービスを提供するためのものです.be_port=2200は、内部の他のImpaladプロセスと対話するためのポートです.state_store_subscriber_port=2300は、StateStatedプロセスに自己登録とステータス更新用のポートである.StateStoreコンポーネントの24000ポートは、Impaladの23000ポートとインタラクティブに使用されています.他のポートはあまり重要ではありません.紹介しません.
全体のコードファイル構造は以下の通りです.
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
20 #include
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 }
続きます...