diff options
author | Benoit Foucher <benoit@zeroc.com> | 2007-12-03 15:04:10 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2007-12-03 15:04:10 +0100 |
commit | 7bae461be57d06320c1d7860e6967bcd0b14718c (patch) | |
tree | 1763ec9f485e6f1ad0af51fa2c8fa6ae6e409907 /cpp | |
parent | Added more @deprecated tags to the Java generated code to reduce the number o... (diff) | |
download | ice-7bae461be57d06320c1d7860e6967bcd0b14718c.tar.bz2 ice-7bae461be57d06320c1d7860e6967bcd0b14718c.tar.xz ice-7bae461be57d06320c1d7860e6967bcd0b14718c.zip |
- Changed AdminI server start/stop methods to use AMI/AMD
- Minor exception handling fix in registry server admin router.
- Changed Admin::getServerAdmin method to check if the server exists and
can be loaded on the node before to return the server admin object.
- Fixed icegridadmin to use the process facet to write messages
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/IceGrid/AdminI.cpp | 114 | ||||
-rw-r--r-- | cpp/src/IceGrid/AdminI.h | 4 | ||||
-rw-r--r-- | cpp/src/IceGrid/Internal.ice | 4 | ||||
-rw-r--r-- | cpp/src/IceGrid/Parser.cpp | 14 | ||||
-rw-r--r-- | cpp/src/IceGrid/RegistryServerAdminRouter.cpp | 6 | ||||
-rw-r--r-- | cpp/src/IceGrid/ServerCache.cpp | 30 |
6 files changed, 138 insertions, 34 deletions
diff --git a/cpp/src/IceGrid/AdminI.cpp b/cpp/src/IceGrid/AdminI.cpp index 22c43e316cb..d8c08ae0d81 100644 --- a/cpp/src/IceGrid/AdminI.cpp +++ b/cpp/src/IceGrid/AdminI.cpp @@ -38,6 +38,15 @@ public: { _proxy = database->getServer(_id)->getProxy(_activationTimeout, _deactivationTimeout, _node); } + + ServerProxyWrapper(const ServerProxyWrapper& wrapper) : + _id(wrapper._id), + _proxy(wrapper._proxy), + _activationTimeout(wrapper._activationTimeout), + _deactivationTimeout(wrapper._deactivationTimeout), + _node(wrapper._node) + { + } void useActivationTimeout() @@ -58,7 +67,7 @@ public: } void - handleException(const Ice::Exception& ex) + handleException(const Ice::Exception& ex) const { try { @@ -367,6 +376,8 @@ AdminI::getServerAdminCategory(const Current&) const Ice::ObjectPrx AdminI::getServerAdmin(const string& id, const Current& current) const { + ServerProxyWrapper proxy(_database, id); // Ensure that the server exists and loaded on the node. + Ice::Identity adminId; adminId.name = id; adminId.category = _registry->getServerAdminCategory(); @@ -374,36 +385,99 @@ AdminI::getServerAdmin(const string& id, const Current& current) const } void -AdminI::startServer(const string& id, const Current&) +AdminI::startServer_async(const AMD_Admin_startServerPtr& amdCB, const string& id, const Current&) { ServerProxyWrapper proxy(_database, id); proxy.useActivationTimeout(); - try - { - proxy->start(); - } - catch(const Ice::Exception& ex) + + class StartCB : public AMI_Server_start { - proxy.handleException(ex); - } + public: + + StartCB(const ServerProxyWrapper& proxy, const AMD_Admin_startServerPtr& amdCB) : _proxy(proxy), _amdCB(amdCB) + { + } + + virtual void + ice_response() + { + _amdCB->ice_response(); + } + + virtual void + ice_exception(const Ice::Exception& ex) + { + try + { + _proxy.handleException(ex); + assert(false); + } + catch(const Ice::Exception& ex) + { + _amdCB->ice_exception(ex); + } + } + + private: + + const ServerProxyWrapper _proxy; + const AMD_Admin_startServerPtr _amdCB; + }; + + // + // Since the server might take a while to be activated, we use AMI. + // + proxy->start_async(new StartCB(proxy, amdCB)); } void -AdminI::stopServer(const string& id, const Current&) +AdminI::stopServer_async(const AMD_Admin_stopServerPtr& amdCB, const string& id, const Current&) { ServerProxyWrapper proxy(_database, id); proxy.useDeactivationTimeout(); - try - { - proxy->stop(); - } - catch(const Ice::TimeoutException&) - { - } - catch(const Ice::Exception& ex) + + class StopCB : public AMI_Server_stop { - proxy.handleException(ex); - } + public: + + StopCB(const ServerProxyWrapper& proxy, const AMD_Admin_stopServerPtr& amdCB) : _proxy(proxy), _amdCB(amdCB) + { + } + + virtual void + ice_response() + { + _amdCB->ice_response(); + } + + virtual void + ice_exception(const Ice::Exception& ex) + { + try + { + _proxy.handleException(ex); + assert(false); + } + catch(const Ice::TimeoutException&) + { + _amdCB->ice_response(); + } + catch(const Ice::Exception& ex) + { + _amdCB->ice_exception(ex); + } + } + + private: + + const ServerProxyWrapper _proxy; + const AMD_Admin_stopServerPtr _amdCB; + }; + + // + // Since the server might take a while to be deactivated, we use AMI. + // + proxy->stop_async(new StopCB(proxy, amdCB)); } void diff --git a/cpp/src/IceGrid/AdminI.h b/cpp/src/IceGrid/AdminI.h index 132c95d8d39..883e0b33a2e 100644 --- a/cpp/src/IceGrid/AdminI.h +++ b/cpp/src/IceGrid/AdminI.h @@ -51,8 +51,8 @@ public: virtual Ice::Int getServerPid(const ::std::string&, const Ice::Current&) const; virtual std::string getServerAdminCategory(const Ice::Current&) const; virtual Ice::ObjectPrx getServerAdmin(const std::string&, const Ice::Current&) const; - virtual void startServer(const ::std::string&, const Ice::Current&); - virtual void stopServer(const ::std::string&, const Ice::Current&); + virtual void startServer_async(const AMD_Admin_startServerPtr&, const ::std::string&, const Ice::Current&); + virtual void stopServer_async(const AMD_Admin_stopServerPtr&, const ::std::string&, const Ice::Current&); virtual void patchServer_async(const AMD_Admin_patchServerPtr&, const ::std::string&, bool, const Ice::Current&); virtual void sendSignal(const ::std::string&, const ::std::string&, const Ice::Current&); virtual void writeMessage(const ::std::string&, const ::std::string&, Ice::Int, const Ice::Current&); diff --git a/cpp/src/IceGrid/Internal.ice b/cpp/src/IceGrid/Internal.ice index 28de6d295c7..57f5612d678 100644 --- a/cpp/src/IceGrid/Internal.ice +++ b/cpp/src/IceGrid/Internal.ice @@ -219,7 +219,7 @@ interface Server extends FileReader * otherwise. * **/ - ["amd"] void start() + ["amd", "ami"] void start() throws ServerStartException; /** @@ -229,7 +229,7 @@ interface Server extends FileReader * amount of time, it will be killed. * **/ - ["amd"] void stop() + ["amd", "ami"] void stop() throws ServerStopException; /** diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp index 99340f6c8f2..d0eefad29bd 100644 --- a/cpp/src/IceGrid/Parser.cpp +++ b/cpp/src/IceGrid/Parser.cpp @@ -1075,7 +1075,19 @@ Parser::writeMessage(const list<string>& args, int fd) { list<string>::const_iterator p = args.begin(); string server = *p++; - _admin->writeMessage(server, *p, fd); + + Ice::ObjectPrx serverAdmin = _admin->getServerAdmin(server); + Ice::ProcessPrx process = Ice::ProcessPrx::uncheckedCast(serverAdmin, "Process"); + + process->writeMessage(*p, fd); + } + catch(const Ice::ObjectNotExistException&) + { + error("couldn't reach the server's Admin object"); + } + catch(const Ice::FacetNotExistException&) + { + error("the server's Admin object does not provide a 'Process' facet"); } catch(const Ice::Exception& ex) { diff --git a/cpp/src/IceGrid/RegistryServerAdminRouter.cpp b/cpp/src/IceGrid/RegistryServerAdminRouter.cpp index 6bca684303b..ff3b8a29b30 100644 --- a/cpp/src/IceGrid/RegistryServerAdminRouter.cpp +++ b/cpp/src/IceGrid/RegistryServerAdminRouter.cpp @@ -61,6 +61,12 @@ IceGrid::RegistryServerAdminRouter::ice_invoke_async(const AMD_Array_Object_ice_ catch(const ServerNotExistException&) { } + catch(const NodeUnreachableException&) + { + } + catch(const DeploymentException&) + { + } if(target == 0) { diff --git a/cpp/src/IceGrid/ServerCache.cpp b/cpp/src/IceGrid/ServerCache.cpp index d2f87fbc65e..502a8d93672 100644 --- a/cpp/src/IceGrid/ServerCache.cpp +++ b/cpp/src/IceGrid/ServerCache.cpp @@ -360,6 +360,11 @@ ServerEntry::getId() const ServerPrx ServerEntry::getProxy(bool upToDate) { + // + // NOTE: this might throw ServerNotExistException, NodeUnreachableException + // or DeploymentException. + // + int actTimeout, deactTimeout; string node; return getProxy(actTimeout, deactTimeout, node, upToDate); @@ -368,6 +373,11 @@ ServerEntry::getProxy(bool upToDate) ServerPrx ServerEntry::getProxy(int& activationTimeout, int& deactivationTimeout, string& node, bool upToDate) { + // + // NOTE: this might throw ServerNotExistException, NodeUnreachableException + // or DeploymentException. + // + { Lock sync(*this); if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine @@ -420,20 +430,17 @@ ServerEntry::getAdminProxy() Ice::Identity adminId; adminId.name = _id; adminId.category = _cache.getInstanceName() + "-NodeRouter"; - - try - { - return getProxy(true)->ice_identity(adminId); - } - catch(const ServerNotExistException&) - { - return 0; - } + return getProxy(true)->ice_identity(adminId); } AdapterPrx ServerEntry::getAdapter(const string& id, bool upToDate) { + // + // NOTE: this might throw AdapterNotExistException, NodeUnreachableException + // or DeploymentException. + // + int activationTimeout, deactivationTimeout; return getAdapter(activationTimeout, deactivationTimeout, id, upToDate); } @@ -441,6 +448,11 @@ ServerEntry::getAdapter(const string& id, bool upToDate) AdapterPrx ServerEntry::getAdapter(int& activationTimeout, int& deactivationTimeout, const string& id, bool upToDate) { + // + // NOTE: this might throw AdapterNotExistException, NodeUnreachableException + // or DeploymentException. + // + { Lock sync(*this); if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine |