本文整理汇总了C++中TestIntfPrx::getReplicaIdAndShutdown方法的典型用法代码示例。如果您正苦于以下问题:C++ TestIntfPrx::getReplicaIdAndShutdown方法的具体用法?C++ TestIntfPrx::getReplicaIdAndShutdown怎么用?C++ TestIntfPrx::getReplicaIdAndShutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestIntfPrx
的用法示例。
在下文中一共展示了TestIntfPrx::getReplicaIdAndShutdown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
//.........这里部分代码省略.........