virtual void run() { CommunicatorPtr communicator = initialize(initData); ObjectPrx routerBase = communicator->stringToProxy( "Glacier2/router:" + TestHelper::getTestEndpoint(communicator->getProperties(), 50)); _router = Glacier2::RouterPrx::checkedCast(routerBase); communicator->setDefaultRouter(_router); ostringstream os; os << "userid-" << _id; Glacier2::SessionPrx session = _router->createSession(os.str(), "abc123"); communicator->getProperties()->setProperty("Ice.PrintAdapterReady", ""); ObjectAdapterPtr adapter = communicator->createObjectAdapterWithRouter("CallbackReceiverAdapter", _router); adapter->activate(); string category = _router->getCategoryForClient(); _callbackReceiver = new CallbackReceiverI; Identity ident; ident.name = "callbackReceiver"; ident.category = category; CallbackReceiverPrx receiver = CallbackReceiverPrx::uncheckedCast(adapter->add(_callbackReceiver, ident)); ObjectPrx base = communicator->stringToProxy( "c1/callback:" + TestHelper::getTestEndpoint(communicator->getProperties())); base = base->ice_oneway(); CallbackPrx callback = CallbackPrx::uncheckedCast(base); { Lock sync(*this); _initialized = true; notifyAll(); } { Lock sync(*this); while(!_notified) { wait(); } } // // Stress the router until the connection is closed. // stress(callback, receiver); communicator->destroy(); }
virtual void run() { CommunicatorPtr communicator = initialize(initData); ObjectPrx routerBase = communicator->stringToProxy("Glacier2/router:default -p 12347 -t 10000"); Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(routerBase); communicator->setDefaultRouter(router); ostringstream os; os << "userid-" << _id; Glacier2::SessionPrx session = router->createSession(os.str(), "abc123"); communicator->getProperties()->setProperty("Ice.PrintAdapterReady", ""); ObjectAdapterPtr adapter = communicator->createObjectAdapterWithRouter("CallbackReceiverAdapter", router); adapter->activate(); string category = router->getCategoryForClient(); { Lock sync(*this); _callbackReceiver = new CallbackReceiverI; notify(); } Identity ident; ident.name = "callbackReceiver"; ident.category = category; CallbackReceiverPrx receiver = CallbackReceiverPrx::uncheckedCast(adapter->add(_callbackReceiver, ident)); ObjectPrx base = communicator->stringToProxy("c1/callback:tcp -p 12010 -t 10000"); base = base->ice_oneway(); CallbackPrx callback = CallbackPrx::uncheckedCast(base); // // Block the CallbackReceiver in wait() to prevent the client from // processing other incoming calls and wait to receive the callback. // callback->initiateWaitCallback(receiver); test(_callbackReceiver->waitCallbackOK()); // // Notify the main thread that the callback was received. // { Lock sync(*this); _callback = true; notify(); } // // Callback the client with a large payload. This should cause // the Glacier2 request queue thread to block trying to send the // callback to the client because the client is currently blocked // in CallbackReceiverI::waitCallback() and can't process more // requests. // callback->initiateCallbackWithPayload(receiver); test(_callbackReceiver->callbackWithPayloadOK()); try { router->destroySession(); test(false); } catch(const Ice::ConnectionLostException&) { } catch(const Ice::LocalException&) { test(false); } communicator->destroy(); }