void allTests(const Ice::CommunicatorPtr& communicator) { IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(communicator->stringToProxy("IceGrid/Registry")); test(registry); IceGrid::AdminSessionPrx session = registry->createAdminSession("foo", "bar"); SessionKeepAliveThreadPtr keepAlive = new SessionKeepAliveThread(session, registry->getSessionTimeout()/2); keepAlive->start(); IceGrid::AdminPrx admin = session->getAdmin(); test(admin); admin->startServer("node-1"); admin->startServer("node-2"); int nRetry = 0; while(!admin->pingNode("node-1") && nRetry < 15) { IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); ++nRetry; } nRetry = 0; while(!admin->pingNode("node-2") && nRetry < 15) { IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); ++nRetry; } cout << "testing on-demand activation... " << flush; try { test(admin->getServerState("server") == IceGrid::Inactive); TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server")); waitForServerState(admin, "server", IceGrid::Active); obj->shutdown(); waitForServerState(admin, "server", IceGrid::Inactive); nRetry = 4; while(--nRetry > 0) { obj->shutdown(); } waitForServerState(admin, "server", IceGrid::Inactive); } catch(const Ice::LocalException& ex) { cerr << ex << endl; test(false); } cout << "ok" << endl; cout << "testing manual activation... " << flush; try { test(admin->getServerState("server-manual") == IceGrid::Inactive); TestIntfPrx obj; try { obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-manual")); test(false); } catch(const Ice::NoEndpointException&) { } test(admin->getServerState("server-manual") == IceGrid::Inactive); admin->startServer("server-manual"); test(admin->getServerState("server-manual") == IceGrid::Active); obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-manual")); test(admin->getServerState("server-manual") == IceGrid::Active); obj->shutdown(); waitForServerState(admin, "server-manual", IceGrid::Inactive); } catch(const Ice::LocalException& ex) { cerr << ex << endl; test(false); } cout << "ok" << endl; cout << "testing always activation... " << flush; try { waitForServerState(admin, "server-always", IceGrid::Active); TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server-always")); admin->stopServer("server-always"); waitForServerState(admin, "server-always", IceGrid::Active); obj->shutdown(); waitForServerState(admin, "server-always", IceGrid::Active); nRetry = 4; while(--nRetry > 0) { obj->shutdown(); } waitForServerState(admin, "server-always", IceGrid::Active); } catch(const Ice::LocalException& ex) { cerr << ex << endl; test(false); } cout << "ok" << endl; cout << "testing session activation... " << flush; try { IceGrid::SessionPrx session = registry->createSession("test", ""); test(admin->getServerState("server-session") == IceGrid::Inactive); TestIntfPrx obj = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-session")); try { obj->ice_ping(); test(false); } catch(const Ice::NoEndpointException&) { } session->allocateObjectById(obj->ice_getIdentity()); obj->ice_ping(); waitForServerState(admin, "server-session", IceGrid::Active); obj->shutdown(); waitForServerState(admin, "server-session", IceGrid::Inactive); obj->ice_ping(); waitForServerState(admin, "server-session", IceGrid::Active); nRetry = 4; while(--nRetry > 0) { obj->shutdown(); } obj->ice_ping(); waitForServerState(admin, "server-session", IceGrid::Active); session->releaseObject(obj->ice_getIdentity()); try { obj->ice_ping(); test(false); } catch(const Ice::NoEndpointException&) { } waitForServerState(admin, "server-session", IceGrid::Inactive); session->allocateObjectById(obj->ice_getIdentity()); obj->ice_ping(); waitForServerState(admin, "server-session", IceGrid::Active); session->destroy(); try { obj->ice_ping(); test(false); } catch(const Ice::NoEndpointException&) { } waitForServerState(admin, "server-session", IceGrid::Inactive); } catch(const Ice::LocalException& ex) { cerr << ex << endl; test(false); } cout << "ok" << endl; cout << "testing server disable... " << flush; try { test(admin->getServerState("server") == IceGrid::Inactive); admin->enableServer("server", false); try { communicator->stringToProxy("server")->ice_ping(); test(false); } catch(const Ice::NoEndpointException&) { } try { admin->startServer("server"); test(false); } catch(const IceGrid::ServerStartException&) { } test(admin->getServerState("server") == IceGrid::Inactive); test(admin->getServerState("server-manual") == IceGrid::Inactive); admin->enableServer("server-manual", false); try { communicator->stringToProxy("server-manual")->ice_ping(); test(false); } catch(const Ice::NoEndpointException&) { } try { admin->startServer("server-manual"); test(false); } catch(const IceGrid::ServerStartException&) { } test(admin->getServerState("server-manual") == IceGrid::Inactive); test(admin->getServerState("server-always") == IceGrid::Active); admin->enableServer("server-always", false); admin->stopServer("server-always"); test(admin->getServerState("server-always") == IceGrid::Inactive); try { communicator->stringToProxy("server-always")->ice_ping(); test(false); } catch(const Ice::NoEndpointException&) { } try { admin->startServer("server-always"); test(false); } catch(const IceGrid::ServerStartException&) { } test(admin->getServerState("server-always") == IceGrid::Inactive); } catch(const Ice::LocalException& ex) { cerr << ex << endl; test(false); } cout << "ok" << endl; cout << "testing server enable... " << flush; try { test(admin->getServerState("server") == IceGrid::Inactive); admin->enableServer("server", true); communicator->stringToProxy("server")->ice_ping(); admin->stopServer("server"); test(admin->getServerState("server") == IceGrid::Inactive); admin->startServer("server"); test(admin->getServerState("server") == IceGrid::Active); admin->stopServer("server"); test(admin->getServerState("server") == IceGrid::Inactive); test(admin->getServerState("server-manual") == IceGrid::Inactive); admin->enableServer("server-manual", true); try { communicator->stringToProxy("server-manual")->ice_ping(); test(false); } catch(const Ice::NoEndpointException&) { } test(admin->getServerState("server-manual") == IceGrid::Inactive); admin->startServer("server-manual"); test(admin->getServerState("server-manual") == IceGrid::Active); admin->stopServer("server-manual"); test(admin->getServerState("server-manual") == IceGrid::Inactive); test(admin->getServerState("server-always") == IceGrid::Inactive); admin->enableServer("server-always", true); waitForServerState(admin, "server-always", IceGrid::Active); admin->stopServer("server-always"); try { admin->startServer("server-always"); // test(false); } catch(const IceGrid::ServerStartException&) { } test(admin->getServerState("server-always") == IceGrid::Active); } catch(const Ice::LocalException& ex) { cerr << ex << endl; test(false); } cout << "ok" << endl; cout << "testing activation failure... " << flush; try { int i; const int nThreads = 3; Ice::ObjectPrx invalid = communicator->stringToProxy("invalid-exe"); vector<PingThreadPtr> threads; threads.reserve(nThreads); vector<PingThreadPtr>::const_iterator p; for(i = 0; i < nThreads; i++) { threads.push_back(new PingThread(invalid, 10)); } for(p = threads.begin(); p != threads.end(); ++p) { (*p)->start(); } for(p = threads.begin(); p != threads.end(); ++p) { auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); } threads.resize(0); invalid = communicator->stringToProxy("invalid-pwd"); for(i = 0; i < nThreads; i++) { threads.push_back(new PingThread(invalid, 10)); } for(p = threads.begin(); p != threads.end(); ++p) { (*p)->start(); } for(p = threads.begin(); p != threads.end(); ++p) { auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); } threads.resize(0); invalid = communicator->stringToProxy("fail-on-startup"); for(i = 0; i < nThreads; i++) { threads.push_back(new PingThread(invalid, 5)); } for(p = threads.begin(); p != threads.end(); ++p) { (*p)->start(); } for(p = threads.begin(); p != threads.end(); ++p) { auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); } threads.resize(0); } catch(const Ice::LocalException& ex) { cerr << ex << endl; test(false); } cout << "ok" << endl; cout << "testing activation timeout... " << flush; try { test(admin->getServerState("server-activation-timeout") == IceGrid::Inactive); const int nThreads = 5; Ice::ObjectPrx proxy = communicator->stringToProxy("server-activation-timeout"); vector<PingThreadPtr> threads; threads.reserve(nThreads); vector<PingThreadPtr>::const_iterator p; int i; for(i = 0; i < nThreads; i++) { threads.push_back(new PingThread(proxy, 1)); } for(p = threads.begin(); p != threads.end(); ++p) { (*p)->start(); } for(p = threads.begin(); p != threads.end(); ++p) { auto_ptr<Ice::LocalException> ex((*p)->waitUntilFinished()); test(dynamic_cast<Ice::NoEndpointException*>(ex.get())); } admin->stopServer("server-activation-timeout"); } catch(const IceGrid::ServerStopException& ex) { cerr << ex << ": " << ex.reason << endl; test(false); } catch(const Ice::LocalException& ex) { cerr << ex << endl; test(false); } cout << "ok" << endl; cout << "testing deactivation timeout... " << flush; try { test(admin->getServerState("server-deactivation-timeout") == IceGrid::Inactive); communicator->stringToProxy("server-deactivation-timeout")->ice_ping(); admin->stopServer("server-deactivation-timeout"); } catch(const Ice::LocalException& ex) { cerr << ex << endl; test(false); } cout << "ok" << endl; cout << "testing permanent disable on failure... " << flush; try { test(admin->getServerState("server1") == IceGrid::Inactive); TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server1")); waitForServerState(admin, "server1", IceGrid::Active); obj->fail(); waitForServerState(admin, "server1", IceGrid::Inactive); try { obj->ice_ping(); test(false); } catch(const Ice::NoEndpointException&) { } test(!admin->isServerEnabled("server1")); test(admin->getServerState("server1-manual") == IceGrid::Inactive); admin->startServer("server1-manual"); test(admin->getServerState("server1-manual") == IceGrid::Active); obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server1-manual")); test(admin->getServerState("server1-manual") == IceGrid::Active); obj->fail(); waitForServerState(admin, "server1-manual", IceGrid::Inactive); test(!admin->isServerEnabled("server1-manual")); test(admin->getServerState("server1-always") == IceGrid::Active); obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server1-always")); obj->fail(); waitForServerState(admin, "server1-always", IceGrid::Inactive); test(!admin->isServerEnabled("server1-always")); } catch(const Ice::LocalException& ex) { cerr << ex << endl; test(false); } cout << "ok" << endl; cout << "testing temporary disable on failure... " << flush; try { test(admin->getServerState("server2") == IceGrid::Inactive); TestIntfPrx obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server2")); waitForServerState(admin, "server2", IceGrid::Active); obj->fail(); waitForServerState(admin, "server2", IceGrid::Inactive); try { obj->ice_ping(); test(false); } catch(const Ice::NoEndpointException&) { } test(!admin->isServerEnabled("server2")); nRetry = 0; while(!admin->isServerEnabled("server2") && nRetry < 15) { IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); ++nRetry; try { obj->ice_ping(); } catch(const Ice::NoEndpointException&) { } } test(admin->isServerEnabled("server2")); waitForServerState(admin, "server2", IceGrid::Active); obj->ice_ping(); admin->stopServer("server2"); test(admin->getServerState("server2-manual") == IceGrid::Inactive); admin->startServer("server2-manual"); test(admin->getServerState("server2-manual") == IceGrid::Active); obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server2-manual")); obj->fail(); waitForServerState(admin, "server2-manual", IceGrid::Inactive); test(!admin->isServerEnabled("server2-manual")); admin->startServer("server2-manual"); test(admin->isServerEnabled("server2-manual")); test(admin->getServerState("server2-manual") == IceGrid::Active); admin->stopServer("server2-manual"); test(admin->getServerState("server2-always") == IceGrid::Active); obj = TestIntfPrx::checkedCast(communicator->stringToProxy("server2-always")); obj->fail(); waitForServerState(admin, "server2-always", IceGrid::Inactive); test(!admin->isServerEnabled("server2-always")); nRetry = 0; while((!admin->isServerEnabled("server2-always") || admin->getServerState("server2-always") != IceGrid::Active) && nRetry < 15) { IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); ++nRetry; } test(admin->isServerEnabled("server2-always") && admin->getServerState("server2-always") == IceGrid::Active); obj->ice_ping(); } catch(const Ice::LocalException& ex) { cerr << ex << endl; test(false); } cout << "ok" << endl; admin->stopServer("node-1"); admin->stopServer("node-2"); keepAlive->destroy(); keepAlive->getThreadControl().join(); keepAlive = 0; session->destroy(); }
void allTests(const Ice::CommunicatorPtr& communicator) { RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(communicator->stringToProxy("IceGrid/Registry")); test(registry); AdminSessionPrx session = registry->createAdminSession("foo", "bar"); SessionKeepAliveThreadPtr keepAlive = new SessionKeepAliveThread(session, registry->getSessionTimeout()/2); keepAlive->start(); AdminPrx admin = session->getAdmin(); test(admin); cout << "testing distributions... " << flush; { admin->startServer("Test.IcePatch2"); admin->startServer("IcePatch2-Direct"); TestIntfPrx test; test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all")); test(test->getServerFile("rootfile") == ""); try { admin->patchServer("server-all", true); } catch(const PatchException& ex) { copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n")); test(false); } test(test->getServerFile("rootfile") == "rootfile"); test(test->getServerFile("dir1/file1") == "dummy-file1"); test(test->getServerFile("dir1/file2") == "dummy-file2"); test(test->getServerFile("dir2/file3") == "dummy-file3"); test(test->getApplicationFile("rootfile") == ""); test(test->getApplicationFile("dir1/file1") == ""); test(test->getApplicationFile("dir1/file2") == ""); test(test->getApplicationFile("dir2/file3") == "dummy-file3"); test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all-direct")); test(test->getServerFile("rootfile") == ""); test(test->getServerFile("dir1/file1") == ""); test(test->getServerFile("dir1/file2") == ""); test(test->getServerFile("dir2/file3") == ""); test(test->getApplicationFile("rootfile") == ""); test(test->getApplicationFile("dir1/file1") == ""); test(test->getApplicationFile("dir1/file2") == ""); test(test->getApplicationFile("dir2/file3") == "dummy-file3"); try { admin->patchServer("server-all-direct", true); } catch(const PatchException& ex) { copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n")); test(false); } test(test->getServerFile("rootfile") == "rootfile"); test(test->getServerFile("dir1/file1") == "dummy-file1"); test(test->getServerFile("dir1/file2") == "dummy-file2"); test(test->getServerFile("dir2/file3") == "dummy-file3"); test(test->getApplicationFile("rootfile") == ""); test(test->getApplicationFile("dir1/file1") == ""); test(test->getApplicationFile("dir1/file2") == ""); test(test->getApplicationFile("dir2/file3") == "dummy-file3"); try { admin->patchApplication("Test", true); } catch(const PatchException& ex) { copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n")); test(false); } test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-dir1")); test(test->getServerFile("rootfile") == ""); test(test->getServerFile("dir1/file1") == "dummy-file1"); test(test->getServerFile("dir1/file2") == "dummy-file2"); test(test->getServerFile("dir2/file3") == ""); test(test->getApplicationFile("rootfile") == ""); test(test->getApplicationFile("dir1/file1") == ""); test(test->getApplicationFile("dir1/file2") == ""); test(test->getApplicationFile("dir2/file3") == "dummy-file3"); admin->stopServer("Test.IcePatch2"); admin->stopServer("IcePatch2-Direct"); } cout << "ok" << endl; cout << "testing distributions after update... " << flush; { ApplicationUpdateDescriptor update; update.name = "Test"; update.variables["icepatch.directory"] = "${test.dir}/data/updated"; admin->updateApplication(update); admin->startServer("Test.IcePatch2"); admin->startServer("IcePatch2-Direct"); TestIntfPrx test; test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all")); test(test->getServerFile("rootfile") == "rootfile"); try { admin->patchServer("server-all", true); } catch(const PatchException& ex) { copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n")); test(false); } test(test->getServerFile("rootfile") == "rootfile-updated!"); test(test->getServerFile("dir1/file1") == ""); test(test->getServerFile("dir1/file2") == "dummy-file2-updated!"); test(test->getServerFile("dir2/file3") == "dummy-file3"); test(test->getServerFile("dir2/file4") == "dummy-file4"); test(test->getApplicationFile("rootfile") == ""); test(test->getApplicationFile("dir1/file1") == ""); test(test->getApplicationFile("dir1/file2") == ""); test(test->getApplicationFile("dir2/file3") == "dummy-file3"); test(test->getApplicationFile("dir2/file4") == "dummy-file4"); try { admin->patchServer("server-all-direct", true); } catch(const PatchException& ex) { copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n")); test(false); } test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all-direct")); test(test->getServerFile("rootfile") == "rootfile-updated!"); test(test->getServerFile("dir1/file1") == ""); test(test->getServerFile("dir1/file2") == "dummy-file2-updated!"); test(test->getServerFile("dir2/file3") == "dummy-file3"); test(test->getServerFile("dir2/file4") == "dummy-file4"); test(test->getApplicationFile("rootfile") == ""); test(test->getApplicationFile("dir1/file1") == ""); test(test->getApplicationFile("dir1/file2") == ""); test(test->getApplicationFile("dir2/file3") == "dummy-file3"); test(test->getApplicationFile("dir2/file4") == "dummy-file4"); try { admin->patchApplication("Test", true); } catch(const PatchException& ex) { copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n")); test(false); } test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-dir1")); test(test->getServerFile("rootfile") == ""); test(test->getServerFile("dir1/file1") == ""); test(test->getServerFile("dir1/file2") == "dummy-file2-updated!"); test(test->getServerFile("dir2/file3") == ""); test(test->getServerFile("dir2/file4") == ""); test(test->getApplicationFile("rootfile") == ""); test(test->getApplicationFile("dir1/file1") == ""); test(test->getApplicationFile("dir1/file2") == ""); test(test->getApplicationFile("dir2/file3") == "dummy-file3"); test(test->getApplicationFile("dir2/file4") == "dummy-file4"); admin->stopServer("Test.IcePatch2"); admin->stopServer("IcePatch2-Direct"); } cout << "ok" << endl; cout << "testing application distrib configuration... " << flush; try { ApplicationDescriptor app = admin->getApplicationInfo("Test").descriptor; admin->removeApplication("Test"); app.variables["icepatch.directory"] = "${test.dir}/data/original"; test(app.nodes["localnode"].servers[2]->id == "server-dir1"); app.nodes["localnode"].servers[2]->applicationDistrib = false; admin->addApplication(app); admin->startServer("Test.IcePatch2"); try { admin->patchServer("server-dir1", true); } catch(const PatchException& ex) { copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n")); test(false); } TestIntfPrx test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-dir1")); test(test->getServerFile("rootfile") == ""); test(test->getServerFile("dir1/file1") == "dummy-file1"); test(test->getServerFile("dir1/file2") == "dummy-file2"); test(test->getServerFile("dir2/file3") == ""); test(test->getApplicationFile("rootfile") == ""); test(test->getApplicationFile("dir1/file1") == ""); test(test->getApplicationFile("dir1/file2") == ""); test(test->getApplicationFile("dir2/file3") == ""); admin->removeApplication("Test"); admin->addApplication(app); admin->startServer("Test.IcePatch2"); admin->startServer("IcePatch2-Direct"); try { admin->patchApplication("Test", true); } catch(const PatchException& ex) { copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n")); test(false); } test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-dir1")); test(test->getServerFile("rootfile") == ""); test(test->getServerFile("dir1/file1") == "dummy-file1"); test(test->getServerFile("dir1/file2") == "dummy-file2"); test(test->getServerFile("dir2/file3") == ""); test(test->getApplicationFile("rootfile") == ""); test(test->getApplicationFile("dir1/file1") == ""); test(test->getApplicationFile("dir1/file2") == ""); test(test->getApplicationFile("dir2/file3") == "dummy-file3"); admin->removeApplication("Test"); app.distrib.icepatch = ""; admin->addApplication(app); admin->startServer("Test.IcePatch2"); admin->startServer("IcePatch2-Direct"); try { admin->patchServer("server-dir1", true); } catch(const PatchException& ex) { copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n")); test(false); } test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-dir1")); test(test->getServerFile("rootfile") == ""); test(test->getServerFile("dir1/file1") == "dummy-file1"); test(test->getServerFile("dir1/file2") == "dummy-file2"); test(test->getServerFile("dir2/file3") == ""); test(test->getApplicationFile("rootfile") == ""); test(test->getApplicationFile("dir1/file1") == ""); test(test->getApplicationFile("dir1/file2") == ""); test(test->getApplicationFile("dir2/file3") == ""); test = TestIntfPrx::uncheckedCast(communicator->stringToProxy("server-all")); test(test->getServerFile("rootfile") == ""); test(test->getServerFile("dir1/file1") == ""); test(test->getServerFile("dir1/file2") == ""); test(test->getServerFile("dir2/file3") == ""); try { admin->patchApplication("Test", true); } catch(const PatchException& ex) { copy(ex.reasons.begin(), ex.reasons.end(), ostream_iterator<string>(cerr, "\n")); test(false); } test(test->getServerFile("rootfile") == "rootfile"); test(test->getServerFile("dir1/file1") == "dummy-file1"); test(test->getServerFile("dir1/file2") == "dummy-file2"); test(test->getServerFile("dir2/file3") == "dummy-file3"); } catch(const DeploymentException& ex) { cerr << ex << ":\n" << ex.reason << endl; test(false); } cout << "ok" << endl; keepAlive->destroy(); keepAlive->getThreadControl().join(); keepAlive = 0; session->destroy(); }
void allTestsWithDeploy(const Ice::CommunicatorPtr& communicator) { cout << "testing stringToProxy... " << flush; Ice::ObjectPrx base = communicator->stringToProxy("test @ TestAdapter"); test(base); Ice::ObjectPrx base2 = communicator->stringToProxy("test"); test(base2); cout << "ok" << endl; cout << "testing checked cast... " << flush; TestIntfPrx obj = TestIntfPrx::checkedCast(base); test(obj); test(obj == base); TestIntfPrx obj2 = TestIntfPrx::checkedCast(base2); test(obj2); test(obj2 == base2); cout << "ok" << endl; cout << "pinging server... " << flush; obj->ice_ping(); obj2->ice_ping(); cout << "ok" << endl; cout << "testing reference with unknown identity... " << flush; try { communicator->stringToProxy("unknown/unknown")->ice_ping(); test(false); } catch (const Ice::NotRegisteredException& ex) { test(ex.kindOfObject == "object"); test(ex.id == "unknown/unknown"); } cout << "ok" << endl; cout << "testing reference with unknown adapter... " << flush; try { communicator->stringToProxy("test @ TestAdapterUnknown")->ice_ping(); test(false); } catch (const Ice::NotRegisteredException& ex) { test(ex.kindOfObject == "object adapter"); test(ex.id == "TestAdapterUnknown"); } cout << "ok" << endl; IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast( communicator->stringToProxy("IceGrid/Registry")); test(registry); IceGrid::AdminSessionPrx session = registry->createAdminSession("foo", "bar"); SessionKeepAliveThreadPtr keepAlive = new SessionKeepAliveThread(session, registry->getSessionTimeout()/2); keepAlive->start(); IceGrid::AdminPrx admin = session->getAdmin(); test(admin); admin->enableServer("server", false); admin->stopServer("server"); cout << "testing whether server is still reachable... " << flush; try { obj = TestIntfPrx::checkedCast(base); test(false); } catch(const Ice::NoEndpointException&) { } try { obj2 = TestIntfPrx::checkedCast(base2); test(false); } catch(const Ice::NoEndpointException&) { } admin->enableServer("server", true); try { obj = TestIntfPrx::checkedCast(base); } catch(const Ice::NoEndpointException&) { test(false); } try { obj2 = TestIntfPrx::checkedCast(base2); } catch(const Ice::NoEndpointException&) { test(false); } cout << "ok" << endl; admin->stopServer("server"); keepAlive->destroy(); keepAlive->getThreadControl().join(); keepAlive = 0; session->destroy(); }
void allTests(const Ice::CommunicatorPtr& communicator) { SessionKeepAliveThreadPtr keepAlive = new SessionKeepAliveThread( communicator->getLogger(), IceUtil::Time::seconds(5)); keepAlive->start(); RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(communicator->stringToProxy("IceGrid/Registry")); test(registry); AdminSessionPrx session = registry->createAdminSession("foo", "bar"); keepAlive->add(session); AdminPrx admin = session->getAdmin(); test(admin); cout << "starting router... " << flush; try { admin->startServer("Glacier2"); } catch(const ServerStartException& ex) { cerr << ex.reason << endl; test(false); } cout << "ok" << endl; const int allocationTimeout = 5000; Ice::ObjectPrx obj; Ice::ObjectPrx dummy; try { cout << "testing create session... " << flush; SessionPrx session1 = registry->createSession("Client1", ""); SessionPrx session2 = registry->createSession("Client2", ""); keepAlive->add(session1); keepAlive->add(session2); cout << "ok" << endl; cout << "testing allocate object by identity... " << flush; Ice::Identity allocatable = communicator->stringToIdentity("allocatable"); Ice::Identity allocatablebis = communicator->stringToIdentity("allocatablebis"); try { session1->allocateObjectById(communicator->stringToIdentity("dummy")); } catch(const ObjectNotRegisteredException&) { } try { session1->releaseObject(communicator->stringToIdentity("dummy")); } catch(const ObjectNotRegisteredException&) { } try { session1->allocateObjectById(communicator->stringToIdentity("nonallocatable")); test(false); } catch(const AllocationException&) { test(false); } catch(const ObjectNotRegisteredException&) { } try { session2->allocateObjectById(communicator->stringToIdentity("nonallocatable")); test(false); } catch(const AllocationException&) { test(false); } catch(const ObjectNotRegisteredException&) { } try { session1->releaseObject(communicator->stringToIdentity("nonallocatable")); test(false); } catch(const AllocationException&) { test(false); } catch(const ObjectNotRegisteredException&) { } try { session2->releaseObject(communicator->stringToIdentity("nonallocatable")); test(false); } catch(const AllocationException&) { test(false); } catch(const ObjectNotRegisteredException&) { } session1->allocateObjectById(allocatable); try { session1->allocateObjectById(allocatable); test(false); } catch(const AllocationException&) { } session1->setAllocationTimeout(0); session2->setAllocationTimeout(0); try { session2->allocateObjectById(allocatable); test(false); } catch(const AllocationTimeoutException&) { } try { session2->releaseObject(allocatable); test(false); } catch(const AllocationException&) { } session1->allocateObjectById(allocatablebis); try { session2->allocateObjectById(allocatablebis); test(false); } catch(const AllocationTimeoutException&) { } session1->releaseObject(allocatablebis); session2->allocateObjectById(allocatablebis); try { session1->allocateObjectById(allocatablebis); test(false); } catch(const AllocationTimeoutException&) { } session2->releaseObject(allocatablebis); session2->setAllocationTimeout(allocationTimeout); AllocateObjectByIdCallbackPtr cb1 = new AllocateObjectByIdCallback(); session2->allocateObjectById_async(cb1, allocatable); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); test(!cb1->hasResponse(dummy)); session1->releaseObject(allocatable); cb1->waitResponse(__FILE__, __LINE__); test(cb1->hasResponse(dummy)); session1->setAllocationTimeout(0); try { session1->allocateObjectById(allocatable); test(false); } catch(const AllocationTimeoutException&) { } try { session1->releaseObject(allocatable); test(false); } catch(const AllocationException&) { } session1->setAllocationTimeout(allocationTimeout); cb1 = new AllocateObjectByIdCallback(); session1->allocateObjectById_async(cb1, allocatable); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); test(!cb1->hasResponse(dummy)); session2->releaseObject(allocatable); cb1->waitResponse(__FILE__, __LINE__); test(cb1->hasResponse(dummy)); session1->releaseObject(allocatable); cout << "ok" << endl; cout << "testing allocate object by type... " << flush; session1->setAllocationTimeout(0); session2->setAllocationTimeout(0); try { obj = session1->allocateObjectByType("::Unknown"); test(false); } catch(const AllocationTimeoutException&) { test(false); } catch(const AllocationException&) { } try { obj = session1->allocateObjectByType("::NotAllocatable"); test(false); } catch(const AllocationTimeoutException&) { test(false); } catch(const AllocationException&) { } obj = session1->allocateObjectByType("::Test"); test(obj && obj->ice_getIdentity().name == "allocatable"); try { session1->allocateObjectByType("::Test"); test(false); } catch(const AllocationException&) { } try { session2->allocateObjectByType("::Test"); test(false); } catch(const AllocationTimeoutException&) { } try { session2->releaseObject(obj->ice_getIdentity()); } catch(const AllocationException&) { } session1->releaseObject(obj->ice_getIdentity()); try { session1->releaseObject(obj->ice_getIdentity()); } catch(const AllocationException&) { } obj = session2->allocateObjectByType("::Test"); // Allocate the object test(obj && obj->ice_getIdentity().name == "allocatable"); try { session2->allocateObjectByType("::Test"); test(false); } catch(const AllocationException&) { } try { session1->allocateObjectByType("::Test"); test(false); } catch(const AllocationTimeoutException&) { } session1->allocateObjectByType("::TestBis"); try { 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); AllocateObjectByTypeCallbackPtr cb3 = new AllocateObjectByTypeCallback(); session1->allocateObjectByType_async(cb3, "::Test"); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); test(!cb3->hasResponse(dummy)); session2->releaseObject(obj->ice_getIdentity()); cb3->waitResponse(__FILE__, __LINE__); test(cb3->hasResponse(obj)); session1->releaseObject(obj->ice_getIdentity()); 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()); } time = IceUtil::Time::now(); try { session2->allocateObjectById(allocatable); test(false); } catch(const AllocationTimeoutException&) { } test(time + IceUtil::Time::milliSeconds(100) < IceUtil::Time::now()); time = IceUtil::Time::now(); try { session2->allocateObjectByType("::Test"); test(false); } catch(const AllocationTimeoutException&) { } test(time + IceUtil::Time::milliSeconds(100) < IceUtil::Time::now()); session1->releaseObject(allocatable); session2->setAllocationTimeout(0); cout << "ok" << endl; cout << "testing server allocation... " << flush; session1->setAllocationTimeout(0); session2->setAllocationTimeout(0); Ice::Identity allocatable3 = communicator->stringToIdentity("allocatable3"); Ice::Identity allocatable4 = communicator->stringToIdentity("allocatable4"); session1->allocateObjectById(allocatable3); try { session2->allocateObjectById(allocatable3); test(false); } catch(const AllocationTimeoutException&) { } try { session2->allocateObjectById(allocatable4); test(false); } catch(const AllocationTimeoutException&) { } session1->allocateObjectById(allocatable4); session1->releaseObject(allocatable3); try { session2->allocateObjectById(allocatable3); test(false); } catch(const AllocationTimeoutException&) { } session1->releaseObject(allocatable4); session2->allocateObjectById(allocatable3); try { session1->allocateObjectById(allocatable3); test(false); } catch(const AllocationTimeoutException&) { } try { session1->allocateObjectById(allocatable4); test(false); } catch(const AllocationTimeoutException&) { } session2->allocateObjectById(allocatable4); session2->releaseObject(allocatable3); try { session1->allocateObjectById(allocatable3); test(false); } catch(const AllocationTimeoutException&) { } try { session1->allocateObjectByType("::TestServer1"); test(false); } catch(AllocationException&) { } try { session1->allocateObjectByType("::TestServer2"); test(false); } catch(AllocationException&) { } test(session2->allocateObjectByType("::TestServer1")); try { session2->allocateObjectByType("::TestServer1"); test(false); } catch(AllocationException&) { } try { session2->allocateObjectByType("::TestServer2"); test(false); } catch(AllocationException&) { } session2->releaseObject(allocatable3); session2->releaseObject(allocatable4); session1->allocateObjectById(allocatable3); session1->allocateObjectById(allocatable4); session2->setAllocationTimeout(allocationTimeout); cb1 = new AllocateObjectByIdCallback(); session2->allocateObjectById_async(cb1, allocatable3); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); test(!cb1->hasResponse(dummy)); session1->releaseObject(allocatable3); test(!cb1->hasResponse(dummy)); session1->releaseObject(allocatable4); cb1->waitResponse(__FILE__, __LINE__); test(cb1->hasResponse(dummy)); session2->releaseObject(allocatable3); session1->setAllocationTimeout(allocationTimeout); test(session2->allocateObjectByType("::TestServer1")); cb3 = new AllocateObjectByTypeCallback(); session1->allocateObjectByType_async(cb3, "::TestServer2"); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); test(!cb3->hasResponse(dummy)); session2->releaseObject(allocatable3); cb3->waitResponse(__FILE__, __LINE__); test(cb3->hasResponse(dummy)); session1->releaseObject(allocatable4); session1->setAllocationTimeout(0); session2->setAllocationTimeout(0); test(session1->allocateObjectByType("::TestMultipleByServer")); try { session2->allocateObjectByType("::TestMultipleByServer"); test(false); } catch(AllocationException&) { } test(session1->allocateObjectByType("::TestMultipleByServer")); session1->releaseObject(communicator->stringToIdentity("allocatable31")); session1->releaseObject(communicator->stringToIdentity("allocatable41")); test(session2->allocateObjectByType("::TestMultipleByServer")); try { session1->allocateObjectByType("::TestMultipleByServer"); test(false); } catch(AllocationException&) { } test(session2->allocateObjectByType("::TestMultipleByServer")); session2->releaseObject(communicator->stringToIdentity("allocatable31")); session2->releaseObject(communicator->stringToIdentity("allocatable41")); Ice::ObjectPrx obj1 = session1->allocateObjectByType("::TestMultipleServer"); test(obj1); Ice::ObjectPrx obj2 = session2->allocateObjectByType("::TestMultipleServer"); test(obj2); try { session1->allocateObjectByType("::TestMultipleServer"); test(false); } catch(AllocationTimeoutException&) { } try { session2->allocateObjectByType("::TestMultipleServer"); test(false); } catch(AllocationTimeoutException&) { } session1->releaseObject(obj1->ice_getIdentity()); obj1 = session2->allocateObjectByType("::TestMultipleServer"); session2->releaseObject(obj1->ice_getIdentity()); session2->releaseObject(obj2->ice_getIdentity()); cout << "ok" << endl; cout << "testing concurrent allocations... " << flush; session1->setAllocationTimeout(allocationTimeout); session2->setAllocationTimeout(allocationTimeout); session2->allocateObjectById(allocatable); AllocateObjectByIdCallbackPtr cb11 = new AllocateObjectByIdCallback(); AllocateObjectByIdCallbackPtr cb12 = new AllocateObjectByIdCallback(); session1->allocateObjectById_async(cb11, allocatable); session1->allocateObjectById_async(cb12, allocatable); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); test(!cb11->hasResponse(dummy)); test(!cb12->hasResponse(dummy)); session2->releaseObject(allocatable); cb11->waitResponse(__FILE__, __LINE__); cb12->waitResponse(__FILE__, __LINE__); test(cb11->hasResponse(dummy) ? cb12->hasException() : cb12->hasResponse(dummy)); test(cb12->hasResponse(dummy) ? cb11->hasException() : cb11->hasResponse(dummy)); session1->releaseObject(allocatable); session2->allocateObjectById(allocatable); AllocateObjectByTypeCallbackPtr cb31 = new AllocateObjectByTypeCallback(); AllocateObjectByTypeCallbackPtr cb32 = new AllocateObjectByTypeCallback(); session1->allocateObjectByType_async(cb31, "::Test"); session1->allocateObjectByType_async(cb32, "::Test"); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); test(!cb31->hasResponse(dummy)); test(!cb32->hasResponse(dummy)); session2->releaseObject(allocatable); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); do { IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); } while(!cb31->hasResponse(dummy) && !cb32->hasResponse(dummy)); test(cb31->hasResponse(dummy) && dummy && !cb32->hasResponse(dummy) || cb32->hasResponse(dummy) && dummy && !cb31->hasResponse(dummy)); session1->releaseObject(allocatable); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); AllocateObjectByTypeCallbackPtr cb33 = cb31->hasResponse(dummy) ? cb32 : cb31; cb33->waitResponse(__FILE__, __LINE__); test(cb33->hasResponse(dummy) && dummy); session1->releaseObject(allocatable); session2->allocateObjectById(allocatable3); cb11 = new AllocateObjectByIdCallback(); cb12 = new AllocateObjectByIdCallback(); session1->allocateObjectById_async(cb11, allocatable3); session1->allocateObjectById_async(cb12, allocatable3); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); test(!cb11->hasResponse(dummy)); test(!cb12->hasResponse(dummy)); session2->releaseObject(allocatable3); cb11->waitResponse(__FILE__, __LINE__); cb12->waitResponse(__FILE__, __LINE__); test(cb11->hasResponse(dummy) ? cb12->hasException() : cb12->hasResponse(dummy)); test(cb12->hasResponse(dummy) ? cb11->hasException() : cb11->hasResponse(dummy)); session1->releaseObject(allocatable3); session2->allocateObjectById(allocatable3); cb31 = new AllocateObjectByTypeCallback(); cb32 = new AllocateObjectByTypeCallback(); session1->allocateObjectByType_async(cb31, "::TestServer1"); session1->allocateObjectByType_async(cb32, "::TestServer1"); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); test(!cb31->hasResponse(dummy)); test(!cb32->hasResponse(dummy)); session2->releaseObject(allocatable3); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); do { IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); } while(!cb31->hasResponse(dummy) && !cb32->hasResponse(dummy)); test(cb31->hasResponse(dummy) && dummy && !cb32->hasResponse(dummy) || cb32->hasResponse(dummy) && dummy && !cb31->hasResponse(dummy)); session1->releaseObject(allocatable3); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); cb33 = cb31->hasResponse(dummy) ? cb32 : cb31; cb33->waitResponse(__FILE__, __LINE__); test(cb33->hasResponse(dummy) && dummy); session1->releaseObject(allocatable3); session1->allocateObjectById(allocatable3); cb31 = new AllocateObjectByTypeCallback(); cb32 = new AllocateObjectByTypeCallback(); session1->allocateObjectByType_async(cb31, "::TestServer1"); session1->allocateObjectByType_async(cb32, "::TestServer1"); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); test(!cb31->hasResponse(dummy)); test(!cb32->hasResponse(dummy)); session1->releaseObject(allocatable3); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); do { IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); } while(!cb31->hasResponse(dummy) && !cb32->hasResponse(dummy)); test(cb31->hasResponse(dummy) && dummy && !cb32->hasResponse(dummy) || cb32->hasResponse(dummy) && dummy && !cb31->hasResponse(dummy)); session1->releaseObject(allocatable3); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); cb33 = cb31->hasResponse(dummy) ? cb32 : cb31; cb33->waitResponse(__FILE__, __LINE__); test(cb33->hasResponse(dummy) && dummy); session1->releaseObject(allocatable3); cout << "ok" << endl; cout << "testing session destroy... " << flush; obj = session2->allocateObjectByType("::Test"); // Allocate the object test(obj && obj->ice_getIdentity().name == "allocatable"); session1->setAllocationTimeout(allocationTimeout); cb3 = new AllocateObjectByTypeCallback(); session1->allocateObjectByType_async(cb3, "::Test"); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); test(!cb3->hasResponse(dummy)); session2->destroy(); cb3->waitResponse(__FILE__, __LINE__); test(cb3->hasResponse(obj)); session1->destroy(); session2 = SessionPrx::uncheckedCast(registry->createSession("Client2", "")); session2->setAllocationTimeout(0); session2->allocateObjectById(allocatable); session2->destroy(); cout << "ok" << endl; cout << "testing allocation with Glacier2 session... " << flush; Ice::ObjectPrx routerBase = communicator->stringToProxy("Glacier2/router:default -p 12347"); Glacier2::RouterPrx router1 = Glacier2::RouterPrx::checkedCast(routerBase->ice_connectionId("client1")); test(router1); Glacier2::SessionPrx sessionBase = router1->createSession("test1", "abc123"); try { session1 = IceGrid::SessionPrx::checkedCast(sessionBase->ice_connectionId("client1")->ice_router(router1)); test(session1); session1->ice_ping(); Ice::ObjectPrx obj; obj = session1->allocateObjectById(allocatable)->ice_connectionId("client1")->ice_router(router1); obj->ice_ping(); session1->releaseObject(allocatable); try { obj->ice_ping(); } catch(const Ice::ObjectNotExistException&) { } obj = session1->allocateObjectById(allocatable3)->ice_connectionId("client1")->ice_router(router1); obj->ice_ping(); obj2 = communicator->stringToProxy("allocatable4")->ice_connectionId("client1")->ice_router(router1); obj2->ice_ping(); session1->releaseObject(allocatable3); try { obj->ice_ping(); } catch(const Ice::ObjectNotExistException&) { } try { obj2->ice_ping(); } catch(const Ice::ObjectNotExistException&) { } session1->destroy(); } catch(const Ice::LocalException& ex) { cerr << ex << endl; test(false); } cout << "ok" << endl; cout << "stress test... " << flush; SessionPrx stressSession = registry->createSession("StressSession", ""); keepAlive->add(stressSession); const int nClients = 10; int i; vector<StressClientPtr> clients; for(i = 0; i < nClients - 2; ++i) { if(IceUtil::random(2) == 1) { clients.push_back(new StressClient(i, registry, false)); } else { clients.push_back(new StressClient(i, stressSession)); } clients.back()->start(); } clients.push_back(new StressClient(i++, registry, true)); clients.back()->start(); clients.push_back(new StressClient(i++, registry, true)); clients.back()->start(); for(vector<StressClientPtr>::const_iterator p = clients.begin(); p != clients.end(); ++p) { (*p)->notifyThread(); } // // Let the stress client run for a bit. // IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(8)); // // Terminate the stress clients. // for(vector<StressClientPtr>::const_iterator q = clients.begin(); q != clients.end(); ++q) { (*q)->terminate(); (*q)->getThreadControl().join(); } stressSession->destroy(); cout << "ok" << endl; } catch(const AllocationTimeoutException& ex) { cerr << ex << endl; test(false); } catch(const AllocationException& ex) { cerr << ex.reason << endl; test(false); } cout << "shutting down router... " << flush; admin->stopServer("Glacier2"); cout << "ok" << endl; keepAlive->terminate(); keepAlive->getThreadControl().join(); keepAlive = 0; session->destroy(); }
int HelloClient::run(int argc, char* argv[]) { if(argc > 1) { cerr << appName() << ": too many arguments" << endl; return EXIT_FAILURE; } int status = EXIT_SUCCESS; IceGrid::RegistryPrx registry = IceGrid::RegistryPrx::checkedCast(communicator()->stringToProxy("DemoIceGrid/Registry")); if(!registry) { cerr << argv[0] << ": could not contact registry" << endl; return EXIT_FAILURE; } IceGrid::SessionPrx session; while(true) { cout << "This demo accepts any user-id / password combination.\n"; string id; cout << "user id: " << flush; getline(cin, id); id = trim(id); string password; cout << "password: "******"permission denied:\n" << ex.reason << endl; } } SessionKeepAliveThreadPtr keepAlive = new SessionKeepAliveThread(session, registry->getSessionTimeout() / 2); keepAlive->start(); try { HelloPrx hello = HelloPrx::checkedCast(session->allocateObjectById(communicator()->stringToIdentity("hello"))); menu(); char c; do { try { cout << "==> "; cin >> c; if(c == 't') { hello->sayHello(); } else if(c == 'x') { // Nothing to do } else if(c == '?') { menu(); } else { cout << "unknown command `" << c << "'" << endl; menu(); } } catch(const Ice::Exception& ex) { cerr << ex << endl; } } while(cin.good() && c != 'x'); } catch(const IceGrid::AllocationException& ex) { cerr << argv[0] << ": could not allocate object: " << ex.reason << endl; status = EXIT_FAILURE; } catch(const IceGrid::ObjectNotRegisteredException&) { cerr << argv[0] << ": object not registered with registry" << endl; status = EXIT_FAILURE; } catch(const Ice::Exception& ex) { cerr << ex << endl; status = EXIT_FAILURE; } catch(...) { cerr << "unexpected exception" << endl; status = EXIT_FAILURE; } // // Destroy the keepAlive thread and the sesion object otherwise // the session will be kept allocated until the timeout occurs. // Destroying the session will release all allocated objects. // keepAlive->destroy(); keepAlive->getThreadControl().join(); session->destroy(); return status; }