void MasterStateMachine :: BeforePropose(const int iGroupIdx, std::string & sValue) { std::lock_guard<std::mutex> oLockGuard(m_oMutex); MasterOperator oMasterOper; bool bSucc = oMasterOper.ParseFromArray(sValue.data(), sValue.size()); if (!bSucc) { return; } oMasterOper.set_lastversion(m_llMasterVersion); sValue.clear(); bSucc = oMasterOper.SerializeToString(&sValue); assert(bSucc == true); }
bool MasterStateMachine :: MakeOpValue( const nodeid_t iNodeID, const uint64_t llVersion, const int iTimeout, const MasterOperatorType iOp, std::string & sPaxosValue) { MasterOperator oMasterOper; oMasterOper.set_nodeid(iNodeID); oMasterOper.set_version(llVersion); oMasterOper.set_timeout(iTimeout); oMasterOper.set_operator_(iOp); oMasterOper.set_sid(OtherUtils::FastRand()); return oMasterOper.SerializeToString(&sPaxosValue); }