本文整理汇总了C++中TestIntfPrx::ice_connectionCached方法的典型用法代码示例。如果您正苦于以下问题:C++ TestIntfPrx::ice_connectionCached方法的具体用法?C++ TestIntfPrx::ice_connectionCached怎么用?C++ TestIntfPrx::ice_connectionCached使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestIntfPrx
的用法示例。
在下文中一共展示了TestIntfPrx::ice_connectionCached方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: test
void
allTests(const Ice::CommunicatorPtr& comm)
{
IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(
comm->stringToProxy(comm->getDefaultLocator()->ice_getIdentity().category + "/Registry"));
test(registry);
IceGrid::QueryPrx query = IceGrid::QueryPrx::checkedCast(
comm->stringToProxy(comm->getDefaultLocator()->ice_getIdentity().category + "/Query"));
test(query);
AdminSessionPrx session = registry->createAdminSession("foo", "bar");
session->ice_getConnection()->setACM(registry->getACMTimeout(), IceUtil::None, Ice::HeartbeatAlways);
AdminPrx admin = session->getAdmin();
test(admin);
set<string> serverReplicaIds;
serverReplicaIds.insert("Server1.ReplicatedAdapter");
serverReplicaIds.insert("Server2.ReplicatedAdapter");
serverReplicaIds.insert("Server3.ReplicatedAdapter");
set<string> svcReplicaIds;
svcReplicaIds.insert("IceBox1.Service1.Service1");
svcReplicaIds.insert("IceBox1.Service2.Service2");
svcReplicaIds.insert("IceBox1.Service3.Service3");
cout << "testing Query::findAllReplicas... " << flush;
{
map<string, string> params;
params["replicaGroup"] = "RoundRobin";
params["id"] = "Server1";
instantiateServer(admin, "Server", "localnode", params);
params["id"] = "Server2";
instantiateServer(admin, "Server", "localnode", params);
params["id"] = "Server3";
instantiateServer(admin, "Server", "localnode", params);
TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("[email protected]"));
Ice::ObjectProxySeq objs = query->findAllReplicas(obj);
test(objs.size() == 3);
test(serverReplicaIds.find(objs[0]->ice_getAdapterId()) != serverReplicaIds.end());
test(serverReplicaIds.find(objs[1]->ice_getAdapterId()) != serverReplicaIds.end());
test(serverReplicaIds.find(objs[2]->ice_getAdapterId()) != serverReplicaIds.end());
obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin"));
objs = query->findAllReplicas(obj);
test(objs.size() == 3);
test(serverReplicaIds.find(objs[0]->ice_getAdapterId()) != serverReplicaIds.end());
test(serverReplicaIds.find(objs[1]->ice_getAdapterId()) != serverReplicaIds.end());
test(serverReplicaIds.find(objs[2]->ice_getAdapterId()) != serverReplicaIds.end());
obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("[email protected]"));
objs = query->findAllReplicas(obj);
test(objs.empty());
obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("[email protected]"));
objs = query->findAllReplicas(obj);
test(objs.empty());
obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("dummy:tcp"));
objs = query->findAllReplicas(obj);
test(objs.empty());
obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("[email protected]"));
objs = query->findAllReplicas(obj);
test(objs.empty());
removeServer(admin, "Server1");
removeServer(admin, "Server2");
removeServer(admin, "Server3");
}
cout << "ok" << endl;
cout << "testing replication with round-robin load balancing... " << flush;
{
map<string, string> params;
params["replicaGroup"] = "RoundRobin";
params["id"] = "Server1";
instantiateServer(admin, "Server", "localnode", params);
params["id"] = "Server2";
instantiateServer(admin, "Server", "localnode", params);
params["id"] = "Server3";
instantiateServer(admin, "Server", "localnode", params);
TestIntfPrx obj = TestIntfPrx::uncheckedCast(comm->stringToProxy("RoundRobin"));
obj = TestIntfPrx::uncheckedCast(obj->ice_locatorCacheTimeout(0));
obj = TestIntfPrx::uncheckedCast(obj->ice_connectionCached(false));
try
{
test(obj->getReplicaIdAndShutdown() == "Server1.ReplicatedAdapter");
test(obj->getReplicaIdAndShutdown() == "Server2.ReplicatedAdapter");
test(obj->getReplicaIdAndShutdown() == "Server3.ReplicatedAdapter");
admin->enableServer("Server1", false);
admin->enableServer("Server2", false);
admin->enableServer("Server3", false);
try
{
obj->getReplicaId();
test(false);
}
//.........这里部分代码省略.........