summaryrefslogtreecommitdiff
path: root/cpp/src/IceGrid/ReplicaCache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src/IceGrid/ReplicaCache.cpp')
-rw-r--r--cpp/src/IceGrid/ReplicaCache.cpp66
1 files changed, 37 insertions, 29 deletions
diff --git a/cpp/src/IceGrid/ReplicaCache.cpp b/cpp/src/IceGrid/ReplicaCache.cpp
index 52fda890dfd..f411e170730 100644
--- a/cpp/src/IceGrid/ReplicaCache.cpp
+++ b/cpp/src/IceGrid/ReplicaCache.cpp
@@ -7,6 +7,7 @@
//
// **********************************************************************
+#include <Ice/Communicator.h>
#include <Ice/LocalException.h>
#include <Ice/LoggerUtil.h>
#include <IceGrid/ReplicaCache.h>
@@ -62,7 +63,7 @@ ReplicaCache::add(const string& name, const ReplicaSessionIPtr& session)
try
{
- _nodes->replicaAdded(session->getProxy());
+ _nodes->replicaAdded(session->getInternalRegistry());
}
catch(const Ice::LocalException&)
{
@@ -91,7 +92,7 @@ ReplicaCache::remove(const string& name)
try
{
- _nodes->replicaRemoved(entry->getSession()->getProxy());
+ _nodes->replicaRemoved(entry->getSession()->getInternalRegistry());
}
catch(const Ice::LocalException&)
{
@@ -101,6 +102,20 @@ ReplicaCache::remove(const string& name)
return entry;
}
+ReplicaEntryPtr
+ReplicaCache::get(const string& name) const
+{
+ Lock sync(*this);
+ ReplicaEntryPtr entry = getImpl(name);
+ if(!entry)
+ {
+ RegistryNotExistException ex;
+ ex.name = name;
+ throw ex;
+ }
+ return entry;
+}
+
void
ReplicaCache::nodeAdded(const NodePrx& node)
{
@@ -134,48 +149,29 @@ ReplicaCache::nodeRemoved(const NodePrx& node)
}
Ice::ObjectPrx
-ReplicaCache::getClientProxy(const Ice::ObjectPrx& proxy) const
+ReplicaCache::getEndpoints(const string& name, const Ice::ObjectPrx& proxy) const
{
Ice::EndpointSeq endpoints;
- Ice::EndpointSeq endpts = proxy->ice_getEndpoints();
- endpoints.insert(endpoints.end(), endpts.begin(), endpts.end());
-
- for(map<string, ReplicaEntryPtr>::const_iterator p = _entries.begin(); p != _entries.end(); ++p)
+ if(proxy)
{
- Ice::ObjectPrx clientProxy = p->second->getSession()->getClientProxy();
- if(clientProxy)
- {
- endpts = clientProxy->ice_getEndpoints();
- endpoints.insert(endpoints.end(), endpts.begin(), endpts.end());
- }
+ Ice::EndpointSeq endpts = proxy->ice_getEndpoints();
+ endpoints.insert(endpoints.end(), endpts.begin(), endpts.end());
}
- return proxy->ice_endpoints(endpoints);
-}
-
-Ice::ObjectPrx
-ReplicaCache::getServerProxy(const Ice::ObjectPrx& proxy) const
-{
- Ice::EndpointSeq endpoints;
-
- Ice::EndpointSeq endpts = proxy->ice_getEndpoints();
- endpoints.insert(endpoints.end(), endpts.begin(), endpts.end());
-
for(map<string, ReplicaEntryPtr>::const_iterator p = _entries.begin(); p != _entries.end(); ++p)
{
- Ice::ObjectPrx serverProxy = p->second->getSession()->getServerProxy();
- if(serverProxy)
+ Ice::ObjectPrx prx = p->second->getSession()->getEndpoint(name);
+ if(prx)
{
- endpts = serverProxy->ice_getEndpoints();
+ Ice::EndpointSeq endpts = prx->ice_getEndpoints();
endpoints.insert(endpoints.end(), endpts.begin(), endpts.end());
}
}
- return proxy->ice_endpoints(endpoints);
+ return _communicator->stringToProxy("dummy")->ice_endpoints(endpoints);
}
-
ReplicaEntry::ReplicaEntry(const std::string& name, const ReplicaSessionIPtr& session) :
_name(name),
_session(session)
@@ -188,3 +184,15 @@ ReplicaEntry::getSession() const
return _session;
}
+RegistryInfo
+ReplicaEntry::getInfo() const
+{
+ return _session->getInfo();
+}
+
+InternalRegistryPrx
+ReplicaEntry::getProxy() const
+{
+ return _session->getInternalRegistry();
+}
+