Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
exec-env.h
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 #ifndef IMPALA_RUNTIME_EXEC_ENV_H
17 #define IMPALA_RUNTIME_EXEC_ENV_H
18 
19 #include <boost/scoped_ptr.hpp>
20 #include <boost/shared_ptr.hpp>
21 #include <boost/thread/thread.hpp>
22 
23 #include "common/status.h"
25 #include "runtime/client-cache.h"
26 #include "util/cgroups-mgr.h"
27 #include "util/hdfs-bulk-ops.h" // For declaration of HdfsOpThreadPool
29 
30 namespace impala {
31 
32 class DataStreamMgr;
33 class DiskIoMgr;
34 class HBaseTableFactory;
35 class HdfsFsCache;
36 class LibCache;
37 class Scheduler;
38 class StatestoreSubscriber;
39 class TestExecEnv;
40 class Webserver;
41 class MetricGroup;
42 class MemTracker;
43 class ThreadResourceMgr;
44 class CgroupsManager;
45 class ImpalaServer;
46 class RequestPoolService;
47 class Frontend;
48 
53 class ExecEnv {
54  public:
55  ExecEnv();
56 
57  ExecEnv(const std::string& hostname, int backend_port, int subscriber_port,
58  int webserver_port, const std::string& statestore_host, int statestore_port);
59 
63  static ExecEnv* GetInstance() { return exec_env_; }
64 
67  virtual ~ExecEnv();
68 
69  void SetImpalaServer(ImpalaServer* server) { impala_server_ = server; }
70 
72  return statestore_subscriber_.get();
73  }
74 
75  DataStreamMgr* stream_mgr() { return stream_mgr_.get(); }
77  return impalad_client_cache_.get();
78  }
80  return catalogd_client_cache_.get();
81  }
83  DiskIoMgr* disk_io_mgr() { return disk_io_mgr_.get(); }
84  Webserver* webserver() { return webserver_.get(); }
85  MetricGroup* metrics() { return metrics_.get(); }
88  CgroupsMgr* cgroups_mgr() { return cgroups_mgr_.get(); }
91  Frontend* frontend() { return frontend_.get(); };
92 
93  void set_enable_webserver(bool enable) { enable_webserver_ = enable; }
94 
96  Scheduler* scheduler() { return scheduler_.get(); }
98 
99  const TNetworkAddress& backend_address() const { return backend_address_; }
100 
102  virtual Status StartServices();
103 
106 
110  bool is_fe_tests() { return is_fe_tests_; }
111 
116 
117  protected:
119  boost::scoped_ptr<DataStreamMgr> stream_mgr_;
120  boost::scoped_ptr<ResourceBroker> resource_broker_;
121  boost::scoped_ptr<Scheduler> scheduler_;
122  boost::scoped_ptr<StatestoreSubscriber> statestore_subscriber_;
123  boost::scoped_ptr<ImpalaInternalServiceClientCache> impalad_client_cache_;
124  boost::scoped_ptr<CatalogServiceClientCache> catalogd_client_cache_;
125  boost::scoped_ptr<HBaseTableFactory> htable_factory_;
126  boost::scoped_ptr<DiskIoMgr> disk_io_mgr_;
127  boost::scoped_ptr<Webserver> webserver_;
128  boost::scoped_ptr<MetricGroup> metrics_;
129  boost::scoped_ptr<MemTracker> mem_tracker_;
130  boost::scoped_ptr<ThreadResourceMgr> thread_mgr_;
131  boost::scoped_ptr<CgroupsMgr> cgroups_mgr_;
132  boost::scoped_ptr<HdfsOpThreadPool> hdfs_op_thread_pool_;
133  boost::scoped_ptr<RequestPoolService> request_pool_service_;
134  boost::scoped_ptr<Frontend> frontend_;
135 
138 
140 
141  private:
145 
147  TNetworkAddress backend_address_;
148 
153 
155  void InitRm();
156 };
157 
158 } // namespace impala
159 
160 #endif
void SetImpalaServer(ImpalaServer *server)
Definition: exec-env.h:69
boost::scoped_ptr< DiskIoMgr > disk_io_mgr_
Definition: exec-env.h:126
StatestoreSubscriber * statestore_subscriber()
Definition: exec-env.h:71
void InitRm()
Initialise cgroups manager, detect test RM environment and init resource broker.
Definition: exec-env.cc:223
boost::scoped_ptr< MemTracker > mem_tracker_
Definition: exec-env.h:129
boost::scoped_ptr< RequestPoolService > request_pool_service_
Definition: exec-env.h:133
TNetworkAddress backend_address_
Address of the Impala backend server instance.
Definition: exec-env.h:147
Functions to load and access the timestamp database.
Status InitForFeTests()
Initializes the exec env for running FE tests.
Definition: exec-env.cc:276
boost::scoped_ptr< HdfsOpThreadPool > hdfs_op_thread_pool_
Definition: exec-env.h:132
boost::scoped_ptr< Scheduler > scheduler_
Definition: exec-env.h:121
bool enable_webserver_
Definition: exec-env.h:139
boost::scoped_ptr< CgroupsMgr > cgroups_mgr_
Definition: exec-env.h:131
static ExecEnv * exec_env_
Definition: exec-env.h:142
MetricGroups may be organised hierarchically as a tree.
Definition: metrics.h:200
Webserver * webserver()
Definition: exec-env.h:84
boost::scoped_ptr< ResourceBroker > resource_broker_
Definition: exec-env.h:120
boost::scoped_ptr< Frontend > frontend_
Definition: exec-env.h:134
Scheduler * scheduler()
Definition: exec-env.h:96
HBaseTableFactory * htable_factory()
Definition: exec-env.h:82
Frontend * frontend()
Definition: exec-env.h:91
boost::scoped_ptr< ImpalaInternalServiceClientCache > impalad_client_cache_
Definition: exec-env.h:123
boost::scoped_ptr< StatestoreSubscriber > statestore_subscriber_
Definition: exec-env.h:122
ResourceBroker * resource_broker()
Definition: exec-env.h:95
ImpalaServer * impala_server()
Definition: exec-env.h:90
TimezoneDatabase tz_database_
Definition: exec-env.h:143
MemTracker * process_mem_tracker()
Definition: exec-env.h:86
CgroupsMgr * cgroups_mgr()
Definition: exec-env.h:88
MetricGroup * metrics()
Definition: exec-env.h:85
bool is_pseudo_distributed_llama_
Definition: exec-env.h:152
CatalogServiceClientCache * catalogd_client_cache()
Definition: exec-env.h:79
const TNetworkAddress & backend_address() const
Definition: exec-env.h:99
boost::scoped_ptr< HBaseTableFactory > htable_factory_
Definition: exec-env.h:125
bool is_fe_tests_
Definition: exec-env.h:144
boost::scoped_ptr< CatalogServiceClientCache > catalogd_client_cache_
Definition: exec-env.h:124
HdfsOpThreadPool * hdfs_op_thread_pool()
Definition: exec-env.h:89
virtual Status StartServices()
Starts any dependent services in their correct order.
Definition: exec-env.cc:282
This class is thread-safe.
Definition: mem-tracker.h:61
boost::scoped_ptr< MetricGroup > metrics_
Definition: exec-env.h:128
static ExecEnv * GetInstance()
Definition: exec-env.h:63
boost::scoped_ptr< ThreadResourceMgr > thread_mgr_
Definition: exec-env.h:130
virtual ~ExecEnv()
Definition: exec-env.cc:273
bool is_pseudo_distributed_llama()
Definition: exec-env.h:115
DiskIoMgr * disk_io_mgr()
Definition: exec-env.h:83
DataStreamMgr * stream_mgr()
Definition: exec-env.h:75
bool is_fe_tests()
Definition: exec-env.h:110
ImpalaServer * impala_server_
Not owned by this class.
Definition: exec-env.h:137
StatestoreSubscriber * subscriber()
Definition: exec-env.h:97
ThreadResourceMgr * thread_mgr()
Definition: exec-env.h:87
void set_enable_webserver(bool enable)
Definition: exec-env.h:93
boost::scoped_ptr< DataStreamMgr > stream_mgr_
Leave protected so that subclasses can override.
Definition: exec-env.h:119
boost::scoped_ptr< Webserver > webserver_
Definition: exec-env.h:127
ImpalaInternalServiceClientCache * impalad_client_cache()
Definition: exec-env.h:76