diff options
author | Benoit Foucher <benoit@zeroc.com> | 2005-10-12 17:21:02 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2005-10-12 17:21:02 +0000 |
commit | aac841a43441f7911056ddbc6fc8c21aa6126431 (patch) | |
tree | 8dcad281655b53155e9c10e72b07d436208787a8 /cpp/src/Ice/ObjectAdapterI.cpp | |
parent | changing getLogger to return a custom Python impl (diff) | |
download | ice-aac841a43441f7911056ddbc6fc8c21aa6126431.tar.bz2 ice-aac841a43441f7911056ddbc6fc8c21aa6126431.tar.xz ice-aac841a43441f7911056ddbc6fc8c21aa6126431.zip |
Added support for replica groups and removed replicated adapters.
Diffstat (limited to 'cpp/src/Ice/ObjectAdapterI.cpp')
-rw-r--r-- | cpp/src/Ice/ObjectAdapterI.cpp | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index 36bae61cca3..6b823d7ad5d 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -64,7 +64,6 @@ Ice::ObjectAdapterI::activate() LocatorRegistryPrx locatorRegistry; bool registerProcess = false; string serverId; - string replicaId; CommunicatorPtr communicator; bool printAdapterReady = false; @@ -82,7 +81,6 @@ Ice::ObjectAdapterI::activate() registerProcess = _instance->properties()->getPropertyAsInt(_name + ".RegisterProcess") > 0; serverId = _instance->properties()->getProperty("Ice.ServerId"); - replicaId = _instance->properties()->getPropertyWithDefault(_name + ".ReplicaId", serverId); printAdapterReady = _instance->properties()->getPropertyAsInt("Ice.PrintAdapterReady") > 0; if(registerProcess && !locatorRegistry) @@ -122,17 +120,24 @@ Ice::ObjectAdapterI::activate() { Identity ident; ident.name = "dummy"; - locatorRegistry->setAdapterDirectProxy(_id, replicaId, createDirectProxy(ident)); + locatorRegistry->setAdapterDirectProxy(_id, _replicaGroupId, createDirectProxy(ident)); } catch(const ObjectAdapterDeactivatedException&) { // IGNORE: The object adapter is already inactive. } - catch(const AdapterNotFoundException& e) + catch(const AdapterNotFoundException&) { NotRegisteredException ex(__FILE__, __LINE__); ex.kindOfObject = "object adapter"; - ex.id = e.replica ? _id + " (replica = " + replicaId + ")" : _id; + ex.id = _id; + throw ex; + } + catch(const InvalidReplicaGroupIdException&) + { + NotRegisteredException ex(__FILE__, __LINE__); + ex.kindOfObject = "replica group"; + ex.id = _replicaGroupId; throw ex; } catch(const AdapterAlreadyActiveException&) @@ -453,6 +458,17 @@ Ice::ObjectAdapterI::createDirectProxy(const Identity& ident) const } ObjectPrx +Ice::ObjectAdapterI::createIndirectProxy(const Identity& ident) const +{ + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + + checkForDeactivation(); + checkIdentity(ident); + + return newIndirectProxy(ident, "", _id); +} + +ObjectPrx Ice::ObjectAdapterI::createReverseProxy(const Identity& ident) const { IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); @@ -748,6 +764,7 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const Communica _printAdapterReadyDone(false), _name(name), _id(instance->properties()->getProperty(name + ".AdapterId")), + _replicaGroupId(instance->properties()->getProperty(name + ".ReplicaGroupId")), _directCount(0), _waitForDeactivate(false) { @@ -849,19 +866,13 @@ Ice::ObjectAdapterI::newProxy(const Identity& ident, const string& facet) const { return newDirectProxy(ident, facet); } + else if(_replicaGroupId.empty()) + { + return newIndirectProxy(ident, facet, _id); + } else { - // - // Create a reference with the adapter id. - // - ReferencePtr ref = _instance->referenceFactory()->create( - ident, _instance->getDefaultContext(), facet, Reference::ModeTwoway, false, _id, - 0, _locatorInfo, _instance->defaultsAndOverrides()->defaultCollocationOptimization); - - // - // Return a proxy for the reference. - // - return _instance->proxyFactory()->referenceToProxy(ref); + return newIndirectProxy(ident, facet, _replicaGroupId); } } @@ -887,6 +898,22 @@ Ice::ObjectAdapterI::newDirectProxy(const Identity& ident, const string& facet) } +ObjectPrx +Ice::ObjectAdapterI::newIndirectProxy(const Identity& ident, const string& facet, const string& id) const +{ + // + // Create an indirect reference with the given adapter id. + // + ReferencePtr ref = _instance->referenceFactory()->create( + ident, _instance->getDefaultContext(), facet, Reference::ModeTwoway, false, id, 0, _locatorInfo, + _instance->defaultsAndOverrides()->defaultCollocationOptimization); + + // + // Return a proxy for the reference. + // + return _instance->proxyFactory()->referenceToProxy(ref); +} + void Ice::ObjectAdapterI::checkForDeactivation() const { |