Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impalad-main.cc
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 //
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"
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 #include "common/names.h"
44 
45 using namespace impala;
46 
47 DECLARE_string(classpath);
48 DECLARE_bool(use_statestore);
49 DECLARE_int32(beeswax_port);
50 DECLARE_int32(hs2_port);
51 DECLARE_int32(be_port);
52 DECLARE_string(principal);
53 
54 int main(int argc, char** argv) {
55  InitCommonRuntime(argc, argv, true);
56 
62  InitFeSupport();
63 
64  // start backend service for the coordinator on be_port
65  ExecEnv exec_env;
66  StartThreadInstrumentation(exec_env.metrics(), exec_env.webserver());
67  InitRpcEventTracing(exec_env.webserver());
68 
69  ThriftServer* beeswax_server = NULL;
70  ThriftServer* hs2_server = NULL;
71  ThriftServer* be_server = NULL;
72  ImpalaServer* server = NULL;
73  EXIT_IF_ERROR(CreateImpalaServer(&exec_env, FLAGS_beeswax_port, FLAGS_hs2_port,
74  FLAGS_be_port, &beeswax_server, &hs2_server, &be_server, &server));
75 
76  EXIT_IF_ERROR(be_server->Start());
77 
78  Status status = exec_env.StartServices();
79  if (!status.ok()) {
80  LOG(ERROR) << "Impalad services did not start correctly, exiting. Error: "
81  << status.GetDetail();
83  exit(1);
84  }
85 
86  // this blocks until the beeswax and hs2 servers terminate
87  EXIT_IF_ERROR(beeswax_server->Start());
88  EXIT_IF_ERROR(hs2_server->Start());
89  ImpaladMetrics::IMPALA_SERVER_READY->set_value(true);
90  LOG(INFO) << "Impala has started.";
91  beeswax_server->Join();
92  hs2_server->Join();
93 
94  delete be_server;
95  delete beeswax_server;
96  delete hs2_server;
97 }
void ShutdownLogging()
Definition: logging.cc:146
const std::string GetDetail() const
Definition: status.cc:184
int main(int argc, char **argv)
Definition: impalad-main.cc:54
void InitFeSupport()
Definition: fe-support.cc:346
void InitCommonRuntime(int argc, char **argv, bool init_jvm, TestInfo::Mode m=TestInfo::NON_TEST)
Definition: init.cc:122
Webserver * webserver()
Definition: exec-env.h:84
void Join()
Blocks until the server stops and exits its main thread.
DECLARE_int32(beeswax_port)
static void InitLibhdfs()
Call this prior to any libhdfs calls.
Definition: jni-util.cc:140
Status StartThreadInstrumentation(MetricGroup *metrics, Webserver *webserver)
Definition: thread.cc:266
MetricGroup * metrics()
Definition: exec-env.h:85
DECLARE_bool(use_statestore)
void InitRpcEventTracing(Webserver *webserver)
Initialises rpc event tracing, must be called before any RpcEventHandlers are created.
Definition: rpc-trace.cc:67
static Status InitJNI()
Grab all of the Java classes needed to get data into and out of HBase.
#define EXIT_IF_ERROR(stmt)
Definition: status.h:248
virtual Status StartServices()
Starts any dependent services in their correct order.
Definition: exec-env.cc:282
static BooleanProperty * IMPALA_SERVER_READY
Status CreateImpalaServer(ExecEnv *exec_env, int beeswax_port, int hs2_port, int be_port, ThriftServer **beeswax_server, ThriftServer **hs2_server, ThriftServer **be_server, ImpalaServer **impala_server)
static void InitializeLlvm(bool load_backend=false)
Definition: llvm-codegen.cc:78
DECLARE_string(classpath)