diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-11-14 13:37:33 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-11-14 13:37:33 +0000 |
commit | 212e427c71fc9090ac365de6ec42f2ba62838909 (patch) | |
tree | 4569d566eb17ec18407fe194542fc2a41eb0a9b8 /cpp/src/IceGrid/QueryI.cpp | |
parent | - Merging recent changes to R3_1_branch: (diff) | |
download | ice-212e427c71fc9090ac365de6ec42f2ba62838909.tar.bz2 ice-212e427c71fc9090ac365de6ec42f2ba62838909.tar.xz ice-212e427c71fc9090ac365de6ec42f2ba62838909.zip |
Added findAllReplicas to IceGrid::Query interface
Diffstat (limited to 'cpp/src/IceGrid/QueryI.cpp')
-rw-r--r-- | cpp/src/IceGrid/QueryI.cpp | 61 |
1 files changed, 43 insertions, 18 deletions
diff --git a/cpp/src/IceGrid/QueryI.cpp b/cpp/src/IceGrid/QueryI.cpp index efa395a0c67..b48e668a7bf 100644 --- a/cpp/src/IceGrid/QueryI.cpp +++ b/cpp/src/IceGrid/QueryI.cpp @@ -25,40 +25,65 @@ QueryI::~QueryI() { } -void -QueryI::findObjectById_async(const AMD_Query_findObjectByIdPtr& cb, const Ice::Identity& id, const Ice::Current&) const +Ice::ObjectPrx +QueryI::findObjectById(const Ice::Identity& id, const Ice::Current&) const { try { - cb->ice_response(_database->getObjectProxy(id)); + return _database->getObjectProxy(id); } catch(const ObjectNotRegisteredException&) { - cb->ice_response(0); + return 0; } } -void -QueryI::findObjectByType_async(const AMD_Query_findObjectByTypePtr& cb, const string& type, const Ice::Current&) const +Ice::ObjectPrx +QueryI::findObjectByType(const string& type, const Ice::Current&) const { - cb->ice_response(_database->getObjectByType(type)); + return _database->getObjectByType(type); } -void -QueryI::findObjectByTypeOnLeastLoadedNode_async(const AMD_Query_findObjectByTypeOnLeastLoadedNodePtr& cb, - const string& type, - LoadSample sample, - const Ice::Current&) const +Ice::ObjectPrx +QueryI::findObjectByTypeOnLeastLoadedNode(const string& type, LoadSample sample, const Ice::Current&) const { - cb->ice_response(_database->getObjectByTypeOnLeastLoadedNode(type, sample)); + return _database->getObjectByTypeOnLeastLoadedNode(type, sample); } -void -QueryI::findAllObjectsByType_async(const AMD_Query_findAllObjectsByTypePtr& cb, - const string& type, - const Ice::Current&) const +Ice::ObjectProxySeq +QueryI::findAllObjectsByType(const string& type, const Ice::Current&) const { - cb->ice_response(_database->getObjectsByType(type)); + return _database->getObjectsByType(type); } +Ice::ObjectProxySeq +QueryI::findAllReplicas(const Ice::ObjectPrx& proxy, const Ice::Current&) const +{ + try + { + if(!proxy) + { + return Ice::ObjectProxySeq(); + } + + AdapterInfoSeq infos = _database->getAdapterInfo(proxy->ice_getAdapterId()); + assert(!infos.empty()); + if(infos[0].replicaGroupId != proxy->ice_getAdapterId()) // The adapter id doesn't refer to a replica group. + { + return Ice::ObjectProxySeq(); + } + + Ice::ObjectProxySeq proxies; + for(AdapterInfoSeq::const_iterator p = infos.begin(); p != infos.end(); ++p) + { + assert(!p->id.empty()); + proxies.push_back(proxy->ice_adapterId(p->id)); + } + return proxies; + } + catch(const AdapterNotExistException&) + { + return Ice::ObjectProxySeq(); + } +} |