diff options
author | Benoit Foucher <benoit@zeroc.com> | 2008-01-10 15:42:06 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2008-01-10 15:42:06 +0100 |
commit | 5fffe43155bf1d4f74116cbc9a7fc52cf3868159 (patch) | |
tree | b9e0f02997a91ffa853aab7c4f9c169798b46f0b /cpp/src | |
parent | Some more changes wrt use of mcpp (diff) | |
download | ice-5fffe43155bf1d4f74116cbc9a7fc52cf3868159.tar.bz2 ice-5fffe43155bf1d4f74116cbc9a7fc52cf3868159.tar.xz ice-5fffe43155bf1d4f74116cbc9a7fc52cf3868159.zip |
Fixed bug 2629
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/ConnectionI.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IceGrid/IceGridNode.cpp | 4 | ||||
-rw-r--r-- | cpp/src/IceGrid/NodeI.cpp | 148 | ||||
-rw-r--r-- | cpp/src/IceGrid/NodeI.h | 4 | ||||
-rw-r--r-- | cpp/src/IceGrid/ServerI.cpp | 24 | ||||
-rw-r--r-- | cpp/src/IceGrid/ServerI.h | 1 |
6 files changed, 111 insertions, 72 deletions
diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index 71032f12073..c33e6d3467c 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -222,7 +222,7 @@ Ice::ConnectionI::start(const StartCallbackPtr& callback) // // If start is called with a callback, the callback is notified either by the - // thread per conncetion or the thread pool. + // thread per connection or the thread pool. // if(callback) { diff --git a/cpp/src/IceGrid/IceGridNode.cpp b/cpp/src/IceGrid/IceGridNode.cpp index 0ac32aae283..054c0f9136f 100644 --- a/cpp/src/IceGrid/IceGridNode.cpp +++ b/cpp/src/IceGrid/IceGridNode.cpp @@ -623,10 +623,10 @@ NodeService::start(int argc, char* argv[]) << "registry database is locked by `" << ex.lockUserId << "'"; warning(ostr.str()); } - catch(const LocalException& ex) + catch(const std::exception& ex) { ostringstream ostr; - ostr << "failed to deploy application `" << desc << "':\n" << ex; + ostr << "failed to deploy application `" << desc << "':\n" << ex.what(); warning(ostr.str()); } catch(const string& reason) diff --git a/cpp/src/IceGrid/NodeI.cpp b/cpp/src/IceGrid/NodeI.cpp index 4b86ca96a3a..ca6a0c17343 100644 --- a/cpp/src/IceGrid/NodeI.cpp +++ b/cpp/src/IceGrid/NodeI.cpp @@ -10,6 +10,7 @@ #include <IceUtil/Timer.h> #include <Ice/Ice.h> #include <IcePatch2/Util.h> +#include <IcePatch2/OS.h> #include <IcePatch2/ClientUtil.h> #include <IceGrid/NodeI.h> #include <IceGrid/Activator.h> @@ -444,52 +445,69 @@ NodeI::patch_async(const AMD_Node_patchPtr& amdCB, } _patchInProgress.insert(application); } - + + set<ServerIPtr> servers; - if(!appDistrib->icepatch.empty()) + bool patchApplication = !appDistrib->icepatch.empty(); + if(server.empty()) { // - // Get all the application servers (even the ones which - // don't have a distribution since they depend on the - // application distribution). + // Patch all the servers from the application. // servers = getApplicationServers(application); } - else if(server.empty()) + else { - // - // Get all the application servers which have a distribution. - // - servers = getApplicationServers(application); - set<ServerIPtr>::iterator s = servers.begin(); - while(s != servers.end()) + ServerIPtr svr; + try { - if((*s)->getDistribution()) + svr = ServerIPtr::dynamicCast(_adapter->find(createServerIdentity(server))); + } + catch(const Ice::ObjectAdapterDeactivatedException&) + { + } + + if(svr) + { + if(appDistrib->icepatch.empty() || !svr->dependsOnApplicationDistrib()) { - ++s; + // + // Don't patch the application if the server doesn't + // depend on it. + // + patchApplication = false; + servers.insert(svr); } else { - servers.erase(s++); + // + // If the server to patch depends on the application, + // we need to shutdown all the application servers + // that depend on the application. + // + servers = getApplicationServers(application); } } } - else + + set<ServerIPtr>::iterator s = servers.begin(); + while(s != servers.end()) { - // - // Get the given server. - // - Ice::Identity id = createServerIdentity(server); - try + if(!appDistrib->icepatch.empty() && (*s)->dependsOnApplicationDistrib()) { - ServerIPtr svr = ServerIPtr::dynamicCast(_adapter->find(id)); - if(svr) - { - servers.insert(svr); - } + ++s; } - catch(const Ice::ObjectAdapterDeactivatedException&) + else if((*s)->getDistribution() && (server.empty() || server == (*s)->getId())) + { + ++s; + } + else { + // + // Exclude servers which don't depend on the application distribution + // or don't have a distribution. + // + servers.erase(s++); } } @@ -520,7 +538,7 @@ NodeI::patch_async(const AMD_Node_patchPtr& amdCB, } } - if((servers.empty() || !appDistrib->icepatch.empty()) && !running.empty()) + if(!running.empty()) { if(running.size() == 1) { @@ -541,8 +559,9 @@ NodeI::patch_async(const AMD_Node_patchPtr& amdCB, // Patch the application. // FileServerPrx icepatch; - if(!appDistrib->icepatch.empty()) + if(patchApplication) { + assert(!appDistrib->icepatch.empty()); icepatch = FileServerPrx::checkedCast(_communicator->stringToProxy(appDistrib->icepatch)); if(!icepatch) { @@ -550,28 +569,26 @@ NodeI::patch_async(const AMD_Node_patchPtr& amdCB, } patch(icepatch, "distrib/" + application, appDistrib->directories); } - + // // Patch the server(s). // for(s = servers.begin(); s != servers.end(); ++s) { InternalDistributionDescriptorPtr dist = (*s)->getDistribution(); - if(!dist || (!server.empty() && (*s)->getId() != server)) + if(dist && (server.empty() || (*s)->getId() == server)) { - continue; - } - - icepatch = FileServerPrx::checkedCast(_communicator->stringToProxy(dist->icepatch)); - if(!icepatch) - { - throw "proxy `" + dist->icepatch + "' is not a file server."; - } - patch(icepatch, "servers/" + (*s)->getId() + "/distrib", dist->directories); - - if(!server.empty()) - { - break; + icepatch = FileServerPrx::checkedCast(_communicator->stringToProxy(dist->icepatch)); + if(!icepatch) + { + throw "proxy `" + dist->icepatch + "' is not a file server."; + } + patch(icepatch, "servers/" + (*s)->getId() + "/distrib", dist->directories); + + if(!server.empty()) + { + break; // No need to continue. + } } } } @@ -934,36 +951,43 @@ NodeI::observerUpdateAdapter(const AdapterDynamicInfo& info) } void -NodeI::addServer(const ServerIPtr& server, const string& application, bool dependsOnApplicationDistrib) +NodeI::addServer(const ServerIPtr& server, const string& application) { IceUtil::Mutex::Lock sync(_serversLock); - - if(dependsOnApplicationDistrib) + map<string, set<ServerIPtr> >::iterator p = _serversByApplication.find(application); + if(p == _serversByApplication.end()) { - map<string, set<ServerIPtr> >::iterator p = _serversByApplication.find(application); - if(p == _serversByApplication.end()) - { - map<string, set<ServerIPtr> >::value_type v(application, set<ServerIPtr>()); - p = _serversByApplication.insert(p, v); - } - p->second.insert(server); + map<string, set<ServerIPtr> >::value_type v(application, set<ServerIPtr>()); + p = _serversByApplication.insert(p, v); } + p->second.insert(server); } void -NodeI::removeServer(const ServerIPtr& server, const std::string& application, bool dependsOnApplicationDistrib) +NodeI::removeServer(const ServerIPtr& server, const std::string& application) { IceUtil::Mutex::Lock sync(_serversLock); - - if(dependsOnApplicationDistrib) + map<string, set<ServerIPtr> >::iterator p = _serversByApplication.find(application); + if(p != _serversByApplication.end()) { - map<string, set<ServerIPtr> >::iterator p = _serversByApplication.find(application); - if(p != _serversByApplication.end()) + p->second.erase(server); + if(p->second.empty()) { - p->second.erase(server); - if(p->second.empty()) + _serversByApplication.erase(p); + + string appDir = _dataDir + "/distrib/" + application; + OS::structstat buf; + if(OS::osstat(appDir, &buf) != -1 && S_ISDIR(buf.st_mode)) { - _serversByApplication.erase(p); + try + { + IcePatch2::removeRecursive(appDir); + } + catch(const string& msg) + { + Ice::Warning out(_traceLevels->logger); + out << "removing application directory `" << appDir << "' failed:\n" << msg; + } } } } diff --git a/cpp/src/IceGrid/NodeI.h b/cpp/src/IceGrid/NodeI.h index 1342427a7b5..4a6c0464904 100644 --- a/cpp/src/IceGrid/NodeI.h +++ b/cpp/src/IceGrid/NodeI.h @@ -98,8 +98,8 @@ public: void observerUpdateServer(const ServerDynamicInfo&); void observerUpdateAdapter(const AdapterDynamicInfo&); - void addServer(const ServerIPtr&, const std::string&, bool); - void removeServer(const ServerIPtr&, const std::string&, bool); + void addServer(const ServerIPtr&, const std::string&); + void removeServer(const ServerIPtr&, const std::string&); Ice::Identity createServerIdentity(const std::string&) const; std::string getServerAdminCategory() const; diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp index 7132944a443..d4eacad1224 100644 --- a/cpp/src/IceGrid/ServerI.cpp +++ b/cpp/src/IceGrid/ServerI.cpp @@ -910,6 +910,13 @@ ServerI::getDistribution() const return _desc ? _desc->distrib : InternalDistributionDescriptorPtr(); } +bool +ServerI::dependsOnApplicationDistrib() const +{ + Lock sync(*this); + return _desc ? _desc->applicationDistrib : false; +} + void ServerI::start(ServerActivation activation, const AMD_Server_startPtr& amdCB) { @@ -1521,7 +1528,7 @@ ServerI::destroy() adpts = _adapters; } - _node->removeServer(this, _desc->application, _desc->applicationDistrib); + _node->removeServer(this, _desc->application); try { @@ -1695,13 +1702,20 @@ ServerI::update() { throw DeploymentException(msg); } - + if(oldDescriptor) { - _node->removeServer(this, oldDescriptor->application, oldDescriptor->applicationDistrib); + if(oldDescriptor->application != _desc->application) + { + _node->removeServer(this, oldDescriptor->application); + _node->addServer(this, _desc->application); + } } - _node->addServer(this, _desc->application, _desc->applicationDistrib); - + else + { + _node->addServer(this, _desc->application); + } + AdapterPrxDict adapters; for(ServerAdapterDict::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p) { diff --git a/cpp/src/IceGrid/ServerI.h b/cpp/src/IceGrid/ServerI.h index f3fb183a5c8..5b449e6e386 100644 --- a/cpp/src/IceGrid/ServerI.h +++ b/cpp/src/IceGrid/ServerI.h @@ -90,6 +90,7 @@ public: bool isAdapterActivatable(const std::string&) const; const std::string& getId() const; InternalDistributionDescriptorPtr getDistribution() const; + bool dependsOnApplicationDistrib() const; void start(ServerActivation, const AMD_Server_startPtr& = AMD_Server_startPtr()); ServerCommandPtr load(const AMD_Node_loadServerPtr&, const InternalServerDescriptorPtr&, const std::string&); |