diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-11-23 14:44:51 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-11-23 14:44:51 +0000 |
commit | ad476fdda5c9a9f23b9e65fc3c4b3016f7704848 (patch) | |
tree | 329b46efefd33095fe3ed8dc92ef3d8726cd0857 /cpp/src/IceGrid/ServerCache.cpp | |
parent | Remove deprecated methods (diff) | |
download | ice-ad476fdda5c9a9f23b9e65fc3c4b3016f7704848.tar.bz2 ice-ad476fdda5c9a9f23b9e65fc3c4b3016f7704848.tar.xz ice-ad476fdda5c9a9f23b9e65fc3c4b3016f7704848.zip |
Code cleanup and fixed startup scalability issue of the registry (it no
longer contacts all the nodes).
Diffstat (limited to 'cpp/src/IceGrid/ServerCache.cpp')
-rw-r--r-- | cpp/src/IceGrid/ServerCache.cpp | 85 |
1 files changed, 25 insertions, 60 deletions
diff --git a/cpp/src/IceGrid/ServerCache.cpp b/cpp/src/IceGrid/ServerCache.cpp index 88c0cbac8ad..124359630d2 100644 --- a/cpp/src/IceGrid/ServerCache.cpp +++ b/cpp/src/IceGrid/ServerCache.cpp @@ -26,19 +26,20 @@ namespace IceGrid struct AddCommunicator : std::unary_function<CommunicatorDescriptorPtr&, void> { - AddCommunicator(ServerCache& serverCache, const ServerEntryPtr& entry) : - _serverCache(serverCache), _entry(entry) + AddCommunicator(ServerCache& serverCache, const ServerEntryPtr& entry, const string& application) : + _serverCache(serverCache), _entry(entry), _application(application) { } void operator()(const CommunicatorDescriptorPtr& desc) { - _serverCache.addCommunicator(desc, _entry); + _serverCache.addCommunicator(desc, _entry, _application); } ServerCache& _serverCache; const ServerEntryPtr _entry; + const string _application; }; struct RemoveCommunicator : std::unary_function<CommunicatorDescriptorPtr&, void> @@ -86,7 +87,7 @@ ServerCache::add(const ServerInfo& info) entry->update(info); _nodeCache.get(info.node, true)->addServer(entry); - forEachCommunicator(AddCommunicator(*this, entry))(info.descriptor); + forEachCommunicator(AddCommunicator(*this, entry, info.application))(info.descriptor); if(_traceLevels && _traceLevels->server > 0) { @@ -153,13 +154,14 @@ ServerCache::clear(const string& id) } void -ServerCache::addCommunicator(const CommunicatorDescriptorPtr& comm, const ServerEntryPtr& server) +ServerCache::addCommunicator(const CommunicatorDescriptorPtr& comm, + const ServerEntryPtr& server, + const string& application) { - const string application = server->getApplication(); for(AdapterDescriptorSeq::const_iterator q = comm->adapters.begin() ; q != comm->adapters.end(); ++q) { assert(!q->id.empty()); - _adapterCache.addServerAdapter(*q, server); + _adapterCache.addServerAdapter(*q, server, application); ObjectDescriptorSeq::const_iterator r; for(r = q->objects.begin(); r != q->objects.end(); ++r) @@ -208,7 +210,7 @@ ServerEntry::ServerEntry(ServerCache& cache, const string& id) : } void -ServerEntry::sync() +ServerEntry::load() { try { @@ -221,6 +223,18 @@ ServerEntry::sync() } void +ServerEntry::unload() +{ + Lock sync(*this); + if(_loaded.get()) + { + _load = _loaded; + } + _proxy = 0; + _adapters.clear(); +} + +void ServerEntry::update(const ServerInfo& info) { Lock sync(*this); @@ -324,28 +338,15 @@ ServerEntry::getId() const ServerPrx ServerEntry::getProxy(int& activationTimeout, int& deactivationTimeout, string& node, bool upToDate) { - ServerPrx proxy; { Lock sync(*this); if(_loaded.get() || _proxy && !upToDate) // Synced or if not up to date is fine { assert(_loaded.get() || _load.get()); - proxy = _proxy; activationTimeout = _activationTimeout; deactivationTimeout = _deactivationTimeout; node = _loaded.get() ? _loaded->node : _load->node; - } - } - - if(proxy) - { - try - { - proxy->ice_ping(); - return proxy; - } - catch(const Ice::LocalException&) - { + return _proxy; } } @@ -378,8 +379,6 @@ ServerEntry::getProxy(int& activationTimeout, int& deactivationTimeout, string& AdapterPrx ServerEntry::getAdapter(const string& id, bool upToDate) { - AdapterPrx proxy; - { Lock sync(*this); if(_loaded.get() || _proxy && !upToDate) // Synced or if not up to date is fine @@ -387,8 +386,8 @@ ServerEntry::getAdapter(const string& id, bool upToDate) AdapterPrxDict::const_iterator p = _adapters.find(id); if(p != _adapters.end()) { - proxy = p->second; - assert(proxy); + assert(p->second); + return p->second; } else { @@ -397,18 +396,6 @@ ServerEntry::getAdapter(const string& id, bool upToDate) } } - if(proxy) - { - try - { - proxy->ice_ping(); - return proxy; - } - catch(const Ice::LocalException&) - { - } - } - while(true) { syncImpl(true); @@ -439,28 +426,6 @@ ServerEntry::getAdapter(const string& id, bool upToDate) } } -NodeEntryPtr -ServerEntry::getNode() const -{ - Lock sync(*this); - if(!_loaded.get() && !_load.get()) - { - throw ServerNotExistException(); - } - return _loaded.get() ? _cache.getNodeCache().get(_loaded->node) : _cache.getNodeCache().get(_load->node); -} - -string -ServerEntry::getApplication() const -{ - Lock sync(*this); - if(!_loaded.get() && !_load.get()) - { - throw ServerNotExistException(); - } - return _loaded.get() ? _loaded->application : _load->application; -} - float ServerEntry::getLoad(LoadSample sample) const { |