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
HermesExecutionServer.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 HERMES_EXECUTION_SERVER_H
19 #define HERMES_EXECUTION_SERVER_H
20 
21 #include "PDBDebug.h"
22 #include "ServerFunctionality.h"
23 #include "SharedMem.h"
24 #include "Configuration.h"
25 #include "PageScanner.h"
26 #include "DataTypes.h"
27 #include "HashSetManager.h"
28 #include <string>
29 
30 namespace pdb {
31 
32 // this server functionality is supposed to run in backend
33 // a HermesExecutionServer runs in backend for distributed query execution.
34 // the QuerySchedulerServer split a query job into mulitple JobStages and dispatch
35 // those JobStages to HermesExecutionServer for execution.
36 
37 // There are four different types of JobStages in total:
38 // -- TupleSetJobStage: this encapsulates a pipeline of computations;
39 // -- AggregationJobStage: this encapsulates the final aggregation execution that
40 // receives data from a shuffled set, and build multiple hash tables over the data;
41 // -- BroadcastJoinBuildHTJobStage: this encapsulates the execution of hash table building
42 // for broadcast join;
43 // -- PartitionedJoinBuildHTJobStage: this encapsulates the execution of hash table
44 // building for hash partitioned join.
45 
46 // HermesExecutionServer executes each of those JobStages and
47 // stores intermediate data in local storage.
48 
49 
50 
52 
53 public:
54  // creates an execution server...
59  this->shm = shm;
60  this->conf = conf;
61  this->nodeId = conf->getNodeID();
62  this->curScanner = nullptr;
63  this->logger = logger;
64  this->workers = workers;
65  }
66 
67  // set the configuration instance;
69  this->conf = conf;
70  }
71 
72  // return the configuration instance;
74  return this->conf;
75  }
76 
77  // set the shared memory instance;
79  this->shm = shm;
80  }
81 
82  // return the shared memory instance;
84  return this->shm;
85  }
86 
87  // set the nodeId for this backend server;
89  this->nodeId = nodeId;
90  }
91 
92  // return the nodeId of this backend server;
94  return this->nodeId;
95  }
96 
97 
98  // from the ServerFunctionality interface... registers the HermesExecutionServer's //
99  // handlers
100  void registerHandlers(PDBServer& forMe) override;
101 
102  // register the PageScanner for current job;
103  // now only one job is allowed to run in an execution server at a time
104  bool setCurPageScanner(PageScannerPtr curPageScanner) {
105  if (curPageScanner == nullptr) {
106  this->curScanner = nullptr;
107  return true;
108  }
109 
110  if (this->curScanner == nullptr) {
111  this->curScanner = curPageScanner;
112  PDB_COUT << "scanner set for current job\n";
113  return true;
114  } else {
115  // a job is already running
116  cout << "PDBBackEnd: a job is already running...\n";
117  return false;
118  }
119  }
120 
121 
122  // return the PageScanner of current job;
124  return this->curScanner;
125  }
126 
127  // set the logger
129  this->logger = logger;
130  }
131 
132  // get the logger
134  return this->logger;
135  }
136 
137  // set the workers
139  this->workers = workers;
140  }
141 
142  // get the workers
144  return this->workers;
145  }
146 
147  // destructor
149 
150  // get hash set
151  AbstractHashSetPtr getHashSet(std::string name) {
152  return this->hashSetMgr.getHashSet(name);
153  }
154 
155  // add hash set
156  bool addHashSet(std::string name, AbstractHashSetPtr hashSet) {
157  return this->hashSetMgr.addHashSet(name, hashSet);
158  }
159 
160  // remove hash set
161  bool removeHashSet(std::string name) {
162  return this->hashSetMgr.removeHashSet(name);
163  }
164 
165  size_t getHashSetsSize() {
166 
167  return this->hashSetMgr.getTotalSize();
168  }
169 
170 private:
178 };
179 }
180 
181 #endif
shared_ptr< PageScanner > PageScannerPtr
Definition: PageScanner.h:39
std::shared_ptr< AbstractHashSet > AbstractHashSetPtr
void registerHandlers(PDBServer &forMe) override
bool addHashSet(std::string name, AbstractHashSetPtr hashSet)
void setSharedMem(SharedMemPtr shm)
unsigned int NodeID
Definition: DataTypes.h:27
void setWorkers(PDBWorkerQueuePtr workers)
bool setCurPageScanner(PageScannerPtr curPageScanner)
void setConf(ConfigurationPtr conf)
shared_ptr< SharedMem > SharedMemPtr
Definition: SharedMem.h:32
AbstractHashSetPtr getHashSet(std::string name)
HermesExecutionServer(SharedMemPtr shm, PDBWorkerQueuePtr workers, PDBLoggerPtr logger, ConfigurationPtr conf)
void setLogger(pdb::PDBLoggerPtr logger)
bool removeHashSet(std::string name)
shared_ptr< PDBWorkerQueue > PDBWorkerQueuePtr
#define PDB_COUT
Definition: PDBDebug.h:31
shared_ptr< Configuration > ConfigurationPtr
Definition: Configuration.h:89
std::shared_ptr< PDBLogger > PDBLoggerPtr
Definition: PDBLogger.h:40
bool removeHashSet(std::string name)
AbstractHashSetPtr getHashSet(std::string name)
bool addHashSet(std::string name, AbstractHashSetPtr hashSet)