forked from dase/CLAIMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Environment.h
executable file
·115 lines (106 loc) · 3.51 KB
/
Environment.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* Environment.h
*
* Created on: Aug 10, 2013
* Author: wangli
*/
#ifndef ENVIRONMENT_H_
#define ENVIRONMENT_H_
#include "Executor/IteratorExecutorMaster.h"
#include "Executor/IteratorExecutorSlave.h"
#include "storage/BlockManager.h"
#include "storage/BlockManagerMaster.h"
#include "Resource/ResourceManagerMaster.h"
#include "Resource/ResourceManagerSlave.h"
#include "IndexManager/IndexManager.h"
#include "Executor/PortManager.h"
#include "common/Logging.h"
#include "utility/thread_pool.h"
#include "Client/ClaimsServer.h"
#include "exec_tracker/stmt_exec_tracker.h"
#include "exec_tracker/segment_exec_tracker.h"
#include "Executor/exchange_tracker.h"
#include "Executor/expander_tracker.h"
#include "node_manager/master_node.h"
#include "node_manager/slave_node.h"
#include "Resource/BufferManager.h"
using claims::catalog::Catalog;
using claims::MasterNode;
using claims::SegmentExecTracker;
using claims::SlaveNode;
using claims::StmtExecTracker;
class Catalog;
class IteratorExecutorSlave;
class BlockManager;
class ResourceManagerMaster;
class InstanceResourceManager;
class BlockManagerMaster;
class Environment {
public:
virtual ~Environment();
static Environment* getInstance(bool ismaster = 0);
std::string getIp();
unsigned getPort();
ExchangeTracker* getExchangeTracker();
ResourceManagerMaster* getResourceManagerMaster();
InstanceResourceManager* getResourceManagerSlave();
NodeID getNodeID() const;
claims::catalog::Catalog* getCatalog() const;
ThreadPool* getThreadPool() const;
IteratorExecutorSlave* getIteratorExecutorSlave() const;
Environment(bool ismaster = false);
MasterNode* get_master_node() { return master_node_; }
SlaveNode* get_slave_node() { return slave_node_; }
BlockManager* get_block_manager() { return blockManager_; }
IteratorExecutorMaster* get_iterator_executor_master() {
return iteratorExecutorMaster;
}
BlockManagerMaster* get_block_manager_master() { return blockManagerMaster_; }
StmtExecTracker* get_stmt_exec_tracker() { return stmt_exec_tracker_; }
SegmentExecTracker* get_segment_exec_tracker() { return seg_exec_tracker_; }
private:
void AnnounceCafMessage();
void readConfigFile();
void initializeStorage();
void initializeResourceManager();
void initializeBufferManager();
void initializeIndexManager();
void initializeClientListener();
void initializeExpressionSystem();
void destoryClientListener();
bool initializeThreadPool();
void InitMembership();
private:
static Environment* _instance;
PortManager* portManager;
std::string ip;
unsigned port;
IteratorExecutorSlave* iteratorExecutorSlave;
IteratorExecutorMaster* iteratorExecutorMaster;
ExchangeTracker* exchangeTracker;
Logging* logging_;
bool ismaster_;
ResourceManagerMaster* resourceManagerMaster_;
InstanceResourceManager* resourceManagerSlave_;
Catalog* catalog_;
/* the globally unique node id*/
NodeID nodeid;
BlockManagerMaster* blockManagerMaster_;
BlockManager* blockManager_;
BufferManager* bufferManager_;
IndexManager* indexManager_;
ExpanderTracker* expander_tracker_;
ClientListener* listener_;
ThreadPool* thread_pool_;
MasterNode* master_node_;
SlaveNode* slave_node_;
StmtExecTracker* stmt_exec_tracker_;
SegmentExecTracker* seg_exec_tracker_;
/**
* TODO: the master and slave pair, such as ResouceManagerMaster and
* ResourceManagerSlave, should have a
* base class which provides the access methods and is derived by
* ResouceManagerMaster and ResourceManagerSlave.
*/
};
#endif /* ENVIRONMENT_H_ */