diff options
author | Benoit Foucher <benoit@zeroc.com> | 2012-01-30 16:51:24 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2012-01-30 16:51:24 +0100 |
commit | 6f99bac58a16e55487b98ddb5d6f837574c55b02 (patch) | |
tree | 20db5f71eeee5c7eb0796aed44a150206dff14b0 /cpp | |
parent | ICE-4775 - memory leak in Glacier2 (diff) | |
download | ice-6f99bac58a16e55487b98ddb5d6f837574c55b02.tar.bz2 ice-6f99bac58a16e55487b98ddb5d6f837574c55b02.tar.xz ice-6f99bac58a16e55487b98ddb5d6f837574c55b02.zip |
Fixed ICE-4772, IceGrid server disable patch for Cengage
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/IceGrid/ServerAdapterI.cpp | 21 | ||||
-rw-r--r-- | cpp/src/IceGrid/ServerAdapterI.h | 4 | ||||
-rwxr-xr-x | cpp/src/IceGrid/ServerI.cpp | 10 | ||||
-rw-r--r-- | cpp/test/IceGrid/activation/AllTests.cpp | 21 |
4 files changed, 48 insertions, 8 deletions
diff --git a/cpp/src/IceGrid/ServerAdapterI.cpp b/cpp/src/IceGrid/ServerAdapterI.cpp index 814a2f283e2..4c4122ac2ca 100644 --- a/cpp/src/IceGrid/ServerAdapterI.cpp +++ b/cpp/src/IceGrid/ServerAdapterI.cpp @@ -20,12 +20,14 @@ ServerAdapterI::ServerAdapterI(const NodeIPtr& node, ServerI* server, const string& serverName, const AdapterPrx& proxy, - const string& id) : + const string& id, + bool enabled) : _node(node), _this(proxy), _serverId(serverName), _id(id), - _server(server) + _server(server), + _enabled(enabled) { } @@ -39,7 +41,7 @@ ServerAdapterI::activate_async(const AMD_Adapter_activatePtr& cb, const Ice::Cur { { Lock sync(*this); - if(_proxy) + if(_enabled && _proxy) { // // Return the adapter direct proxy. @@ -53,7 +55,7 @@ ServerAdapterI::activate_async(const AMD_Adapter_activatePtr& cb, const Ice::Cur // Nothing else waits for this adapter so we must make sure that this // adapter if still activatable. // - if(!_server->isAdapterActivatable(_id)) + if(!_enabled || !_server->isAdapterActivatable(_id)) { cb->ice_response(0); return; @@ -113,14 +115,14 @@ ServerAdapterI::getDirectProxy(const Ice::Current& current) const // Return the adapter direct proxy if it's set. Otherwise, throw. The caller can eventually // activate the adapter if it's activatable. // - if(_proxy) + if(_proxy && _enabled) { return _proxy; } else { AdapterNotActiveException ex; - ex.activatable = _server->isAdapterActivatable(_id); + ex.activatable = _enabled && _server->isAdapterActivatable(_id); throw ex; } } @@ -206,6 +208,13 @@ ServerAdapterI::destroy() } void +ServerAdapterI::updateEnabled() +{ + Lock sync(*this); + _enabled = _server->isEnabled(); +} + +void ServerAdapterI::clear() { Lock sync(*this); diff --git a/cpp/src/IceGrid/ServerAdapterI.h b/cpp/src/IceGrid/ServerAdapterI.h index 12ba4e0e45a..ad9762d96e3 100644 --- a/cpp/src/IceGrid/ServerAdapterI.h +++ b/cpp/src/IceGrid/ServerAdapterI.h @@ -25,13 +25,14 @@ class ServerAdapterI : public Adapter, public IceUtil::Mutex { public: - ServerAdapterI(const NodeIPtr&, ServerI*, const std::string&, const AdapterPrx&, const std::string&); + ServerAdapterI(const NodeIPtr&, ServerI*, const std::string&, const AdapterPrx&, const std::string&, bool); virtual ~ServerAdapterI(); virtual void activate_async(const AMD_Adapter_activatePtr& cb, const Ice::Current&); virtual Ice::ObjectPrx getDirectProxy(const Ice::Current& = Ice::Current()) const; virtual void setDirectProxy(const ::Ice::ObjectPrx&, const ::Ice::Current& = Ice::Current()); void destroy(); + void updateEnabled(); void clear(); void activationFailed(const std::string&); void activationCompleted(); @@ -48,6 +49,7 @@ private: ServerI* _server; Ice::ObjectPrx _proxy; + bool _enabled; std::vector<AMD_Adapter_activatePtr> _activateCB; bool _activateAfterDeactivating; }; diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp index 4b9f758f78b..965bb914742 100755 --- a/cpp/src/IceGrid/ServerI.cpp +++ b/cpp/src/IceGrid/ServerI.cpp @@ -790,6 +790,7 @@ void ServerI::setEnabled(bool enabled, const ::Ice::Current&) { bool activate = false; + ServerAdapterDict adpts; { Lock sync(*this); checkDestroyed(); @@ -816,9 +817,15 @@ ServerI::setEnabled(bool enabled, const ::Ice::Current&) return; // Nothing to change! } + adpts = _adapters; _node->observerUpdateServer(getDynamicInfo()); } + for(ServerAdapterDict::iterator r = adpts.begin(); r != adpts.end(); ++r) + { + r->second->updateEnabled(); + } + if(activate) { try @@ -1896,7 +1903,8 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor) if(!servant) { AdapterPrx proxy = AdapterPrx::uncheckedCast(adapter->createProxy(id)); - servant = new ServerAdapterI(_node, this, _id, proxy, (*r)->id); + servant = new ServerAdapterI(_node, this, _id, proxy, (*r)->id, _activation != Disabled || + _failureTime != IceUtil::Time()); adapter->add(servant, id); } _adapters.insert(make_pair((*r)->id, servant)); diff --git a/cpp/test/IceGrid/activation/AllTests.cpp b/cpp/test/IceGrid/activation/AllTests.cpp index ae413a33d6e..5e09788f2a3 100644 --- a/cpp/test/IceGrid/activation/AllTests.cpp +++ b/cpp/test/IceGrid/activation/AllTests.cpp @@ -364,6 +364,27 @@ allTests(const Ice::CommunicatorPtr& communicator) { } test(admin->getServerState("server-always") == IceGrid::Inactive); + + + test(admin->getServerState("server") == IceGrid::Inactive); + admin->enableServer("server", true); + communicator->stringToProxy("server")->ice_locatorCacheTimeout(0)->ice_ping(); + int pid = admin->getServerPid("server"); + admin->enableServer("server", false); + test(admin->getServerState("server") == IceGrid::Active); + try + { + communicator->stringToProxy("server")->ice_locatorCacheTimeout(0)->ice_ping(); + test(false); + } + catch(const Ice::NoEndpointException&) + { + } + admin->enableServer("server", true); + communicator->stringToProxy("server")->ice_locatorCacheTimeout(0)->ice_ping(); + test(admin->getServerPid("server") == pid); + admin->stopServer("server"); + test(admin->getServerState("server") == IceGrid::Inactive); } catch(const Ice::LocalException& ex) { |