diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-05-30 14:40:22 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-05-30 14:40:22 +0000 |
commit | 3bb83324d1004564bcc6e1a56e4bc937f28b6524 (patch) | |
tree | 4c568a7c2076b11c870dbcf261946d71bf3a0e7d /cpp | |
parent | Fixed bug 967 (diff) | |
download | ice-3bb83324d1004564bcc6e1a56e4bc937f28b6524.tar.bz2 ice-3bb83324d1004564bcc6e1a56e4bc937f28b6524.tar.xz ice-3bb83324d1004564bcc6e1a56e4bc937f28b6524.zip |
Fixed bug 971 and 983.
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/slice/IceGrid/Admin.ice | 12 | ||||
-rw-r--r-- | cpp/slice/IceGrid/Exception.ice | 10 | ||||
-rw-r--r-- | cpp/src/IceGrid/Activator.cpp | 10 | ||||
-rw-r--r-- | cpp/src/IceGrid/Internal.ice | 3 | ||||
-rw-r--r-- | cpp/src/IceGrid/Parser.cpp | 11 | ||||
-rw-r--r-- | cpp/src/IceGrid/ServerI.cpp | 36 |
6 files changed, 60 insertions, 22 deletions
diff --git a/cpp/slice/IceGrid/Admin.ice b/cpp/slice/IceGrid/Admin.ice index 038134cb8b1..9f57869dd28 100644 --- a/cpp/slice/IceGrid/Admin.ice +++ b/cpp/slice/IceGrid/Admin.ice @@ -476,8 +476,11 @@ interface Admin * @throws ServerNotExistException Raised if the server doesn't * exist. * - * @throws NodeUnreachableException Raised if the node could not be - * reached. + * @throws ServerStartException Raised if the server couldn't be + * started. + * + * @throws NodeUnreachableException Raised if the node could not + * be reached. * * @throws DeploymentException Raised if the server couldn't be * deployed on the node. @@ -495,6 +498,9 @@ interface Admin * @throws ServerNotExistException Raised if the server doesn't * exist. * + * @throws ServerStopException Raised if the server couldn't be + * stopped. + * * @throws NodeUnreachableException Raised if the node could not be * reached. * @@ -503,7 +509,7 @@ interface Admin * **/ ["ami"] void stopServer(string id) - throws ServerNotExistException, NodeUnreachableException, DeploymentException; + throws ServerNotExistException, ServerStopException, NodeUnreachableException, DeploymentException; /** * diff --git a/cpp/slice/IceGrid/Exception.ice b/cpp/slice/IceGrid/Exception.ice index 840b348f178..2663a8c5f84 100644 --- a/cpp/slice/IceGrid/Exception.ice +++ b/cpp/slice/IceGrid/Exception.ice @@ -50,6 +50,15 @@ exception ServerStartException string reason; }; +exception ServerStopException +{ + /** The identifier of the server. */ + string id; + + /** The reason of the failure. */ + string reason; +}; + /** * * This exception is raised if an adapter does not exist. @@ -128,6 +137,7 @@ exception NodeUnreachableException **/ exception BadSignalException { + string reason; }; /** diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp index 4d607d551f1..dacdc8519a6 100644 --- a/cpp/src/IceGrid/Activator.cpp +++ b/cpp/src/IceGrid/Activator.cpp @@ -172,7 +172,7 @@ int stringToSignal(const string& str) { #ifdef _WIN32 - throw BadSignalException(); + throw BadSignalException("signals are not supported on Windows"); #else if(str == ICE_STRING(SIGHUP)) @@ -246,7 +246,7 @@ stringToSignal(const string& str) return static_cast<int>(signal); } } - throw BadSignalException(); + throw BadSignalException("unknown signal `" + str + "'"); } } #endif @@ -900,7 +900,7 @@ Activator::sendSignal(const string& name, int signal) // // TODO: Win32 implementation? // - throw BadSignalException(); + throw BadSignalException("signals are not supported on Windows"); #else Ice::Int pid = getServerPid(name); @@ -1045,6 +1045,10 @@ Activator::deactivateAll() { p->second.server->stop_async(0); } + catch(const ServerStopException&) + { + // Server already stopped or destroyed. + } catch(const ObjectNotExistException&) { // diff --git a/cpp/src/IceGrid/Internal.ice b/cpp/src/IceGrid/Internal.ice index c44a07bd467..9135a6b6bc9 100644 --- a/cpp/src/IceGrid/Internal.ice +++ b/cpp/src/IceGrid/Internal.ice @@ -114,7 +114,8 @@ interface Server * amount of time, it will be killed. * **/ - ["amd"] void stop(); + ["amd"] void stop() + throws ServerStopException; /** * diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp index 379bf7989c8..c2fea1297fd 100644 --- a/cpp/src/IceGrid/Parser.cpp +++ b/cpp/src/IceGrid/Parser.cpp @@ -698,6 +698,10 @@ Parser::stopServer(const list<string>& args) { _admin->stopServer(args.front()); } + catch(const ServerStopException& ex) + { + error("the server didn't stop successfully:\n" + ex.reason); + } catch(const Ice::Exception& ex) { exception(ex); @@ -852,6 +856,11 @@ Parser::stateServer(const list<string>& args) cout << "deactivating (" << enabled << ")" << endl; break; } + case Destroying: + { + cout << "destroying (" << enabled << ")" << endl; + break; + } case Destroyed: { cout << "destroyed (" << enabled << ")" << endl; @@ -1558,7 +1567,7 @@ Parser::exception(const Ice::Exception& ex) catch(const BadSignalException& ex) { ostringstream s; - s << ex; + s << ex.reason; error(s.str()); } catch(const NodeUnreachableException& ex) diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp index e697ba17b74..2544c99dad5 100644 --- a/cpp/src/IceGrid/ServerI.cpp +++ b/cpp/src/IceGrid/ServerI.cpp @@ -329,12 +329,6 @@ public: { } - static bool - isStarted(ServerI::InternalServerState state) - { - return state == ServerI::ActivationTimeout || state == ServerI::Active; - } - virtual bool canExecute(ServerI::InternalServerState state) { @@ -441,6 +435,18 @@ public: } void + failed(const string& reason) + { + stopTimer(); + ServerStopException ex(_server->getId(), reason); + for(vector<AMD_Server_stopPtr>::const_iterator p = _stopCB.begin(); p != _stopCB.end(); ++p) + { + (*p)->ice_exception(ex); + } + _stopCB.clear(); + } + + void finished() { stopTimer(); @@ -607,14 +613,16 @@ ServerI::stop_async(const AMD_Server_stopPtr& amdCB, const Ice::Current&) { Lock sync(*this); checkDestroyed(); + if(StopCommand::isStopped(_state)) { - if(amdCB) - { - amdCB->ice_response(); - } - return; + throw ServerStopException(_id, "The server is already inactive."); + } + else if(_state == Destroying) + { + throw ServerStopException(_id, "The server is being destroyed."); } + if(!_stop) { _stop = new StopCommand(this, _node->getWaitQueue(), _deactivationTimeout); @@ -2044,13 +2052,13 @@ ServerI::setStateNoSync(InternalServerState st, const std::string& reason) _start->failed("The server is being destroyed."); _start = 0; } - break; - case Destroyed: if(_stop) { - _stop->finished(); + _stop->failed("The server is being destroyed."); _stop = 0; } + break; + case Destroyed: if(_destroy) { _destroy->finished(); |