Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mini-impala-cluster.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 // A standalone test utility that starts multiple Impala backends and a state store
17 // within a single process.
18 
19 #include <boost/foreach.hpp>
20 
21 #include "codegen/llvm-codegen.h"
22 #include "common/logging.h"
23 #include "common/init.h"
26 #include "rpc/authentication.h"
27 #include "rpc/thrift-util.h"
28 #include "rpc/thrift-server.h"
29 #include "service/fe-support.h"
30 #include "service/impala-server.h"
31 #include "util/jni-util.h"
33 
34 DEFINE_int32(num_backends, 3, "The number of backends to start");
35 DECLARE_int32(be_port);
36 DECLARE_int32(beeswax_port);
37 DECLARE_int32(hs2_port);
38 DECLARE_string(principal);
39 DECLARE_bool(use_statestore);
40 
41 #include "common/names.h"
42 
43 using namespace impala;
44 
45 int main(int argc, char** argv) {
46  InitCommonRuntime(argc, argv, true);
47  if (FLAGS_num_backends <= 0) {
48  LOG(ERROR) << "-num_backends arg must be > 0";
49  exit(1);
50  }
51 
57  InitFeSupport();
58 
59  int base_be_port = FLAGS_be_port;
60  int base_subscriber_port = 21500;
61  int base_webserver_port = 25000;
62 
63  int beeswax_port = 21000;
64  int hs2_port = 21050;
65 
66  scoped_ptr<InProcessStatestore> statestore(new InProcessStatestore(23000, 25100));
67  if (FLAGS_use_statestore) EXIT_IF_ERROR(statestore->Start());
68  LOG(INFO) << "Started in-process statestore";
69 
70  vector<InProcessImpalaServer*> impala_servers;
71  for (int i = 0; i < FLAGS_num_backends; ++i) {
72  impala_servers.push_back(
73  new InProcessImpalaServer(FLAGS_hostname, base_be_port + i,
74  base_subscriber_port + i, base_webserver_port + i,
75  FLAGS_hostname, 23000));
76  // First server in the list runs client servers
77  if (i == 0) {
78  EXIT_IF_ERROR(impala_servers[i]->StartWithClientServers(beeswax_port, hs2_port,
79  FLAGS_use_statestore));
80  } else {
81  EXIT_IF_ERROR(impala_servers[i]->StartAsBackendOnly(FLAGS_use_statestore));
82  }
83  }
84 
85  impala_servers[0]->Join();
86 
87  BOOST_FOREACH(InProcessImpalaServer* server, impala_servers) {
88  delete server;
89  }
90 }
DECLARE_string(principal)
An in-process statestore, with webserver and metrics.
void InitFeSupport()
Definition: fe-support.cc:346
DECLARE_bool(use_statestore)
int main(int argc, char **argv)
DEFINE_int32(num_backends, 3,"The number of backends to start")
void InitCommonRuntime(int argc, char **argv, bool init_jvm, TestInfo::Mode m=TestInfo::NON_TEST)
Definition: init.cc:122
static void InitLibhdfs()
Call this prior to any libhdfs calls.
Definition: jni-util.cc:140
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
static void InitializeLlvm(bool load_backend=false)
Definition: llvm-codegen.cc:78
DECLARE_int32(be_port)