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 /cpp/src/IceGrid/WellKnownObjectsManager.cpp | |
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
Diffstat (limited to 'cpp/src/IceGrid/WellKnownObjectsManager.cpp')
-rw-r--r-- | cpp/src/IceGrid/WellKnownObjectsManager.cpp | 52 |
1 files changed, 49 insertions, 3 deletions
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); + } } |