A platform for high-performance distributed tool and library development written in C++. It can be deployed in two different cluster modes: standalone or distributed. API for v0.5.0, released on June 13, 2018.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Configuration.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * *
3  * Copyright 2018 Rice University *
4  * *
5  * Licensed under the Apache License, Version 2.0 (the "License"); *
6  * you may not use this file except in compliance with the License. *
7  * You may obtain a copy of the License at *
8  * *
9  * http://www.apache.org/licenses/LICENSE-2.0 *
10  * *
11  * Unless required by applicable law or agreed to in writing, software *
12  * distributed under the License is distributed on an "AS IS" BASIS, *
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14  * See the License for the specific language governing permissions and *
15  * limitations under the License. *
16  * *
17  *****************************************************************************/
18 #ifndef CONFIGURATION_H
19 #define CONFIGURATION_H
20 
21 #include <assert.h>
22 #include <memory>
23 #include <string>
24 #include <sys/types.h>
25 #include <sys/stat.h>
26 #include <unistd.h>
27 #include <iostream>
28 #include "DataTypes.h"
29 
30 #include "LogLevel.h"
31 
32 
33 using namespace std;
34 
35 #ifndef DEFAULT_PAGE_SIZE
36 #define DEFAULT_PAGE_SIZE ((size_t)(256) * (size_t)(1024) * (size_t)(1024))
37 #endif
38 
39 #ifndef DEFAULT_MAX_PAGE_SIZE
40 #define DEFAULT_MAX_PAGE_SIZE DEFAULT_PAGE_SIZE
41 #endif
42 
43 #ifndef DEFAULT_NET_PAGE_SIZE
44 #define DEFAULT_NET_PAGE_SIZE \
45  DEFAULT_PAGE_SIZE - (sizeof(NodeID) + sizeof(DatabaseID) + sizeof(UserTypeID) + \
46  sizeof(SetID) + sizeof(PageID) + sizeof(int) + sizeof(size_t))
47 #endif
48 
49 #ifndef DEFAULT_SHUFFLE_PAGE_SIZE
50 #define DEFAULT_SHUFFLE_PAGE_SIZE DEFAULT_PAGE_SIZE
51 #endif
52 
53 #ifndef DEFAULT_BROADCAST_PAGE_SIZE
54 #define DEFAULT_BROADCAST_PAGE_SIZE DEFAULT_PAGE_SIZE
55 #endif
56 
57 
58 #ifndef DEFAULT_MAX_CONNECTIONS
59 #define DEFAULT_MAX_CONNECTIONS 200
60 #endif
61 
62 #ifndef DEFAULT_SHAREDMEM_SIZE
63 #define DEFAULT_SHAREDMEM_SIZE ((size_t)12 * (size_t)1024 * (size_t)1024 * (size_t)1024)
64 #endif
65 
66 #ifndef DEFAULT_NUM_THREADS
67 #define DEFAULT_NUM_THREADS 2
68 #endif
69 
70 #ifndef DEFAULT_BATCH_SIZE
71 #define DEFAULT_BATCH_SIZE 100
72 #endif
73 
74 
75 #ifndef DEFAULT_HASH_PAGE_SIZE
76 #define DEFAULT_HASH_PAGE_SIZE ((size_t)(512) * (size_t)(1024) * (size_t)(1024))
77 #endif
78 
79 // unit: KB
80 #ifndef DEFAULT_MEM_SIZE
81 #define DEFAULT_MEM_SIZE ((size_t)(68) * (size_t)(1024) * (size_t)(1024))
82 #endif
83 
84 #ifndef DEFAULT_NUM_CORES
85 #define DEFAULT_NUM_CORES 8
86 #endif
87 
88 // create a smart pointer for Configuration objects
90 typedef shared_ptr<Configuration> ConfigurationPtr;
91 
93 private:
95  string serverName;
96  string serverAddress;
98  bool usePangea;
99  int port;
101  string ipcFile;
102  string logFile;
103  size_t pageSize;
106  size_t maxPageSize;
108  size_t shmSize;
110  string dataDirs;
111  string metaDir;
112  string metaTempDir;
113  string dataTempDirs;
114  unsigned int numThreads;
117  size_t hashPageSize;
118  bool isManager;
123  string rootDir;
124  string statisticsDB;
125 
126 public:
128  // set default values.
129  this->nodeId = 0;
130  this->logLevel = LogLevel::ERROR;
131  serverName = "testServer";
132  serverAddress = "localhost";
133  isManagerCatalogServer = false;
134  usePangea = true;
135  port = 8108;
136  maxConnections = DEFAULT_MAX_CONNECTIONS;
137  logFile = "serverLog";
138  maxPageSize = DEFAULT_MAX_PAGE_SIZE;
139  pageSize = DEFAULT_PAGE_SIZE;
140  assert(pageSize <= maxPageSize);
141  shufflePageSize = DEFAULT_SHUFFLE_PAGE_SIZE;
142  assert(shufflePageSize <= maxPageSize);
143  broadcastPageSize = DEFAULT_BROADCAST_PAGE_SIZE;
144  assert(broadcastPageSize <= maxPageSize);
145  useUnixDomainSock = false;
146  shmSize = DEFAULT_SHAREDMEM_SIZE;
147  logEnabled = false;
148  numThreads = DEFAULT_NUM_THREADS;
149  ipcFile = "/tmp/ipcFile";
150  backEndIpcFile = "/tmp/backEndIpcFile";
151  batchSize = DEFAULT_BATCH_SIZE;
152  isManager = false;
153  hashPageSize = DEFAULT_HASH_PAGE_SIZE;
154  initDirs();
155  statisticsDB = "statDB";
156  }
157 
158  void initDirs() {
159  rootDir = std::string("pdbRoot_") + serverAddress + std::string("_") + std::to_string(port);
160  // temporarily added for unit tests
161  this->createDir(rootDir);
162  // dataDirs =
163  // "pdbRoot/data1,pdbRoot/data2,pdbRoot/data3,pdbRoot/data4,pdbRoot/data5,pdbRoot/data6,pdbRoot/data7,pdbRoot/data8,pdbRoot/data9,pdbRoot/data10,pdbRoot/data11,pdbRoot/data12";
164  // dataDirs = "/data/data,/mnt/data";
165  dataDirs = rootDir + std::string("/data");
166  metaDir = rootDir + std::string("/meta");
167  metaTempDir = rootDir + std::string("/metaTmp");
168  // dataTempDirs = "/data/tmp,/mnt/tmp";
169  dataTempDirs = rootDir + std::string("/tmp");
170  // dataTempDirs = "/data10/tmp,/mnt/tmp";
171  // dataTempDirs =
172  // "/data1/tmp,/data2/tmp,/data3/tmp,/data4/tmp,/data5/tmp,/data6/tmp,/data7/tmp,/data8/tmp,/data9/tmp,pdbRoot/tmp,/data10/tmp,/mnt/tmp";
173  }
174 
175 
176  NodeID getNodeID() const {
177  return nodeId;
178  }
179 
180  string getServerName() const {
181  return serverName;
182  }
183 
184  string getIpcFile() const {
185  return ipcFile;
186  }
187 
188  string getLogFile() const {
189  return logFile;
190  }
191 
192  int getMaxConnections() const {
193  return maxConnections;
194  }
195 
196  size_t getPageSize() const {
197  return pageSize;
198  }
199 
200  size_t getNetPageSize() const {
201  return pageSize - (sizeof(NodeID) + sizeof(DatabaseID) + sizeof(UserTypeID) +
202  sizeof(SetID) + sizeof(PageID) + sizeof(int) + sizeof(size_t));
203  }
204 
205 
206  size_t getMaxPageSize() const {
207  return maxPageSize;
208  }
209 
210  size_t getShufflePageSize() const {
211  return shufflePageSize;
212  }
213 
214  size_t getNetShufflePageSize() const {
215  return shufflePageSize - (sizeof(NodeID) + sizeof(DatabaseID) + sizeof(UserTypeID) +
216  sizeof(SetID) + sizeof(PageID) + sizeof(int) + sizeof(size_t));
217  }
218 
219  size_t getBroadcastPageSize() const {
220  return broadcastPageSize;
221  }
222 
223  size_t getNetBroadcastPageSize() const {
224  return broadcastPageSize - (sizeof(NodeID) + sizeof(DatabaseID) + sizeof(UserTypeID) +
225  sizeof(SetID) + sizeof(PageID) + sizeof(int) + sizeof(size_t));
226  }
227 
228 
229  size_t getHashPageSize() const {
230  return hashPageSize;
231  }
232 
233  int getPort() const {
234  return port;
235  }
236 
237  size_t getShmSize() const {
238  return shmSize;
239  }
240 
241  bool isLogEnabled() const {
242  return logEnabled;
243  }
244 
245  bool isUseUnixDomainSock() const {
246  return useUnixDomainSock;
247  }
248 
249  string getDataDirs() const {
250  return dataDirs;
251  }
252 
253  string getMetaDir() const {
254  return metaDir;
255  }
256 
257  string getMetaTempDir() const {
258  return metaTempDir;
259  }
260 
261  string getDataTempDirs() const {
262  return dataTempDirs;
263  }
264 
265  unsigned int getNumThreads() const {
266  return numThreads;
267  }
268 
269  string getBackEndIpcFile() const {
270  return backEndIpcFile;
271  }
272 
273  void setNodeId(NodeID nodeId) {
274  this->nodeId = nodeId;
275  }
276 
277  void setServerName(string serverName) {
278  this->serverName = serverName;
279  }
280 
281  void setIpcFile(string ipcFile) {
282  this->ipcFile = ipcFile;
283  }
284 
285  void setLogFile(string logFile) {
286  this->logFile = logFile;
287  }
288 
289  void setMaxConnections(int maxConnections) {
290  this->maxConnections = maxConnections;
291  }
292 
293  void setPageSize(size_t pageSize) {
294  assert(pageSize <= maxPageSize);
295  this->pageSize = pageSize;
296  }
297 
298  void setMaxPageSize(size_t maxPageSize) {
299  assert(pageSize <= maxPageSize);
300  assert(shufflePageSize <= maxPageSize);
301  assert(broadcastPageSize <= maxPageSize);
302  this->maxPageSize = maxPageSize;
303  }
304 
305  void setShufflePageSize(size_t shufflePageSize) {
306  assert(shufflePageSize < maxPageSize);
307  this->shufflePageSize = shufflePageSize;
308  }
309 
310  void setHashPageSize(size_t hashPageSize) {
311  this->hashPageSize = hashPageSize;
312  }
313 
314  void setBroadcastPageSize(size_t broadcastPageSize) {
315  assert(broadcastPageSize <= maxPageSize);
316  this->broadcastPageSize = broadcastPageSize;
317  }
318 
319 
320  void setPort(int port) {
321  this->port = port;
322  }
323 
324  void setShmSize(size_t shmSize) {
325  this->shmSize = shmSize;
326  }
327 
328  void setUseUnixDomainSock(bool useUnixDomainSock) {
329  this->useUnixDomainSock = useUnixDomainSock;
330  }
331 
332  void setLogEnabled(bool logEnabled) {
333  this->logEnabled = logEnabled;
334  }
335 
336  void setDataDirs(string dataDirs) {
337  this->dataDirs = dataDirs;
338  }
339 
340  void setMetaDir(string metaDir) {
341  this->metaDir = metaDir;
342  }
343 
344  void setMetaTempDir(string tempDir) {
345  this->metaTempDir = tempDir;
346  }
347 
348  void setDataTempDirs(string tempDirs) {
349  this->dataTempDirs = tempDirs;
350  }
351 
352  void setNumThreads(unsigned int numThreads) {
353  this->numThreads = numThreads;
354  }
355 
356  void setBackEndIpcFile(string backEndIpcFile) {
357  this->backEndIpcFile = backEndIpcFile;
358  }
359 
360  void createDir(string path) {
361  struct stat st = {0};
362  if (stat(path.c_str(), &st) == -1) {
363  mkdir(path.c_str(), 0777);
364  }
365  }
366 
367  bool getIsManager() const {
368  return isManager;
369  }
370 
371  void setIsManager(bool isManager) {
372  this->isManager = isManager;
373  }
374 
375  string getManagerNodeHostName() const {
376  return managerNodeHostName;
377  }
378 
379  void setManagerNodeHostName(string managerNodeHostName) {
380  this->managerNodeHostName = managerNodeHostName;
381  }
382 
383  int getManagerNodePort() const {
384  return managerNodePort;
385  }
386 
387  void setManagerNodePort(int managerNodePort) {
388  this->managerNodePort = managerNodePort;
389  }
390 
391  const string getQueryPlannerPlace() const {
392  return queryPlannerPlace;
393  }
394 
395  void setQueryPlannerPlace(const string queryPlannerPlace) {
396  this->queryPlannerPlace = queryPlannerPlace;
397  }
398 
400  return logLevel;
401  }
402 
403  void setLogLevel(LogLevel logLevel) {
404  this->logLevel = logLevel;
405  }
406 
407  void setManagerCatalogServer(bool isManagerCatalogServer) {
408  this->isManagerCatalogServer = isManagerCatalogServer;
409  }
410 
412  return this->isManagerCatalogServer;
413  }
414 
415  void setServerAddress(string serverAddress) {
416  this->serverAddress = serverAddress;
417  }
418 
419  string getServerAddress() {
420  return this->serverAddress;
421  }
422 
423  void setUsePangea(bool usePangea) {
424  this->usePangea = usePangea;
425  }
426 
427  bool getUsePangea() {
428  return this->usePangea;
429  }
430 
431  int getBatchSize() {
432  return this->batchSize;
433  }
434 
435  void setBatchSize(int batchSize) {
436  this->batchSize = batchSize;
437  }
438 
439  std::string getStatisticsDB() {
440  return this->statisticsDB;
441  }
442 
443  void setStatisticsDB(std::string statisticsDB) {
444  this->statisticsDB = statisticsDB;
445  }
446 
447  void printOut() {
448  cout << "nodeID: " << nodeId << endl;
449  cout << "serverName: " << serverName << endl;
450  cout << "serverAddress: " << serverAddress << endl;
451  cout << "isManagerCatalogServer: " << isManagerCatalogServer << endl;
452  cout << "usePangea: " << usePangea << endl;
453  cout << "port: " << port << endl;
454  cout << "maxConnections: " << maxConnections << endl;
455  cout << "ipcFile: " << ipcFile << endl;
456  cout << "logFile: " << logFile << endl;
457  cout << "pageSize: " << pageSize << endl;
458  cout << "maxPageSize: " << maxPageSize << endl;
459  cout << "shufflePageSize: " << shufflePageSize << endl;
460  cout << "broadcastPageSize: " << broadcastPageSize << endl;
461  cout << "hashPageSize: " << hashPageSize << endl;
462  cout << "useUnixDomainSock: " << useUnixDomainSock << endl;
463  cout << "shmSize: " << shmSize << endl;
464  cout << "dataDirs: " << dataDirs << endl;
465  cout << "metaDir: " << metaDir << endl;
466  cout << "metaTempDir: " << metaTempDir << endl;
467  cout << "dataTempDirs: " << dataTempDirs << endl;
468  cout << "numThreads: " << numThreads << endl;
469  cout << "backEndIpcFile: " << backEndIpcFile << endl;
470  cout << "isManager: " << isManager << endl;
471  cout << "managerNodeHostName: " << managerNodeHostName << endl;
472  cout << "managerNodePort: " << managerNodePort << endl;
473  cout << "logEnabled: " << logEnabled << endl;
474  cout << "batchSize: " << batchSize << endl;
475  cout << "statisticsDB: " << statisticsDB << endl;
476  }
477 };
478 
479 #endif /* CONFIGURATION_H */
#define DEFAULT_NUM_THREADS
Definition: Configuration.h:67
int getManagerNodePort() const
unsigned int SetID
Definition: DataTypes.h:31
void setNumThreads(unsigned int numThreads)
LogLevel logLevel
size_t broadcastPageSize
void setServerName(string serverName)
string getDataDirs() const
void setBackEndIpcFile(string backEndIpcFile)
void setLogLevel(LogLevel logLevel)
bool isUseUnixDomainSock() const
bool getManagerCatalogServer()
string getMetaDir() const
void setIpcFile(string ipcFile)
string getServerName() const
void setLogFile(string logFile)
const string getQueryPlannerPlace() const
#define DEFAULT_SHAREDMEM_SIZE
Definition: Configuration.h:63
bool getIsManager() const
string backEndIpcFile
void setBatchSize(int batchSize)
size_t getPageSize() const
unsigned int NodeID
Definition: DataTypes.h:27
string getDataTempDirs() const
Definition: LogLevel.h:40
#define DEFAULT_MAX_PAGE_SIZE
Definition: Configuration.h:40
void setBroadcastPageSize(size_t broadcastPageSize)
string queryPlannerPlace
#define DEFAULT_MAX_CONNECTIONS
Definition: Configuration.h:59
size_t getNetPageSize() const
void setShufflePageSize(size_t shufflePageSize)
void setStatisticsDB(std::string statisticsDB)
void setHashPageSize(size_t hashPageSize)
string getBackEndIpcFile() const
size_t getBroadcastPageSize() const
size_t getHashPageSize() const
void setUsePangea(bool usePangea)
void setDataDirs(string dataDirs)
#define DEFAULT_BROADCAST_PAGE_SIZE
Definition: Configuration.h:54
void setMaxPageSize(size_t maxPageSize)
string dataTempDirs
bool getUsePangea()
string managerNodeHostName
void setManagerCatalogServer(bool isManagerCatalogServer)
void setManagerNodePort(int managerNodePort)
unsigned int DatabaseID
Definition: DataTypes.h:29
string serverAddress
Definition: Configuration.h:96
unsigned int PageID
Definition: DataTypes.h:26
unsigned int numThreads
size_t getShmSize() const
size_t getNetBroadcastPageSize() const
bool isManagerCatalogServer
Definition: Configuration.h:97
NodeID getNodeID() const
#define DEFAULT_SHUFFLE_PAGE_SIZE
Definition: Configuration.h:50
void setNodeId(NodeID nodeId)
void setPageSize(size_t pageSize)
void setDataTempDirs(string tempDirs)
string serverName
Definition: Configuration.h:95
void setManagerNodeHostName(string managerNodeHostName)
void setPort(int port)
int getMaxConnections() const
LogLevel getLogLevel() const
string statisticsDB
string getManagerNodeHostName() const
unsigned int getNumThreads() const
#define DEFAULT_BATCH_SIZE
Definition: Configuration.h:71
void setIsManager(bool isManager)
std::string getStatisticsDB()
shared_ptr< Configuration > ConfigurationPtr
Definition: Configuration.h:89
string getMetaTempDir() const
size_t maxPageSize
bool useUnixDomainSock
void setMaxConnections(int maxConnections)
void setQueryPlannerPlace(const string queryPlannerPlace)
#define DEFAULT_HASH_PAGE_SIZE
Definition: Configuration.h:76
void setServerAddress(string serverAddress)
void setShmSize(size_t shmSize)
string getLogFile() const
int getPort() const
string getIpcFile() const
void setUseUnixDomainSock(bool useUnixDomainSock)
#define DEFAULT_PAGE_SIZE
Definition: Configuration.h:36
void createDir(string path)
size_t getNetShufflePageSize() const
size_t getShufflePageSize() const
void setMetaTempDir(string tempDir)
void setMetaDir(string metaDir)
string metaTempDir
bool isLogEnabled() const
string getServerAddress()
size_t shufflePageSize
size_t getMaxPageSize() const
unsigned int UserTypeID
Definition: DataTypes.h:25
void setLogEnabled(bool logEnabled)
size_t hashPageSize
LogLevel
Definition: LogLevel.h:40