Salome HOME
CCAR: add traces to CALCIUM ports, some debug in ModuleCatalog
authorcaremoli <caremoli>
Fri, 30 May 2008 09:02:44 +0000 (09:02 +0000)
committercaremoli <caremoli>
Fri, 30 May 2008 09:02:44 +0000 (09:02 +0000)
      add CEXE option to component catalog to be able to specify a specific container
      executable for special component
      some debug in python container

idl/SALOME_ModuleCatalog.idl
src/Container/SALOME_ContainerManager.cxx
src/Container/SALOME_ContainerManager.hxx
src/Container/SALOME_ContainerPy.py
src/DSC/DSC_User/Datastream/Calcium/CalciumCouplingPolicy.cxx
src/DSC/DSC_User/Datastream/Calcium/CalciumCouplingPolicy.hxx
src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx
src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx
src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx

index dfc8764f6777fd8dfd14f77b97ff12e25c5ebf34..9231f7e399e952d905cd5232ab6c057761a90cbe 100644 (file)
@@ -171,7 +171,8 @@ Implementation type
   enum ImplType {
     SO,                       /* component implemented as a dynamic library loadable with dlopen */
     PY,                       /* component implemented as a python module loadable with import */
-    EXE                       /* component implemented as an executable */
+    EXE,                      /* component implemented as an executable */
+    CEXE                      /* component to be loaded by a container which executable is given in the catalog */
   } ;
 
 /*!
index 52802a1442d01d4d9267abf7643f15394899e2a7..20f46f6d7c48d28afa4a86b5cbc005c1c55600a1 100644 (file)
@@ -19,6 +19,7 @@
 //
 #include "SALOME_ContainerManager.hxx"
 #include "SALOME_NamingService.hxx"
+#include "SALOME_ModuleCatalog.hh"
 #include "OpUtil.hxx"
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -199,7 +200,7 @@ Engines::Container_ptr
 SALOME_ContainerManager::
 StartContainer(const Engines::MachineParameters& params,
               const Engines::MachineList& possibleComputers,
-              Engines::ResPolicy policy)
+              Engines::ResPolicy policy,const std::string& container_exe)
 {
 #ifdef WITH_PACO_PARALLEL
   std::string parallelLib(params.parallelLib);
@@ -259,9 +260,9 @@ StartContainer(const Engines::MachineParameters& params,
     return Engines::Container::_nil();
   }
   else if(theMachine==GetHostname())
-    command = BuildCommandToLaunchLocalContainer(params,id);
+    command = BuildCommandToLaunchLocalContainer(params,id,container_exe);
   else
-    command = BuildCommandToLaunchRemoteContainer(theMachine,params,id);
+    command = BuildCommandToLaunchRemoteContainer(theMachine,params,id,container_exe);
 
   RmTmpFile();
 
@@ -349,7 +350,55 @@ StartContainer(const Engines::MachineParameters& params,
               const Engines::CompoList& componentList)
 {
   Engines::MachineList_var possibleComputers = _ResManager->GetFittingResources(params,componentList);
-  return StartContainer(params,possibleComputers,policy);
+
+  // Look into ModulCatalog if a specific container must be launched
+  CORBA::String_var container_exe;
+  int found=0;
+  try
+    {
+      CORBA::Object_var obj = _NS->Resolve("/Kernel/ModulCatalog");
+      SALOME_ModuleCatalog::ModuleCatalog_var Catalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj) ;
+      if (CORBA::is_nil (Catalog))
+        return Engines::Container::_nil();
+      // Loop through component list
+      for(int i=0;i<componentList.length();i++)
+        {
+          const char* compoi = componentList[i];
+          SALOME_ModuleCatalog::Acomponent_var compoInfo = Catalog->GetComponent(compoi);
+          if (CORBA::is_nil (compoInfo))
+            {
+              INFOS("ContainerManager Error: Component not found in the catalog" );
+              INFOS( compoi );
+              return Engines::Container::_nil();
+            }
+          SALOME_ModuleCatalog::ImplType impl=compoInfo->implementation_type();
+          container_exe=compoInfo->implementation_name();
+          if(impl==SALOME_ModuleCatalog::CEXE)
+            {
+              if(found)
+                {
+                  INFOS("ContainerManager Error: you can't have 2 CEXE component in the same container" );
+                  return Engines::Container::_nil();
+                }
+              found=1;
+            }
+        }
+    }
+  catch (ServiceUnreachable&)
+    {
+      INFOS("Caught exception: Naming Service Unreachable");
+      return Engines::Container::_nil();
+    }
+  catch (...)
+    {
+      INFOS("Caught unknown exception.");
+      return Engines::Container::_nil();
+    }
+
+  if(found)
+    return StartContainer(params,possibleComputers,policy,container_exe.in());
+  else
+    return StartContainer(params,possibleComputers,policy);
 }
 
 #ifdef WITH_PACO_PARALLEL
@@ -738,7 +787,7 @@ bool isPythonContainer(const char* ContainerName)
 string
 SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer
 (const string& machine,
- const Engines::MachineParameters& params, const long id)
+ const Engines::MachineParameters& params, const long id,const std::string& container_exe)
 {
   string command;
   int nbproc;
@@ -822,7 +871,7 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer
          command += " SALOME_MPIContainer ";
        }
       else
-       command += " SALOME_Container ";
+        command += " " +container_exe+ " ";
 
       command += _NS->ContainerName(params);
       command += " -id ";
@@ -845,7 +894,7 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer
 
 string
 SALOME_ContainerManager::BuildCommandToLaunchLocalContainer
-(const Engines::MachineParameters& params, const long id)
+(const Engines::MachineParameters& params, const long id,const std::string& container_exe)
 {
   _TmpFileName = "";
   string command;
@@ -906,7 +955,7 @@ SALOME_ContainerManager::BuildCommandToLaunchLocalContainer
       if (isPythonContainer(params.container_name))
         command += "SALOME_ContainerPy.py ";
       else
-        command += "SALOME_Container ";
+        command += container_exe + " ";
     }
 
   command += _NS->ContainerName(params);
index d8be68833208b647e07f400435b39dd304c5abd4..869b9c23514e9e3b376df6a93831c6eab7198bb2 100644 (file)
@@ -47,7 +47,8 @@ public:
   Engines::Container_ptr
   StartContainer(const Engines::MachineParameters& params,
                 const Engines::MachineList& possibleComputer,
-                Engines::ResPolicy policy);
+                Engines::ResPolicy policy,
+     const std::string& container_exe="SALOME_Container");
 
   Engines::Container_ptr
   StartContainer(const Engines::MachineParameters& params,
@@ -88,9 +89,11 @@ protected:
   long GetIdForContainer(void);
 
   std::string BuildCommandToLaunchRemoteContainer(const std::string& machine,
-                                                 const Engines::MachineParameters& params, const long id);
+                                                 const Engines::MachineParameters& params, const long id,
+              const std::string& container_exe="SALOME_Container");
 
-  std::string BuildCommandToLaunchLocalContainer(const Engines::MachineParameters& params, const long id);
+  std::string BuildCommandToLaunchLocalContainer(const Engines::MachineParameters& params, const long id,
+                                                 const std::string& container_exe="SALOME_Container");
 
   std::string BuildTempFileToLaunchRemoteContainer(const std::string& machine,
                                                   const Engines::MachineParameters& params) throw(SALOME_Exception);
index 1694bc79df93c5bf7e7adb2dc19949dec6712342..db23b6c79d3d94bc88dfeefa20f955e17128b018 100755 (executable)
@@ -307,6 +307,13 @@ class SALOME_ContainerPy_i (Engines__POA.Container):
         self._orb.shutdown(0)
         pass
 
+    def _get_logfilename(self):
+      return self._logfilename
+    def _set_logfilename(self,logfilename):
+      self._logfilename=logfilename
+    def _get_workingdir(self):
+      return os.getcwd()
+
 #=============================================================================
 
 #initialise the ORB and find the root POA
@@ -323,6 +330,8 @@ cpy_i = SALOME_ContainerPy_i(orb, poa, containerName)
 print "SALOME_ContainerPy_i instance created ",cpy_i 
 cpy_o = cpy_i._this()
 print "SALOME_ContainerPy_i instance activated ",cpy_o
+sys.stdout.flush()
+sys.stderr.flush()
 
 #activate the POA
 poaManager = poa._get_the_POAManager()
index 2a18b69e328aa5a1b6d16de6901ee1350be1b63f..6835898f90c2acba8202f273ad23a808f21d7ddc 100644 (file)
@@ -38,12 +38,18 @@ void CalciumCouplingPolicy::setDependencyType (CalciumTypes::DependencyType depe
 CalciumTypes::DependencyType CalciumCouplingPolicy::getDependencyType () const              { return _dependencyType;}
  
 void   CalciumCouplingPolicy::setStorageLevel   (size_t         storageLevel)   {
+#ifdef _DEBUG_
+  std::cerr << "CalciumCouplingPolicy::setStorageLevel: " << storageLevel << std::endl;
+#endif
   if ( storageLevel < 1 && (storageLevel != CalciumTypes::UNLIMITED_STORAGE_LEVEL)  )
     throw CalciumException(CalciumTypes::CPRENA,LOC("Un niveau < 1 n'est pas autorisé"));
   _storageLevel = storageLevel;
 }
 size_t CalciumCouplingPolicy::getStorageLevel   () const                        {return _storageLevel;}
 void   CalciumCouplingPolicy::setDateCalSchem   (CalciumTypes::DateCalSchem   dateCalSchem)   {
+#ifdef _DEBUG_
+  std::cerr << "CalciumCouplingPolicy::setDateCalSchem: " << dateCalSchem << std::endl;
+#endif
   if ( _dependencyType != CalciumTypes::TIME_DEPENDENCY )
     throw CalciumException(CalciumTypes::CPITVR,LOC("Il est impossible de positionner un schéma temporel sur un port qui n'est pas en dépendance temporelle"));
   _dateCalSchem = dateCalSchem;
@@ -52,6 +58,9 @@ void   CalciumCouplingPolicy::setDateCalSchem   (CalciumTypes::DateCalSchem   da
 CalciumTypes::DateCalSchem CalciumCouplingPolicy::getDateCalSchem () const   { return _dateCalSchem; }
 
 void CalciumCouplingPolicy::setAlpha(double alpha) {
+#ifdef _DEBUG_
+  std::cerr << "CalciumCouplingPolicy::setAlpha: " << alpha << std::endl;
+#endif
   if ( _dependencyType != CalciumTypes::TIME_DEPENDENCY )
     throw CalciumException(CalciumTypes::CPITVR,LOC("Il est impossible de positionner alpha sur un port qui n'est pas en dépendance temporelle"));
   
@@ -72,6 +81,9 @@ void CalciumCouplingPolicy::setDeltaT(double deltaT ) {
 double CalciumCouplingPolicy::getDeltaT() const  {return _deltaT;}
 
 void CalciumCouplingPolicy::setInterpolationSchem (CalciumTypes::InterpolationSchem interpolationSchem) {
+#ifdef _DEBUG_
+  std::cerr << "CalciumCouplingPolicy::setInterpolationSchem: " << interpolationSchem << std::endl;
+#endif
   if ( _dependencyType != CalciumTypes::TIME_DEPENDENCY )
     throw CalciumException(CalciumTypes::CPITVR,LOC("Le paramètre InterpolationSchem sur un port qui n'est pas en dépendance temporelle n'a pas de sens"));
   _interpolationSchem=interpolationSchem;
index 1fe1c0e5b04ee4876376b18c51fa66463cfcc48f..4ae601ad7ecfbb2189a969ca6521ea9fde4e4e26 100644 (file)
@@ -244,6 +244,12 @@ struct CalciumCouplingPolicy::BoundedDataIdProcessor<
     Type              dataOut = DataManipulator::create(dataSize);
     InnerType * const OutIt   = DataManipulator::getPointer(dataOut);
  
+#ifdef _DEBUG_
+    std::cerr << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : interpolationSchem : " << _couplingPolicy._interpolationSchem << std::endl;
+    std::cerr << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : alpha : " << _couplingPolicy._alpha << std::endl;
+    std::cerr << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : datecalschem : " << _couplingPolicy._dateCalSchem << std::endl;
+    std::cerr << "-------- CalciumCouplingPolicy::BoundedDataIdProcessor : storageLevel : " << _couplingPolicy._storageLevel << std::endl;
+#endif
     if ( timeDiff == 0.0 ||  _couplingPolicy._interpolationSchem == CalciumTypes::L0_SCHEM ) {
       std::copy(InIt1,InIt1+dataSize,OutIt);
     } else {
index e693d70f40c5d23e933c8e87d39a9e1d43b3b2dd..0c8661430a20fd793fa9e320544961c659c3543a 100644 (file)
@@ -137,7 +137,7 @@ public:
 
   //! method to define if a component is implemented in a dyn lib a python module or an executable
   /*!
-    \return an enum SO or PY or EXE
+    \return an enum SO or PY or EXE or CEXE
   */
   virtual SALOME_ModuleCatalog::ImplType implementation_type();
 
index 5fd1ff4e45549ae7a2c6791ca7641477f0a5f937..88fd5e7bc59eddb2f705ac001c09801e438d33ac 100644 (file)
@@ -413,6 +413,8 @@ void SALOME_ModuleCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc)
         _aModule.constraint = "";
         _aModule.icon="";       
         _aModule.interfaces.resize(0);
+        _aModule.implementationType ="";
+        _aModule.implementationName ="";
 
         xmlNodePtr aComponentSubNode = aComponentNode->xmlChildrenNode;
         while(aComponentSubNode != NULL)
index c63e0cdea5a28e90a989542e154b2e50e7cbe0f4..87c1f80a90618569d9c5de4b5685287381f58c10 100644 (file)
@@ -747,6 +747,8 @@ void SALOME_ModuleCatalogImpl::duplicate
   C_corba.type = ComponentTypeConvert[C_parser.type];
   if(C_parser.implementationType == "EXE")
     C_corba.implementationType=SALOME_ModuleCatalog::EXE;
+  else if(C_parser.implementationType == "CEXE")
+    C_corba.implementationType=SALOME_ModuleCatalog::CEXE;
   else if(C_parser.implementationType == "PY")
     C_corba.implementationType=SALOME_ModuleCatalog::PY;
   else