Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
catalogd-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 // This file contains the main() function for the catalog daemon process,
16 
17 #include <jni.h>
18 #include <boost/scoped_ptr.hpp>
19 
20 #include "catalog/catalog-server.h"
21 #include "common/init.h"
22 #include "common/status.h"
23 #include "rpc/authentication.h"
24 #include "rpc/rpc-trace.h"
25 #include "rpc/thrift-util.h"
26 #include "rpc/thrift-server.h"
27 #include "runtime/mem-tracker.h"
28 #include "service/fe-support.h"
29 #include "util/debug-util.h"
30 #include "util/jni-util.h"
31 #include "util/metrics.h"
32 #include "util/network-util.h"
33 #include "util/memory-metrics.h"
34 #include "util/webserver.h"
36 
37 DECLARE_string(classpath);
38 DECLARE_string(principal);
39 DECLARE_int32(catalog_service_port);
40 DECLARE_int32(webserver_port);
41 DECLARE_bool(enable_webserver);
42 DECLARE_int32(state_store_subscriber_port);
43 
44 #include "common/names.h"
45 
46 using namespace impala;
47 using namespace apache::thrift;
48 
49 int main(int argc, char** argv) {
50  FLAGS_webserver_port = 25020;
51  FLAGS_state_store_subscriber_port = 23020;
52  InitCommonRuntime(argc, argv, true);
53  InitFeSupport();
54 
55  MemTracker process_mem_tracker;
56  scoped_ptr<Webserver> webserver(new Webserver());
57  if (FLAGS_enable_webserver) {
58  AddDefaultUrlCallbacks(webserver.get(), &process_mem_tracker);
59  EXIT_IF_ERROR(webserver->Start());
60  } else {
61  LOG(INFO) << "Not starting webserver";
62  }
63 
64  scoped_ptr<MetricGroup> metrics(new MetricGroup("catalog"));
65  metrics->Init(FLAGS_enable_webserver ? webserver.get() : NULL);
66  EXIT_IF_ERROR(RegisterMemoryMetrics(metrics.get(), true));
67  StartThreadInstrumentation(metrics.get(), webserver.get());
68 
69  InitRpcEventTracing(webserver.get());
70  metrics->AddProperty<string>("catalog.version", GetVersionString(true),
71  "catalogd build version");
72 
73  CatalogServer catalog_server(metrics.get());
74  EXIT_IF_ERROR(catalog_server.Start());
75  catalog_server.RegisterWebpages(webserver.get());
76  shared_ptr<TProcessor> processor(
77  new CatalogServiceProcessor(catalog_server.thrift_iface()));
78  shared_ptr<TProcessorEventHandler> event_handler(
79  new RpcEventHandler("catalog-server", metrics.get()));
80  processor->setEventHandler(event_handler);
81 
82  ThriftServer* server = new ThriftServer("CatalogService", processor,
83  FLAGS_catalog_service_port, NULL, metrics.get(), 5);
84  EXIT_IF_ERROR(server->Start());
85  LOG(INFO) << "CatalogService started on port: " << FLAGS_catalog_service_port;
86  server->Join();
87 }
DECLARE_bool(enable_webserver)
void InitFeSupport()
Definition: fe-support.cc:346
void AddDefaultUrlCallbacks(Webserver *webserver, MemTracker *process_mem_tracker=NULL)
string GetVersionString(bool compact)
Returns "<program short name> version <GetBuildVersion(compact)>".
Definition: debug-util.cc:239
Status RegisterMemoryMetrics(MetricGroup *metrics, bool register_jvm_metrics)
void InitCommonRuntime(int argc, char **argv, bool init_jvm, TestInfo::Mode m=TestInfo::NON_TEST)
Definition: init.cc:122
MetricGroups may be organised hierarchically as a tree.
Definition: metrics.h:200
void Join()
Blocks until the server stops and exits its main thread.
DECLARE_int32(catalog_service_port)
Status StartThreadInstrumentation(MetricGroup *metrics, Webserver *webserver)
Definition: thread.cc:266
void InitRpcEventTracing(Webserver *webserver)
Initialises rpc event tracing, must be called before any RpcEventHandlers are created.
Definition: rpc-trace.cc:67
#define EXIT_IF_ERROR(stmt)
Definition: status.h:248
This class is thread-safe.
Definition: mem-tracker.h:61
int main(int argc, char **argv)
DECLARE_string(classpath)