diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/demo/IceGrid/simple/Server.cpp | 9 | ||||
-rw-r--r-- | cpp/slice/IceGrid/Admin.ice | 26 | ||||
-rw-r--r-- | cpp/slice/IceGrid/Exception.ice | 23 | ||||
-rw-r--r-- | cpp/src/IceGrid/AdminI.cpp | 15 | ||||
-rw-r--r-- | cpp/src/IceGrid/AdminI.h | 1 | ||||
-rw-r--r-- | cpp/src/IceGrid/Internal.ice | 10 | ||||
-rw-r--r-- | cpp/src/IceGrid/ServerI.cpp | 52 | ||||
-rw-r--r-- | cpp/src/IceGrid/ServerI.h | 1 |
8 files changed, 136 insertions, 1 deletions
diff --git a/cpp/demo/IceGrid/simple/Server.cpp b/cpp/demo/IceGrid/simple/Server.cpp index a2a578e2b5e..d057cef9c68 100644 --- a/cpp/demo/IceGrid/simple/Server.cpp +++ b/cpp/demo/IceGrid/simple/Server.cpp @@ -23,8 +23,15 @@ public: int main(int argc, char* argv[]) { + // + // Set the 'BuildId' property displayed in the IceGridAdmin GUI + // + Ice::InitializationData initData; + initData.properties = Ice::createProperties(); + initData.properties->setProperty("BuildId", string("Ice ") + ICE_STRING_VERSION); + Server app; - int status = app.main(argc, argv); + int status = app.main(argc, argv, initData); return status; } diff --git a/cpp/slice/IceGrid/Admin.ice b/cpp/slice/IceGrid/Admin.ice index f682430d39a..da26a86d622 100644 --- a/cpp/slice/IceGrid/Admin.ice +++ b/cpp/slice/IceGrid/Admin.ice @@ -12,6 +12,7 @@ #include <Ice/Identity.ice> #include <Ice/BuiltinSequences.ice> +#include <Ice/Properties.ice> #include <Ice/SliceChecksumDict.ice> #include <Glacier2/Session.ice> #include <IceGrid/Exception.ice> @@ -593,6 +594,31 @@ interface Admin ["nonmutating", "cpp:const"] idempotent int getServerPid(string id) throws ServerNotExistException, NodeUnreachableException, DeploymentException; + + /** + * + * Get a server's properties. + * + * @param id The server id. + * + * @return The server's properties + * + * @throws ServerNotExistException Raised if the server doesn't exist. + * + * @throws ServerUnreachableException Raised if the server could not be + * reached. + * + * @throws NodeUnreachableException Raised if the node could not be + * reached. + * + * @throws DeploymentException Raised if the server couldn't be + * deployed on the node. + * + **/ + ["ami", "java:type:{java.util.TreeMap}", "cpp:const"] + idempotent Ice::PropertyDict getServerProperties(string id) + throws ServerNotExistException, ServerUnreachableException, NodeUnreachableException, DeploymentException; + /** * * Enable or disable a server. A disabled server can't be started diff --git a/cpp/slice/IceGrid/Exception.ice b/cpp/slice/IceGrid/Exception.ice index 4689e70ea99..dd4335013bf 100644 --- a/cpp/slice/IceGrid/Exception.ice +++ b/cpp/slice/IceGrid/Exception.ice @@ -199,6 +199,29 @@ exception NodeUnreachableException /** * + * This exception is raised if a server could not be reached. + * + **/ +exception ServerUnreachableException +{ + /** + * + * The id of the server that is not reachable. + * + **/ + string name; + + /** + * + * The reason why the server couldn't be reached. + * + **/ + string reason; +}; + + +/** + * * This exception is raised if a registry could not be reached. * **/ diff --git a/cpp/src/IceGrid/AdminI.cpp b/cpp/src/IceGrid/AdminI.cpp index dd5a7fa0dce..141112c5b59 100644 --- a/cpp/src/IceGrid/AdminI.cpp +++ b/cpp/src/IceGrid/AdminI.cpp @@ -358,6 +358,21 @@ AdminI::getServerPid(const string& id, const Current&) const } } +Ice::PropertyDict +AdminI::getServerProperties(const string& id, const Current&) const +{ + ServerProxyWrapper proxy(_database, id); + try + { + return proxy->getProperties(); + } + catch(const Ice::Exception& ex) + { + proxy.handleException(ex); + return Ice::PropertyDict(); + } +} + void AdminI::startServer(const string& id, const Current&) { diff --git a/cpp/src/IceGrid/AdminI.h b/cpp/src/IceGrid/AdminI.h index a5c63735ad9..1d4356b994a 100644 --- a/cpp/src/IceGrid/AdminI.h +++ b/cpp/src/IceGrid/AdminI.h @@ -49,6 +49,7 @@ public: virtual ServerInfo getServerInfo(const ::std::string&, const Ice::Current&) const; virtual ServerState getServerState(const ::std::string&, const Ice::Current&) const; virtual Ice::Int getServerPid(const ::std::string&, const Ice::Current&) const; + virtual Ice::PropertyDict getServerProperties(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 patchServer_async(const AMD_Admin_patchServerPtr&, const ::std::string&, bool, const Ice::Current&); diff --git a/cpp/src/IceGrid/Internal.ice b/cpp/src/IceGrid/Internal.ice index 4f3cdbfa291..85ab0cc5fc6 100644 --- a/cpp/src/IceGrid/Internal.ice +++ b/cpp/src/IceGrid/Internal.ice @@ -14,6 +14,7 @@ #include <Ice/BuiltinSequences.ice> #include <Ice/ProcessF.ice> #include <Ice/Locator.ice> +#include <Ice/Properties.ice> #include <Glacier2/Session.ice> #include <IceGrid/Admin.ice> @@ -281,6 +282,15 @@ interface Server extends FileReader **/ ["nonmutating", "cpp:const"] idempotent int getPid(); + + /** + * + * Get the server properties + * + **/ + ["cpp:const"] idempotent Ice::PropertyDict getProperties() + throws ServerUnreachableException; + /** * * Set the process proxy. diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp index 0ec35344f6e..072c76d30ad 100644 --- a/cpp/src/IceGrid/ServerI.cpp +++ b/cpp/src/IceGrid/ServerI.cpp @@ -742,6 +742,55 @@ ServerI::getPid(const Ice::Current&) const return _node->getActivator()->getServerPid(_id); } +Ice::PropertyDict +ServerI::getProperties(const Ice::Current&) const +{ + Ice::ProcessPrx process = 0; + { + Lock sync(*this); + checkDestroyed(); + + // + // Wait for _process to be set + // + while(_desc->processRegistered && _process == 0) + { + wait(); + checkDestroyed(); + } + process = _process; + } + + if(process == 0) + { + throw ServerUnreachableException(_id, "no Admin object"); + } + + try + { + return Ice::PropertiesAdminPrx::uncheckedCast(process, "Properties")->getPropertiesForPrefix(""); + } + catch(const Ice::FacetNotExistException&) + { + // + // Probably an old server + // + throw ServerUnreachableException(_id, "no Properties facet"); + } + catch(const Ice::ObjectNotExistException&) + { + // + // Looks like the server was shut down + // + throw ServerUnreachableException(_id, "no Admin object"); + } + catch(const Ice::LocalException& ex) + { + throw ServerUnreachableException(_id, ex.what()); + } +} + + void ServerI::setEnabled(bool enabled, const ::Ice::Current&) { @@ -810,6 +859,7 @@ ServerI::setProcess_async(const AMD_Server_setProcessPtr& amdCB, const Ice::Proc checkDestroyed(); _process = process; deact = _state == DeactivatingWaitForProcess; + notifyAll(); } amdCB->ice_response(); if(deact) @@ -2355,6 +2405,7 @@ ServerI::setStateNoSync(InternalServerState st, const std::string& reason) InternalServerState previous = _state; _state = st; + // // Check if some commands are done. // @@ -2427,6 +2478,7 @@ ServerI::setStateNoSync(InternalServerState st, const std::string& reason) _destroy->finished(); _destroy = 0; } + notifyAll(); // for getProperties() break; default: break; diff --git a/cpp/src/IceGrid/ServerI.h b/cpp/src/IceGrid/ServerI.h index ac50abfb299..350d121f5ca 100644 --- a/cpp/src/IceGrid/ServerI.h +++ b/cpp/src/IceGrid/ServerI.h @@ -79,6 +79,7 @@ public: virtual ServerState getState(const ::Ice::Current& = Ice::Current()) const; virtual Ice::Int getPid(const ::Ice::Current& = Ice::Current()) const; + virtual Ice::PropertyDict getProperties(const ::Ice::Current& = Ice::Current()) const; virtual void setEnabled(bool, const ::Ice::Current&); virtual bool isEnabled(const ::Ice::Current& = Ice::Current()) const; |