summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2014-10-14 12:55:46 +0200
committerBenoit Foucher <benoit@zeroc.com>2014-10-14 12:58:58 +0200
commitd87cf8ef07bd13cf4bdeef88c7d75fe9c2593972 (patch)
treee0cd124ba9820e2740bcf199954457be7d30319e /cpp
parentAdded interrupt test for retry sleeps (diff)
downloadice-d87cf8ef07bd13cf4bdeef88c7d75fe9c2593972.tar.bz2
ice-d87cf8ef07bd13cf4bdeef88c7d75fe9c2593972.tar.xz
ice-d87cf8ef07bd13cf4bdeef88c7d75fe9c2593972.zip
Fixed ICE-5458: Locator::getRegistry now returns a replicated proxy
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/Ice/LocatorInfo.cpp6
-rw-r--r--cpp/src/IceGrid/LocatorI.cpp11
-rw-r--r--cpp/src/IceGrid/LocatorI.h7
-rw-r--r--cpp/src/IceGrid/RegistryI.cpp19
-rw-r--r--cpp/src/IceGrid/RegistryI.h4
-rw-r--r--cpp/src/IceGrid/WellKnownObjectsManager.cpp52
-rw-r--r--cpp/src/IceGrid/WellKnownObjectsManager.h3
7 files changed, 77 insertions, 25 deletions
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;