From: Anthony Geay Date: Thu, 4 Jan 2018 15:12:46 +0000 (+0100) Subject: Make the RequestSwitcher able to listVars and fetch data X-Git-Tag: EMC2_V_1_0_2~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4e054dca627289f89d752427f54c7f6cd9db7c14;p=modules%2Fkernel.git Make the RequestSwitcher able to listVars and fetch data --- diff --git a/idl/SALOME_SDS.idl b/idl/SALOME_SDS.idl index 51048ba1a..07950bd6e 100644 --- a/idl/SALOME_SDS.idl +++ b/idl/SALOME_SDS.idl @@ -76,6 +76,8 @@ module SALOME { void holdRequests(); void activeRequests(); + StringVec listVars(); + ByteVec fetchSerializedContent(in string varName) raises (SALOME::SALOME_Exception); }; interface DataScopeServerBase diff --git a/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx b/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx index 069b61882..986242775 100644 --- a/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx +++ b/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx @@ -52,7 +52,7 @@ void DataScopeKiller::shutdown() _orb->shutdown(0); } -RequestSwitcher::RequestSwitcher(CORBA::ORB_ptr orb) +RequestSwitcher::RequestSwitcher(CORBA::ORB_ptr orb, DataScopeServerBase *ds):_ds(ds) { CORBA::Object_var obj(orb->resolve_initial_references("RootPOA")); PortableServer::POA_var poa(PortableServer::POA::_narrow(obj)); @@ -82,6 +82,16 @@ void RequestSwitcher::activeRequests() _poa_manager_under_control->activate(); } +SALOME::StringVec *RequestSwitcher::listVars() +{ + return _ds->listVars(); +} + +SALOME::ByteVec *RequestSwitcher::fetchSerializedContent(const char *varName) +{ + return _ds->fetchSerializedContent(varName); +} + DataScopeServerBase::DataScopeServerBase(CORBA::ORB_ptr orb, SALOME::DataScopeKiller_var killer, const std::string& scopeName):_globals(0),_locals(0),_pickler(0),_orb(CORBA::ORB::_duplicate(orb)),_name(scopeName),_killer(killer) { } @@ -260,7 +270,7 @@ SALOME::RequestSwitcher_ptr DataScopeServerBase::getRequestSwitcher() { if(_rs.isNull()) { - _rs=new RequestSwitcher(_orb); + _rs=new RequestSwitcher(_orb,this); } CORBA::Object_var obj(_rs->activate()); return SALOME::RequestSwitcher::_narrow(obj); diff --git a/src/SALOMESDS/SALOMESDS_DataScopeServer.hxx b/src/SALOMESDS/SALOMESDS_DataScopeServer.hxx index eebdb37ec..64eb544c9 100644 --- a/src/SALOMESDS/SALOMESDS_DataScopeServer.hxx +++ b/src/SALOMESDS/SALOMESDS_DataScopeServer.hxx @@ -45,17 +45,27 @@ namespace SALOMESDS private: CORBA::ORB_var _orb; }; - + + class DataScopeServerBase; + + /*! + * Servant activated by a specific POA (single thread) having itself its specific POA_manager. + * This class is able to hold/active the default POA_manager shared by other POA than this. + */ class SALOMESDS_EXPORT RequestSwitcher : public POA_SALOME::RequestSwitcher, public POAHolder { public: - RequestSwitcher(CORBA::ORB_ptr orb); + RequestSwitcher(CORBA::ORB_ptr orb, DataScopeServerBase *ds); void holdRequests(); void activeRequests(); + SALOME::StringVec *listVars(); + SALOME::ByteVec *fetchSerializedContent(const char *varName); PortableServer::POA_var getPOA() const { return _poa_for_request_control; } private: PortableServer::POA_var _poa_for_request_control; PortableServer::POAManager_var _poa_manager_under_control; + //! handle on its creator to give access to services when _poa_manager_under_control is in hold mode. + DataScopeServerBase *_ds; }; class KeyWaiter; diff --git a/src/SALOMESDS/TestSalomeSDS.py b/src/SALOMESDS/TestSalomeSDS.py index 338953335..6ed7efc14 100644 --- a/src/SALOMESDS/TestSalomeSDS.py +++ b/src/SALOMESDS/TestSalomeSDS.py @@ -355,7 +355,7 @@ class SalomeSDSTest(unittest.TestCase): l.acquire() ; l2.acquire() cv=mp.Condition(mp.Lock()) dss,isCreated=dsm.giveADataScopeTransactionCalled(scopeName) - #assert(isCreated) + self.assertTrue(isCreated) p=mp.Process(target=func_test7,args=(scopeName,l,l2,cv)) p.start() l.acquire() @@ -371,7 +371,7 @@ class SalomeSDSTest(unittest.TestCase): rs.holdRequests() # the aim of the test is here. main process is occupied 1s -> holdRequests is Expected to wait s=(datetime.now()-s).total_seconds() rs.activeRequests() - assert(s>=0.99*nbOfSecWait and s=0.99*nbOfSecWait and s