本文整理汇总了C++中PaxosMsg::set_rejectbypromiseid方法的典型用法代码示例。如果您正苦于以下问题:C++ PaxosMsg::set_rejectbypromiseid方法的具体用法?C++ PaxosMsg::set_rejectbypromiseid怎么用?C++ PaxosMsg::set_rejectbypromiseid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PaxosMsg
的用法示例。
在下文中一共展示了PaxosMsg::set_rejectbypromiseid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AcceptNotPass
TEST(Proposer, OnAcceptReply_Reject)
{
ProposerBuilder ob;
MockProposerBP & oProposerBP = ob.oMockBreakpoint.m_oMockProposerBP;
ob.poProposer->m_oProposerState.m_llProposalID = 100;
ob.poProposer->m_bIsAccepting = true;
ob.poProposer->m_oProposerState.m_sValue = "abc";
PaxosMsg oPaxosMsg;
oPaxosMsg.set_proposalid(100);
//first call
oPaxosMsg.set_rejectbypromiseid(101);
oPaxosMsg.set_nodeid(2);
ob.poProposer->OnAcceptReply(oPaxosMsg);
EXPECT_TRUE(ob.poProposer->m_bWasRejectBySomeone == true);
//second call
oPaxosMsg.set_rejectbypromiseid(0);
oPaxosMsg.set_nodeid(GetMyNode().GetNodeID());
ob.poProposer->OnAcceptReply(oPaxosMsg);
//third call
oPaxosMsg.set_rejectbypromiseid(102);
oPaxosMsg.set_nodeid(3);
EXPECT_CALL(oProposerBP, AcceptNotPass()).Times(1);
ob.poProposer->OnAcceptReply(oPaxosMsg);
EXPECT_TRUE(ob.poProposer->m_bCanSkipPrepare == false);
EXPECT_TRUE(ob.poProposer->m_oProposerState.m_sValue == "abc");
}
示例2: PreparePass
TEST(Proposer, OnPrepareReply_Pass)
{
ProposerBuilder ob;
MockProposerBP & oProposerBP = ob.oMockBreakpoint.m_oMockProposerBP;
ob.poProposer->m_oProposerState.m_llProposalID = 100;
ob.poProposer->m_bIsPreparing = true;
ob.poProposer->m_oProposerState.m_sValue = "abc";
PaxosMsg oPaxosMsg;
oPaxosMsg.set_proposalid(100);
//first call
oPaxosMsg.set_preacceptid(95);
oPaxosMsg.set_preacceptnodeid(GetMyNode().GetNodeID());
oPaxosMsg.set_nodeid(GetMyNode().GetNodeID());
oPaxosMsg.set_value("hello paxos");
ob.poProposer->OnPrepareReply(oPaxosMsg);
EXPECT_TRUE(ob.poProposer->m_oProposerState.m_sValue == "hello paxos");
//second call
oPaxosMsg.set_rejectbypromiseid(101);
oPaxosMsg.set_nodeid(2);
ob.poProposer->OnPrepareReply(oPaxosMsg);
//third call
oPaxosMsg.set_rejectbypromiseid(0);
oPaxosMsg.set_preacceptid(98);
oPaxosMsg.set_preacceptnodeid(3);
oPaxosMsg.set_nodeid(3);
oPaxosMsg.set_value("hello world");
EXPECT_CALL(oProposerBP, PreparePass(_)).Times(1);
ob.poProposer->OnPrepareReply(oPaxosMsg);
EXPECT_TRUE(ob.poProposer->m_bCanSkipPrepare == true);
EXPECT_TRUE(ob.poProposer->m_bIsAccepting == true);
EXPECT_TRUE(ob.poProposer->m_oProposerState.m_sValue == "hello world");
}