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/ReplicaCache.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/ReplicaCache.cpp')
-rw-r--r-- | cpp/src/IceGrid/ReplicaCache.cpp | 92 |
1 files changed, 49 insertions, 43 deletions
diff --git a/cpp/src/IceGrid/ReplicaCache.cpp b/cpp/src/IceGrid/ReplicaCache.cpp index 5717f3e66f0..c04f680deba 100644 --- a/cpp/src/IceGrid/ReplicaCache.cpp +++ b/cpp/src/IceGrid/ReplicaCache.cpp @@ -37,42 +37,32 @@ ReplicaCache::ReplicaCache(const Ice::CommunicatorPtr& communicator, const IceSt ReplicaEntryPtr ReplicaCache::add(const string& name, const ReplicaSessionIPtr& session) { - ReplicaEntryPtr entry; + Lock sync(*this); + + while(true) { - Lock sync(*this); - - while(true) + ReplicaEntryPtr entry = getImpl(name); + if(entry) { - ReplicaEntryPtr entry = getImpl(name); - if(entry) + if(entry->getSession()->isDestroyed()) { - if(entry->getSession()->isDestroyed()) - { - wait(); - continue; - } - else - { - throw ReplicaActiveException(); - } + wait(); + continue; + } + else + { + throw ReplicaActiveException(); } - break; - } - - if(_traceLevels && _traceLevels->replica > 0) - { - Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat); - out << "replica `" << name << "' up"; } + break; + } - entry = addImpl(name, new ReplicaEntry(name, session)); + if(_traceLevels && _traceLevels->replica > 0) + { + Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat); + out << "replica `" << name << "' up"; } - - // - // Note: it's safe to do this outside the synchronization because - // remove() can't be called until this method returns (and until - // the replica session is fully created). - // + try { _nodes->replicaAdded(session->getInternalRegistry()); @@ -91,25 +81,23 @@ ReplicaCache::add(const string& name, const ReplicaSessionIPtr& session) } } - return entry; + return addImpl(name, new ReplicaEntry(name, session)); } ReplicaEntryPtr ReplicaCache::remove(const string& name, bool shutdown) { - ReplicaEntryPtr entry; - { - Lock sync(*this); - entry = getImpl(name); - assert(entry); - removeImpl(name); - notifyAll(); - - if(_traceLevels && _traceLevels->replica > 0) - { - Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat); - out << "replica `" << name << "' down"; - } + Lock sync(*this); + + ReplicaEntryPtr entry = getImpl(name); + assert(entry); + removeImpl(name); + notifyAll(); + + if(_traceLevels && _traceLevels->replica > 0) + { + Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat); + out << "replica `" << name << "' down"; } if(!shutdown) @@ -221,6 +209,24 @@ ReplicaCache::getEndpoints(const string& name, const Ice::ObjectPrx& proxy) cons return _communicator->stringToProxy("dummy")->ice_endpoints(endpoints); } +void +ReplicaCache::setInternalRegistry(const InternalRegistryPrx& proxy) +{ + // + // Setup this replica internal registry proxy. + // + _self = proxy; +} + +InternalRegistryPrx +ReplicaCache::getInternalRegistry() const +{ + // + // This replica internal registry proxy. + // + return _self; +} + ReplicaEntry::ReplicaEntry(const std::string& name, const ReplicaSessionIPtr& session) : _name(name), _session(session) |