diff options
author | Benoit Foucher <benoit@zeroc.com> | 2014-10-14 12:55:46 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2014-10-14 12:58:58 +0200 |
commit | d87cf8ef07bd13cf4bdeef88c7d75fe9c2593972 (patch) | |
tree | e0cd124ba9820e2740bcf199954457be7d30319e | |
parent | Added interrupt test for retry sleeps (diff) | |
download | ice-d87cf8ef07bd13cf4bdeef88c7d75fe9c2593972.tar.bz2 ice-d87cf8ef07bd13cf4bdeef88c7d75fe9c2593972.tar.xz ice-d87cf8ef07bd13cf4bdeef88c7d75fe9c2593972.zip |
Fixed ICE-5458: Locator::getRegistry now returns a replicated proxy
-rw-r--r-- | CHANGES | 6 | ||||
-rw-r--r-- | cpp/src/Ice/LocatorInfo.cpp | 6 | ||||
-rw-r--r-- | cpp/src/IceGrid/LocatorI.cpp | 11 | ||||
-rw-r--r-- | cpp/src/IceGrid/LocatorI.h | 7 | ||||
-rw-r--r-- | cpp/src/IceGrid/RegistryI.cpp | 19 | ||||
-rw-r--r-- | cpp/src/IceGrid/RegistryI.h | 4 | ||||
-rw-r--r-- | cpp/src/IceGrid/WellKnownObjectsManager.cpp | 52 | ||||
-rw-r--r-- | cpp/src/IceGrid/WellKnownObjectsManager.h | 3 | ||||
-rw-r--r-- | cs/src/Ice/LocatorInfo.cs | 7 | ||||
-rw-r--r-- | java/src/IceInternal/LocatorInfo.java | 7 | ||||
-rw-r--r-- | js/src/Ice/LocatorInfo.js | 7 |
11 files changed, 98 insertions, 31 deletions
@@ -27,6 +27,12 @@ Changes since version 3.5.1 General Changes =============== +- The IceGrid implementation of Ice::Locator::getRegistry now returns + a replicated proxy if IceGrid replication is used. This way, if a an + IceGrid replica becomes un-available during the server activation, + the server will still be able to register its endpoints if one of + the other replica. + - Added a cancel() method to AsyncResult. Calling it prevents a queued asynchronous request from being sent, or ignores the reply if the request has already been sent. It does not cancel the request in the diff --git a/cpp/src/Ice/LocatorInfo.cpp b/cpp/src/Ice/LocatorInfo.cpp index e668dc3a248..85b4cd2b03b 100644 --- a/cpp/src/Ice/LocatorInfo.cpp +++ b/cpp/src/Ice/LocatorInfo.cpp @@ -549,9 +549,11 @@ IceInternal::LocatorInfo::getLocatorRegistry() IceUtil::Mutex::Lock sync(*this); // - // The locator registry can't be located. + // The locator registry can't be located. We use ordered + // endpoint selection in case the locator returned a proxy + // with some endpoints which are prefered to be tried first. // - _locatorRegistry = LocatorRegistryPrx::uncheckedCast(locatorRegistry->ice_locator(0)); + _locatorRegistry = locatorRegistry->ice_locator(0)->ice_endpointSelection(Ice::Ordered); return _locatorRegistry; } } diff --git a/cpp/src/IceGrid/LocatorI.cpp b/cpp/src/IceGrid/LocatorI.cpp index 0a0add3df0d..2fef3c8c1e3 100644 --- a/cpp/src/IceGrid/LocatorI.cpp +++ b/cpp/src/IceGrid/LocatorI.cpp @@ -10,6 +10,7 @@ #include <Ice/Ice.h> #include <IceGrid/LocatorI.h> #include <IceGrid/Database.h> +#include <IceGrid/WellKnownObjectsManager.h> #include <IceGrid/SessionI.h> #include <IceGrid/Util.h> @@ -813,12 +814,12 @@ private: LocatorI::LocatorI(const Ice::CommunicatorPtr& communicator, const DatabasePtr& database, - const Ice::LocatorRegistryPrx& locatorRegistry, + const WellKnownObjectsManagerPtr& wellKnownObjects, const RegistryPrx& registry, const QueryPrx& query) : - _communicator(communicator), - _database(database), - _locatorRegistry(locatorRegistry), + _communicator(communicator), + _database(database), + _wellKnownObjects(wellKnownObjects), _localRegistry(registry), _localQuery(query) { @@ -933,7 +934,7 @@ LocatorI::findAdapterById_async(const Ice::AMD_Locator_findAdapterByIdPtr& cb, Ice::LocatorRegistryPrx LocatorI::getRegistry(const Ice::Current&) const { - return _locatorRegistry; + return _wellKnownObjects->getLocatorRegistry(); } RegistryPrx diff --git a/cpp/src/IceGrid/LocatorI.h b/cpp/src/IceGrid/LocatorI.h index 7753b0232db..85228263d9f 100644 --- a/cpp/src/IceGrid/LocatorI.h +++ b/cpp/src/IceGrid/LocatorI.h @@ -20,6 +20,9 @@ namespace IceGrid class Database; typedef IceUtil::Handle<Database> DatabasePtr; + +class WellKnownObjectsManager; +typedef IceUtil::Handle<WellKnownObjectsManager> WellKnownObjectsManagerPtr; class LocatorI; typedef IceUtil::Handle<LocatorI> LocatorIPtr; @@ -45,7 +48,7 @@ public: }; typedef IceUtil::Handle<Request> RequestPtr; - LocatorI(const Ice::CommunicatorPtr&, const DatabasePtr&, const Ice::LocatorRegistryPrx&, const RegistryPrx&, + LocatorI(const Ice::CommunicatorPtr&, const DatabasePtr&, const WellKnownObjectsManagerPtr&, const RegistryPrx&, const QueryPrx&); virtual void findObjectById_async(const Ice::AMD_Locator_findObjectByIdPtr&, const Ice::Identity&, @@ -69,7 +72,7 @@ protected: const Ice::CommunicatorPtr _communicator; const DatabasePtr _database; - const Ice::LocatorRegistryPrx _locatorRegistry; + const WellKnownObjectsManagerPtr _wellKnownObjects; const RegistryPrx _localRegistry; const QueryPrx _localQuery; diff --git a/cpp/src/IceGrid/RegistryI.cpp b/cpp/src/IceGrid/RegistryI.cpp index e21f87da173..521ba01dc8d 100644 --- a/cpp/src/IceGrid/RegistryI.cpp +++ b/cpp/src/IceGrid/RegistryI.cpp @@ -519,8 +519,8 @@ RegistryI::startImpl() QueryPrx query = setupQuery(); RegistryPrx registry = setupRegistry(); - Ice::LocatorRegistryPrx locatorRegistry = setupLocatorRegistry(); - LocatorPrx internalLocator = setupLocator(locatorRegistry, registry, query); + setupLocatorRegistry(); + LocatorPrx internalLocator = setupLocator(registry, query); // // Create the session servant manager. The session servant manager is responsible @@ -639,23 +639,20 @@ RegistryI::startImpl() return true; } -Ice::LocatorRegistryPrx +void RegistryI::setupLocatorRegistry() { - bool dynReg = _communicator->getProperties()->getPropertyAsInt("IceGrid.Registry.DynamicRegistration") > 0; + const bool dynReg = _communicator->getProperties()->getPropertyAsInt("IceGrid.Registry.DynamicRegistration") > 0; Identity locatorRegId; locatorRegId.category = _instanceName; - locatorRegId.name = "LocatorRegistry-" + _replicaName; - ObjectPrx obj = _serverAdapter->add(new LocatorRegistryI(_database, dynReg, _master, *_session), locatorRegId); - return LocatorRegistryPrx::uncheckedCast(obj); + locatorRegId.name = "LocatorRegistry"; + _serverAdapter->add(new LocatorRegistryI(_database, dynReg, _master, *_session), locatorRegId); } IceGrid::LocatorPrx -RegistryI::setupLocator(const Ice::LocatorRegistryPrx& locatorRegistry, - const RegistryPrx& registry, - const QueryPrx& query) +RegistryI::setupLocator(const RegistryPrx& registry, const QueryPrx& query) { - LocatorPtr locator = new LocatorI(_communicator, _database, locatorRegistry, registry, query); + LocatorPtr locator = new LocatorI(_communicator, _database, _wellKnownObjects, registry, query); Identity locatorId; locatorId.category = _instanceName; diff --git a/cpp/src/IceGrid/RegistryI.h b/cpp/src/IceGrid/RegistryI.h index 76a59b0cb06..e8b134f94b7 100644 --- a/cpp/src/IceGrid/RegistryI.h +++ b/cpp/src/IceGrid/RegistryI.h @@ -85,8 +85,8 @@ public: private: - Ice::LocatorRegistryPrx setupLocatorRegistry(); - LocatorPrx setupLocator(const Ice::LocatorRegistryPrx&, const RegistryPrx&, const QueryPrx&); + void setupLocatorRegistry(); + LocatorPrx setupLocator(const RegistryPrx&, const QueryPrx&); QueryPrx setupQuery(); RegistryPrx setupRegistry(); InternalRegistryPrx setupInternalRegistry(); diff --git a/cpp/src/IceGrid/WellKnownObjectsManager.cpp b/cpp/src/IceGrid/WellKnownObjectsManager.cpp index 596f43644bb..66f17cc77da 100644 --- a/cpp/src/IceGrid/WellKnownObjectsManager.cpp +++ b/cpp/src/IceGrid/WellKnownObjectsManager.cpp @@ -104,6 +104,11 @@ WellKnownObjectsManager::updateReplicatedWellKnownObjects() info.proxy = replicatedClientProxy->ice_identity(id); objects.push_back(info); + id.name = "LocatorRegistry"; + info.type = Ice::Locator::ice_staticId(); + info.proxy = _database->getReplicaCache().getEndpoints("Server", _endpoints["Server"])->ice_identity(id); + objects.push_back(info); + _database->addOrUpdateRegistryWellKnownObjects(objects); } @@ -124,10 +129,51 @@ WellKnownObjectsManager::getEndpoints(const string& name) LocatorPrx WellKnownObjectsManager::getLocator() { - Lock sync(*this); Ice::Identity id; id.name = "Locator"; id.category = _database->getInstanceName(); - Ice::ObjectPrx prx = _database->getReplicaCache().getEndpoints("Client", _endpoints["Client"]); - return LocatorPrx::uncheckedCast(prx->ice_identity(id)); + return LocatorPrx::uncheckedCast(getWellKnownObjectReplicatedProxy(id, "Client")); +} + +Ice::LocatorRegistryPrx +WellKnownObjectsManager::getLocatorRegistry() +{ + Ice::Identity id; + id.name = "LocatorRegistry"; + id.category = _database->getInstanceName(); + return Ice::LocatorRegistryPrx::uncheckedCast(getWellKnownObjectReplicatedProxy(id, "Server")); +} + +Ice::ObjectPrx +WellKnownObjectsManager::getWellKnownObjectReplicatedProxy(const Ice::Identity& id, const string& endpt) +{ + try + { + Ice::ObjectPrx proxy = _database->getObjectProxy(id); + Ice::EndpointSeq registryEndpoints = getEndpoints(endpt)->ice_getEndpoints(); + + // + // Re-order the endpoints to return first the endpoint for this + // registry replica. + // + Ice::EndpointSeq endpoints = proxy->ice_getEndpoints(); + Ice::EndpointSeq newEndpoints = registryEndpoints; + for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p) + { + if(find(registryEndpoints.begin(), registryEndpoints.end(), *p) == registryEndpoints.end()) + { + newEndpoints.push_back(*p); + } + } + return proxy->ice_endpoints(newEndpoints); + } + catch(const ObjectNotRegisteredException&) + { + // + // If for some reasons the object isn't registered, we compute + // the endpoints with the replica cache. For slaves, this will + // however only return the slave endpoints. + // + return _database->getReplicaCache().getEndpoints(endpt, getEndpoints(endpt))->ice_identity(id); + } } diff --git a/cpp/src/IceGrid/WellKnownObjectsManager.h b/cpp/src/IceGrid/WellKnownObjectsManager.h index f6ee5a35112..1cde35b9957 100644 --- a/cpp/src/IceGrid/WellKnownObjectsManager.h +++ b/cpp/src/IceGrid/WellKnownObjectsManager.h @@ -36,11 +36,14 @@ public: Ice::ObjectPrx getEndpoints(const std::string&); LocatorPrx getLocator(); + Ice::LocatorRegistryPrx getLocatorRegistry(); private: bool initialized() const; + Ice::ObjectPrx getWellKnownObjectReplicatedProxy(const Ice::Identity&, const std::string&); + const DatabasePtr _database; bool _initialized; diff --git a/cs/src/Ice/LocatorInfo.cs b/cs/src/Ice/LocatorInfo.cs index d8d67c1f21b..f0961278ae1 100644 --- a/cs/src/Ice/LocatorInfo.cs +++ b/cs/src/Ice/LocatorInfo.cs @@ -341,9 +341,12 @@ namespace IceInternal lock(this) { // - // The locator registry can't be located. + // The locator registry can't be located. We use ordered + // endpoint selection in case the locator returned a proxy + // with some endpoints which are prefered to be tried first. // - _locatorRegistry = Ice.LocatorRegistryPrxHelper.uncheckedCast(locatorRegistry.ice_locator(null)); + _locatorRegistry = (Ice.LocatorRegistryPrx)locatorRegistry.ice_locator(null).ice_endpointSelection( + Ice.EndpointSelectionType.Ordered); return _locatorRegistry; } } diff --git a/java/src/IceInternal/LocatorInfo.java b/java/src/IceInternal/LocatorInfo.java index e64d73b8a58..fe20942a315 100644 --- a/java/src/IceInternal/LocatorInfo.java +++ b/java/src/IceInternal/LocatorInfo.java @@ -330,9 +330,12 @@ public final class LocatorInfo synchronized(this) { // - // The locator registry can't be located. + // The locator registry can't be located. We use ordered + // endpoint selection in case the locator returned a proxy + // with some endpoints which are prefered to be tried first. // - _locatorRegistry = Ice.LocatorRegistryPrxHelper.uncheckedCast(locatorRegistry.ice_locator(null)); + _locatorRegistry = (Ice.LocatorRegistryPrx)locatorRegistry.ice_locator(null).ice_endpointSelection( + Ice.EndpointSelectionType.Ordered); return _locatorRegistry; } } diff --git a/js/src/Ice/LocatorInfo.js b/js/src/Ice/LocatorInfo.js index b223e338ab1..a3173bd3dcb 100644 --- a/js/src/Ice/LocatorInfo.js +++ b/js/src/Ice/LocatorInfo.js @@ -79,9 +79,12 @@ var LocatorInfo = Class({ function(reg) { // - // The locator registry can't be located. + // The locator registry can't be located. We use ordered + // endpoint selection in case the locator returned a proxy + // with some endpoints which are prefered to be tried first. // - self._locatorRegistry = LocatorRegistryPrx.uncheckedCast(reg.ice_locator(null)); + self._locatorRegistry = LocatorRegistryPrx.uncheckedCast(reg.ice_locator(null).ice_endpointSelection( + Ice.EndpointSelectionType.Ordered)); return self._locatorRegistry; }); }, |