本文整理汇总了C++中PaxosMsg::proposalnodeid方法的典型用法代码示例。如果您正苦于以下问题:C++ PaxosMsg::proposalnodeid方法的具体用法?C++ PaxosMsg::proposalnodeid怎么用?C++ PaxosMsg::proposalnodeid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PaxosMsg
的用法示例。
在下文中一共展示了PaxosMsg::proposalnodeid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: oBallot
void Learner :: OnAskforLearn(const PaxosMsg & oPaxosMsg)
{
BP->GetLearnerBP()->OnAskforLearn();
PLGHead("START Msg.InstanceID %lu Now.InstanceID %lu Msg.from_nodeid %lu MinChosenInstanceID %lu",
oPaxosMsg.instanceid(), GetInstanceID(), oPaxosMsg.nodeid(),
m_poCheckpointMgr->GetMinChosenInstanceID());
SetSeenInstanceID(oPaxosMsg.instanceid(), oPaxosMsg.nodeid());
if (oPaxosMsg.proposalnodeid() == m_poConfig->GetMyNodeID())
{
//Found a node follow me.
PLImp("Found a node %lu follow me.", oPaxosMsg.nodeid());
m_poConfig->AddFollowerNode(oPaxosMsg.nodeid());
}
if (oPaxosMsg.instanceid() >= GetInstanceID())
{
return;
}
if (oPaxosMsg.instanceid() >= m_poCheckpointMgr->GetMinChosenInstanceID())
{
if (!m_oLearnerSender.Prepare(oPaxosMsg.instanceid(), oPaxosMsg.nodeid()))
{
BP->GetLearnerBP()->OnAskforLearnGetLockFail();
PLGErr("LearnerSender working for others.");
if (oPaxosMsg.instanceid() == (GetInstanceID() - 1))
{
PLGImp("InstanceID only difference one, just send this value to other.");
//send one value
AcceptorStateData oState;
int ret = m_oPaxosLog.ReadState(m_poConfig->GetMyGroupIdx(), oPaxosMsg.instanceid(), oState);
if (ret == 0)
{
BallotNumber oBallot(oState.acceptedid(), oState.acceptednodeid());
SendLearnValue(oPaxosMsg.nodeid(), oPaxosMsg.instanceid(), oBallot, oState.acceptedvalue(), 0);
}
}
return;
}
}
SendNowInstanceID(oPaxosMsg.instanceid(), oPaxosMsg.nodeid());
}
示例2: if
void Learner :: OnSendLearnValue(const PaxosMsg & oPaxosMsg)
{
BP->GetLearnerBP()->OnSendLearnValue();
PLGHead("START Msg.InstanceID %lu Now.InstanceID %lu Msg.ballot_proposalid %lu Msg.ballot_nodeid %lu Msg.ValueSize %zu",
oPaxosMsg.instanceid(), GetInstanceID(), oPaxosMsg.proposalid(),
oPaxosMsg.nodeid(), oPaxosMsg.value().size());
if (oPaxosMsg.instanceid() > GetInstanceID())
{
PLGDebug("[Latest Msg] i can't learn");
return;
}
else if (oPaxosMsg.instanceid() < GetInstanceID())
{
PLGDebug("[Lag Msg] no need to learn");
return;
}
//learn value
BallotNumber oBallot(oPaxosMsg.proposalid(), oPaxosMsg.proposalnodeid());
int ret = m_oLearnerState.LearnValue(oPaxosMsg.instanceid(), oBallot, oPaxosMsg.value(), GetLastChecksum());
if (ret != 0)
{
PLGErr("LearnState.LearnValue fail, ret %d", ret);
return;
}
PLGHead("END LearnValue OK, proposalid %lu proposalid_nodeid %lu valueLen %zu",
oPaxosMsg.proposalid(), oPaxosMsg.nodeid(), oPaxosMsg.value().size());
if (oPaxosMsg.flag() == PaxosMsgFlagType_SendLearnValue_NeedAck)
{
//every time' when receive valid need ack learn value, reset noop timeout.
Reset_AskforLearn_Noop();
SendLearnValue_Ack(oPaxosMsg.nodeid());
}
}