int PhxEchoServer :: RunPaxos() { Options oOptions; int ret = MakeLogStoragePath(oOptions.sLogStoragePath); if (ret != 0) { return ret; } //this groupcount means run paxos group count. //every paxos group is independent, there are no any communicate between any 2 paxos group. oOptions.iGroupCount = 1; oOptions.oMyNode = m_oMyNode; // 这里为什么要使用深拷贝呢,不过似乎开销并不大。 oOptions.vecNodeInfoList = m_vecNodeList; GroupSMInfo oSMInfo; // 这里的 group index 只是为了区分不同的 group,同时运行多个 group 只是为了提高系统的并行度,互相不干扰。 oSMInfo.iGroupIdx = 0; //one paxos group can have multi state machine. oSMInfo.vecSMList.push_back(&m_oEchoSM); oOptions.vecGroupSMInfoList.push_back(oSMInfo); //use logger_google to print log LogFunc pLogFunc; ret = LoggerGoogle :: GetLogger("phxecho", "./log", 3, pLogFunc); if (ret != 0) { printf("get logger_google fail, ret %d\n", ret); return ret; } //set logger oOptions.pLogFunc = pLogFunc; // 这里注意RunNode()为一个静态函数。 // 主要的实现流程都在 RunNode() 函数里面。 ret = Node::RunNode(oOptions, m_poPaxosNode); if (ret != 0) { printf("run paxos fail, ret %d\n", ret); return ret; } printf("run paxos ok\n"); return 0; }
int BenchServer :: RunPaxos() { Options oOptions; int ret = MakeLogStoragePath(oOptions.sLogStoragePath); if (ret != 0) { return ret; } //this groupcount means run paxos group count. //every paxos group is independent, there are no any communicate between any 2 paxos group. oOptions.iGroupCount = m_iGroupCount; oOptions.oMyNode = m_oMyNode; oOptions.vecNodeInfoList = m_vecNodeList; //different paxos group can have different state machine. for (auto & poBenchSM : m_vecSMList) { GroupSMInfo oSMInfo; oSMInfo.iGroupIdx = poBenchSM->GetGroupIdx(); //one paxos group can have multi state machine. oSMInfo.vecSMList.push_back(poBenchSM); oOptions.vecGroupSMInfoList.push_back(oSMInfo); } ret = Node::RunNode(oOptions, m_poPaxosNode); if (ret != 0) { printf("run paxos fail, ret %d\n", ret); return ret; } printf("run paxos ok\n"); return 0; }