diff options
Diffstat (limited to 'cpp/src/IceGrid/ReplicaSessionI.cpp')
-rw-r--r-- | cpp/src/IceGrid/ReplicaSessionI.cpp | 77 |
1 files changed, 51 insertions, 26 deletions
diff --git a/cpp/src/IceGrid/ReplicaSessionI.cpp b/cpp/src/IceGrid/ReplicaSessionI.cpp index ed64af89e9b..1c34e7cba67 100644 --- a/cpp/src/IceGrid/ReplicaSessionI.cpp +++ b/cpp/src/IceGrid/ReplicaSessionI.cpp @@ -11,19 +11,24 @@ #include <IceGrid/ReplicaSessionI.h> #include <IceGrid/Database.h> +#include <IceGrid/WellKnownObjectsManager.h> using namespace std; using namespace IceGrid; ReplicaSessionI::ReplicaSessionI(const DatabasePtr& database, + const WellKnownObjectsManagerPtr& wellKnownObjects, const string& name, + const RegistryInfo& info, const InternalRegistryPrx& proxy, - const RegistryObserverPrx& observer) : + const DatabaseObserverPrx& databaseObserver) : _database(database), + _wellKnownObjects(wellKnownObjects), _traceLevels(database->getTraceLevels()), _name(name), - _proxy(InternalRegistryPrx::uncheckedCast(proxy->ice_timeout(_database->getSessionTimeout() * 1000))), - _observer(observer), + _internalRegistry(InternalRegistryPrx::uncheckedCast(proxy->ice_timeout(_database->getSessionTimeout() * 1000))), + _databaseObserver(databaseObserver), + _info(info), _timestamp(IceUtil::Time::now()), _destroy(false) { @@ -65,31 +70,59 @@ ReplicaSessionI::getTimeout(const Ice::Current& current) const } void -ReplicaSessionI::setClientAndServerProxies(const Ice::ObjectPrx& clientProxy, - const Ice::ObjectPrx& serverProxy, - const Ice::Current&) +ReplicaSessionI::setEndpoints(const StringObjectProxyDict& endpoints, const Ice::Current& current) { { Lock sync(*this); - _clientProxy = clientProxy; - _serverProxy = serverProxy; + if(_destroy) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + _replicaEndpoints = endpoints; } - _database->updateReplicatedWellKnownObjects(); + _wellKnownObjects->updateReplicatedWellKnownObjects(); } void -ReplicaSessionI::destroy(const Ice::Current& current) +ReplicaSessionI::registerWellKnownObjects(const ObjectInfoSeq& objects, const Ice::Current& current) { - Lock sync(*this); - if(_destroy) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + Lock sync(*this); + if(_destroy) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + _replicaWellKnownObjects = objects; } + _wellKnownObjects->registerWellKnownObjects(objects); +} - _destroy = true; +void +ReplicaSessionI::destroy(const Ice::Current& current) +{ + { + Lock sync(*this); + if(_destroy) + { + throw Ice::ObjectNotExistException(__FILE__, __LINE__); + } + _destroy = true; + } + _database->removeReplica(_name, this); - _database->removeReplica(_name, this, !current.adapter); - _database->updateReplicatedWellKnownObjects(); + _wellKnownObjects->unregisterWellKnownObjects(_replicaWellKnownObjects); + bool shutdown = !current.adapter; + if(shutdown) + { + ObjectInfo info; + info.type = InternalRegistry::ice_staticId(); + info.proxy = _internalRegistry; + _database->addObject(info, true); + } + else + { + _wellKnownObjects->updateReplicatedWellKnownObjects(); // No need to update these if we're shutting down. + } if(current.adapter) { @@ -97,7 +130,6 @@ ReplicaSessionI::destroy(const Ice::Current& current) { current.adapter->remove(current.id); } - catch(const Ice::ObjectAdapterDeactivatedException&) { } @@ -116,15 +148,8 @@ ReplicaSessionI::timestamp() const } Ice::ObjectPrx -ReplicaSessionI::getClientProxy() const -{ - Lock sync(*this); - return _clientProxy; -} - -Ice::ObjectPrx -ReplicaSessionI::getServerProxy() const +ReplicaSessionI::getEndpoint(const std::string& name) { Lock sync(*this); - return _serverProxy; + return _replicaEndpoints[name]; } |