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


C++ TestIntfPrx::getAdapterId方法代码示例

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


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

示例1: catch


//.........这里部分代码省略.........
    {
        proxies[0]->activateObjectAdapter("oa", "oa1", "");
        proxies[1]->activateObjectAdapter("oa", "oa2", "");

        proxies[0]->addObject("oa", "object");
        communicator->stringToProxy("object @ oa1")->ice_ping();
        communicator->stringToProxy("object")->ice_ping();
        proxies[0]->removeObject("oa", "object");

        proxies[1]->addObject("oa", "object");
        communicator->stringToProxy("object @ oa2")->ice_ping();
        communicator->stringToProxy("object")->ice_ping();
        proxies[1]->removeObject("oa", "object");

        try
        {
            communicator->stringToProxy("object @ oa1")->ice_ping();
        }
        catch(const Ice::ObjectNotExistException&)
        {
        }
        try
        {
            communicator->stringToProxy("object @ oa2")->ice_ping();
        }
        catch(const Ice::ObjectNotExistException&)
        {
        }

        proxies[0]->deactivateObjectAdapter("oa");
        proxies[1]->deactivateObjectAdapter("oa");
    }
    cout << "ok" << endl;

    cout << "testing replica groups..." << flush;
    {
        proxies[0]->activateObjectAdapter("oa", "oa1", "rg");
        proxies[1]->activateObjectAdapter("oa", "oa2", "rg");
        proxies[2]->activateObjectAdapter("oa", "oa3", "rg");

        proxies[0]->addObject("oa", "object");
        proxies[1]->addObject("oa", "object");
        proxies[2]->addObject("oa", "object");

        communicator->stringToProxy("object @ oa1")->ice_ping();
        communicator->stringToProxy("object @ oa2")->ice_ping();
        communicator->stringToProxy("object @ oa3")->ice_ping();

        communicator->stringToProxy("object @ rg")->ice_ping();

        set<string> adapterIds;
        adapterIds.insert("oa1");
        adapterIds.insert("oa2");
        adapterIds.insert("oa3");
        TestIntfPrx intf = TestIntfPrx::uncheckedCast(communicator->stringToProxy("object"));
        intf = intf->ice_connectionCached(false)->ice_locatorCacheTimeout(0);
        while(!adapterIds.empty())
        {
            adapterIds.erase(intf->getAdapterId());
        }

        while(true)
        {
            adapterIds.insert("oa1");
            adapterIds.insert("oa2");
            adapterIds.insert("oa3");
            intf = TestIntfPrx::uncheckedCast(communicator->stringToProxy("object @ rg"))->ice_connectionCached(false);
            int nRetry = 100;
            while(!adapterIds.empty() && --nRetry > 0)
            {
                adapterIds.erase(intf->getAdapterId());
            }
            if(nRetry > 0)
            {
                break;
            }

            // The previous locator lookup probably didn't return all the replicas... try again.
            communicator->stringToProxy("object @ rg")->ice_locatorCacheTimeout(0)->ice_ping();
        }

        proxies[0]->deactivateObjectAdapter("oa");
        proxies[1]->deactivateObjectAdapter("oa");
        test(TestIntfPrx::uncheckedCast(communicator->stringToProxy("object @ rg"))->getAdapterId() == "oa3");
        proxies[2]->deactivateObjectAdapter("oa");

        proxies[0]->activateObjectAdapter("oa", "oa1", "rg");
        proxies[0]->addObject("oa", "object");
        test(TestIntfPrx::uncheckedCast(communicator->stringToProxy("object @ rg"))->getAdapterId() == "oa1");
        proxies[0]->deactivateObjectAdapter("oa");
    }
    cout << "ok" << endl;

    cout << "shutting down... " << flush;
    for(vector<ControllerPrx>::const_iterator p = proxies.begin(); p != proxies.end(); ++p)
    {
        (*p)->shutdown();
    }
    cout << "ok" << endl;
}
开发者ID:Jonavin,项目名称:ice,代码行数:101,代码来源:AllTests.cpp


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