18 #ifndef MASTER_MAIN_CC
19 #define MASTER_MAIN_CC
33 #include "SharedEmployee.h"
35 int main(
int argc,
char* argv[]) {
37 std::string managerIp;
38 std::string pemFile =
"conf/pdb.key";
39 bool pseudoClusterMode =
false;
40 double partitionToCoreRatio = 0.75;
44 }
else if ((argc == 4) || (argc == 5) || (argc == 6)) {
47 std::string isPseudoStr(argv[3]);
48 if (isPseudoStr.compare(std::string(
"Y")) == 0) {
49 pseudoClusterMode =
true;
50 std::cout <<
"Running in standalone cluster mode" << std::endl;
52 if ((argc == 5) || (argc == 6)) {
56 partitionToCoreRatio = stod(argv[5]);
60 std::cout <<
"[Usage] #managerIp #port #runPseudoClusterOnOneNode (Y for running a "
61 "pseudo-cluster on one node, N for running a real-cluster distributedly, and "
62 "default is N) #pemFile (by default is conf/pdb.key) #partitionToCoreRatio "
63 "(by default is 0.75)"
68 std::cout <<
"Starting up a distributed storage manager server\n";
78 std::shared_ptr<StatisticsDB> statisticsDB = std::make_shared<StatisticsDB>(conf);
79 if (statisticsDB ==
nullptr) {
80 std::cout <<
"fatal error in initializing statisticsDB" << std::endl;
84 std::string errMsg =
" ";
89 string serverListFile;
92 if (pseudoClusterMode==
true) serverListFile =
"conf/serverlist.test";
93 else serverListFile =
"conf/serverlist";
96 serverListFile, port, pseudoClusterMode, pemFile);
102 pdb::makeObject<pdb::CatalogNodeMetadata>(
String(
"localhost:" + std::to_string(port)),
110 std::cout <<
"Metadata for manager node was not added because " + errMsg << std::endl;
112 std::cout <<
"Metadata for manager node successfully added to catalog." << std::endl;
118 for (
int i = 0; i < allNodes->size(); i++) {
119 nodeName =
"worker_" + std::to_string(numNodes);
120 hostName = (*allNodes)[i]->getAddress().c_str();
121 portValue = (*allNodes)[i]->getPort();
123 pdb::makeObject<pdb::CatalogNodeMetadata>(
String(hostName +
":" + std::to_string(portValue)),
130 std::cout <<
"Metadata for worker node was not added because " + errMsg << std::endl;
132 std::cout <<
"Metadata for worker node successfully added to catalog. "
133 << hostName <<
" | " << std::to_string(portValue) <<
" | " << nodeName <<
" | "
143 port, myLogger, conf, statisticsDB, pseudoClusterMode, partitionToCoreRatio);
144 frontEnd.startServer(
nullptr);
Functionality & getFunctionality()
int main(int argc, char *argv[])
bool addNodeMetadata(Handle< CatalogNodeMetadata > &nodeMetadata, std::string &errMsg)
shared_ptr< Configuration > ConfigurationPtr
std::shared_ptr< PDBLogger > PDBLoggerPtr
void makeObjectAllocatorBlock(size_t numBytesIn, bool throwExceptionOnFail)