]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
RdExtInit is now OK for recovery.
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 12 Aug 2015 13:44:11 +0000 (15:44 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 12 Aug 2015 13:44:11 +0000 (15:44 +0200)
idl/SALOME_SDS.idl
src/SALOMESDS/SALOMESDS_DataScopeServer.cxx
src/SALOMESDS/SALOMESDS_DataScopeServer.hxx
src/SALOMESDS/SALOMESDS_PickelizedPyObjRdExtInitServer.cxx
src/SALOMESDS/SALOMESDS_PickelizedPyObjRdExtInitServer.hxx
src/SALOMESDS/SALOMESDS_Transaction.cxx
src/SALOMESDS/SALOMESDS_Transaction.hxx
src/SALOMESDS/TestSalomeSDS.py

index e0ccd185bb17422a6eaa586b6e05d89aa6f972b7..cabea85c95c825a6526d8d3b06854cea208e45ff 100644 (file)
@@ -117,6 +117,7 @@ module SALOME
     string getAccessOfVar(in string varName) raises (SALOME::SALOME_Exception);
     Transaction createRdOnlyVarTransac(in string varName, in ByteVec constValue) raises (SALOME::SALOME_Exception);
     Transaction createRdExtVarTransac(in string varName, in ByteVec constValue) raises (SALOME::SALOME_Exception);
+    Transaction createRdExtInitVarTransac(in string varName, in ByteVec constValue) raises (SALOME::SALOME_Exception);
     Transaction createRdWrVarTransac(in string varName, in ByteVec constValue) raises (SALOME::SALOME_Exception);
     Transaction addKeyValueInVarHard(in string varName, in ByteVec keyValue, in ByteVec constValue) raises (SALOME::SALOME_Exception);
     Transaction addKeyValueInVarErrorIfAlreadyExisting(in string varName, in ByteVec keyValue, in ByteVec constValue) raises (SALOME::SALOME_Exception);
index 528e2566400f9b1a5898f800af7f5950e892f17c..e471c502f8b46ddd85a19ee3aa6fbd78b65e1940 100644 (file)
@@ -362,19 +362,23 @@ void DataScopeServerBase::moveStatusOfVarFromRdOnlyToRdWr(const std::string& var
   varc->decrRef();
 }
 
-void DataScopeServerBase::moveStatusOfVarFromRdExtToRdExtInit(const std::string& varName)
+void DataScopeServerBase::moveStatusOfVarFromRdExtOrRdExtInitToRdExtInit(const std::string& varName)
 {
   std::list< std::pair< SALOME::BasicDataServer_var, BasicDataServer * > >::iterator it(retrieveVarInternal4(varName));
   std::pair< SALOME::BasicDataServer_var, BasicDataServer * >& p(*it);
-  PickelizedPyObjRdExtServer *varc(dynamic_cast<PickelizedPyObjRdExtServer *>(p.second));
-  if(!varc)
-    throw Exception("DataScopeServerBase::moveStatusOfVarFromRdExtToRdExtInit : var is not a RdExt !");
-  PyObject *pyobj(varc->getPyObj()); Py_XINCREF(pyobj);
-  PickelizedPyObjRdExtInitServer *newVar(new PickelizedPyObjRdExtInitServer(this,varName,pyobj));
-  CORBA::Object_var obj(newVar->activate());
-  SALOME::BasicDataServer_var obj2(SALOME::BasicDataServer::_narrow(obj));
-  p.first=obj2; p.second=newVar;
-  varc->decrRef();
+  PickelizedPyObjRdExtServer *varc0(dynamic_cast<PickelizedPyObjRdExtServer *>(p.second));
+  PickelizedPyObjRdExtInitServer *varc1(dynamic_cast<PickelizedPyObjRdExtInitServer *>(p.second));
+  if(!varc0 && !varc1)
+    throw Exception("DataScopeServerBase::moveStatusOfVarFromRdExtOrRdExtInitToRdExtInit : var is neither RdExt nor RdExtInit !");
+  if(varc0)
+    {
+      PyObject *pyobj(varc0->getPyObj()); Py_XINCREF(pyobj);
+      PickelizedPyObjRdExtInitServer *newVar(new PickelizedPyObjRdExtInitServer(this,varName,pyobj));
+      CORBA::Object_var obj(newVar->activate());
+      SALOME::BasicDataServer_var obj2(SALOME::BasicDataServer::_narrow(obj));
+      p.first=obj2; p.second=newVar;
+      varc0->decrRef();
+    }
 }
 
 void DataScopeServerBase::moveStatusOfVarFromRdExtInitToRdExt(const std::string& varName)
@@ -525,6 +529,15 @@ void DataScopeServerTransaction::createRdExtVarInternal(const std::string& varNa
   _vars.push_back(p);
 }
 
+void DataScopeServerTransaction::createRdExtInitVarInternal(const std::string& varName, const SALOME::ByteVec& constValue)
+{
+  checkNotAlreadyExistingVar(varName);
+  PickelizedPyObjRdExtInitServer *tmp(new PickelizedPyObjRdExtInitServer(this,varName,constValue));
+  CORBA::Object_var ret(tmp->activate());
+  std::pair< SALOME::BasicDataServer_var, BasicDataServer * > p(SALOME::BasicDataServer::_narrow(ret),tmp);
+  _vars.push_back(p);
+}
+
 void DataScopeServerTransaction::createRdWrVarInternal(const std::string& varName, const SALOME::ByteVec& constValue)
 {
   checkNotAlreadyExistingVar(varName);
@@ -550,6 +563,14 @@ SALOME::Transaction_ptr DataScopeServerTransaction::createRdExtVarTransac(const
   return SALOME::Transaction::_narrow(obj);
 }
 
+SALOME::Transaction_ptr DataScopeServerTransaction::createRdExtInitVarTransac(const char *varName, const SALOME::ByteVec& constValue)
+{
+  checkNotAlreadyExistingVar(varName);
+  TransactionRdExtInitVarCreate *ret(new TransactionRdExtInitVarCreate(this,varName,constValue));
+  CORBA::Object_var obj(ret->activate());
+  return SALOME::Transaction::_narrow(obj);
+}
+
 SALOME::Transaction_ptr DataScopeServerTransaction::createRdWrVarTransac(const char *varName, const SALOME::ByteVec& constValue)
 {
   checkNotAlreadyExistingVar(varName);
index cab0c12bd577c18d3059f0e8bc8782e9665be8f2..261b5ac00e1a3bbefbbd8ea1e7885e78bd456534 100644 (file)
@@ -85,7 +85,7 @@ namespace SALOMESDS
   public:
     void moveStatusOfVarFromRdWrToRdOnly(const std::string& varName);
     void moveStatusOfVarFromRdOnlyToRdWr(const std::string& varName);
-    void moveStatusOfVarFromRdExtToRdExtInit(const std::string& varName);
+    void moveStatusOfVarFromRdExtOrRdExtInitToRdExtInit(const std::string& varName);
     void moveStatusOfVarFromRdExtInitToRdExt(const std::string& varName);
   protected:
     std::list< std::pair< SALOME::BasicDataServer_var, BasicDataServer * > >::const_iterator retrieveVarInternal3(const std::string& varName) const;
@@ -122,6 +122,7 @@ namespace SALOMESDS
     ~DataScopeServerTransaction();
     void createRdOnlyVarInternal(const std::string& varName, const SALOME::ByteVec& constValue);
     void createRdExtVarInternal(const std::string& varName, const SALOME::ByteVec& constValue);
+    void createRdExtInitVarInternal(const std::string& varName, const SALOME::ByteVec& constValue);
     void createRdWrVarInternal(const std::string& varName, const SALOME::ByteVec& constValue);
     PortableServer::POA_var getPOA4KeyWaiter() const { return _poa_for_key_waiter; }
     void addWaitKey(KeyWaiter *kw);
@@ -132,6 +133,7 @@ namespace SALOMESDS
     char *getAccessOfVar(const char *varName);
     SALOME::Transaction_ptr createRdOnlyVarTransac(const char *varName, const SALOME::ByteVec& constValue);
     SALOME::Transaction_ptr createRdExtVarTransac(const char *varName, const SALOME::ByteVec& constValue);
+    SALOME::Transaction_ptr createRdExtInitVarTransac(const char *varName, const SALOME::ByteVec& constValue);
     SALOME::Transaction_ptr createRdWrVarTransac(const char *varName, const SALOME::ByteVec& constValue);
     SALOME::Transaction_ptr addKeyValueInVarHard(const char *varName, const SALOME::ByteVec& key, const SALOME::ByteVec& value);
     SALOME::Transaction_ptr addKeyValueInVarErrorIfAlreadyExisting(const char *varName, const SALOME::ByteVec& key, const SALOME::ByteVec& value);
index 608af2dfb0e24a8776e35bb385711a2dd4a8217b..d345fd15aa06e6016cb585df1ab1311c15d0f0ae 100644 (file)
@@ -29,6 +29,11 @@ using namespace SALOMESDS;
 
 const char PickelizedPyObjRdExtInitServer::ACCESS_REPR[]="RdExtInit";
 
+PickelizedPyObjRdExtInitServer::PickelizedPyObjRdExtInitServer(DataScopeServerBase *father, const std::string& varName, const SALOME::ByteVec& value):PickelizedPyObjServerModifiable(father,varName,value)
+{
+  _self_deep_copy=DeepCopyPyObj(_self);
+}
+
 //! obj is consumed
 PickelizedPyObjRdExtInitServer::PickelizedPyObjRdExtInitServer(DataScopeServerBase *father, const std::string& varName, PyObject *obj):PickelizedPyObjServerModifiable(father,varName,obj),_self_deep_copy(0)
 {
index d5b7c781cc5ab97447b264ca679980f5b281ef12..25f94d6f783999a06115d2b1df9152a11282f07b 100644 (file)
@@ -33,6 +33,7 @@ namespace SALOMESDS
   class PickelizedPyObjRdExtInitServer : public PickelizedPyObjServerModifiable, public virtual POA_SALOME::PickelizedPyObjRdExtInitServer
   {
   public:
+    PickelizedPyObjRdExtInitServer(DataScopeServerBase *father, const std::string& varName, const SALOME::ByteVec& value);
     PickelizedPyObjRdExtInitServer(DataScopeServerBase *father, const std::string& varName, PyObject *obj);
     ~PickelizedPyObjRdExtInitServer();
   public:
index a903cca490388cae93e929603410ad781ed8b48c..6b4577cfab09fb0fce42bba60d7359ef88971273 100644 (file)
@@ -87,6 +87,13 @@ void TransactionRdExtVarCreate::perform()
   _dsct->createRdExtVarInternal(_var_name,data2);
 }
 
+void TransactionRdExtInitVarCreate::perform()
+{
+  SALOME::ByteVec data2;
+  FromVBToByteSeq(_data,data2);
+  _dsct->createRdExtInitVarInternal(_var_name,data2);
+}
+
 void TransactionRdWrVarCreate::perform()
 {
   SALOME::ByteVec data2;
@@ -228,7 +235,7 @@ void TransactionMorphRdWrIntoRdOnly::notify()
 
 TransactionMultiKeyAddSession::TransactionMultiKeyAddSession(DataScopeServerTransaction *dsct, const std::string& varName):Transaction(dsct,varName)
 {
-  _dsct->moveStatusOfVarFromRdExtToRdExtInit(_var_name);
+  _dsct->moveStatusOfVarFromRdExtOrRdExtInitToRdExtInit(_var_name);
 }
 
 void TransactionMultiKeyAddSession::addKeyValueInVarErrorIfAlreadyExistingNow(const SALOME::ByteVec& key, const SALOME::ByteVec& value)
index 8d3db4479a894dc3920997841211006c9dac1175..c58ccd9294af5d873328a5c2fbdd3e49e213d948 100644 (file)
@@ -83,6 +83,13 @@ namespace SALOMESDS
     void perform();
   };
 
+  class TransactionRdExtInitVarCreate : public TransactionVarCreate
+  {
+  public:
+    TransactionRdExtInitVarCreate(DataScopeServerTransaction *dsct, const std::string& varName, const SALOME::ByteVec& constValue):TransactionVarCreate(dsct,varName,constValue) { }
+    void perform();
+  };
+
   class TransactionRdWrVarCreate : public TransactionVarCreate
   {
   public:
index 80557dc58a26731bead3d3f590ca773114c7fdb1..bd333ca39995c5c1e4e0a8af8be9efd62c81d4a3 100644 (file)
@@ -277,6 +277,30 @@ class SalomeSDSTest(unittest.TestCase):
       dsm.removeDataScope(scopeName)
     pass
 
+  def testTransaction7(self):
+    """Like testTransaction5 but after a recovery."""
+    scopeName="Scope1"
+    varName="a"
+    dsm=salome.naming_service.Resolve("/DataServerManager")
+    dsm.cleanScopesInNS()
+    if scopeName in dsm.listScopes():
+      dsm.removeDataScope(scopeName)
+    dss,isCreated=dsm.giveADataScopeTransactionCalled(scopeName)
+    self.assertTrue(isCreated)
+    #
+    t0=dss.createRdExtInitVarTransac(varName,obj2Str({"ab":[4,5,6]}))
+    dss.atomicApply([t0])
+    #
+    self.assertEqual(dss.getAccessOfVar(varName),"RdExtInit")
+    t1=dss.addMultiKeyValueSession(varName)
+    self.assertEqual(dss.getAccessOfVar(varName),"RdExtInit")
+    t1.addKeyValueInVarErrorIfAlreadyExistingNow(obj2Str("cd"),obj2Str([7,8,9,10]))
+    self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'ab':[4,5,6]})# it is not a bug ! commit of t1 not done !
+    dss.atomicApply([t1])
+    self.assertEqual(dss.getAccessOfVar(varName),"RdExt")
+    self.assertEqual(str2Obj(dss.fetchSerializedContent(varName)),{'ab':[4,5,6],'cd':[7,8,9,10]})
+    pass
+
   def setUp(self):
     salome.salome_init()
     pass