From 2d918e1915c9151c298eec7b92d83e0cb45d8b4a Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Fri, 1 Dec 2006 09:03:37 +0000 Subject: Use deactivation timeout for loadServer call --- cpp/src/IceGrid/NodeCache.cpp | 31 +++++++++++++++++++++---------- cpp/src/IceGrid/NodeCache.h | 2 +- cpp/src/IceGrid/ServerCache.cpp | 20 ++++++++++++++++---- 3 files changed, 38 insertions(+), 15 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/IceGrid/NodeCache.cpp b/cpp/src/IceGrid/NodeCache.cpp index c765115d331..d0a8e000671 100644 --- a/cpp/src/IceGrid/NodeCache.cpp +++ b/cpp/src/IceGrid/NodeCache.cpp @@ -30,10 +30,9 @@ public: LoadCB(const TraceLevelsPtr& traceLevels, const ServerEntryPtr& server, - const string& id, const string& node, int timeout) : - _traceLevels(traceLevels), _server(server), _id(id), _node(node), _timeout(timeout) + _traceLevels(traceLevels), _server(server), _id(server->getId()), _node(node), _timeout(timeout) { } @@ -47,7 +46,7 @@ public: } // - // Apply the node session timeout on the proxies. + // Add the node session timeout on the proxies. // ServerPrx server = ServerPrx::uncheckedCast(proxy->ice_timeout(_timeout * 1000)); AdapterPrxDict adapters; @@ -105,8 +104,8 @@ class DestroyCB : public AMI_Node_destroyServer { public: - DestroyCB(const TraceLevelsPtr& traceLevels, const ServerEntryPtr& server, const string& id, const string& node) : - _traceLevels(traceLevels), _server(server), _id(id), _node(node) + DestroyCB(const TraceLevelsPtr& traceLevels, const ServerEntryPtr& server, const string& node) : + _traceLevels(traceLevels), _server(server), _id(server->getId()), _node(node) { } @@ -408,18 +407,30 @@ NodeEntry::canRemove() } void -NodeEntry::loadServer(const ServerEntryPtr& entry, const ServerInfo& server, const SessionIPtr& session) +NodeEntry::loadServer(const ServerEntryPtr& entry, const ServerInfo& server, const SessionIPtr& session, int timeout) { try { NodePrx node; - int timeout; + int sessionTimeout; ServerDescriptorPtr desc; { Lock sync(*this); checkSession(); node = _session->getNode(); - timeout = _session->getTimeout(); + sessionTimeout = _session->getTimeout(); + + // + // Check if we should use a specific timeout (the load + // call can deactivate the server and it can take some + // time to deactivate, up to "deactivation-timeout" + // seconds). + // + if(timeout > 0 && timeout != sessionTimeout) + { + node = NodePrx::uncheckedCast(node->ice_timeout(sessionTimeout)); + } + try { desc = getServerDescriptor(server, session); @@ -452,7 +463,7 @@ NodeEntry::loadServer(const ServerEntryPtr& entry, const ServerInfo& server, con } } - AMI_Node_loadServerPtr amiCB = new LoadCB(_cache.getTraceLevels(), entry, entry->getId(), _name, timeout); + AMI_Node_loadServerPtr amiCB = new LoadCB(_cache.getTraceLevels(), entry, _name, sessionTimeout); ServerInfo info = server; info.descriptor = desc; node->loadServer_async(amiCB, info, _cache.isMaster()); @@ -473,7 +484,7 @@ NodeEntry::destroyServer(const ServerEntryPtr& entry, const ServerInfo& info) Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->serverCat); out << "unloading `" << info.descriptor->id << "' on node `" << _name << "'"; } - AMI_Node_destroyServerPtr amiCB = new DestroyCB(_cache.getTraceLevels(), entry, info.descriptor->id, _name); + AMI_Node_destroyServerPtr amiCB = new DestroyCB(_cache.getTraceLevels(), entry, _name); getProxy()->destroyServer_async(amiCB, info.descriptor->id, info.uuid, info.revision); } catch(const NodeUnreachableException& ex) diff --git a/cpp/src/IceGrid/NodeCache.h b/cpp/src/IceGrid/NodeCache.h index e2228f275f2..c61c1363ea3 100644 --- a/cpp/src/IceGrid/NodeCache.h +++ b/cpp/src/IceGrid/NodeCache.h @@ -53,7 +53,7 @@ public: bool canRemove(); - void loadServer(const ServerEntryPtr&, const ServerInfo&, const SessionIPtr&); + void loadServer(const ServerEntryPtr&, const ServerInfo&, const SessionIPtr&, int); void destroyServer(const ServerEntryPtr&, const ServerInfo&); ServerInfo getServerInfo(const ServerInfo&, const SessionIPtr&); diff --git a/cpp/src/IceGrid/ServerCache.cpp b/cpp/src/IceGrid/ServerCache.cpp index 8da34d4ffca..ba6a18f73a2 100644 --- a/cpp/src/IceGrid/ServerCache.cpp +++ b/cpp/src/IceGrid/ServerCache.cpp @@ -233,6 +233,8 @@ ServerEntry::unload() } _proxy = 0; _adapters.clear(); + _activationTimeout = -1; + _deactivationTimeout = -1; } void @@ -473,6 +475,7 @@ ServerEntry::syncImpl(bool waitForUpdate) ServerInfo load; SessionIPtr session; ServerInfo destroy; + int timeout = -1; { Lock sync(*this); @@ -507,6 +510,7 @@ ServerEntry::syncImpl(bool waitForUpdate) { load = *_load; session = _session; + timeout = _deactivationTimeout; // loadServer might block to deactivate the previous server. } else { @@ -531,7 +535,7 @@ ServerEntry::syncImpl(bool waitForUpdate) { try { - _cache.getNodeCache().get(load.node)->loadServer(this, load, session); + _cache.getNodeCache().get(load.node)->loadServer(this, load, session, timeout); } catch(NodeNotExistException&) { @@ -576,6 +580,7 @@ ServerEntry::loadCallback(const ServerPrx& proxy, const AdapterPrxDict& adpts, i ServerInfo load; SessionIPtr session; ServerInfo destroy; + int timeout = -1; { Lock sync(*this); @@ -611,6 +616,7 @@ ServerEntry::loadCallback(const ServerPrx& proxy, const AdapterPrxDict& adpts, i { load = *_load; session = _session; + timeout = _deactivationTimeout; // loadServer might block to deactivate the previous server. } } } @@ -631,7 +637,7 @@ ServerEntry::loadCallback(const ServerPrx& proxy, const AdapterPrxDict& adpts, i { try { - _cache.getNodeCache().get(load.node)->loadServer(this, load, session); + _cache.getNodeCache().get(load.node)->loadServer(this, load, session, timeout); } catch(NodeNotExistException&) { @@ -651,6 +657,8 @@ ServerEntry::destroyCallback() _destroy.reset(0); _proxy = 0; _adapters.clear(); + _activationTimeout = -1; + _deactivationTimeout = -1; if(!_load.get()) { @@ -670,7 +678,7 @@ ServerEntry::destroyCallback() { try { - _cache.getNodeCache().get(load.node)->loadServer(this, load, session); + _cache.getNodeCache().get(load.node)->loadServer(this, load, session, -1); } catch(NodeNotExistException&) { @@ -689,6 +697,7 @@ ServerEntry::exception(const Ice::Exception& ex) ServerInfo load; SessionIPtr session; bool remove = false; + int timeout = -1; { Lock sync(*this); @@ -699,6 +708,8 @@ ServerEntry::exception(const Ice::Exception& ex) _exception.reset(ex.ice_clone()); _proxy = 0; _adapters.clear(); + _activationTimeout = -1; + _deactivationTimeout = -1; _synchronizing = false; notifyAll(); } @@ -708,6 +719,7 @@ ServerEntry::exception(const Ice::Exception& ex) _updated = false; load = *_load.get(); session = _session; + timeout = _deactivationTimeout; // loadServer might block to deactivate the previous server. } } @@ -715,7 +727,7 @@ ServerEntry::exception(const Ice::Exception& ex) { try { - _cache.getNodeCache().get(load.node)->loadServer(this, load, session); + _cache.getNodeCache().get(load.node)->loadServer(this, load, session, timeout); } catch(NodeNotExistException&) { -- cgit v1.2.3