本文整理汇总了C++中AdminPrx::enableServer方法的典型用法代码示例。如果您正苦于以下问题:C++ AdminPrx::enableServer方法的具体用法?C++ AdminPrx::enableServer怎么用?C++ AdminPrx::enableServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdminPrx
的用法示例。
在下文中一共展示了AdminPrx::enableServer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: catch
void
removeServer(const AdminPrx& admin, const string& id)
{
try
{
admin->enableServer(id, false); // Makes sure the server isn't activated on-demand after the stop.
admin->stopServer(id);
}
catch(const ServerStopException&)
{
}
catch(const NodeUnreachableException&)
{
}
catch(const Ice::UserException& ex)
{
cerr << ex << endl;
test(false);
}
ServerInfo info = admin->getServerInfo(id);
NodeUpdateDescriptor nodeUpdate;
nodeUpdate.name = info.node;
nodeUpdate.removeServers.push_back(id);
ApplicationUpdateDescriptor update;
update.name = info.application;
update.nodes.push_back(nodeUpdate);
try
{
admin->updateApplication(update);
}
catch(const DeploymentException& ex)
{
cerr << ex.reason << endl;
test(false);
}
}
示例2: test
//.........这里部分代码省略.........
{
session2->allocateObjectByType("::TestBis");
test(false);
}
catch(const AllocationTimeoutException&)
{
}
session1->releaseObject(allocatablebis);
session2->allocateObjectByType("::TestBis");
try
{
session1->allocateObjectByType("::TestBis");
test(false);
}
catch(const AllocationTimeoutException&)
{
}
session2->releaseObject(allocatablebis);
session1->setAllocationTimeout(allocationTimeout);
CallbackPtr asyncCB3 = new Callback();
IceGrid::Callback_Session_allocateObjectByTypePtr cb3 =
IceGrid::newCallback_Session_allocateObjectByType(asyncCB3, &Callback::response, &Callback::exception);
session1->begin_allocateObjectByType("::Test", cb3);
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500));
test(!asyncCB3->hasResponse(dummy));
session2->releaseObject(obj->ice_getIdentity());
asyncCB3->waitResponse(__FILE__, __LINE__);
test(asyncCB3->hasResponse(obj));
session1->releaseObject(obj->ice_getIdentity());
admin->enableServer("ObjectAllocation", false);
try
{
while(true)
{
// The notification of the server being disabled is asynchronous and might
// not be visible to the allocation system immediately.
session1->allocateObjectByType("::Test");
session1->releaseObject(obj->ice_getIdentity());
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100));
}
test(false);
}
catch(const AllocationException&)
{
}
admin->enableServer("ObjectAllocation", true);
cout << "ok" << endl;
cout << "testing object allocation timeout... " << flush;
session1->allocateObjectById(allocatable);
IceUtil::Time time = IceUtil::Time::now();
session2->setAllocationTimeout(500);
try
{
session2->allocateObjectById(allocatable);
test(false);
}
catch(const AllocationTimeoutException&)
{
test(time + IceUtil::Time::milliSeconds(100) < IceUtil::Time::now());
示例3: 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);
}
//.........这里部分代码省略.........