当前位置: 首页>>代码示例>>C++>>正文


C++ NodeInfoList::push_back方法代码示例

本文整理汇总了C++中NodeInfoList::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeInfoList::push_back方法的具体用法?C++ NodeInfoList::push_back怎么用?C++ NodeInfoList::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NodeInfoList的用法示例。


在下文中一共展示了NodeInfoList::push_back方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ProposalMembership

int PNode :: AddMember(const int iGroupIdx, const NodeInfo & oNode)
{
    if (!CheckGroupID(iGroupIdx))
    {
        return Paxos_GroupIdxWrong;
    }

    SystemVSM * poSystemVSM = m_vecGroupList[iGroupIdx]->GetConfig()->GetSystemVSM();

    if (poSystemVSM->GetGid() == 0)
    {
        return Paxos_MembershipOp_NoGid;
    }

    uint64_t llVersion = 0;
    NodeInfoList vecNodeInfoList;
    poSystemVSM->GetMembership(vecNodeInfoList, llVersion);

    for (auto & oNodeInfo : vecNodeInfoList)
    {
        if (oNodeInfo.GetNodeID() == oNode.GetNodeID())
        {
            return Paxos_MembershipOp_Add_NodeExist;
        }
    }

    vecNodeInfoList.push_back(oNode);

    return ProposalMembership(poSystemVSM, iGroupIdx, vecNodeInfoList, llVersion);
}
开发者ID:chaozh,项目名称:phxpaxos,代码行数:30,代码来源:pnode.cpp

示例2: MakeConfig

void MakeConfig(MockLogStorage * poMockLogStorage, Config *& poConfig)
{
    string sIP = "127.0.0.1";
    int iPort = 11111;

    NodeInfo oMyNode(sIP, iPort);
    NodeInfoList vecNodeInfoList;

    for (int i = 0; i < 3; i++)
    {
        vecNodeInfoList.push_back(NodeInfo(sIP, iPort));
        iPort++;
    }

    FollowerNodeInfoList vecFollowerNodeInfoList;

    int iMyGroupIdx = 0;
    int iGroupCount = 1;

    poConfig = nullptr;
    poConfig = new Config(poMockLogStorage, true, 0, false, oMyNode, vecNodeInfoList, vecFollowerNodeInfoList, iMyGroupIdx, iGroupCount, nullptr);
    assert(poConfig != nullptr);

    EXPECT_CALL(*poMockLogStorage, GetSystemVariables(_,_)).Times(1).WillOnce(Return(1));

    poConfig->Init();
}
开发者ID:LngMH,项目名称:phxpaxos,代码行数:27,代码来源:make_class.cpp

示例3: parse_ipport_list

int parse_ipport_list(const char * pcStr, NodeInfoList & vecNodeInfoList)
{
    string sTmpStr;
    int iStrLen = strlen(pcStr);

    for (int i = 0; i < iStrLen; i++)
    {
        if (pcStr[i] == ',' || i == iStrLen - 1)
        {
            if (i == iStrLen - 1 && pcStr[i] != ',')
            {
                sTmpStr += pcStr[i];
            }
            
            NodeInfo oNodeInfo;
            int ret = parse_ipport(sTmpStr.c_str(), oNodeInfo);
            if (ret != 0)
            {
                return ret;
            }

            vecNodeInfoList.push_back(oNodeInfo);

            sTmpStr = "";
        }
        else
        {
            sTmpStr += pcStr[i];
        }
    }

    return 0;
}
开发者ID:BLiYing,项目名称:phxpaxos,代码行数:33,代码来源:bench_main.cpp

示例4: if

int PNode :: ChangeMember(const int iGroupIdx, const NodeInfo & oFromNode, const NodeInfo & oToNode)
{
    if (!CheckGroupID(iGroupIdx))
    {
        return Paxos_GroupIdxWrong;
    }

    SystemVSM * poSystemVSM = m_vecGroupList[iGroupIdx]->GetConfig()->GetSystemVSM();

    if (poSystemVSM->GetGid() == 0)
    {
        return Paxos_MembershipOp_NoGid;
    }

    uint64_t llVersion = 0;
    NodeInfoList vecNodeInfoList;
    poSystemVSM->GetMembership(vecNodeInfoList, llVersion);

    NodeInfoList vecAfterNodeInfoList;
    bool bFromNodeExist = false;
    bool bToNodeExist = false;
    for (auto & oNodeInfo : vecNodeInfoList)
    {
        if (oNodeInfo.GetNodeID() == oFromNode.GetNodeID())
        {
            bFromNodeExist = true;
            continue;
        }
        else if (oNodeInfo.GetNodeID() == oToNode.GetNodeID())
        {
            bToNodeExist = true;
            continue;
        }

        vecAfterNodeInfoList.push_back(oNodeInfo);
    }

    if ((!bFromNodeExist) && bToNodeExist)
    {
        return Paxos_MembershipOp_Change_NoChange;
    }

    vecAfterNodeInfoList.push_back(oToNode);

    return ProposalMembership(poSystemVSM, iGroupIdx, vecAfterNodeInfoList, llVersion);
}
开发者ID:chaozh,项目名称:phxpaxos,代码行数:46,代码来源:pnode.cpp

示例5: tTmpNode

void SystemVSM :: GetMembership(NodeInfoList & vecNodeInfoList, uint64_t & llVersion)
{
    //must must get version first!
    llVersion = m_oSystemVariables.version();

    for (int i = 0; i < m_oSystemVariables.membership_size(); i++)
    {
        PaxosNodeInfo oNodeInfo = m_oSystemVariables.membership(i);

        NodeInfo tTmpNode(oNodeInfo.nodeid());
        vecNodeInfoList.push_back(tTmpNode);
    }
}
开发者ID:chaozh,项目名称:phxpaxos,代码行数:13,代码来源:system_v_sm.cpp


注:本文中的NodeInfoList::push_back方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。