diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-05-23 12:23:55 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-05-23 12:23:55 +0000 |
commit | 029fd83551338ea01613c54ddbc4906c09227c60 (patch) | |
tree | df5e77cbb88f29def748393baf98d88d172cb7ba | |
parent | fix test for recent slice change (diff) | |
download | ice-029fd83551338ea01613c54ddbc4906c09227c60.tar.bz2 ice-029fd83551338ea01613c54ddbc4906c09227c60.tar.xz ice-029fd83551338ea01613c54ddbc4906c09227c60.zip |
Added support for Glacier2 filters.
-rw-r--r-- | cpp/src/IceGrid/ObjectCache.cpp | 29 | ||||
-rw-r--r-- | cpp/src/IceGrid/ServerCache.cpp | 35 | ||||
-rw-r--r-- | cpp/src/IceGrid/ServerI.cpp | 3 | ||||
-rw-r--r-- | cpp/src/IceGrid/SessionI.cpp | 54 | ||||
-rw-r--r-- | cpp/src/IceGrid/SessionI.h | 1 | ||||
-rw-r--r-- | cpp/test/IceGrid/allocation/AllTests.cpp | 38 | ||||
-rw-r--r-- | cpp/test/IceGrid/allocation/application.xml | 11 | ||||
-rwxr-xr-x | cpp/test/IceGrid/allocation/run.py | 2 |
8 files changed, 167 insertions, 6 deletions
diff --git a/cpp/src/IceGrid/ObjectCache.cpp b/cpp/src/IceGrid/ObjectCache.cpp index d1eb882e2ef..95f98c99742 100644 --- a/cpp/src/IceGrid/ObjectCache.cpp +++ b/cpp/src/IceGrid/ObjectCache.cpp @@ -10,6 +10,7 @@ #include <IceUtil/Random.h> #include <Ice/Communicator.h> #include <Ice/LoggerUtil.h> +#include <Ice/LocalException.h> #include <IceGrid/ObjectCache.h> #include <IceGrid/NodeSessionI.h> #include <IceGrid/ServerCache.h> @@ -365,6 +366,20 @@ ObjectEntry::allocated(const SessionIPtr& session) out << "object `" << _cache.communicator()->identityToString(id) << "' allocated by `" << session->getId() << "' (" << _count << ")"; } + + Glacier2::SessionControlPrx ctl = session->getSessionControl(); + if(ctl) + { + try + { + Ice::IdentitySeq seq(1); + seq.push_back(_info.proxy->ice_getIdentity()); + ctl->objectIdFilter()->addAccept(seq); + } + catch(const Ice::ObjectNotExistException&) + { + } + } } void @@ -375,6 +390,20 @@ ObjectEntry::released(const SessionIPtr& session) // session->removeAllocation(this); + Glacier2::SessionControlPrx ctl = session->getSessionControl(); + if(ctl) + { + try + { + Ice::IdentitySeq seq(1); + seq.push_back(_info.proxy->ice_getIdentity()); + ctl->objectIdFilter()->removeAccept(seq); + } + catch(const Ice::ObjectNotExistException&) + { + } + } + TraceLevelsPtr traceLevels = _cache.getTraceLevels(); if(traceLevels && traceLevels->object > 1) { diff --git a/cpp/src/IceGrid/ServerCache.cpp b/cpp/src/IceGrid/ServerCache.cpp index b328fa5a3b3..5b68c70bc5a 100644 --- a/cpp/src/IceGrid/ServerCache.cpp +++ b/cpp/src/IceGrid/ServerCache.cpp @@ -9,6 +9,7 @@ #include <Ice/LoggerUtil.h> #include <Ice/Communicator.h> +#include <Ice/LocalException.h> #include <IceGrid/ServerCache.h> #include <IceGrid/NodeCache.h> #include <IceGrid/AdapterCache.h> @@ -787,6 +788,23 @@ ServerEntry::allocated(const SessionIPtr& session) _session = session; } } + + Glacier2::SessionControlPrx ctl = session->getSessionControl(); + if(ctl) + { + try + { + Ice::StringSeq seq(_adapters.size()); + for(AdapterPrxDict::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p) + { + seq.push_back(p->first); + } + ctl->adapterIdFilter()->addAccept(seq); + } + catch(const Ice::ObjectNotExistException&) + { + } + } } void @@ -817,6 +835,23 @@ ServerEntry::released(const SessionIPtr& session) } } + Glacier2::SessionControlPrx ctl = session->getSessionControl(); + if(ctl) + { + try + { + Ice::StringSeq seq(_adapters.size()); + for(AdapterPrxDict::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p) + { + seq.push_back(p->first); + } + ctl->adapterIdFilter()->removeAccept(seq); + } + catch(const Ice::ObjectNotExistException&) + { + } + } + TraceLevelsPtr traceLevels = _cache.getTraceLevels(); if(traceLevels && traceLevels->server > 1) { diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp index 2f20d322179..f8b44a878a8 100644 --- a/cpp/src/IceGrid/ServerI.cpp +++ b/cpp/src/IceGrid/ServerI.cpp @@ -57,6 +57,7 @@ chownRecursive(const string& path, uid_t uid, gid_t gid) { string name = namelist[i]->d_name; assert(!name.empty()); + free(namelist[i]); if(name != ".." && name != ".") { @@ -77,8 +78,6 @@ chownRecursive(const string& path, uid_t uid, gid_t gid) chownRecursive(name, uid, gid); } } - - free(namelist[i]); } free(namelist); diff --git a/cpp/src/IceGrid/SessionI.cpp b/cpp/src/IceGrid/SessionI.cpp index f096ee3ff4f..21b10bc90f4 100644 --- a/cpp/src/IceGrid/SessionI.cpp +++ b/cpp/src/IceGrid/SessionI.cpp @@ -300,7 +300,32 @@ ClientSessionManagerI::ClientSessionManagerI(const DatabasePtr& database, int ti Glacier2::SessionPrx ClientSessionManagerI::create(const string& user, const Glacier2::SessionControlPrx& ctl, const Ice::Current& current) { - return Glacier2::SessionPrx::uncheckedCast(current.adapter->addWithUUID(create(user, ctl))); + Glacier2::SessionPrx s = Glacier2::SessionPrx::uncheckedCast(current.adapter->addWithUUID(create(user, ctl))); + if(ctl) + { + try + { + // + // Restrict the objects the session is allowed to access to the session object itself, + // the query and registry objects. + // + Ice::IdentitySeq ids; + Ice::Identity id; + id.category = "IceGrid"; + id.name = "Query"; + ids.push_back(id); + id.name = "Registry"; + ids.push_back(id); + ids.push_back(s->ice_getIdentity()); + ctl->objectIdFilter()->addAccept(ids); + } + catch(const Ice::LocalException&) + { + s->destroy(); + return 0; + } + } + return s; } SessionIPtr @@ -338,5 +363,30 @@ ClientSSLSessionManagerI::create(const Glacier2::SSLInfo& info, const Glacier2:: } SessionIPtr session = new SessionI(userDN, _database, _timeout, _waitQueue, ctl); - return Glacier2::SessionPrx::uncheckedCast(current.adapter->addWithUUID(session)); + Glacier2::SessionPrx s = Glacier2::SessionPrx::uncheckedCast(current.adapter->addWithUUID(session)); + if(ctl) + { + try + { + // + // Restrict the objects the session is allowed to access to the session object itself, + // the query and registry objects. + // + Ice::IdentitySeq ids; + Ice::Identity id; + id.category = "IceGrid"; + id.name = "Query"; + ids.push_back(id); + id.name = "Registry"; + ids.push_back(id); + ids.push_back(s->ice_getIdentity()); + ctl->objectIdFilter()->addAccept(ids); + } + catch(const Ice::LocalException&) + { + s->destroy(); + return 0; + } + } + return s; } diff --git a/cpp/src/IceGrid/SessionI.h b/cpp/src/IceGrid/SessionI.h index 927f1e8a026..b4a4f4967c2 100644 --- a/cpp/src/IceGrid/SessionI.h +++ b/cpp/src/IceGrid/SessionI.h @@ -84,6 +84,7 @@ public: int getAllocationTimeout() const; const WaitQueuePtr& getWaitQueue() const { return _waitQueue; } const std::string& getId() const { return _id; } + Glacier2::SessionControlPrx getSessionControl() const { return _sessionControl; } bool addAllocationRequest(const AllocationRequestPtr&); void removeAllocationRequest(const AllocationRequestPtr&); diff --git a/cpp/test/IceGrid/allocation/AllTests.cpp b/cpp/test/IceGrid/allocation/AllTests.cpp index 34a234689af..64ec1a87426 100644 --- a/cpp/test/IceGrid/allocation/AllTests.cpp +++ b/cpp/test/IceGrid/allocation/AllTests.cpp @@ -13,6 +13,7 @@ #include <IceGrid/Registry.h> #include <IceGrid/Admin.h> #include <IceGrid/Query.h> +#include <Glacier2/Router.h> #include <TestCommon.h> #include <Test.h> @@ -325,6 +326,18 @@ allTests(const Ice::CommunicatorPtr& communicator) AdminPrx admin = AdminPrx::checkedCast(communicator->stringToProxy("IceGrid/Admin")); test(admin); + cout << "starting router... " << flush; + try + { + admin->startServer("Glacier2"); + } + catch(const ServerStartException& ex) + { + cerr << ex.reason << endl; + test(false); + } + cout << "ok" << endl; + RegistryPrx registry = RegistryPrx::checkedCast(communicator->stringToProxy("IceGrid/Registry")); test(registry); @@ -925,6 +938,27 @@ allTests(const Ice::CommunicatorPtr& communicator) cout << "ok" << endl; +// cout << "testing allocation with Glacier2 router... " << flush; +// Ice::ObjectPrx routerBase = communicator->stringToProxy("Glacier2/router:default -p 12347"); +// Glacier2::RouterPrx router1 = Glacier2::RouterPrx::checkedCast(routerBase->ice_connectionId("client1")); +// test(router1); + +// Glacier2::SessionPrx sessionBase = router1->createSession("test1", "abc123"); +// try +// { +// session1 = IceGrid::SessionPrx::checkedCast(sessionBase->ice_connectionId("client1")->ice_router(router1)); +// test(session1); +// session1->ice_ping(); + +// session1->destroy(); +// } +// catch(const Ice::LocalException& ex) +// { +// cerr << ex << endl; +// test(false); +// } +// cout << "ok" << endl; + cout << "stress test... " << flush; const int nClients = 4; int i; @@ -970,4 +1004,8 @@ allTests(const Ice::CommunicatorPtr& communicator) cerr << ex.reason << endl; test(false); } + + cout << "shutting down router... " << flush; + admin->stopServer("Glacier2"); + cout << "ok" << endl; } diff --git a/cpp/test/IceGrid/allocation/application.xml b/cpp/test/IceGrid/allocation/application.xml index 3679da32f20..26cbf3f13a6 100644 --- a/cpp/test/IceGrid/allocation/application.xml +++ b/cpp/test/IceGrid/allocation/application.xml @@ -1,6 +1,6 @@ <icegrid> - <application name="test" import-default-templates="true"> + <application name="Test" import-default-templates="true"> <replica-group id="Test"> <object identity="nonallocatable" type="::Test"/> @@ -9,6 +9,15 @@ <node name="localnode"> + <server id="Glacier2" exe="${ice.dir}/bin/glacier2router"> + <adapter name="Glacier2.Client" id="" endpoints="default -p 12347 -h 127.0.0.1 -t 10000"/> + <adapter name="Glacier2.Server" id="" endpoints="tcp -h 127.0.01"/> + <adapter name="Glacier2.Admin" id="" endpoints="tcp -h 127.0.0.1" register-process="true"/> + <property name="Glacier2.SessionManager" value="IceGrid/SessionManager"/> + <property name="Glacier2.PermissionsVerifier" value="IceGrid/NullPermissionsVerifier"/> + <property name="Glacier2.Client.Trace.Reject" value="2"/> + </server> + <server id="ObjectAllocation" exe="${test.dir}/server" activation="on-demand" pwd="."> <adapter name="Server" endpoints="default"> <object identity="allocatable" type="::Test"/> diff --git a/cpp/test/IceGrid/allocation/run.py b/cpp/test/IceGrid/allocation/run.py index 62306eb7763..34900817a5c 100755 --- a/cpp/test/IceGrid/allocation/run.py +++ b/cpp/test/IceGrid/allocation/run.py @@ -55,7 +55,7 @@ except: clientStatus = TestUtil.closePipe(clientPipe) print "removing application...", -IceGridAdmin.removeApplication("test") +IceGridAdmin.removeApplication("Test") print "ok" IceGridAdmin.shutdownIceGridNode() |