Salome HOME
merge from BR_For40_DSC 28 jan 08
authorprascle <prascle>
Mon, 28 Jan 2008 22:03:05 +0000 (22:03 +0000)
committerprascle <prascle>
Mon, 28 Jan 2008 22:03:05 +0000 (22:03 +0000)
86 files changed:
bin/appli_gen.py
bin/orbmodule.py
bin/server.py
idl/Makefile.am
idl/SALOME_Component.idl
idl/SALOME_ModuleCatalog.idl
resources/CatalogResources.xml.in
resources/KERNELCatalog.xml.in
salome_adm/unix/Makefile.am
salome_adm/unix/pythonbe.py [deleted file]
src/Batch/BatchLight_BatchManager.cxx [deleted file]
src/Batch/BatchLight_BatchManager.hxx [deleted file]
src/Batch/BatchLight_BatchManager_PBS.cxx [deleted file]
src/Batch/BatchLight_BatchManager_PBS.hxx [deleted file]
src/Batch/BatchLight_BatchManager_SLURM.cxx [deleted file]
src/Batch/BatchLight_BatchManager_SLURM.hxx [deleted file]
src/Batch/BatchLight_Job.cxx [deleted file]
src/Batch/BatchLight_Job.hxx [deleted file]
src/Batch/Batch_BatchManagerCatalog.cxx
src/Batch/Batch_BatchManagerCatalog.hxx
src/Batch/Batch_Date.cxx
src/Batch/Batch_PyVersatile.cxx
src/Batch/Makefile.am
src/Batch/MpiImpl.cxx [deleted file]
src/Batch/MpiImpl.hxx [deleted file]
src/Container/Component_i.cxx
src/Container/Container_i.cxx
src/Container/SALOME_ComponentPy.py
src/Container/SALOME_Component_i.hxx
src/Container/SALOME_Container.cxx
src/Container/SALOME_Container.py
src/Container/SALOME_ContainerManager.cxx
src/Container/SALOME_Container_i.hxx
src/Container/Salome_file_i.cxx
src/Container/Salome_file_i.hxx
src/DF/DF_definitions.hxx
src/DSC/ParallelDSC/ParallelDSC_i.cxx
src/DSC/ParallelDSC/ParallelDSC_i.hxx
src/KERNEL_PY/salome_study.py
src/Launcher/BatchLight_BatchManager.cxx [new file with mode: 0644]
src/Launcher/BatchLight_BatchManager.hxx [new file with mode: 0644]
src/Launcher/BatchLight_BatchManager_PBS.cxx [new file with mode: 0644]
src/Launcher/BatchLight_BatchManager_PBS.hxx [new file with mode: 0644]
src/Launcher/BatchLight_BatchManager_SLURM.cxx [new file with mode: 0644]
src/Launcher/BatchLight_BatchManager_SLURM.hxx [new file with mode: 0644]
src/Launcher/BatchLight_Job.cxx [new file with mode: 0644]
src/Launcher/BatchLight_Job.hxx [new file with mode: 0644]
src/Launcher/Makefile.am
src/Launcher/MpiImpl.cxx [new file with mode: 0644]
src/Launcher/MpiImpl.hxx [new file with mode: 0644]
src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx
src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.cxx
src/ModuleCatalog/SALOME_ModuleCatalog_Acomponent_impl.hxx
src/ModuleCatalog/SALOME_ModuleCatalog_Handler.cxx
src/ModuleCatalog/SALOME_ModuleCatalog_Handler.hxx
src/ModuleCatalog/SALOME_ModuleCatalog_Parser.hxx
src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx
src/ModuleCatalog/SALOME_ModuleCatalog_impl.hxx
src/NamingService/NamingService_WaitForServerReadiness.cxx
src/NamingService/SALOME_NamingService.cxx
src/NamingService/Test/NamingServiceTest.cxx
src/NamingService/Test/TestNamingService.py
src/ParallelContainer/Makefile.am
src/ParallelContainer/Parallel_Salome_file_i.cxx
src/ParallelContainer/Parallel_Salome_file_i.hxx
src/ParallelContainer/SALOME_ParallelComponent_i.cxx
src/ParallelContainer/SALOME_ParallelComponent_i.hxx
src/ParallelContainer/SALOME_ParallelContainerNodeDummy.cxx
src/ParallelContainer/SALOME_ParallelContainerNodeMpi.cxx
src/ParallelContainer/SALOME_ParallelContainerProxyDummy.cxx
src/ParallelContainer/SALOME_ParallelContainerProxyMpi.cxx
src/ParallelContainer/SALOME_ParallelContainerProxy_i.cxx [new file with mode: 0644]
src/ParallelContainer/SALOME_ParallelContainerProxy_i.hxx [new file with mode: 0644]
src/ParallelContainer/SALOME_ParallelContainer_i.cxx
src/ParallelContainer/SALOME_ParallelContainer_i.hxx
src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx
src/ResourcesManager/SALOME_ResourcesManager.cxx
src/SALOMEDS/SALOMEDS.cxx
src/SALOMEDS/SALOMEDS_Driver_i.hxx
src/SALOMEDS/SALOMEDS_Server.cxx
src/SALOMEDS/SALOMEDS_StudyManager_i.cxx
src/SALOMEDS/SALOMEDS_StudyManager_i.hxx
src/SALOMELocalTrace/FileTraceCollector.cxx
src/SALOMETraceCollector/SALOMETraceCollector.cxx
src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx
src/Utils/Utils_ORB_INIT.cxx

index 89e30a94e02a4ff6bba8a68f75465228c548eae2..c24614cc15a3dd705cd34eeb9aac508568d199ff 100644 (file)
@@ -224,6 +224,16 @@ def install(prefix,config_file):
     <parameter name="standalone" value="pyContainer,supervContainer"/>
   </section>
 </document>
+"""
+    f.write(command)    
+    f.close()
+
+    #Add default CatalogResources.xml file
+    f =open(os.path.join(home_dir,'CatalogResources.xml'),'w')
+    command="""<!DOCTYPE ResourcesCatalog>
+<resources>
+   <machine hostname="localhost" />
+</resources>
 """
     f.write(command)    
     f.close()
index 7de5715c1c6f6ed53982ca38626f5686b8679763..9f3c66324b7852108f47dfa85faaa4af3d2877e5 100755 (executable)
@@ -35,7 +35,7 @@ class client:
       # Initialise the ORB
       self.orb=CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
       # Initialise the Naming Service
-      self.initNS(args)
+      self.initNS(args or {})
 
    # --------------------------------------------------------------------------
 
index 5bd61799d0e88b0ec203bfc71b78dff9884ec1e7..98b2ef95b5e6c76b056419cecb6c7fd96f01eb55 100755 (executable)
@@ -15,7 +15,7 @@ class Server:
         self.PID=None
         self.CMD=[]
         self.ARGS=[]
-        if self.args['xterm']:
+        if self.args.get('xterm'):
             self.ARGS=['xterm', '-iconic', '-sb', '-sl', '500', '-hold']
 
     def __init__(self,args):
@@ -26,7 +26,7 @@ class Server:
     def run(self):
         global process_id
         myargs=self.ARGS
-        if self.args['xterm']:
+        if self.args.get('xterm'):
             # (Debian) send LD_LIBRARY_PATH to children shells (xterm)
             env_ld_library_path=['env', 'LD_LIBRARY_PATH='
                                  + os.getenv("LD_LIBRARY_PATH")]
index b6a3f3d0b93ca03940a985971dbeb8aafd6c5768..b046999d75a628341e9bfbe07385abaf9b0b08a4 100644 (file)
 
 include $(top_srcdir)/salome_adm/unix/make_common_starter.am
 
+if WITH_PACO_PARALLEL
+MAKEFLAGS = -j1
+endif
+
 AM_CXXFLAGS = -fPIC
 
 BASEIDL_FILES = \
@@ -91,7 +95,7 @@ BASEIDL_SOURCES =\
   Calcium_PortsSK.cc \
   Palm_PortsSK.cc
 
-DYNIDL_SOURCES = \
+DYNIDL_SRCS = \
   SALOME_PortsDynSK.cc  Calcium_PortsDynSK.cc     SALOME_ContainerManagerDynSK.cc \
   SALOME_CommDynSK.cc   SALOME_RegistryDynSK.cc   SALOME_ModuleCatalogDynSK.cc \
   SALOMEDSDynSK.cc      SALOME_SessionDynSK.cc    SALOME_RessourcesCatalogDynSK.cc \
@@ -115,9 +119,7 @@ if MPI_IS_OK
   STATIDL_SOURCES += $(MPIIDL_SOURCES)
 endif
 
-IDL_SOURCES += $(DYNIDL_SOURCES)
-
-$(DYNIDL_SOURCES) : $(IDL_SOURCES)
+$(DYNIDL_SRCS) : $(IDL_SOURCES)
 
 # also install all generated headers to use result library from another modules
 salomeinclude_DATA= $(STATIDL_SOURCES:%SK.cc=%.hh)
@@ -198,7 +200,7 @@ DSC_EnginesPaCO.h DSC_EnginesPaCO.cc : DSC_Engines.idl DSC_Engines.xml
 
 lib_LTLIBRARIES = libSalomeIDLKernel.la $(PAR_LIB)
 
-nodist_libSalomeIDLKernel_la_SOURCES = $(IDL_SOURCES)
+nodist_libSalomeIDLKernel_la_SOURCES = $(IDL_SOURCES) $(DYNIDL_SRCS)
 libSalomeIDLKernel_la_CPPFLAGS =-I$(top_builddir)/salome_adm/unix \
                                -I$(top_builddir)/idl \
                                @CORBA_CXXFLAGS@ @CORBA_INCLUDES@
@@ -223,8 +225,11 @@ IDLPYFLAGS  = @IDLPYFLAGS@
 SUFFIXES = .idl .hh SK.cc
 .idlSK.cc:
        $(OMNIORB_IDL) $(IDLCXXFLAGS) $(OMNIORB_IDLCXXFLAGS) $<
-.idl.hh:
-       $(OMNIORB_IDL) $(IDLCXXFLAGS) $(OMNIORB_IDLCXXFLAGS) $<
+SK.cc.hh:
+
+#Dummy rule to replace the following one (for parallel make)
+#.idl.hh:
+#      $(OMNIORB_IDL) $(IDLCXXFLAGS) $(OMNIORB_IDLCXXFLAGS) $<
 
 %PaCO.h %PaCO.cc : %.idl %.xml
        @PACO_IDL@ -I $(srcdir):@PACOPATH@/idl $^ omniORB4 0
index 08aea29fc669d1ac0c81e61979e7f0d4a2fd843d..f3139b6ecf37474a7587a437e721d3e6e25f91c4 100644 (file)
@@ -135,7 +135,7 @@ module Engines
     /*!
       Shutdown the Container process.
     */
-    oneway void Shutdown();
+    void Shutdown();
 
     /*!
       Returns the hostname of the container
index 9fc9dac5bf6a4572643b0ff2b26e035d139748fb..dfc8764f6777fd8dfd14f77b97ff12e25c5ebf34 100644 (file)
@@ -64,19 +64,10 @@ This struct contains fields defining the parameter of the service.
     DATASTREAM_ITERATIVE
   } ;
 
-  enum DataStreamType {
-    DATASTREAM_UNKNOWN,
-    DATASTREAM_INTEGER,
-    DATASTREAM_FLOAT,
-    DATASTREAM_DOUBLE,
-    DATASTREAM_STRING,
-    DATASTREAM_BOOLEAN
-  } ;
-
   struct ServicesDataStreamParameter
   {
-    DataStreamType Parametertype; /*!<Type of the parameter.*/
-    string Parametername;         /*!<Name of the parameter.*/
+    string Parametertype;                     /*!<Type of the parameter.*/
+    string Parametername;                     /*!<Name of the parameter.*/
     DataStreamDependency Parameterdependency; /*!<Temporal or iterative dependency.*/
   } ;
 
@@ -174,6 +165,15 @@ List of path prefixes
 */
   typedef sequence<PathPrefix> PathPrefixes;
 
+/*!
+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 */
+  } ;
+
 /*!
 Description of a component
 */
@@ -183,7 +183,8 @@ Description of a component
     string             name;
     string             username;
     boolean            multistudy;
-    boolean            implementationType;
+    ImplType           implementationType;
+    string             implname;
     string             icon;
     string             constraint;
     ListOfDefInterface interfaces;
@@ -324,9 +325,14 @@ Gets the icone of the component (for IAPP)
     readonly attribute string component_icone;
 
 /*! 
-Gets the implementation type of the component : C++ or Python (for IAPP)
+Gets the implementation type of the component : C++ (dyn lib), Python (module) or executable 
+*/
+    readonly attribute ImplType implementation_type;
+/*! 
+Gets the implementation name of the component : name of the dyn lib or the python module or the executable
+if the default naming scheme is not convenient.
 */
-    readonly attribute boolean implementation_type;
+    readonly attribute string implementation_name;
   } ;
 
 /*! \brief %Module catalog interface
index 874d32492f1d158e325475ae32baf477440f96f4..11e6b6e2659e128f01a68f4e4ae318afb42e8bc1 100644 (file)
@@ -1,43 +1,4 @@
 <!DOCTYPE ResourcesCatalog>
 <resources>
-
-<machine hostname="is111918" OS="LINUX" CPUFreqMHz="2992" memInMB="1024" protocol="r" mode="i" nbOfNodes="1" nbOfProcPerNode="1" preReqFilePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/env_products.sh" >
-<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/KERNEL_3.2.6" moduleName="KERNEL" />
-<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/MED_3.2.6" moduleName="MED" />
-<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/GEOM_3.2.6" moduleName="GEOM" />
-<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/SMESH_3.2.6" moduleName="SMESH" />
-<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/SUPERV_3.2.6" moduleName="SUPERV" />
-<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/VISU_3.2.6" moduleName="VISU" />
-</machine>
-
-<machine hostname="is102430" OS="LINUX" CPUFreqMHz="2992" memInMB="1024" protocol="r" mode="i" nbOfNodes="1" nbOfProcPerNode="1" preReqFilePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/env_products.sh" >
-<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/KERNEL_3.2.6" moduleName="KERNEL" />
-<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/MED_3.2.6" moduleName="MED" />
-<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/GEOM_3.2.6" moduleName="GEOM" />
-<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/SMESH_3.2.6" moduleName="SMESH" />
-<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/SUPERV_3.2.6" moduleName="SUPERV" />
-<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/VISU_3.2.6" moduleName="VISU" />
-</machine>
-
-<machine hostname="is125604" OS="LINUX" CPUFreqMHz="2992" memInMB="1024" protocol="r" mode="i" nbOfNodes="1" nbOfProcPerNode="1" preReqFilePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/env_products.sh" >
-<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/KERNEL_3.2.6" moduleName="KERNEL" />
-<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/MED_3.2.6" moduleName="MED" />
-<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/GEOM_3.2.6" moduleName="GEOM" />
-<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/SMESH_3.2.6" moduleName="SMESH" />
-<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/SUPERV_3.2.6" moduleName="SUPERV" />
-<modules modulePath="/data/tmplgls/rahuel/YACS/Salome_3.2.6pre4/VISU_3.2.6" moduleName="VISU" />
-</machine>
-
-<machine hostname="tantal" alias="tantale.ccc.cea.fr" OS="LINUX" CPUFreqMHz="2992" memInMB="1024" protocol="s" mode="b" nbOfNodes="236" nbOfProcPerNode="4" appliPath="/workdir/rahuel/YACS/Salome_3.2.6pre4/env_products.sh" >
-<modules modulePath="/workdir/rahuel/YACS/Salome_3.2.6pre4/KERNEL_install" moduleName="KERNEL" />
-<modules modulePath="/workdir/rahuel/YACS/Salome_3.2.6pre4/MED_3.2.6" moduleName="MED" />
-<modules modulePath="/workdir/rahuel/YACS/Salome_3.2.6pre4/GEOM_3.2.6" moduleName="GEOM" />
-<modules modulePath="/workdir/rahuel/YACS/Salome_3.2.6pre4/SMESH_3.2.6" moduleName="SMESH" />
-<modules modulePath="/workdir/rahuel/YACS/Salome_3.2.6pre4/NETGENPLUGIN_3.2.6" moduleName="NETGENPLUGIN" />
-<modules modulePath="/workdir/rahuel/YACS/Salome_3.2.6pre4/NETGENPLUGIN_3.2.6" moduleName="NETGENPLUGIN" />
-<modules modulePath="/workdir/rahuel/YACS/Salome_3.2.6pre4/YACS_install" moduleName="YACS" />
-<modules modulePath="/workdir/rahuel/YACS/Salome_3.2.6pre4/SRHEOLEFCPP_install" moduleName="SRHEOLEFCPP" />
-<modules modulePath="/workdir/rahuel/YACS/Salome_3.2.6pre4/SRHEOLEF_install" moduleName="SRHEOLEF" />
-</machine>
-
+  <machine hostname="localhost" />
 </resources>
index 347458ed48824af92d12e8e25e7e955d684e884a..8986273cea20789e91fbba657eb1aca682ceb7a1 100644 (file)
@@ -28,6 +28,7 @@
   <objref name="CALCIUM_double" id="IDL:Ports/Calcium_Ports/Calcium_Double_Port:1.0"/>
   <objref name="CALCIUM_string" id="IDL:Ports/Calcium_Ports/Calcium_String_Port:1.0"/>
   <objref name="CALCIUM_boolean" id="IDL:Ports/Calcium_Ports/Calcium_Logical_Port:1.0"/>
+  <objref name="BASIC_short" id="IDL:Ports/Data_Short_Port:1.0"/>
   <objref name="Study" id="IDL:SALOMEDS/Study:1.0"/>
   <objref name="SObject" id="IDL:SALOMEDS/SObject:1.0"/>
 </type-list>
index 72b1f2dd78f4d5591235d31a292928241c6e276e..b2d2a9a5f5dbaf40797c041ae2fef94e40616ec0 100644 (file)
@@ -54,5 +54,4 @@ SALOMEconfig.h: $(top_builddir)/salome_adm/unix/SALOMEconfig.ref
 # The deprecated files are deprecated for the KERNEL but not for the
 # related modules (GUI, MED, ...), for now. Some files have to be installed.
 dist_salomeadmux_DATA=\
-       pythonbe.py \
        $(DEPRECATED_FILES)
diff --git a/salome_adm/unix/pythonbe.py b/salome_adm/unix/pythonbe.py
deleted file mode 100644 (file)
index 403e5cf..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright (C) 2005  OPEN CASCADE, CEA, EDF R&D, LEG
-#           PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either 
-# version 2.1 of the License.
-# 
-# This library is distributed in the hope that it will be useful 
-# but WITHOUT ANY WARRANTY; without even the implied warranty of 
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-# Lesser General Public License for more details.
-# 
-# You should have received a copy of the GNU Lesser General Public  
-# License along with this library; if not, write to the Free Software 
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-# 
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-# 
-
-pymodule_template = """\
-# DO NOT EDIT THIS FILE!
-#
-# Python module @module@ generated by omniidl
-
-import omnipatch
-omnipatch.updateModule("@module@")
-
-# ** 1. Stub files contributing to this module
-
-# ** 2. Sub-modules
-
-# ** 3. End"""
-
-import omniidl_be.python
-omniidl_be.python.pymodule_template=pymodule_template
-
-def run(tree, args):
-    omniidl_be.python.run(tree, args)
-
diff --git a/src/Batch/BatchLight_BatchManager.cxx b/src/Batch/BatchLight_BatchManager.cxx
deleted file mode 100644 (file)
index 4e0241f..0000000
+++ /dev/null
@@ -1,272 +0,0 @@
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either 
-// version 2.1 of the License.
-// 
-// This library is distributed in the hope that it will be useful 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public  
-// License along with this library; if not, write to the Free Software 
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
- * BatchManager.cxx : 
- *
- * Auteur : Bernard SECHER - CEA/DEN
- * Date   : Juillet 2007
- * Projet : SALOME
- *
- */
-
-#include <iostream>
-#include <sstream>
-#include <string>
-#include <netdb.h>
-#include "BatchLight_Job.hxx"
-#include "BatchLight_BatchManager.hxx"
-#include "Batch_Date.hxx"
-using namespace std;
-
-namespace BatchLight {
-
-  // Constructeur
-  BatchManager::BatchManager(const batchParams& p) throw(SALOME_Exception) : _params(p)
-  {
-    SCRUTE(_params.hostname);
-    SCRUTE(_params.protocol);
-    SCRUTE(_params.username);
-    // On verifie que le hostname est correct
-    if (!gethostbyname(_params.hostname.c_str())) { // hostname unknown from network
-      string msg = "hostname \"";
-      msg += _params.hostname;
-      msg += "\" unknown from the network";
-      throw SALOME_Exception(msg.c_str());
-    }
-    _mpiImpl = NULL;
-  }
-
-  // Destructeur
-  BatchManager::~BatchManager()
-  {
-    MESSAGE("BatchManager destructor "<<_params.hostname);
-    std::map < int, const BatchLight::Job * >::const_iterator it;
-    for(it=_jobmap.begin();it!=_jobmap.end();it++)
-      delete it->second; 
-    if(_mpiImpl) delete _mpiImpl;
-  }
-
-  // Methode pour le controle des jobs : soumet un job au gestionnaire
-  const int BatchManager::submitJob(Job* job)
-  {
-    BEGIN_OF("BatchManager::submitJob");
-    int id;
-
-    // temporary directory on cluster to put input files for job
-    setDirForTmpFiles();
-    SCRUTE(_dirForTmpFiles);
-
-    // export input files on cluster
-    exportInputFiles(job->getFileToExecute(),job->getFilesToExportList());
-
-    // build salome coupling script for job
-    buildSalomeCouplingScript(job->getFileToExecute());
-
-    // build batch script for job
-    buildSalomeBatchScript(job->getNbProc());
-
-    // submit job on cluster
-    id = submit();
-
-    // register job on map
-    _jobmap[id] = job;
-    END_OF("BatchManager::submitJob");
-    return id;
-  }
-
-  void BatchManager::setDirForTmpFiles()
-  {
-    int i;
-
-    _dirForTmpFiles = string("Batch/");
-    Batch::Date date = Batch::Date(time(0)) ;
-    std::string thedate = date.str() ;
-    int lend = thedate.size() ;
-    i = 0 ;
-    while ( i < lend ) {
-      if ( thedate[i] == '/' || thedate[i] == '-' || thedate[i] == ':' ) {
-        thedate[i] = '_' ;
-      }
-      i++ ;
-    }
-    _dirForTmpFiles += thedate ;
-  }
-
-  void BatchManager::exportInputFiles(const char *fileToExecute, const Engines::FilesList filesToExportList) throw(SALOME_Exception)
-  {
-    BEGIN_OF("BatchManager::exportInFiles");
-    string command = _params.protocol;
-    int status;
-
-    command += " ";
-
-    if (_params.username != ""){
-      command += _params.username;
-      command += "@";
-    }
-
-    command += _params.hostname;
-    command += " \"mkdir -p ";
-    command += _dirForTmpFiles ;
-    command += "\"" ;
-    SCRUTE(command.c_str());
-    status = system(command.c_str());
-    if(status)
-      throw SALOME_Exception("Error of connection on remote host");    
-
-    if( _params.protocol == "rsh" )
-      command = "rcp ";
-    else if( _params.protocol == "ssh" )
-      command = "scp ";
-    else
-      throw SALOME_Exception("Unknown protocol");
-
-    command += fileToExecute;
-    command += " ";
-
-    if (_params.username != ""){
-      command += _params.username;
-      command += "@";
-    }
-
-    command += _params.hostname;
-    command += ":";
-    command += _dirForTmpFiles ;
-    SCRUTE(command.c_str());
-    status = system(command.c_str());
-    if(status)
-      throw SALOME_Exception("Error of connection on remote host");    
-    
-    int i ;
-    for ( i = 0 ; i < filesToExportList.length() ; i++ ) {
-      if( _params.protocol == "rsh" )
-       command = "rcp ";
-      else if( _params.protocol == "ssh" )
-       command = "scp ";
-      else
-       throw SALOME_Exception("Unknown protocol");
-      command += filesToExportList[i] ;
-      command += " ";
-      if (_params.username != ""){
-       command += _params.username;
-       command += "@";
-      }
-      command += _params.hostname;
-      command += ":";
-      command += _dirForTmpFiles ;
-      SCRUTE(command.c_str());
-      status = system(command.c_str());
-      if(status)
-       throw SALOME_Exception("Error of connection on remote host");    
-    }
-
-    END_OF("BatchManager::exportInFiles");
-  }
-
-  void BatchManager::importOutputFiles( const char *directory, const CORBA::Long jobId ) throw(SALOME_Exception)
-  {
-    BEGIN_OF("BatchManager::importOutputFiles");
-    string command;
-    int status;
-
-    const BatchLight::Job* myJob = _jobmap[jobId];
-    Engines::FilesList filesToImportList = myJob->getFilesToImportList();
-
-    for ( int i = 0 ; i < filesToImportList.length() ; i++ ) {
-      if( _params.protocol == "rsh" )
-       command = "rcp ";
-      else if( _params.protocol == "ssh" )
-       command = "scp ";
-      else
-       throw SALOME_Exception("Unknown protocol");
-      if (_params.username != ""){
-       command += _params.username;
-       command += "@";
-      }
-      command += _params.hostname;
-      command += ":";
-      command += filesToImportList[i] ;
-      command += " ";
-      command += directory;
-      SCRUTE(command.c_str());
-      status = system(command.c_str());
-      if(status)
-       throw SALOME_Exception("Error of connection on remote host");    
-    }
-
-    END_OF("BatchManager::importOutputFiles");
-  }
-
-  string BatchManager::BuildTemporaryFileName() const
-  {
-    //build more complex file name to support multiple salome session
-    char *temp = new char[19];
-    strcpy(temp, "/tmp/command");
-    strcat(temp, "XXXXXX");
-#ifndef WNT
-
-    mkstemp(temp);
-#else
-
-    char aPID[80];
-    itoa(getpid(), aPID, 10);
-    strcat(temp, aPID);
-#endif
-
-    string command(temp);
-    delete [] temp;
-    command += ".sh";
-    return command;
-  }
-
-  void BatchManager::RmTmpFile()
-  {
-    if (_TmpFileName != ""){
-      string command = "rm ";
-      command += _TmpFileName;
-      char *temp = strdup(command.c_str());
-      int lgthTemp = strlen(temp);
-      temp[lgthTemp - 3] = '*';
-      temp[lgthTemp - 2] = '\0';
-      system(temp);
-      free(temp);
-    }
-  }
-
-  MpiImpl *BatchManager::FactoryMpiImpl(string mpiImpl) throw(SALOME_Exception)
-  {
-    if(mpiImpl == "lam")
-      return new MpiImpl_LAM();
-    else if(mpiImpl == "mpich1")
-      return new MpiImpl_MPICH1();
-    else if(mpiImpl == "mpich2")
-      return new MpiImpl_MPICH2();
-    else if(mpiImpl == "openmpi")
-      return new MpiImpl_OPENMPI();
-    else if(mpiImpl == "indif")
-      throw SALOME_Exception("you must specify a mpi implementation in CatalogResources.xml file");
-    else{
-      ostringstream oss;
-      oss << mpiImpl << " : not yet implemented";
-      throw SALOME_Exception(oss.str().c_str());
-    }
-  }
-
-}
diff --git a/src/Batch/BatchLight_BatchManager.hxx b/src/Batch/BatchLight_BatchManager.hxx
deleted file mode 100644 (file)
index a8ea006..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either 
-// version 2.1 of the License.
-// 
-// This library is distributed in the hope that it will be useful 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public  
-// License along with this library; if not, write to the Free Software 
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
- * BatchManager.hxx : 
- *
- * Auteur : Bernard SECHER - CEA/DEN
- * Date   : Juillet 2007
- * Projet : SALOME
- *
- */
-
-#ifndef _BL_BATCHMANAGER_H_
-#define _BL_BATCHMANAGER_H_
-
-#include <vector>
-#include <map>
-#include <string>
-#include "Utils_SALOME_Exception.hxx"
-#include <SALOMEconfig.h>
-#include <stdlib.h>
-#include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
-#include "MpiImpl.hxx"
-
-namespace BatchLight {
-
-  class Job;
-
-  struct batchParams{
-    std::string hostname; // serveur ou tourne le BatchManager
-    std::string protocol; // protocole d'acces au serveur: ssh ou rsh
-    std::string username; // username d'acces au serveur
-    std::string applipath; // path of apllication directory on server
-    std::vector<std::string> modulesList; // list of Salome modules installed on server
-    unsigned int nbnodes; // number of nodes on cluster
-    unsigned int nbprocpernode; // number of processors on each node
-    std::string mpiImpl; // mpi implementation
-  };
-
-  class BatchManager
-  {
-  public:
-    // Constructeur et destructeur
-    BatchManager(const batchParams& p) throw(SALOME_Exception); // connexion a la machine host
-    virtual ~BatchManager();
-
-    // Methodes pour le controle des jobs : virtuelles pures
-    const int submitJob(BatchLight::Job* job); // soumet un job au gestionnaire
-    virtual void deleteJob(const int & jobid) = 0; // retire un job du gestionnaire
-    virtual std::string queryJob(const int & jobid) = 0; // renvoie l'etat du job
-    void importOutputFiles( const char *directory, const CORBA::Long jobId ) throw(SALOME_Exception);
-
-  protected:
-    batchParams _params;
-    MpiImpl *_mpiImpl;
-
-    std::map <int,const BatchLight::Job *> _jobmap;
-    std::string _dirForTmpFiles; // repertoire temporaire sur le serveur
-    std::string _TmpFileName;
-    std::string _fileNameToExecute;
-
-    virtual int submit() throw(SALOME_Exception) = 0;
-    void setDirForTmpFiles();
-    void exportInputFiles( const char *fileToExecute, const Engines::FilesList filesToExportList ) throw(SALOME_Exception);
-    virtual void buildSalomeCouplingScript( const char *fileToExecute ) throw(SALOME_Exception) = 0;
-    virtual void buildSalomeBatchScript( const int nbproc ) throw(SALOME_Exception) = 0;
-
-    std::string BuildTemporaryFileName() const;
-    void RmTmpFile();
-    MpiImpl *FactoryMpiImpl(std::string mpiImpl) throw(SALOME_Exception);
-
-  private:
-
-  };
-
-}
-
-#endif
diff --git a/src/Batch/BatchLight_BatchManager_PBS.cxx b/src/Batch/BatchLight_BatchManager_PBS.cxx
deleted file mode 100644 (file)
index bba030a..0000000
+++ /dev/null
@@ -1,375 +0,0 @@
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either 
-// version 2.1 of the License.
-// 
-// This library is distributed in the hope that it will be useful 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public  
-// License along with this library; if not, write to the Free Software 
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
- * BatchManager.cxx : 
- *
- * Auteur : Bernard SECHER - CEA/DEN
- * Date   : Juillet 2007
- * Projet : SALOME
- *
- */
-
-#include "BatchLight_BatchManager_PBS.hxx"
-#include "utilities.h"
-#include "BatchLight_Job.hxx"
-#include <fstream>
-#include <iostream>
-#include <sstream>
-#include <sys/stat.h>
-
-using namespace std;
-
-namespace BatchLight {
-
-  // Constructeur
-  BatchManager_PBS::BatchManager_PBS(const batchParams& p) throw(SALOME_Exception) : BatchManager(p)
-  {
-    // pbs batch system needs to know mpi implementation
-    _mpiImpl = FactoryMpiImpl(_params.mpiImpl);
-  }
-
-  // Destructeur
-  BatchManager_PBS::~BatchManager_PBS()
-  {
-    MESSAGE("BatchManager_PBS destructor "<<_params.hostname);
-  }
-
-  // Methode pour le controle des jobs : retire un job du gestionnaire
-  void BatchManager_PBS::deleteJob(const int & jobid)
-  {
-    BEGIN_OF("BatchManager_PBS::deleteJob");
-    string command;
-    int status;
-    ostringstream oss;
-    oss << jobid;
-
-    // define command to submit batch
-    if( _params.protocol == "rsh" )
-      command = "rsh ";
-    else if( _params.protocol == "ssh" )
-      command = "ssh ";
-    else
-      throw SALOME_Exception("Unknown protocol");
-
-    if (_params.username != ""){
-      command += _params.username;
-      command += "@";
-    }
-
-    command += _params.hostname;
-    command += " \"qdel " ;
-    command += oss.str();
-    command += "\"";
-    SCRUTE(command.c_str());
-    status = system(command.c_str());
-    if(status)
-      throw SALOME_Exception("Error of connection on remote host");
-
-    MESSAGE("jobId = " << jobid << "killed");
-    END_OF("BatchManager_PBS::deleteJob");
-  }
-   
-  // Methode pour le controle des jobs : renvoie l'etat du job
-  string BatchManager_PBS::queryJob(const int & jobid)
-  {
-    BEGIN_OF("BatchManager_PBS::queryJob");
-    // define name of log file
-    string jstatus;
-    string logFile="/tmp/logs/";
-    logFile += getenv("USER");
-    logFile += "/batchSalome_";
-
-    srand ( time(NULL) );
-    int ir = rand();
-    ostringstream oss;
-    oss << ir;
-    logFile += oss.str();
-    logFile += ".log";
-
-    string command;
-    int status;
-
-    // define command to submit batch
-    if( _params.protocol == "rsh" )
-      command = "rsh ";
-    else if( _params.protocol == "ssh" )
-      command = "ssh ";
-    else
-      throw SALOME_Exception("Unknown protocol");
-
-    if (_params.username != ""){
-      command += _params.username;
-      command += "@";
-    }
-
-    command += _params.hostname;
-    command += " \"qstat -f " ;
-    ostringstream oss2;
-    oss2 << jobid;
-    command += oss2.str();
-    command += "\" > ";
-    command += logFile;
-    SCRUTE(command.c_str());
-    status = system(command.c_str());
-    if(status && status != 153 && status != 256*153){
-      MESSAGE("status="<<status);
-      throw SALOME_Exception("Error of connection on remote host");
-    }
-
-    if(status == 153 || status == 256*153 )
-      // If job is finished qstat command return 153 status
-      jstatus = "D";
-    else{
-      // read status of job in log file
-      char line[128];
-      ifstream fp(logFile.c_str(),ios::in);
-      
-      string sline;
-      int pos = string::npos;
-      while( (pos == string::npos) && fp.getline(line,80,'\n') ){
-       sline = string(line);
-       pos = sline.find("job_state");
-      };
-      
-      if(pos!=string::npos){
-       istringstream iss(sline);
-       iss >> jstatus;
-       iss >> jstatus;
-       iss >> jstatus;
-      }
-      else
-       jstatus = "U";
-    }
-
-    MESSAGE("jobId = " << jobid << " " << jstatus);
-    END_OF("BatchManager_PBS::queryJob");
-    return jstatus;
-  }
-
-  void BatchManager_PBS::buildSalomeCouplingScript( const char *fileToExecute ) throw(SALOME_Exception)
-  {
-    BEGIN_OF("BatchManager_PBS::buildSalomeCouplingScript");
-    int status;
-
-    string::size_type p1 = string(fileToExecute).find_last_of("/");
-    string::size_type p2 = string(fileToExecute).find_last_of(".");
-    _fileNameToExecute = string(fileToExecute).substr(p1+1,p2-p1-1);
-
-    _TmpFileName = BuildTemporaryFileName();
-    ofstream tempOutputFile;
-    tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
-    tempOutputFile << "#! /bin/sh -f" << endl ;
-    tempOutputFile << "cd " ;
-    tempOutputFile << _params.applipath << endl ;
-    tempOutputFile << "export PYTHONPATH=~/" ;
-    tempOutputFile << _dirForTmpFiles ;
-    tempOutputFile << ":$PYTHONPATH" << endl ;
-    tempOutputFile << "if test " ;
-    tempOutputFile << _mpiImpl->rank() ;
-    tempOutputFile << " = 0; then" << endl ;
-    tempOutputFile << "  ./runAppli --terminal --modules=" ;
-    for ( int i = 0 ; i < _params.modulesList.size() ; i++ ) {
-      tempOutputFile << _params.modulesList[i] ;
-      if ( i != _params.modulesList.size()-1 )
-       tempOutputFile << "," ;
-    }
-    tempOutputFile << " --standalone=registry,study,moduleCatalog --killall &" << endl ;
-    tempOutputFile << "  for ((ip=1; ip < ";
-    tempOutputFile << _mpiImpl->size();
-    tempOutputFile << " ; ip++))" << endl;
-    tempOutputFile << "  do" << endl ;
-    tempOutputFile << "    arglist=\"$arglist YACS_Server_\"$ip" << endl ;
-    tempOutputFile << "  done" << endl ;
-    tempOutputFile << "  sleep 5" << endl ;
-    tempOutputFile << "  ./runSession waitContainers.py $arglist" << endl ;
-    tempOutputFile << "  ./runSession python ~/" << _dirForTmpFiles << "/" << _fileNameToExecute << ".py" << endl;
-    tempOutputFile << "  ./runSession killCurrentPort" << endl;
-    tempOutputFile << "else" << endl ;
-    tempOutputFile << "  sleep 5" << endl ;
-    tempOutputFile << "  ./runSession waitNS.py" << endl ;
-    tempOutputFile << "  ./runSession SALOME_Container 'YACS_Server_'";
-    tempOutputFile << _mpiImpl->rank() << endl ;
-    tempOutputFile << "fi" << endl ;
-    tempOutputFile.flush();
-    tempOutputFile.close();
-    chmod(_TmpFileName.c_str(), 0x1ED);
-    SCRUTE(_TmpFileName.c_str()) ;
-
-    string command;
-    if( _params.protocol == "rsh" )
-      command = "rcp ";
-    else if( _params.protocol == "ssh" )
-      command = "scp ";
-    else
-      throw SALOME_Exception("Unknown protocol");
-    
-    command += _TmpFileName;
-    command += " ";
-    if (_params.username != ""){
-      command += _params.username;
-      command += "@";
-    }
-    command += _params.hostname;
-    command += ":";
-    command += _dirForTmpFiles ;
-    command += "/runSalome_" ;
-    command += _fileNameToExecute ;
-    command += "_Batch.sh" ;
-    SCRUTE(_fileNameToExecute) ;
-    SCRUTE(command.c_str());
-    status = system(command.c_str());
-    if(status)
-      throw SALOME_Exception("Error of connection on remote host");    
-    RmTmpFile();
-    
-    END_OF("BatchManager_PBS::buildSalomeCouplingScript");
-  }
-
-  void BatchManager_PBS::buildSalomeBatchScript( const int nbproc ) throw(SALOME_Exception)
-  {
-    BEGIN_OF("BatchManager_PBS::buildSalomeBatchScript");
-    int status;
-
-    int nbmaxproc = _params.nbnodes * _params.nbprocpernode;
-    if( nbproc > nbmaxproc ){
-      MESSAGE(nbproc << " processors asked on a cluster of " << nbmaxproc << " processors");
-      throw SALOME_Exception("Too much processors asked for that cluster");
-    }
-
-    int nbnodes;
-    if( nbproc < _params.nbnodes )
-      nbnodes = nbproc;
-    else
-      nbnodes = _params.nbnodes;
-
-    _TmpFileName = BuildTemporaryFileName();
-    ofstream tempOutputFile;
-    tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
-
-    ostringstream filenameToExecute;
-    filenameToExecute << " ~/" << _dirForTmpFiles << "/runSalome_" << _fileNameToExecute << "_Batch.sh";
-
-    tempOutputFile << "#! /bin/sh -f" << endl ;
-    tempOutputFile << "#PBS -l nodes=" << nbnodes << endl ;
-    tempOutputFile << "#PBS -o ~/" << _dirForTmpFiles << "/runSalome.log${PBS_JOBID}" << endl ;
-    tempOutputFile << _mpiImpl->boot("${PBS_NODEFILE}",nbnodes);
-    tempOutputFile << _mpiImpl->run("${PBS_NODEFILE}",nbproc,filenameToExecute.str());
-    tempOutputFile << _mpiImpl->halt();
-    tempOutputFile.flush();
-    tempOutputFile.close();
-    chmod(_TmpFileName.c_str(), 0x1ED);
-    SCRUTE(_TmpFileName.c_str()) ;
-
-    string command;
-    if( _params.protocol == "rsh" )
-      command = "rcp ";
-    else if( _params.protocol == "ssh" )
-      command = "scp ";
-    else
-      throw SALOME_Exception("Unknown protocol");
-    command += _TmpFileName;
-    command += " ";
-    if (_params.username != ""){
-      command += _params.username;
-      command += "@";
-    }
-    command += _params.hostname;
-    command += ":";
-    command += _dirForTmpFiles ;
-    command += "/" ;
-    command += _fileNameToExecute ;
-    command += "_Batch.sh" ;
-    SCRUTE(command.c_str());
-    status = system(command.c_str());
-    if(status)
-      throw SALOME_Exception("Error of connection on remote host");    
-
-    RmTmpFile();
-    END_OF("BatchManager_PBS::buildSalomeBatchScript");
-    
-  }
-
-  int BatchManager_PBS::submit() throw(SALOME_Exception)
-  {
-    BEGIN_OF("BatchManager_PBS::submit");
-
-    // define name of log file
-    string logFile="/tmp/logs/";
-    logFile += getenv("USER");
-    logFile += "/batchSalome_";
-
-    srand ( time(NULL) );
-    int ir = rand();
-    ostringstream oss;
-    oss << ir;
-    logFile += oss.str();
-    logFile += ".log";
-
-    string command;
-    int status;
-
-    // define command to submit batch
-    if( _params.protocol == "rsh" )
-      command = "rsh ";
-    else if( _params.protocol == "ssh" )
-      command = "ssh ";
-    else
-      throw SALOME_Exception("Unknown protocol");
-
-    if (_params.username != ""){
-      command += _params.username;
-      command += "@";
-    }
-
-    command += _params.hostname;
-    command += " \"qsub " ;
-    command += _dirForTmpFiles ;
-    command += "/" ;
-    command += _fileNameToExecute ;
-    command += "_Batch.sh\" > ";
-    command += logFile;
-    SCRUTE(command.c_str());
-    status = system(command.c_str());
-    if(status)
-      throw SALOME_Exception("Error of connection on remote host");
-
-    // read id of submitted job in log file
-    char line[128];
-    FILE *fp = fopen(logFile.c_str(),"r");
-    fgets( line, 128, fp);
-    fclose(fp);
-    
-    string sline(line);
-    int pos = sline.find(".");
-    string strjob;
-    if(pos == string::npos)
-      strjob = sline;
-    else
-      strjob = sline.substr(0,pos);
-
-    int id;
-    istringstream iss(strjob);
-    iss >> id;
-
-    END_OF("BatchManager_PBS::submit");
-    return id;
-  }
-
-}
diff --git a/src/Batch/BatchLight_BatchManager_PBS.hxx b/src/Batch/BatchLight_BatchManager_PBS.hxx
deleted file mode 100644 (file)
index e7e5789..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either 
-// version 2.1 of the License.
-// 
-// This library is distributed in the hope that it will be useful 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public  
-// License along with this library; if not, write to the Free Software 
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
- * BatchManager.hxx : 
- *
- * Auteur : Bernard SECHER - CEA/DEN
- * Date   : Juillet 2007
- * Projet : SALOME
- *
- */
-
-#ifndef _BL_BATCHMANAGER_PBS_H_
-#define _BL_BATCHMANAGER_PBS_H_
-
-#include <string>
-#include "Utils_SALOME_Exception.hxx"
-#include "BatchLight_BatchManager.hxx"
-
-namespace BatchLight {
-
-  class Job;
-
-  class BatchManager_PBS : public BatchManager
-  {
-  public:
-    // Constructeur et destructeur
-    BatchManager_PBS(const batchParams& p) throw(SALOME_Exception); // connexion a la machine host
-    virtual ~BatchManager_PBS();
-
-    // Methodes pour le controle des jobs : virtuelles pures
-    void deleteJob(const int & jobid); // retire un job du gestionnaire
-    std::string queryJob(const int & jobid); // renvoie l'etat du job
-
-  private:
-    void buildSalomeCouplingScript( const char *fileToExecute ) throw(SALOME_Exception);
-    void buildSalomeBatchScript( const int nbproc ) throw(SALOME_Exception);
-    int submit() throw(SALOME_Exception);
-  };
-
-}
-
-#endif
diff --git a/src/Batch/BatchLight_BatchManager_SLURM.cxx b/src/Batch/BatchLight_BatchManager_SLURM.cxx
deleted file mode 100644 (file)
index 9a740e3..0000000
+++ /dev/null
@@ -1,327 +0,0 @@
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either 
-// version 2.1 of the License.
-// 
-// This library is distributed in the hope that it will be useful 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public  
-// License along with this library; if not, write to the Free Software 
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
- * BatchManager.cxx : 
- *
- * Auteur : Bernard SECHER - CEA/DEN
- * Date   : Juillet 2007
- * Projet : SALOME
- *
- */
-
-#include "BatchLight_BatchManager_SLURM.hxx"
-#include "utilities.h"
-#include "BatchLight_Job.hxx"
-#include <fstream>
-#include <iostream>
-#include <sstream>
-#include <sys/stat.h>
-
-using namespace std;
-
-namespace BatchLight {
-
-  // Constructeur
-  BatchManager_SLURM::BatchManager_SLURM(const batchParams& p) throw(SALOME_Exception) : BatchManager(p)
-  {
-  }
-
-  // Destructeur
-  BatchManager_SLURM::~BatchManager_SLURM()
-  {
-    MESSAGE("BatchManager_SLURM destructor "<<_params.hostname);
-  }
-
-  // Methode pour le controle des jobs : retire un job du gestionnaire
-  void BatchManager_SLURM::deleteJob(const int & jobid)
-  {
-    BEGIN_OF("BatchManager_SLURM::deleteJob");
-    string command;
-    int status;
-    ostringstream oss;
-    oss << jobid;
-
-    // define command to submit batch
-    if( _params.protocol == "rsh" )
-      command = "rsh ";
-    else if( _params.protocol == "ssh" )
-      command = "ssh ";
-    else
-      throw SALOME_Exception("Unknown protocol");
-
-    if (_params.username != ""){
-      command += _params.username;
-      command += "@";
-    }
-
-    command += _params.hostname;
-    command += " \"bkill " ;
-    command += oss.str();
-    command += "\"";
-    SCRUTE(command.c_str());
-    status = system(command.c_str());
-    if(status)
-      throw SALOME_Exception("Error of connection on remote host");
-
-    MESSAGE("jobId = " << jobid << "killed");
-    END_OF("BatchManager_SLURM::deleteJob");
-  }
-   
-  // Methode pour le controle des jobs : renvoie l'etat du job
-  string BatchManager_SLURM::queryJob(const int & jobid)
-  {
-    BEGIN_OF("BatchManager_SLURM::queryJob");
-    // define name of log file
-    string logFile="/tmp/logs/";
-    logFile += getenv("USER");
-    logFile += "/batchSalome_";
-
-    srand ( time(NULL) );
-    int ir = rand();
-    ostringstream oss;
-    oss << ir;
-    logFile += oss.str();
-    logFile += ".log";
-
-    string command;
-    int status;
-
-    // define command to submit batch
-    if( _params.protocol == "rsh" )
-      command = "rsh ";
-    else if( _params.protocol == "ssh" )
-      command = "ssh ";
-    else
-      throw SALOME_Exception("Unknown protocol");
-
-    if (_params.username != ""){
-      command += _params.username;
-      command += "@";
-    }
-
-    command += _params.hostname;
-    command += " \"bjobs " ;
-    ostringstream oss2;
-    oss2 << jobid;
-    command += oss2.str();
-    command += "\" > ";
-    command += logFile;
-    SCRUTE(command.c_str());
-    status = system(command.c_str());
-    if(status)
-      throw SALOME_Exception("Error of connection on remote host");
-
-    // read staus of job in log file
-    char line[128];
-    ifstream fp(logFile.c_str(),ios::in);
-    fp.getline(line,80,'\n');
-    
-    string sjobid, username, jstatus;
-    fp >> sjobid;
-    fp >> username;
-    fp >> jstatus;
-
-    MESSAGE("jobId = " << jobid << " " << jstatus);
-    END_OF("BatchManager_SLURM::queryJob");
-    return jstatus;
-  }
-
-  void BatchManager_SLURM::buildSalomeCouplingScript( const char *fileToExecute ) throw(SALOME_Exception)
-  {
-    BEGIN_OF("BatchManager_SLURM::buildSalomeCouplingScript");
-    int status;
-
-    string::size_type p1 = string(fileToExecute).find_last_of("/");
-    string::size_type p2 = string(fileToExecute).find_last_of(".");
-    _fileNameToExecute = string(fileToExecute).substr(p1+1,p2-p1-1);
-
-    _TmpFileName = BuildTemporaryFileName();
-    ofstream tempOutputFile;
-    tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
-    tempOutputFile << "#! /bin/sh -f" << endl ;
-    tempOutputFile << "cd " ;
-    tempOutputFile << _params.applipath << endl ;
-    tempOutputFile << "export PYTHONPATH=~/" ;
-    tempOutputFile << _dirForTmpFiles ;
-    tempOutputFile << ":$PYTHONPATH" << endl ;
-    tempOutputFile << "if test $SLURM_PROCID = 0; then" << endl ;
-    tempOutputFile << "  ./runAppli --terminal --modules=" ;
-    for ( int i = 0 ; i < _params.modulesList.size() ; i++ ) {
-      tempOutputFile << _params.modulesList[i] ;
-      if ( i != _params.modulesList.size()-1 )
-       tempOutputFile << "," ;
-    }
-    tempOutputFile << " --standalone=registry,study,moduleCatalog --killall &" << endl ;
-    tempOutputFile << "  for ((ip=1; ip < ${SLURM_NPROCS} ; ip++))" << endl;
-    tempOutputFile << "  do" << endl ;
-    tempOutputFile << "    arglist=\"$arglist YACS_Server_\"$ip" << endl ;
-    tempOutputFile << "  done" << endl ;
-    tempOutputFile << "  ./runSession waitNS.sh" << endl ;
-    tempOutputFile << "  ./runSession waitContainers.py $arglist" << endl ;
-    tempOutputFile << "  ./runSession python ~/" << _dirForTmpFiles << "/" << _fileNameToExecute << ".py" << endl;
-    tempOutputFile << "  ./runSession killCurrentPort" << endl;
-    tempOutputFile << "else" << endl ;
-    tempOutputFile << "  ./runSession waitNS.sh" << endl ;
-    tempOutputFile << "  ./runSession SALOME_Container 'YACS_Server_'${SLURM_PROCID}" << endl ;
-    tempOutputFile << "fi" << endl ;
-    tempOutputFile.flush();
-    tempOutputFile.close();
-    chmod(_TmpFileName.c_str(), 0x1ED);
-    SCRUTE(_TmpFileName.c_str()) ;
-
-    string command;
-    if( _params.protocol == "rsh" )
-      command = "rcp ";
-    else if( _params.protocol == "ssh" )
-      command = "scp ";
-    else
-      throw SALOME_Exception("Unknown protocol");
-    
-    command += _TmpFileName;
-    command += " ";
-    if (_params.username != ""){
-      command += _params.username;
-      command += "@";
-    }
-    command += _params.hostname;
-    command += ":";
-    command += _dirForTmpFiles ;
-    command += "/runSalome_" ;
-    command += _fileNameToExecute ;
-    command += "_Batch.sh" ;
-    SCRUTE(command.c_str());
-    status = system(command.c_str());
-    if(status)
-      throw SALOME_Exception("Error of connection on remote host");    
-    RmTmpFile();
-    
-    END_OF("BatchManager_SLURM::buildSalomeCouplingScript");
-  }
-
-  void BatchManager_SLURM::buildSalomeBatchScript( const int nbproc ) throw(SALOME_Exception)
-  {
-    BEGIN_OF("BatchManager_SLURM::buildSalomeBatchScript");
-    int status;
-    _TmpFileName = BuildTemporaryFileName();
-    ofstream tempOutputFile;
-    tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
-
-    tempOutputFile << "#! /bin/sh -f" << endl ;
-    tempOutputFile << "#BSUB -n " << nbproc << endl ;
-    tempOutputFile << "#BSUB -o " << _dirForTmpFiles << "/runSalome.log%J" << endl ;
-    tempOutputFile << "mpirun -srun ~/" << _dirForTmpFiles << "/runSalome_" << _fileNameToExecute << "_Batch.sh" << endl ;
-    tempOutputFile.flush();
-    tempOutputFile.close();
-    chmod(_TmpFileName.c_str(), 0x1ED);
-    SCRUTE(_TmpFileName.c_str()) ;
-
-    string command;
-    if( _params.protocol == "rsh" )
-      command = "rcp ";
-    else if( _params.protocol == "ssh" )
-      command = "scp ";
-    else
-      throw SALOME_Exception("Unknown protocol");
-    command += _TmpFileName;
-    command += " ";
-    if (_params.username != ""){
-      command += _params.username;
-      command += "@";
-    }
-    command += _params.hostname;
-    command += ":";
-    command += _dirForTmpFiles ;
-    command += "/" ;
-    command += _fileNameToExecute ;
-    command += "_Batch.sh" ;
-    SCRUTE(command.c_str());
-    status = system(command.c_str());
-    if(status)
-      throw SALOME_Exception("Error of connection on remote host");    
-
-    RmTmpFile();
-    END_OF("BatchManager_SLURM::buildSalomeBatchScript");
-    
-  }
-
-  int BatchManager_SLURM::submit() throw(SALOME_Exception)
-  {
-    BEGIN_OF("BatchManager_SLURM::submit");
-
-    // define name of log file
-    string logFile="/tmp/logs/";
-    logFile += getenv("USER");
-    logFile += "/batchSalome_";
-
-    srand ( time(NULL) );
-    int ir = rand();
-    ostringstream oss;
-    oss << ir;
-    logFile += oss.str();
-    logFile += ".log";
-
-    string command;
-    int status;
-
-    // define command to submit batch
-    if( _params.protocol == "rsh" )
-      command = "rsh ";
-    else if( _params.protocol == "ssh" )
-      command = "ssh ";
-    else
-      throw SALOME_Exception("Unknown protocol");
-
-    if (_params.username != ""){
-      command += _params.username;
-      command += "@";
-    }
-
-    command += _params.hostname;
-    command += " \"bsub < " ;
-    command += _dirForTmpFiles ;
-    command += "/" ;
-    command += _fileNameToExecute ;
-    command += "_Batch.sh\" > ";
-    command += logFile;
-    SCRUTE(command.c_str());
-    status = system(command.c_str());
-    if(status)
-      throw SALOME_Exception("Error of connection on remote host");
-
-    // read id of submitted job in log file
-    char line[128];
-    FILE *fp = fopen(logFile.c_str(),"r");
-    fgets( line, 128, fp);
-    fclose(fp);
-    
-    string sline(line);
-    int p1 = sline.find("<");
-    int p2 = sline.find(">");
-    string strjob = sline.substr(p1+1,p2-p1-1);
-
-    int id;
-    istringstream iss(strjob);
-    iss >> id;
-
-    END_OF("BatchManager_SLURM::submit");
-    return id;
-  }
-
-}
diff --git a/src/Batch/BatchLight_BatchManager_SLURM.hxx b/src/Batch/BatchLight_BatchManager_SLURM.hxx
deleted file mode 100644 (file)
index ed21624..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either 
-// version 2.1 of the License.
-// 
-// This library is distributed in the hope that it will be useful 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public  
-// License along with this library; if not, write to the Free Software 
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
- * BatchManager.hxx : 
- *
- * Auteur : Bernard SECHER - CEA/DEN
- * Date   : Juillet 2007
- * Projet : SALOME
- *
- */
-
-#ifndef _BL_BATCHMANAGER_SLURM_H_
-#define _BL_BATCHMANAGER_SLURM_H_
-
-#include <string>
-#include "Utils_SALOME_Exception.hxx"
-#include "BatchLight_BatchManager.hxx"
-
-namespace BatchLight {
-
-  class Job;
-
-  class BatchManager_SLURM : public BatchManager
-  {
-  public:
-    // Constructeur et destructeur
-    BatchManager_SLURM(const batchParams& p) throw(SALOME_Exception); // connexion a la machine host
-    virtual ~BatchManager_SLURM();
-
-    // Methodes pour le controle des jobs : virtuelles pures
-    void deleteJob(const int & jobid); // retire un job du gestionnaire
-    std::string queryJob(const int & jobid); // renvoie l'etat du job
-
-  protected:
-    void buildSalomeCouplingScript( const char *fileToExecute ) throw(SALOME_Exception);
-    void buildSalomeBatchScript( const int nbproc ) throw(SALOME_Exception);
-    int submit() throw(SALOME_Exception);
-
-  private:
-
-  };
-
-}
-
-#endif
diff --git a/src/Batch/BatchLight_Job.cxx b/src/Batch/BatchLight_Job.cxx
deleted file mode 100644 (file)
index 9762a98..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either 
-// version 2.1 of the License.
-// 
-// This library is distributed in the hope that it will be useful 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public  
-// License along with this library; if not, write to the Free Software 
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
- * Job.cxx : 
- *
- * Auteur : Bernard SECHER - CEA/DEN
- * Date   : Juillet 2007
- * Projet : SALOME
- *
- */
-
-#include "BatchLight_Job.hxx"
-using namespace std;
-
-namespace BatchLight {
-
-  // Constructeur
-  Job::Job(const char *fileToExecute, const Engines::FilesList& filesToExport, const Engines::FilesList& filesToImport, const int nbproc) : _fileToExecute(fileToExecute), _filesToExport(filesToExport), _filesToImport(filesToImport), _nbproc(nbproc)
-  {
-    // Nothing to do
-  }
-
-  Job::~Job()
-  {
-    MESSAGE("Job destructor");
-  }
-
-}
diff --git a/src/Batch/BatchLight_Job.hxx b/src/Batch/BatchLight_Job.hxx
deleted file mode 100644 (file)
index 23ac8f3..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either 
-// version 2.1 of the License.
-// 
-// This library is distributed in the hope that it will be useful 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public  
-// License along with this library; if not, write to the Free Software 
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
- * Job.hxx : 
- *
- * Auteur : Bernard SECHER - CEA/DEN
- * Date   : Juillet 2007
- * Projet : SALOME
- *
- */
-
-#ifndef _BL_JOB_H_
-#define _BL_JOB_H_
-
-#include "utilities.h"
-#include <SALOMEconfig.h>
-#include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
-
-namespace BatchLight {
-
-  class Job
-  {
-  public:
-    // Constructeurs et destructeur
-    Job(const char *fileToExecute, const Engines::FilesList& filesToExport, const Engines::FilesList& filesToImport, const int nbproc);
-    virtual ~Job();
-
-    const char *getFileToExecute() const { return _fileToExecute; }
-    const Engines::FilesList getFilesToExportList() const { return _filesToExport; }
-    const Engines::FilesList getFilesToImportList() const { return _filesToImport; }
-    const int getNbProc() const { return _nbproc; }
-    
-  protected:
-    const char* _fileToExecute;
-    const Engines::FilesList _filesToExport;
-    const Engines::FilesList _filesToImport;
-    const int _nbproc;
-
-  private:
-
-  };
-
-}
-
-#endif
index 82c63ff12cd18545fdf6ca627dbee8b3f68c60c0..07bcd0048e59e5fcc638fff95ffbafac34cff9c4 100644 (file)
@@ -37,6 +37,7 @@ namespace Batch {
 
   pthread_mutex_t BatchManagerCatalog::_mutex = PTHREAD_MUTEX_INITIALIZER;
   std::map<string, FactBatchManager *> * BatchManagerCatalog::_p_catalog = 0;
+  BatchManagerCatalog BatchManagerCatalog::theCatalog;
 
   // Constructeur
   BatchManagerCatalog::BatchManagerCatalog()
@@ -47,7 +48,7 @@ namespace Batch {
   // Destructeur
   BatchManagerCatalog::~BatchManagerCatalog()
   {
-    // Nothing to do
+    delete BatchManagerCatalog::_p_catalog;
   }
 
   // Functor
index 62917faa470e6a30bec0379fc9f187fb13321fad..81ab713ec7c303309518dcb4645118d7281deafd 100644 (file)
@@ -53,6 +53,7 @@ namespace Batch {
     virtual std::string __repr__() const;
 
   protected:
+    static BatchManagerCatalog theCatalog;
     static std::map<std::string, FactBatchManager *> * _p_catalog;
     static pthread_mutex_t _mutex;
 
index 0ec1166ef5cb0d6cdb5edab2c0d8eaeeed0a5d1e..a657696acf0641fb55ac7ca91e363094ef5d28e7 100644 (file)
@@ -60,7 +60,7 @@ namespace Batch {
       _sec   = p_tm->tm_sec;
 
     } else {
-      char c;
+//      char c;
 //       istringstream ist(s);
 //       ist >> _day   >> c
 //       >> _month >> c
index 395634bbfea84a8fef76e44e6b8a8c8df0cccde3..f38132ca25e1e5ccddb598f0503365b1f2d4ea53 100644 (file)
  *
  */
 
-#include <string>
 #include <Python.h>
 #include "Batch_TypeMismatchException.hxx"
 #include "Batch_ListIsFullException.hxx"
 #include "Batch_InvalidArgumentException.hxx"
 #include "Batch_PyVersatile.hxx"
+#include <string>
 
 namespace Batch {
 
@@ -93,7 +93,7 @@ namespace Batch {
     if (_maxsize != 1) { // une liste
       obj = PyList_New(0);
       for(Versatile::const_iterator it=begin(); it!=end(); it++) {
-       char ch[2] = {0, 0};
+//     char ch[2] = {0, 0};
        string st;
        Couple cp;
 //     PyObject * tuple;
@@ -137,7 +137,7 @@ namespace Batch {
       }
 
     } else { // un scalaire
-      char ch[2] = {0, 0};
+//      char ch[2] = {0, 0};
       string st;
       Couple cp;
 //       PyObject * tuple;
index 425e39f5c3eb1e9eb76db524b2e2d85e4e587937..0ec62e54ca7a89bcb3d29740748703279f173f86 100644 (file)
@@ -59,12 +59,7 @@ LIB_INCLUDES = \
        Batch_PyVersatile.hxx \
        Batch_RunTimeException.hxx \
        Batch_StringType.hxx \
-       Batch_TypeMismatchException.hxx \
-       BatchLight_BatchManager.hxx \
-       BatchLight_BatchManager_PBS.hxx \
-       BatchLight_BatchManager_SLURM.hxx \
-       BatchLight_Job.hxx \
-       MpiImpl.hxx
+       Batch_TypeMismatchException.hxx 
 
 
 LIB_SRC = \
@@ -96,18 +91,14 @@ LIB_SRC = \
        Batch_PyVersatile.cxx \
        Batch_RunTimeException.cxx \
        Batch_StringType.cxx \
-       Batch_TypeMismatchException.cxx \
-       BatchLight_BatchManager.cxx \
-       BatchLight_BatchManager_SLURM.cxx \
-       BatchLight_BatchManager_PBS.cxx \
-       BatchLight_Job.cxx \
-       MpiImpl.cxx
+       Batch_TypeMismatchException.cxx 
 
 
 LIB_CPPFLAGS = \
-       @PYTHON_INCLUDES@ \
+       ${PYTHON_INCLUDES} \
        -I$(srcdir)/../Basics \
-       -I$(srcdir)/../SALOMELocalTrace
+       -I$(srcdir)/../SALOMELocalTrace \
+  -I$(top_builddir)/salome_adm/unix
 
 LIB_LIBADD   = \
        ../SALOMELocalTrace/libSALOMELocalTrace.la \
@@ -193,8 +184,8 @@ LIB_SRC += \
        Batch_JobInfo_LSF.cxx \
        Batch_Job_LSF.cxx
 
-LIB_CPPFLAGS += @LSF_INCLUDES@
-LIB_LIBADD   += @LSF_LIBDIR@ @LSF_LIBS@
+LIB_CPPFLAGS += ${LSF_INCLUDES}
+LIB_LIBADD   += ${LSF_LIBDIR} ${LSF_LIBS}
 endif
 
 
@@ -209,17 +200,6 @@ salomeinclude_HEADERS = $(LIB_INCLUDES)
 #
 lib_LTLIBRARIES = libSalomeBatch.la 
 libSalomeBatch_la_SOURCES = $(LIB_SRC)
-libSalomeBatch_la_CPPFLAGS = \
-       @PYTHON_INCLUDES@ \
-       -I$(srcdir)/../Basics \
-       -I$(srcdir)/../SALOMELocalTrace \
-       -I$(srcdir)/../Utils \
-       -I$(top_builddir)/salome_adm/unix \
-       -I$(top_builddir)/idl \
-       @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ $(LIB_CPPFLAGS)
-
+libSalomeBatch_la_CPPFLAGS = ${LIB_CPPFLAGS}
 libSalomeBatch_la_LDFLAGS  = -no-undefined -version-info=0:0:0
-libSalomeBatch_la_LIBADD   = \
-       ../SALOMELocalTrace/libSALOMELocalTrace.la \
-       ../Basics/libSALOMEBasics.la \
-       $(LIB_LIBADD)
+libSalomeBatch_la_LIBADD   = $(LIB_LIBADD)
diff --git a/src/Batch/MpiImpl.cxx b/src/Batch/MpiImpl.cxx
deleted file mode 100644 (file)
index 036018b..0000000
+++ /dev/null
@@ -1,212 +0,0 @@
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either 
-// version 2.1 of the License.
-// 
-// This library is distributed in the hope that it will be useful 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public  
-// License along with this library; if not, write to the Free Software 
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
- * BatchManager.cxx : 
- *
- * Auteur : Bernard SECHER - CEA/DEN
- * Date   : Juillet 2007
- * Projet : SALOME
- *
- */
-
-#include <iostream>
-#include <sstream>
-#include <string>
-#include "utilities.h"
-#include "MpiImpl.hxx"
-
-using namespace std;
-
-// Constructor
-MpiImpl::MpiImpl()
-{
-  MESSAGE("MpiImpl constructor");
-}
-
-// Destructor
-MpiImpl::~MpiImpl()
-{
-  MESSAGE("MpiImpl destructor");
-}
-
-// lam implementation
-// Constructor
-MpiImpl_LAM::MpiImpl_LAM() : MpiImpl()
-{
-}
-
-// Destructor
-MpiImpl_LAM::~MpiImpl_LAM()
-{
-  MESSAGE("MpiImpl_LAM destructor");
-}
-
-string MpiImpl_LAM::size()
-{
-  return "${LAMWORLD}";
-}
-
-string MpiImpl_LAM::rank()
-{
-  return "${LAMRANK}";
-}
-
-string MpiImpl_LAM::boot(const string machinefile, const unsigned int nbnodes)
-{
-  ostringstream oss;
-  oss << "lamboot " << machinefile << endl;
-  return oss.str();
-}
-
-string MpiImpl_LAM::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
-{
-  ostringstream oss;
-  oss << "mpirun -np " << nbproc << " " << fileNameToExecute << endl;
-  return oss.str();
-}
-
-string MpiImpl_LAM::halt()
-{
-  ostringstream oss;
-  oss << "lamhalt" << endl;
-  return oss.str();
-}
-
-// mpich1 implementation
-// Constructor
-MpiImpl_MPICH1::MpiImpl_MPICH1() : MpiImpl()
-{
-}
-
-// Destructor
-MpiImpl_MPICH1::~MpiImpl_MPICH1()
-{
-  MESSAGE("MpiImpl_MPICH1 destructor");
-}
-
-string MpiImpl_MPICH1::size()
-{
-  throw SALOME_Exception("mpich1 doesn't work with this batch system to submit salome session");
-}
-
-string MpiImpl_MPICH1::rank()
-{
-  throw SALOME_Exception("mpich1 doesn't work with this batch system to submit salome session");
-}
-
-string MpiImpl_MPICH1::boot(const string machinefile, const unsigned int nbnodes)
-{
-  return "";
-}
-
-string MpiImpl_MPICH1::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
-{
-  ostringstream oss;
-  oss << "mpirun -machinefile " << machinefile << " -np " << nbproc << " " << fileNameToExecute << endl;
-  return oss.str();
-}
-
-string MpiImpl_MPICH1::halt()
-{
-  return "";
-}
-
-// mpich2 implementation
-// Constructor
-MpiImpl_MPICH2::MpiImpl_MPICH2() : MpiImpl()
-{
-}
-
-// Destructor
-MpiImpl_MPICH2::~MpiImpl_MPICH2()
-{
-  MESSAGE("MpiImpl_MPICH2 destructor");
-}
-
-string MpiImpl_MPICH2::size()
-{
-  return "${PMI_SIZE}";
-}
-
-string MpiImpl_MPICH2::rank()
-{
-  return "${PMI_RANK}";
-}
-
-string MpiImpl_MPICH2::boot(const string machinefile, const unsigned int nbnodes)
-{
-  ostringstream oss;
-  oss << "mpdboot -n " << nbnodes << " -f " << machinefile << endl;
-  return oss.str();
-}
-
-string MpiImpl_MPICH2::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
-{
-  ostringstream oss;
-  oss << "mpirun -np " << nbproc << " " << fileNameToExecute << endl;
-  return oss.str();
-}
-
-string MpiImpl_MPICH2::halt()
-{
-  ostringstream oss;
-  oss << "mpdallexit" << endl;
-  return oss.str();
-}
-
-// openmpi implementation
-// Constructor
-MpiImpl_OPENMPI::MpiImpl_OPENMPI() : MpiImpl()
-{
-}
-
-// Destructor
-MpiImpl_OPENMPI::~MpiImpl_OPENMPI()
-{
-  MESSAGE("MpiImpl_OPENMPI destructor");
-}
-
-string MpiImpl_OPENMPI::size()
-{
-  return "${OMPI_MCA_ns_nds_num_procs}";
-}
-
-string MpiImpl_OPENMPI::rank()
-{
-  return "${OMPI_MCA_ns_nds_vpid}";
-}
-
-string MpiImpl_OPENMPI::boot(const string machinefile, const unsigned int nbnodes)
-{
-  return "";
-}
-
-string MpiImpl_OPENMPI::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
-{
-  ostringstream oss;
-  oss << "mpirun -hostfile " << machinefile << " -np " << nbproc << " " << fileNameToExecute << endl;
-  return oss.str();
-}
-
-string MpiImpl_OPENMPI::halt()
-{
-  return "";
-}
-
diff --git a/src/Batch/MpiImpl.hxx b/src/Batch/MpiImpl.hxx
deleted file mode 100644 (file)
index beeac03..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-// 
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either 
-// version 2.1 of the License.
-// 
-// This library is distributed in the hope that it will be useful 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public  
-// License along with this library; if not, write to the Free Software 
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
- * BatchManager.hxx : 
- *
- * Auteur : Bernard SECHER - CEA/DEN
- * Date   : Juillet 2007
- * Projet : SALOME
- *
- */
-
-#ifndef _BL_MPIIMPL_H_
-#define _BL_MPIIMPL_H_
-
-#include <string>
-#include "Utils_SALOME_Exception.hxx"
-#include <SALOMEconfig.h>
-
-class MpiImpl
-{
-public:
-  // Constructeur et destructeur
-  MpiImpl(); // constrcuctor
-  virtual ~MpiImpl(); //Destructor
-  
-  virtual std::string size() = 0; // get number of process of current job
-  virtual std::string rank() = 0; // get process number of current job
-  virtual std::string boot(const std::string machinefile, const unsigned int nbnodes) = 0; // get boot command
-  virtual std::string run(const std::string machinefile, const unsigned int nbproc, const std::string fileNameToExecute) = 0; // get run command
-  virtual std::string halt() = 0; // get stop command
-
-protected:
-
-private:
-
-};
-
-class MpiImpl_LAM : public MpiImpl
-{
-public:
-  // Constructeur et destructeur
-  MpiImpl_LAM(); // constructor
-  virtual ~MpiImpl_LAM(); //Destructor
-
-  std::string size(); // get number of process of current job
-  std::string rank(); // get process number of current job
-  std::string boot( const std::string machinefile, const unsigned int nbnodes); // get boot command
-  std::string run( const std::string machinefile, const unsigned int nbproc, const std::string fileNameToExecute); // get run command
-  std::string halt(); // get stop command
-
-protected:
-  
-private:
-
-};
-
-class MpiImpl_MPICH1 : public MpiImpl
-{
-public:
-  // Constructeur et destructeur
-  MpiImpl_MPICH1(); // constructor
-  virtual ~MpiImpl_MPICH1(); //Destructor
-  
-  std::string size(); // get number of process of current job
-  std::string rank(); // get process number of current job
-  std::string boot( const std::string machinefile, const unsigned int nbnodes); // get boot command
-  std::string run( const std::string machinefile, const unsigned int nbproc, const std::string fileNameToExecute); // get run command
-  std::string halt(); // get stop command
-
-protected:
-  
-private:
-
-};
-
-class MpiImpl_MPICH2 : public MpiImpl
-{
-public:
-  // Constructeur et destructeur
-  MpiImpl_MPICH2(); // constructor
-  virtual ~MpiImpl_MPICH2(); //Destructor
-
-  std::string size(); // get number of process of current job
-  std::string rank(); // get process number of current job
-  std::string boot( const std::string machinefile, const unsigned int nbnodes); // get boot command
-  std::string run( const std::string machinefile, const unsigned int nbproc, const std::string fileNameToExecute); // get run command
-  std::string halt(); // get stop command
-
-protected:
-
-private:
-
-};
-
-class MpiImpl_OPENMPI : public MpiImpl
-{
-public:
-  // Constructeur et destructeur
-  MpiImpl_OPENMPI(); // constructor
-  virtual ~MpiImpl_OPENMPI(); //Destructor
-
-  std::string size(); // get number of process of current job
-  std::string rank(); // get process number of current job
-  std::string boot( const std::string machinefile, const unsigned int nbnodes); // get boot command
-  std::string run( const std::string machinefile, const unsigned int nbproc, const std::string fileNameToExecute); // get run command
-  std::string halt(); // get stop command
-
-protected:
-
-private:
-
-};
-
-#endif
index af8380f8cc3da85ea1e19598c4dcfc0ca7847915..cdbef093f044b1f50fde72b2ff7e8e2131047e6c 100644 (file)
@@ -241,7 +241,6 @@ void Engines_Component_i::destroy()
   delete _myConnexionToRegistry;
   _myConnexionToRegistry = 0 ;
   _poa->deactivate_object(*_id) ;
-  CORBA::release(_poa) ;
   delete(_id) ;
   //SCRUTE(pd_refCount);
   _thisObj->_remove_ref();
@@ -259,7 +258,7 @@ void Engines_Component_i::destroy()
 Engines::Container_ptr Engines_Component_i::GetContainerRef()
 {
   //  MESSAGE("Engines_Component_i::GetContainerRef");
-  CORBA::Object_ptr o = _poa->id_to_reference(*_contId) ;
+  CORBA::Object_var o = _poa->id_to_reference(*_contId) ;
   return Engines::Container::_narrow(o);
 }
 
@@ -851,7 +850,7 @@ void Engines_Component_i::CancelThread()
 void Engines_Component_i::sendMessage(const char *event_type,
                                      const char *message)
 {
-    _notifSupplier->Send(graphName(), nodeName(), event_type, message);
+    _notifSupplier->Send(_graphName.c_str(), _nodeName.c_str(), event_type, message);
 }
 
 //=============================================================================
index 61d3e2a61170cdb2b105b3f2a485773ee9efd512..2f5692fdc3e5f59b4cffab18cf40c1688987faa7 100644 (file)
@@ -103,7 +103,7 @@ Engines_Container_i::Engines_Container_i () :
 //=============================================================================
 
 Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb, 
-                                          PortableServer::POA_var poa,
+                                          PortableServer::POA_ptr poa,
                                           char *containerName ,
                                           int argc , char* argv[],
                                           bool activAndRegist,
@@ -161,10 +161,11 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb,
     {
       _id = _poa->activate_object(this);
       _NS = new SALOME_NamingService();
-      _NS->init_orb( CORBA::ORB::_duplicate(_orb) ) ;
+      _NS->init_orb( _orb ) ;
       CORBA::Object_var obj=_poa->id_to_reference(*_id);
       Engines::Container_var pCont 
         = Engines::Container::_narrow(obj);
+      _remove_ref();
 
       _containerName = _NS->BuildContainerNameForNS(containerName,
                                                     hostname.c_str());
@@ -209,7 +210,9 @@ Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb,
         }
 
       fileTransfer_i* aFileTransfer = new fileTransfer_i();
-      _fileTransfer = Engines::fileTransfer::_narrow(aFileTransfer->_this());
+      CORBA::Object_var obref=aFileTransfer->_this();
+      _fileTransfer = Engines::fileTransfer::_narrow(obref);
+      aFileTransfer->_remove_ref();
     }
 }
 
@@ -223,6 +226,8 @@ Engines_Container_i::~Engines_Container_i()
 {
   MESSAGE("Container_i::~Container_i()");
   delete _id;
+  if(_NS)
+    delete _NS;
 }
 
 //=============================================================================
@@ -298,8 +303,6 @@ void Engines_Container_i::Shutdown()
   if(_isServantAloneInProcess)
     {
       MESSAGE("Effective Shutdown of container Begins...");
-      LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
-      bp1->deleteInstance(bp1);
       if(!CORBA::is_nil(_orb))
        _orb->shutdown(0);
     }
@@ -455,6 +458,7 @@ Engines_Container_i::create_component_instance(const char*genericRegisterName,
                                              instanceName.c_str(),
                                              studyId);
       string iors = PyString_AsString(result);
+      Py_DECREF(result);
       SCRUTE(iors);
       Py_RELEASE_NEW_THREAD;
   
@@ -462,6 +466,7 @@ Engines_Container_i::create_component_instance(const char*genericRegisterName,
       {
         CORBA::Object_var obj = _orb->string_to_object(iors.c_str());
         iobject = Engines::Component::_narrow( obj ) ;
+        _listInstances_map[instanceName] = iobject;
       }
       return iobject._retn();
     }
@@ -904,6 +909,8 @@ Engines_Container_i::createInstance(string genericRegisterName,
 
 void Engines_Container_i::decInstanceCnt(string genericRegisterName)
 {
+  if(_cntInstances_map.count(genericRegisterName)==0)
+    return;
   string aGenRegisterName =genericRegisterName;
   MESSAGE("Engines_Container_i::decInstanceCnt " << aGenRegisterName);
   ASSERT(_cntInstances_map[aGenRegisterName] > 0); 
index 8a3d80d41e6ca7b3edb6af0d7a33164c57dfc39d..5d071b8e422c38e44b653047edade3c9f2911ef1 100755 (executable)
@@ -83,7 +83,9 @@ class SALOME_ComponentPy_i (Engines__POA.Component):
         myMachine=getShortHostName()
         Component_path = self._containerName + "/" + self._instanceName
         MESSAGE(  'SALOME_ComponentPy_i Register' + str( Component_path ) )
-        naming_service.Register(self._this(), Component_path)
+        id_o = poa.activate_object(self)
+        compo_o = poa.id_to_reference(id_o)
+        naming_service.Register(compo_o, Component_path)
 
         # Add componentinstance to registry
         obj = naming_service.Resolve('/Registry')
@@ -145,8 +147,8 @@ class SALOME_ComponentPy_i (Engines__POA.Component):
 
     def destroy(self):
         MESSAGE(  "SALOME_ComponentPy_i::destroy" )
-        self._poa.deactivate_object(self)
-        CORBA.release(self._poa)
+        id = self._poa.servant_to_id(self)
+        self._poa.deactivate_object(id)
         
     #-------------------------------------------------------------------------
 
index de8a42e0ee3116b6d9c5245114cbe77acec595c1..9e3ee13839e0124fec946027ae525481b03056f2 100644 (file)
@@ -142,8 +142,8 @@ protected:
   std::string _instanceName ;
   std::string _interfaceName ;
 
-  CORBA::ORB_ptr _orb;
-  PortableServer::POA_ptr _poa;
+  CORBA::ORB_var _orb;
+  PortableServer::POA_var _poa;
   PortableServer::ObjectId * _id;
   PortableServer::ObjectId * _contId;
   Engines_Component_i * _thisObj ;
index 9a8cf992bb9cfe7686ca6c8f27c2220ed04b9ec0..00345f6700ee9ee26a807609f01e5061312e78af 100644 (file)
@@ -130,7 +130,7 @@ int main(int argc, char* argv[])
   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
   ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
   CORBA::ORB_ptr orb = init(argc , argv ) ;
-         
+
   //  LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
   INFOS_COMPILATION;
   BEGIN_OF(argv[0]);
@@ -168,9 +168,9 @@ int main(int argc, char* argv[])
 
       // add new container to the kill list
 #ifndef WNT
-      ostrstream aCommand ;
+      stringstream aCommand ;
       aCommand << "addToKillList.py " << getpid() << " SALOME_Container" << ends ;
-      system(aCommand.str());
+      system(aCommand.str().c_str());
 #endif
       
       Engines_Container_i * myContainer 
@@ -186,7 +186,10 @@ int main(int argc, char* argv[])
 #endif
 
       HandleServerSideSignals(orb);
-      
+
+      PyGILState_STATE gstate = PyGILState_Ensure();
+      //Delete python container that destroy orb from python (pyCont._orb.destroy())
+      Py_Finalize();
     }
   catch(CORBA::SystemException&)
     {
index 362f077e4bab01dc3e7ca28c5668fa5a64d42e29..17915095442258ac4a9895206cacc724ef5997fa 100644 (file)
@@ -32,12 +32,8 @@ import os
 import sys
 import string
 from omniORB import CORBA, PortableServer
-# import SALOMEDS before other SALOME modules
-# (if not, incomplete import done by SALOME module: no load of SALOMEDS_attributes)
 import SALOMEDS 
 import Engines, Engines__POA
-reload(Engines)
-reload(Engines__POA)
 from SALOME_NamingServicePy import *
 from SALOME_ComponentPy import *
 
@@ -68,6 +64,9 @@ class SALOME_Container_i:
 
     #-------------------------------------------------------------------------
 
+    def __del__(self ):
+      self._orb.destroy()
+
     def import_component(self, componentName):
         MESSAGE( "SALOME_Container_i::import_component" )
         ret=0
index 043ed927d57e3d0d0139b2c305cc0b5967969ed3..b74dda3756bd2ab00479f0e0f0fd7caf81d4acb0 100644 (file)
@@ -102,6 +102,7 @@ void SALOME_ContainerManager::Shutdown()
   _NS->Destroy_Name(_ContainerManagerNameInNS);
   PortableServer::ObjectId_var oid = _poa->servant_to_id(this);
   _poa->deactivate_object(oid);
+  //_remove_ref() has already been done at creation
   //_remove_ref();
 }
 
@@ -135,11 +136,28 @@ void SALOME_ContainerManager::ShutdownContainers()
       SCRUTE((*iter));
       CORBA::Object_var obj=_NS->Resolve((*iter).c_str());
       Engines::Container_var cont=Engines::Container::_narrow(obj);
-      if(!CORBA::is_nil(cont)){
-       MESSAGE("ShutdownContainers: " << (*iter));
-       cont->Shutdown();
-      }
-      else MESSAGE("ShutdownContainers: no container ref for " << (*iter));
+      if(!CORBA::is_nil(cont))
+        {
+         MESSAGE("ShutdownContainers: " << (*iter));
+          try
+            {
+              cont->Shutdown();
+            }
+          catch(CORBA::SystemException& e)
+            {
+              INFOS("CORBA::SystemException ignored : " << e);
+            }
+          catch(CORBA::Exception&)
+            {
+              INFOS("CORBA::Exception ignored.");
+            }
+          catch(...)
+            {
+              INFOS("Unknown exception ignored.");
+            }
+        }
+      else 
+        MESSAGE("ShutdownContainers: no container ref for " << (*iter));
     }
   }
 }
@@ -212,6 +230,10 @@ StartContainer(const Engines::MachineParameters& params,
     return Engines::Container::_nil();
   }
 
+  //If the machine name is localhost use the real name
+  if(theMachine == "localhost")
+    theMachine=GetHostname();
+
   MESSAGE("try to launch it on " << theMachine);
 
   // Get Id for container: a parallel container registers in Naming Service
@@ -326,6 +348,7 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params_const,
                             const Engines::MachineList& possibleComputers)
 {
   CORBA::Object_var obj;
+  PaCO::InterfaceManager_var proxy;
   Engines::Container_ptr ret = Engines::Container::_nil();
   Engines::MachineParameters params(params_const);
 
@@ -338,7 +361,7 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params_const,
   if(CORBA::is_nil(ret)) {
     // Step 2 : Starting a new parallel container
     INFOS("[FindOrStartParallelContainer] Starting a parallel container");
-    
+
     // Step 2.1 : Choose a computer
     string theMachine = _ResManager->FindFirst(possibleComputers);
     if(theMachine == "") {
@@ -353,48 +376,55 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params_const,
        // Step 3 : starting parallel container proxy
        params.hostname = CORBA::string_dup(theMachine.c_str());
        Engines::MachineParameters params_proxy(params);
-       command = _ResManager->BuildCommandToLaunchLocalParallelContainer("SALOME_ParallelContainerProxy", params_proxy, "xterm");
+       try {
+         command = _ResManager->BuildCommandToLaunchLocalParallelContainer("SALOME_ParallelContainerProxy", params_proxy, "xterm");
+       }
+       catch(const SALOME_Exception & ex){
+         MESSAGE(ex.what());
+         return Engines::Container::_nil();
+       }
        // LaunchParallelContainer uses this value to know if it launches the proxy or the nodes
        params_proxy.nb_component_nodes = 0;
        obj = LaunchParallelContainer(command, params_proxy, _NS->ContainerName(params));
        ret = Engines::Container::_narrow(obj);
+       proxy = PaCO::InterfaceManager::_narrow(obj);
 
        // Step 4 : starting parallel container nodes
        command = _ResManager->BuildCommandToLaunchLocalParallelContainer("SALOME_ParallelContainerNode", params, "xterm");
        string name = _NS->ContainerName(params) + "Node";
        LaunchParallelContainer(command, params, name);
-
        // Step 5 : connecting nodes and the proxy to actually create a parallel container
        try {
-       for (int i = 0; i < params.nb_component_nodes; i++) {
+         for (int i = 0; i < params.nb_component_nodes; i++) {
 
-       char buffer [5];
+           char buffer [5];
 #ifndef WNT
-         snprintf(buffer,5,"%d",i);
+           snprintf(buffer,5,"%d",i);
 #else
-         _snprintf(buffer,5,"%d",i);
+           _snprintf(buffer,5,"%d",i);
 #endif
-       string name_cont = name + string(buffer);
-
-       string theNodeMachine(CORBA::string_dup(params.hostname));
-       string containerNameInNS = _NS->BuildContainerNameForNS(name_cont.c_str(),theNodeMachine.c_str());
-       int count = TIME_OUT_TO_LAUNCH_CONT;
-       obj = _NS->Resolve(containerNameInNS.c_str());
-       while (CORBA::is_nil(obj) && count) {
-         INFOS("[FindOrStartParallelContainer] CONNECTION FAILED !!!!!!!!!!!!!!!!!!!!!!!!");
+           string name_cont = name + string(buffer);
+
+           string theNodeMachine(CORBA::string_dup(params.hostname));
+           string containerNameInNS = _NS->BuildContainerNameForNS(name_cont.c_str(),theNodeMachine.c_str());
+           int count = TIME_OUT_TO_LAUNCH_CONT;
+           obj = _NS->Resolve(containerNameInNS.c_str());
+           while (CORBA::is_nil(obj) && count) {
+             INFOS("[FindOrStartParallelContainer] CONNECTION FAILED !!!!!!!!!!!!!!!!!!!!!!!!");
 #ifndef WNT
-         sleep(1) ;
+             sleep(1) ;
 #else
-         Sleep(1000);
+             Sleep(1000);
 #endif
-         count-- ;
-         obj = _NS->Resolve(containerNameInNS.c_str());
-       }
-
-       PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(obj);
-       MESSAGE("[FindOrStartParallelContainer] Deploying node : " << name);
-       node->deploy(i);
-       }
+             count-- ;
+             obj = _NS->Resolve(containerNameInNS.c_str());
+           }
+
+           PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(obj);
+           MESSAGE("[FindOrStartParallelContainer] Deploying node : " << name);
+           node->deploy();
+         }
+         proxy->start();
        }
        catch(CORBA::SystemException& e)
        {
@@ -418,13 +448,12 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params_const,
        }
        INFOS("[FindOrStartParallelContainer] node " << name << " deployed");
       }
-
       else {
        INFOS("[FindOrStartParallelContainer] Currently parallel containers are launched only on the local host");
       }
     }
-  }
-  return ret;
+}
+return ret;
 }
 #else
 //=============================================================================
@@ -533,7 +562,8 @@ SALOME_ContainerManager::LaunchParallelContainer(const std::string& command,
 {
   CORBA::Object_ptr obj = CORBA::Object::_nil();
   string containerNameInNS;
-
+  MESSAGE("[LaunchParallelContainer] : command to launch...");
+  MESSAGE(command);
   if (params.nb_component_nodes == 0) {
     INFOS("[LaunchParallelContainer] launching the proxy of the parallel container");
     int status = system(command.c_str());
@@ -548,7 +578,7 @@ SALOME_ContainerManager::LaunchParallelContainer(const std::string& command,
     string theMachine(CORBA::string_dup(params.hostname));
     containerNameInNS = _NS->BuildContainerNameForNS((char*) name.c_str(),theMachine.c_str());
 
-    INFOS("[LaunchContainer]  Waiting for Parallel Container proxy on " << theMachine);
+    INFOS("[LaunchParallelContainer]  Waiting for Parallel Container proxy on " << theMachine);
     while (CORBA::is_nil(obj) && count) {
 #ifndef WNT
       sleep(1) ;
index 03c27e0d5b0bb6d642ae04b3394504cce458ecb2..f39a54c4b4608fb08f767b626efe7c5c93c77619 100644 (file)
@@ -54,7 +54,7 @@ class CONTAINER_EXPORT Engines_Container_i:
 public:
   Engines_Container_i();
   Engines_Container_i(CORBA::ORB_ptr orb, 
-                     PortableServer::POA_var poa,
+                     PortableServer::POA_ptr poa,
                      char * containerName ,
                       int argc, char* argv[],
                      bool activAndRegist = true,
index 8f10ad2cfb295a9f427d4435dfdfd44f89ff9791..a098c06f95707253605a0f90d4e6810891ec9f07 100644 (file)
@@ -842,6 +842,7 @@ Salome_file_i::getDistributedFile(std::string file_name)
       CORBA::Octet *buf = aBlock->get_buffer();
       int nbWri = fwrite(buf, sizeof(CORBA::Octet), toFollow, fp);
       ASSERT(nbWri == toFollow);
+      delete aBlock;
     }
     fclose(fp);
     MESSAGE("end of transfer of " << comp_file_name);
index 16b09034eb8435c124fc177f99da01c829d5d775..b1337871fef2a5bc2e71b8ddae0ee06757fab3d8 100644 (file)
@@ -100,7 +100,7 @@ class CONTAINER_EXPORT Salome_file_i:
     _t_fileDistributedSource _fileDistributedSource;
     Engines::SfState _state;
     Engines::Container_ptr _container;
-    Engines::Salome_file_ptr _default_source_Salome_file;
+    Engines::Salome_file_var _default_source_Salome_file;
 };
 
 #endif
index 816839cfa15a37db21aec581b55c676937064037..3cfe5585d981cf2169307322839448686acb5ade 100644 (file)
@@ -30,7 +30,7 @@
 # define DF_EXPORT
 #endif
 
-#include <iostream.h
+#include <iostream> 
 #include <stdio.h>
 #include <boost/shared_ptr.hpp> 
 
index c4f15adb57efc617e330ca5ba512525fda130f59..291e3138c6b3e7ea3cfabe1ec84c5fd3fb368aeb 100644 (file)
 
 #include "ParallelDSC_i.hxx"
 
-Engines_ParallelDSC_i::Engines_ParallelDSC_i(CORBA::ORB_ptr orb, char * ior,
+Engines_ParallelDSC_i::Engines_ParallelDSC_i(CORBA::ORB_ptr orb, 
+                                            char * ior,
+                                            int rank,
                                             PortableServer::POA_ptr poa,
                                             PortableServer::ObjectId * contId,
                                             const char *instanceName,
                                             const char *interfaceName,
                                             bool notif) :
-  Engines_Parallel_Component_i(orb, ior, poa, contId, instanceName, interfaceName, notif),
-  Engines::Parallel_DSC_serv(orb, ior),
-  Engines::DSC_serv(orb, ior),
-  Engines::Superv_Component_serv(orb, ior),
-  Engines::Component_serv(orb, ior),
-  Engines::Parallel_Component_serv(orb, ior),
-  InterfaceParallel_impl(orb,ior)
+  Engines_Parallel_Component_i(orb, ior, rank, poa, contId, instanceName, interfaceName, notif),
+  Engines::Parallel_DSC_serv(orb, ior, rank),
+  Engines::DSC_serv(orb, ior, rank),
+  Engines::Superv_Component_serv(orb, ior, rank),
+  Engines::Component_serv(orb, ior, rank),
+  Engines::Parallel_Component_serv(orb, ior, rank),
+  InterfaceParallel_impl(orb, ior, rank)
 {
 }
 
@@ -56,10 +58,8 @@ Engines_ParallelDSC_i::set_paco_proxy(const CORBA::Object_ptr ref,
   Engines_DSC_interface::add_provides_port(Ports::Port::_narrow(ref), 
                                           provides_port_name,
                                           port_prop);
-  PaCO_operation * global_ptr = getContext("global_paco_context");
-  cerr << " my_comm : " << global_ptr->my_com << endl;
   // Waiting that all the nodes have the proxy
-  global_ptr->my_com->paco_barrier(); 
+  _my_com->paco_barrier(); 
   cerr << "set_paco_proxy node fin" << endl;
 }
 
@@ -80,8 +80,8 @@ Engines_ParallelDSC_i::add_parallel_provides_proxy_port(const CORBA::Object_ptr
 {
   assert(provides_port_name);
   CORBA::Boolean rtn_bool = false;
-  CORBA::Object_ptr _comp_proxy = _orb->string_to_object(_ior.c_str());
-  Engines::Parallel_DSC_var real_comp_proxy = Engines::Parallel_DSC::_narrow(_comp_proxy);
+  Engines::Parallel_DSC_var real_comp_proxy = 
+    Engines::Parallel_DSC::_narrow(InterfaceParallel_impl::_proxy);
   real_comp_proxy->set_paco_proxy(ref, provides_port_name, port_prop);
   rtn_bool = true;
   return rtn_bool;
@@ -114,7 +114,7 @@ Engines_ParallelDSC_i::add_parallel_provides_node_port(Ports::Port_PaCO_ptr ref,
 {
   CORBA::Boolean rtn_bool = false;
   PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(ref);
-  node->deploy(getMyRank());
+  node->deploy();
   rtn_bool = true;
   return rtn_bool;
 }
index ed900566fa281a961e104a2ca3cae58dde495888..05859c0023f69070329c80cf8d8fcb20655c13f1 100644 (file)
@@ -39,7 +39,9 @@ class Engines_ParallelDSC_i:
   public virtual Engines_DSC_interface 
 {
 public:
-  Engines_ParallelDSC_i(CORBA::ORB_ptr orb, char * ior,
+  Engines_ParallelDSC_i(CORBA::ORB_ptr orb, 
+                       char * ior,
+                       int rank,
                        PortableServer::POA_ptr poa,
                        PortableServer::ObjectId * contId,
                        const char *instanceName,
index 22b460dd651ec9f008d7f5f9e3c4ea71c31f888d..3c86ed63ae0061e2ac498d8c18ed415e8825d489 100644 (file)
@@ -31,49 +31,50 @@ from launchConfigureParser import verbose
 
 #--------------------------------------------------------------------------
 
-def DumpComponent(Study, SO, offset):
-    it = Study.NewChildIterator(SO)
-    Builder = Study.NewBuilder()
-    while it.More():
-        CSO = it.Value()
-        it.Next()
-        anAttr = Builder.FindOrCreateAttribute(CSO, "AttributeName")
-        AtName = anAttr._narrow(SALOMEDS.AttributeName)
-        t_name = AtName.Value()
-        if t_name[0] == 1:
-            ofs = 1
-            a = ""
-            while ofs <= offset:
-                a = a + "--"
-                ofs = ofs +1
-            MESSAGE( a + ">" + str(CSO.GetID()) + " " + str(t_name[1]) )
-        t_RefSO = CSO.ReferencedObject()
-        if t_RefSO[0] == 1:
-            RefSO = t_RefSO[1]
-            ofs = 1
-            a = ""
-            while ofs <= offset:
-                a = a + "  "
-                ofs = ofs +1
-            MESSAGE( a + ">" + str(RefSO.GetID()) )
-        DumpComponent(Study, CSO, offset+2)
+def DumpComponent(Study, SO, Builder,offset):
+  it = Study.NewChildIterator(SO)
+  while it.More():
+    CSO = it.Value()
+    a=offset*"--" + ">" + CSO.GetID()
+    find,AtName = Builder.FindAttribute(CSO, "AttributeName")
+    if find:
+      a=a+":"+AtName.Value()
+    find,AtIOR = Builder.FindAttribute(CSO, "AttributeIOR")
+    if find:
+      a=a+":"+AtIOR.Value()
+    find,RefSO = CSO.ReferencedObject()
+    if find:
+      a=a+":"+RefSO.GetID()
+    print a
+    DumpComponent(Study, CSO, Builder,offset+2)
+    it.Next()
 
-    #--------------------------------------------------------------------------
+#--------------------------------------------------------------------------
 
 def DumpStudy(Study):
     """
     Dump a study, given the ior
     """
     itcomp = Study.NewComponentIterator()
+    Builder = Study.NewBuilder()
     while itcomp.More():
-        SC = itcomp.Value()
-        itcomp.Next()
-        name = SC.ComponentDataType()
-        MESSAGE( "-> ComponentDataType is " + name )
-        DumpComponent(Study, SC, 1)
-        
+      SC = itcomp.Value()
+      name = SC.ComponentDataType()
+      print "-> ComponentDataType is " + name
+      DumpComponent(Study, SC,Builder, 1)
+      itcomp.Next()
+
+def DumpStudies():
+  """
+    Dump all studies in a StudyManager
+  """
+  for name in myStudyManager.GetOpenStudies():
+    s=myStudyManager.GetStudyByName(name)
+    print "study:",name, s._get_StudyId()
+    DumpStudy(s)
 
-    #--------------------------------------------------------------------------
+
+#--------------------------------------------------------------------------
 
 def IDToObject(id):
     myObj = None
diff --git a/src/Launcher/BatchLight_BatchManager.cxx b/src/Launcher/BatchLight_BatchManager.cxx
new file mode 100644 (file)
index 0000000..4e0241f
--- /dev/null
@@ -0,0 +1,272 @@
+// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+/*
+ * BatchManager.cxx : 
+ *
+ * Auteur : Bernard SECHER - CEA/DEN
+ * Date   : Juillet 2007
+ * Projet : SALOME
+ *
+ */
+
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <netdb.h>
+#include "BatchLight_Job.hxx"
+#include "BatchLight_BatchManager.hxx"
+#include "Batch_Date.hxx"
+using namespace std;
+
+namespace BatchLight {
+
+  // Constructeur
+  BatchManager::BatchManager(const batchParams& p) throw(SALOME_Exception) : _params(p)
+  {
+    SCRUTE(_params.hostname);
+    SCRUTE(_params.protocol);
+    SCRUTE(_params.username);
+    // On verifie que le hostname est correct
+    if (!gethostbyname(_params.hostname.c_str())) { // hostname unknown from network
+      string msg = "hostname \"";
+      msg += _params.hostname;
+      msg += "\" unknown from the network";
+      throw SALOME_Exception(msg.c_str());
+    }
+    _mpiImpl = NULL;
+  }
+
+  // Destructeur
+  BatchManager::~BatchManager()
+  {
+    MESSAGE("BatchManager destructor "<<_params.hostname);
+    std::map < int, const BatchLight::Job * >::const_iterator it;
+    for(it=_jobmap.begin();it!=_jobmap.end();it++)
+      delete it->second; 
+    if(_mpiImpl) delete _mpiImpl;
+  }
+
+  // Methode pour le controle des jobs : soumet un job au gestionnaire
+  const int BatchManager::submitJob(Job* job)
+  {
+    BEGIN_OF("BatchManager::submitJob");
+    int id;
+
+    // temporary directory on cluster to put input files for job
+    setDirForTmpFiles();
+    SCRUTE(_dirForTmpFiles);
+
+    // export input files on cluster
+    exportInputFiles(job->getFileToExecute(),job->getFilesToExportList());
+
+    // build salome coupling script for job
+    buildSalomeCouplingScript(job->getFileToExecute());
+
+    // build batch script for job
+    buildSalomeBatchScript(job->getNbProc());
+
+    // submit job on cluster
+    id = submit();
+
+    // register job on map
+    _jobmap[id] = job;
+    END_OF("BatchManager::submitJob");
+    return id;
+  }
+
+  void BatchManager::setDirForTmpFiles()
+  {
+    int i;
+
+    _dirForTmpFiles = string("Batch/");
+    Batch::Date date = Batch::Date(time(0)) ;
+    std::string thedate = date.str() ;
+    int lend = thedate.size() ;
+    i = 0 ;
+    while ( i < lend ) {
+      if ( thedate[i] == '/' || thedate[i] == '-' || thedate[i] == ':' ) {
+        thedate[i] = '_' ;
+      }
+      i++ ;
+    }
+    _dirForTmpFiles += thedate ;
+  }
+
+  void BatchManager::exportInputFiles(const char *fileToExecute, const Engines::FilesList filesToExportList) throw(SALOME_Exception)
+  {
+    BEGIN_OF("BatchManager::exportInFiles");
+    string command = _params.protocol;
+    int status;
+
+    command += " ";
+
+    if (_params.username != ""){
+      command += _params.username;
+      command += "@";
+    }
+
+    command += _params.hostname;
+    command += " \"mkdir -p ";
+    command += _dirForTmpFiles ;
+    command += "\"" ;
+    SCRUTE(command.c_str());
+    status = system(command.c_str());
+    if(status)
+      throw SALOME_Exception("Error of connection on remote host");    
+
+    if( _params.protocol == "rsh" )
+      command = "rcp ";
+    else if( _params.protocol == "ssh" )
+      command = "scp ";
+    else
+      throw SALOME_Exception("Unknown protocol");
+
+    command += fileToExecute;
+    command += " ";
+
+    if (_params.username != ""){
+      command += _params.username;
+      command += "@";
+    }
+
+    command += _params.hostname;
+    command += ":";
+    command += _dirForTmpFiles ;
+    SCRUTE(command.c_str());
+    status = system(command.c_str());
+    if(status)
+      throw SALOME_Exception("Error of connection on remote host");    
+    
+    int i ;
+    for ( i = 0 ; i < filesToExportList.length() ; i++ ) {
+      if( _params.protocol == "rsh" )
+       command = "rcp ";
+      else if( _params.protocol == "ssh" )
+       command = "scp ";
+      else
+       throw SALOME_Exception("Unknown protocol");
+      command += filesToExportList[i] ;
+      command += " ";
+      if (_params.username != ""){
+       command += _params.username;
+       command += "@";
+      }
+      command += _params.hostname;
+      command += ":";
+      command += _dirForTmpFiles ;
+      SCRUTE(command.c_str());
+      status = system(command.c_str());
+      if(status)
+       throw SALOME_Exception("Error of connection on remote host");    
+    }
+
+    END_OF("BatchManager::exportInFiles");
+  }
+
+  void BatchManager::importOutputFiles( const char *directory, const CORBA::Long jobId ) throw(SALOME_Exception)
+  {
+    BEGIN_OF("BatchManager::importOutputFiles");
+    string command;
+    int status;
+
+    const BatchLight::Job* myJob = _jobmap[jobId];
+    Engines::FilesList filesToImportList = myJob->getFilesToImportList();
+
+    for ( int i = 0 ; i < filesToImportList.length() ; i++ ) {
+      if( _params.protocol == "rsh" )
+       command = "rcp ";
+      else if( _params.protocol == "ssh" )
+       command = "scp ";
+      else
+       throw SALOME_Exception("Unknown protocol");
+      if (_params.username != ""){
+       command += _params.username;
+       command += "@";
+      }
+      command += _params.hostname;
+      command += ":";
+      command += filesToImportList[i] ;
+      command += " ";
+      command += directory;
+      SCRUTE(command.c_str());
+      status = system(command.c_str());
+      if(status)
+       throw SALOME_Exception("Error of connection on remote host");    
+    }
+
+    END_OF("BatchManager::importOutputFiles");
+  }
+
+  string BatchManager::BuildTemporaryFileName() const
+  {
+    //build more complex file name to support multiple salome session
+    char *temp = new char[19];
+    strcpy(temp, "/tmp/command");
+    strcat(temp, "XXXXXX");
+#ifndef WNT
+
+    mkstemp(temp);
+#else
+
+    char aPID[80];
+    itoa(getpid(), aPID, 10);
+    strcat(temp, aPID);
+#endif
+
+    string command(temp);
+    delete [] temp;
+    command += ".sh";
+    return command;
+  }
+
+  void BatchManager::RmTmpFile()
+  {
+    if (_TmpFileName != ""){
+      string command = "rm ";
+      command += _TmpFileName;
+      char *temp = strdup(command.c_str());
+      int lgthTemp = strlen(temp);
+      temp[lgthTemp - 3] = '*';
+      temp[lgthTemp - 2] = '\0';
+      system(temp);
+      free(temp);
+    }
+  }
+
+  MpiImpl *BatchManager::FactoryMpiImpl(string mpiImpl) throw(SALOME_Exception)
+  {
+    if(mpiImpl == "lam")
+      return new MpiImpl_LAM();
+    else if(mpiImpl == "mpich1")
+      return new MpiImpl_MPICH1();
+    else if(mpiImpl == "mpich2")
+      return new MpiImpl_MPICH2();
+    else if(mpiImpl == "openmpi")
+      return new MpiImpl_OPENMPI();
+    else if(mpiImpl == "indif")
+      throw SALOME_Exception("you must specify a mpi implementation in CatalogResources.xml file");
+    else{
+      ostringstream oss;
+      oss << mpiImpl << " : not yet implemented";
+      throw SALOME_Exception(oss.str().c_str());
+    }
+  }
+
+}
diff --git a/src/Launcher/BatchLight_BatchManager.hxx b/src/Launcher/BatchLight_BatchManager.hxx
new file mode 100644 (file)
index 0000000..a8ea006
--- /dev/null
@@ -0,0 +1,94 @@
+// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+/*
+ * BatchManager.hxx : 
+ *
+ * Auteur : Bernard SECHER - CEA/DEN
+ * Date   : Juillet 2007
+ * Projet : SALOME
+ *
+ */
+
+#ifndef _BL_BATCHMANAGER_H_
+#define _BL_BATCHMANAGER_H_
+
+#include <vector>
+#include <map>
+#include <string>
+#include "Utils_SALOME_Exception.hxx"
+#include <SALOMEconfig.h>
+#include <stdlib.h>
+#include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
+#include "MpiImpl.hxx"
+
+namespace BatchLight {
+
+  class Job;
+
+  struct batchParams{
+    std::string hostname; // serveur ou tourne le BatchManager
+    std::string protocol; // protocole d'acces au serveur: ssh ou rsh
+    std::string username; // username d'acces au serveur
+    std::string applipath; // path of apllication directory on server
+    std::vector<std::string> modulesList; // list of Salome modules installed on server
+    unsigned int nbnodes; // number of nodes on cluster
+    unsigned int nbprocpernode; // number of processors on each node
+    std::string mpiImpl; // mpi implementation
+  };
+
+  class BatchManager
+  {
+  public:
+    // Constructeur et destructeur
+    BatchManager(const batchParams& p) throw(SALOME_Exception); // connexion a la machine host
+    virtual ~BatchManager();
+
+    // Methodes pour le controle des jobs : virtuelles pures
+    const int submitJob(BatchLight::Job* job); // soumet un job au gestionnaire
+    virtual void deleteJob(const int & jobid) = 0; // retire un job du gestionnaire
+    virtual std::string queryJob(const int & jobid) = 0; // renvoie l'etat du job
+    void importOutputFiles( const char *directory, const CORBA::Long jobId ) throw(SALOME_Exception);
+
+  protected:
+    batchParams _params;
+    MpiImpl *_mpiImpl;
+
+    std::map <int,const BatchLight::Job *> _jobmap;
+    std::string _dirForTmpFiles; // repertoire temporaire sur le serveur
+    std::string _TmpFileName;
+    std::string _fileNameToExecute;
+
+    virtual int submit() throw(SALOME_Exception) = 0;
+    void setDirForTmpFiles();
+    void exportInputFiles( const char *fileToExecute, const Engines::FilesList filesToExportList ) throw(SALOME_Exception);
+    virtual void buildSalomeCouplingScript( const char *fileToExecute ) throw(SALOME_Exception) = 0;
+    virtual void buildSalomeBatchScript( const int nbproc ) throw(SALOME_Exception) = 0;
+
+    std::string BuildTemporaryFileName() const;
+    void RmTmpFile();
+    MpiImpl *FactoryMpiImpl(std::string mpiImpl) throw(SALOME_Exception);
+
+  private:
+
+  };
+
+}
+
+#endif
diff --git a/src/Launcher/BatchLight_BatchManager_PBS.cxx b/src/Launcher/BatchLight_BatchManager_PBS.cxx
new file mode 100644 (file)
index 0000000..bba030a
--- /dev/null
@@ -0,0 +1,375 @@
+// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+/*
+ * BatchManager.cxx : 
+ *
+ * Auteur : Bernard SECHER - CEA/DEN
+ * Date   : Juillet 2007
+ * Projet : SALOME
+ *
+ */
+
+#include "BatchLight_BatchManager_PBS.hxx"
+#include "utilities.h"
+#include "BatchLight_Job.hxx"
+#include <fstream>
+#include <iostream>
+#include <sstream>
+#include <sys/stat.h>
+
+using namespace std;
+
+namespace BatchLight {
+
+  // Constructeur
+  BatchManager_PBS::BatchManager_PBS(const batchParams& p) throw(SALOME_Exception) : BatchManager(p)
+  {
+    // pbs batch system needs to know mpi implementation
+    _mpiImpl = FactoryMpiImpl(_params.mpiImpl);
+  }
+
+  // Destructeur
+  BatchManager_PBS::~BatchManager_PBS()
+  {
+    MESSAGE("BatchManager_PBS destructor "<<_params.hostname);
+  }
+
+  // Methode pour le controle des jobs : retire un job du gestionnaire
+  void BatchManager_PBS::deleteJob(const int & jobid)
+  {
+    BEGIN_OF("BatchManager_PBS::deleteJob");
+    string command;
+    int status;
+    ostringstream oss;
+    oss << jobid;
+
+    // define command to submit batch
+    if( _params.protocol == "rsh" )
+      command = "rsh ";
+    else if( _params.protocol == "ssh" )
+      command = "ssh ";
+    else
+      throw SALOME_Exception("Unknown protocol");
+
+    if (_params.username != ""){
+      command += _params.username;
+      command += "@";
+    }
+
+    command += _params.hostname;
+    command += " \"qdel " ;
+    command += oss.str();
+    command += "\"";
+    SCRUTE(command.c_str());
+    status = system(command.c_str());
+    if(status)
+      throw SALOME_Exception("Error of connection on remote host");
+
+    MESSAGE("jobId = " << jobid << "killed");
+    END_OF("BatchManager_PBS::deleteJob");
+  }
+   
+  // Methode pour le controle des jobs : renvoie l'etat du job
+  string BatchManager_PBS::queryJob(const int & jobid)
+  {
+    BEGIN_OF("BatchManager_PBS::queryJob");
+    // define name of log file
+    string jstatus;
+    string logFile="/tmp/logs/";
+    logFile += getenv("USER");
+    logFile += "/batchSalome_";
+
+    srand ( time(NULL) );
+    int ir = rand();
+    ostringstream oss;
+    oss << ir;
+    logFile += oss.str();
+    logFile += ".log";
+
+    string command;
+    int status;
+
+    // define command to submit batch
+    if( _params.protocol == "rsh" )
+      command = "rsh ";
+    else if( _params.protocol == "ssh" )
+      command = "ssh ";
+    else
+      throw SALOME_Exception("Unknown protocol");
+
+    if (_params.username != ""){
+      command += _params.username;
+      command += "@";
+    }
+
+    command += _params.hostname;
+    command += " \"qstat -f " ;
+    ostringstream oss2;
+    oss2 << jobid;
+    command += oss2.str();
+    command += "\" > ";
+    command += logFile;
+    SCRUTE(command.c_str());
+    status = system(command.c_str());
+    if(status && status != 153 && status != 256*153){
+      MESSAGE("status="<<status);
+      throw SALOME_Exception("Error of connection on remote host");
+    }
+
+    if(status == 153 || status == 256*153 )
+      // If job is finished qstat command return 153 status
+      jstatus = "D";
+    else{
+      // read status of job in log file
+      char line[128];
+      ifstream fp(logFile.c_str(),ios::in);
+      
+      string sline;
+      int pos = string::npos;
+      while( (pos == string::npos) && fp.getline(line,80,'\n') ){
+       sline = string(line);
+       pos = sline.find("job_state");
+      };
+      
+      if(pos!=string::npos){
+       istringstream iss(sline);
+       iss >> jstatus;
+       iss >> jstatus;
+       iss >> jstatus;
+      }
+      else
+       jstatus = "U";
+    }
+
+    MESSAGE("jobId = " << jobid << " " << jstatus);
+    END_OF("BatchManager_PBS::queryJob");
+    return jstatus;
+  }
+
+  void BatchManager_PBS::buildSalomeCouplingScript( const char *fileToExecute ) throw(SALOME_Exception)
+  {
+    BEGIN_OF("BatchManager_PBS::buildSalomeCouplingScript");
+    int status;
+
+    string::size_type p1 = string(fileToExecute).find_last_of("/");
+    string::size_type p2 = string(fileToExecute).find_last_of(".");
+    _fileNameToExecute = string(fileToExecute).substr(p1+1,p2-p1-1);
+
+    _TmpFileName = BuildTemporaryFileName();
+    ofstream tempOutputFile;
+    tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
+    tempOutputFile << "#! /bin/sh -f" << endl ;
+    tempOutputFile << "cd " ;
+    tempOutputFile << _params.applipath << endl ;
+    tempOutputFile << "export PYTHONPATH=~/" ;
+    tempOutputFile << _dirForTmpFiles ;
+    tempOutputFile << ":$PYTHONPATH" << endl ;
+    tempOutputFile << "if test " ;
+    tempOutputFile << _mpiImpl->rank() ;
+    tempOutputFile << " = 0; then" << endl ;
+    tempOutputFile << "  ./runAppli --terminal --modules=" ;
+    for ( int i = 0 ; i < _params.modulesList.size() ; i++ ) {
+      tempOutputFile << _params.modulesList[i] ;
+      if ( i != _params.modulesList.size()-1 )
+       tempOutputFile << "," ;
+    }
+    tempOutputFile << " --standalone=registry,study,moduleCatalog --killall &" << endl ;
+    tempOutputFile << "  for ((ip=1; ip < ";
+    tempOutputFile << _mpiImpl->size();
+    tempOutputFile << " ; ip++))" << endl;
+    tempOutputFile << "  do" << endl ;
+    tempOutputFile << "    arglist=\"$arglist YACS_Server_\"$ip" << endl ;
+    tempOutputFile << "  done" << endl ;
+    tempOutputFile << "  sleep 5" << endl ;
+    tempOutputFile << "  ./runSession waitContainers.py $arglist" << endl ;
+    tempOutputFile << "  ./runSession python ~/" << _dirForTmpFiles << "/" << _fileNameToExecute << ".py" << endl;
+    tempOutputFile << "  ./runSession killCurrentPort" << endl;
+    tempOutputFile << "else" << endl ;
+    tempOutputFile << "  sleep 5" << endl ;
+    tempOutputFile << "  ./runSession waitNS.py" << endl ;
+    tempOutputFile << "  ./runSession SALOME_Container 'YACS_Server_'";
+    tempOutputFile << _mpiImpl->rank() << endl ;
+    tempOutputFile << "fi" << endl ;
+    tempOutputFile.flush();
+    tempOutputFile.close();
+    chmod(_TmpFileName.c_str(), 0x1ED);
+    SCRUTE(_TmpFileName.c_str()) ;
+
+    string command;
+    if( _params.protocol == "rsh" )
+      command = "rcp ";
+    else if( _params.protocol == "ssh" )
+      command = "scp ";
+    else
+      throw SALOME_Exception("Unknown protocol");
+    
+    command += _TmpFileName;
+    command += " ";
+    if (_params.username != ""){
+      command += _params.username;
+      command += "@";
+    }
+    command += _params.hostname;
+    command += ":";
+    command += _dirForTmpFiles ;
+    command += "/runSalome_" ;
+    command += _fileNameToExecute ;
+    command += "_Batch.sh" ;
+    SCRUTE(_fileNameToExecute) ;
+    SCRUTE(command.c_str());
+    status = system(command.c_str());
+    if(status)
+      throw SALOME_Exception("Error of connection on remote host");    
+    RmTmpFile();
+    
+    END_OF("BatchManager_PBS::buildSalomeCouplingScript");
+  }
+
+  void BatchManager_PBS::buildSalomeBatchScript( const int nbproc ) throw(SALOME_Exception)
+  {
+    BEGIN_OF("BatchManager_PBS::buildSalomeBatchScript");
+    int status;
+
+    int nbmaxproc = _params.nbnodes * _params.nbprocpernode;
+    if( nbproc > nbmaxproc ){
+      MESSAGE(nbproc << " processors asked on a cluster of " << nbmaxproc << " processors");
+      throw SALOME_Exception("Too much processors asked for that cluster");
+    }
+
+    int nbnodes;
+    if( nbproc < _params.nbnodes )
+      nbnodes = nbproc;
+    else
+      nbnodes = _params.nbnodes;
+
+    _TmpFileName = BuildTemporaryFileName();
+    ofstream tempOutputFile;
+    tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
+
+    ostringstream filenameToExecute;
+    filenameToExecute << " ~/" << _dirForTmpFiles << "/runSalome_" << _fileNameToExecute << "_Batch.sh";
+
+    tempOutputFile << "#! /bin/sh -f" << endl ;
+    tempOutputFile << "#PBS -l nodes=" << nbnodes << endl ;
+    tempOutputFile << "#PBS -o ~/" << _dirForTmpFiles << "/runSalome.log${PBS_JOBID}" << endl ;
+    tempOutputFile << _mpiImpl->boot("${PBS_NODEFILE}",nbnodes);
+    tempOutputFile << _mpiImpl->run("${PBS_NODEFILE}",nbproc,filenameToExecute.str());
+    tempOutputFile << _mpiImpl->halt();
+    tempOutputFile.flush();
+    tempOutputFile.close();
+    chmod(_TmpFileName.c_str(), 0x1ED);
+    SCRUTE(_TmpFileName.c_str()) ;
+
+    string command;
+    if( _params.protocol == "rsh" )
+      command = "rcp ";
+    else if( _params.protocol == "ssh" )
+      command = "scp ";
+    else
+      throw SALOME_Exception("Unknown protocol");
+    command += _TmpFileName;
+    command += " ";
+    if (_params.username != ""){
+      command += _params.username;
+      command += "@";
+    }
+    command += _params.hostname;
+    command += ":";
+    command += _dirForTmpFiles ;
+    command += "/" ;
+    command += _fileNameToExecute ;
+    command += "_Batch.sh" ;
+    SCRUTE(command.c_str());
+    status = system(command.c_str());
+    if(status)
+      throw SALOME_Exception("Error of connection on remote host");    
+
+    RmTmpFile();
+    END_OF("BatchManager_PBS::buildSalomeBatchScript");
+    
+  }
+
+  int BatchManager_PBS::submit() throw(SALOME_Exception)
+  {
+    BEGIN_OF("BatchManager_PBS::submit");
+
+    // define name of log file
+    string logFile="/tmp/logs/";
+    logFile += getenv("USER");
+    logFile += "/batchSalome_";
+
+    srand ( time(NULL) );
+    int ir = rand();
+    ostringstream oss;
+    oss << ir;
+    logFile += oss.str();
+    logFile += ".log";
+
+    string command;
+    int status;
+
+    // define command to submit batch
+    if( _params.protocol == "rsh" )
+      command = "rsh ";
+    else if( _params.protocol == "ssh" )
+      command = "ssh ";
+    else
+      throw SALOME_Exception("Unknown protocol");
+
+    if (_params.username != ""){
+      command += _params.username;
+      command += "@";
+    }
+
+    command += _params.hostname;
+    command += " \"qsub " ;
+    command += _dirForTmpFiles ;
+    command += "/" ;
+    command += _fileNameToExecute ;
+    command += "_Batch.sh\" > ";
+    command += logFile;
+    SCRUTE(command.c_str());
+    status = system(command.c_str());
+    if(status)
+      throw SALOME_Exception("Error of connection on remote host");
+
+    // read id of submitted job in log file
+    char line[128];
+    FILE *fp = fopen(logFile.c_str(),"r");
+    fgets( line, 128, fp);
+    fclose(fp);
+    
+    string sline(line);
+    int pos = sline.find(".");
+    string strjob;
+    if(pos == string::npos)
+      strjob = sline;
+    else
+      strjob = sline.substr(0,pos);
+
+    int id;
+    istringstream iss(strjob);
+    iss >> id;
+
+    END_OF("BatchManager_PBS::submit");
+    return id;
+  }
+
+}
diff --git a/src/Launcher/BatchLight_BatchManager_PBS.hxx b/src/Launcher/BatchLight_BatchManager_PBS.hxx
new file mode 100644 (file)
index 0000000..e7e5789
--- /dev/null
@@ -0,0 +1,59 @@
+// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+/*
+ * BatchManager.hxx : 
+ *
+ * Auteur : Bernard SECHER - CEA/DEN
+ * Date   : Juillet 2007
+ * Projet : SALOME
+ *
+ */
+
+#ifndef _BL_BATCHMANAGER_PBS_H_
+#define _BL_BATCHMANAGER_PBS_H_
+
+#include <string>
+#include "Utils_SALOME_Exception.hxx"
+#include "BatchLight_BatchManager.hxx"
+
+namespace BatchLight {
+
+  class Job;
+
+  class BatchManager_PBS : public BatchManager
+  {
+  public:
+    // Constructeur et destructeur
+    BatchManager_PBS(const batchParams& p) throw(SALOME_Exception); // connexion a la machine host
+    virtual ~BatchManager_PBS();
+
+    // Methodes pour le controle des jobs : virtuelles pures
+    void deleteJob(const int & jobid); // retire un job du gestionnaire
+    std::string queryJob(const int & jobid); // renvoie l'etat du job
+
+  private:
+    void buildSalomeCouplingScript( const char *fileToExecute ) throw(SALOME_Exception);
+    void buildSalomeBatchScript( const int nbproc ) throw(SALOME_Exception);
+    int submit() throw(SALOME_Exception);
+  };
+
+}
+
+#endif
diff --git a/src/Launcher/BatchLight_BatchManager_SLURM.cxx b/src/Launcher/BatchLight_BatchManager_SLURM.cxx
new file mode 100644 (file)
index 0000000..9a740e3
--- /dev/null
@@ -0,0 +1,327 @@
+// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+/*
+ * BatchManager.cxx : 
+ *
+ * Auteur : Bernard SECHER - CEA/DEN
+ * Date   : Juillet 2007
+ * Projet : SALOME
+ *
+ */
+
+#include "BatchLight_BatchManager_SLURM.hxx"
+#include "utilities.h"
+#include "BatchLight_Job.hxx"
+#include <fstream>
+#include <iostream>
+#include <sstream>
+#include <sys/stat.h>
+
+using namespace std;
+
+namespace BatchLight {
+
+  // Constructeur
+  BatchManager_SLURM::BatchManager_SLURM(const batchParams& p) throw(SALOME_Exception) : BatchManager(p)
+  {
+  }
+
+  // Destructeur
+  BatchManager_SLURM::~BatchManager_SLURM()
+  {
+    MESSAGE("BatchManager_SLURM destructor "<<_params.hostname);
+  }
+
+  // Methode pour le controle des jobs : retire un job du gestionnaire
+  void BatchManager_SLURM::deleteJob(const int & jobid)
+  {
+    BEGIN_OF("BatchManager_SLURM::deleteJob");
+    string command;
+    int status;
+    ostringstream oss;
+    oss << jobid;
+
+    // define command to submit batch
+    if( _params.protocol == "rsh" )
+      command = "rsh ";
+    else if( _params.protocol == "ssh" )
+      command = "ssh ";
+    else
+      throw SALOME_Exception("Unknown protocol");
+
+    if (_params.username != ""){
+      command += _params.username;
+      command += "@";
+    }
+
+    command += _params.hostname;
+    command += " \"bkill " ;
+    command += oss.str();
+    command += "\"";
+    SCRUTE(command.c_str());
+    status = system(command.c_str());
+    if(status)
+      throw SALOME_Exception("Error of connection on remote host");
+
+    MESSAGE("jobId = " << jobid << "killed");
+    END_OF("BatchManager_SLURM::deleteJob");
+  }
+   
+  // Methode pour le controle des jobs : renvoie l'etat du job
+  string BatchManager_SLURM::queryJob(const int & jobid)
+  {
+    BEGIN_OF("BatchManager_SLURM::queryJob");
+    // define name of log file
+    string logFile="/tmp/logs/";
+    logFile += getenv("USER");
+    logFile += "/batchSalome_";
+
+    srand ( time(NULL) );
+    int ir = rand();
+    ostringstream oss;
+    oss << ir;
+    logFile += oss.str();
+    logFile += ".log";
+
+    string command;
+    int status;
+
+    // define command to submit batch
+    if( _params.protocol == "rsh" )
+      command = "rsh ";
+    else if( _params.protocol == "ssh" )
+      command = "ssh ";
+    else
+      throw SALOME_Exception("Unknown protocol");
+
+    if (_params.username != ""){
+      command += _params.username;
+      command += "@";
+    }
+
+    command += _params.hostname;
+    command += " \"bjobs " ;
+    ostringstream oss2;
+    oss2 << jobid;
+    command += oss2.str();
+    command += "\" > ";
+    command += logFile;
+    SCRUTE(command.c_str());
+    status = system(command.c_str());
+    if(status)
+      throw SALOME_Exception("Error of connection on remote host");
+
+    // read staus of job in log file
+    char line[128];
+    ifstream fp(logFile.c_str(),ios::in);
+    fp.getline(line,80,'\n');
+    
+    string sjobid, username, jstatus;
+    fp >> sjobid;
+    fp >> username;
+    fp >> jstatus;
+
+    MESSAGE("jobId = " << jobid << " " << jstatus);
+    END_OF("BatchManager_SLURM::queryJob");
+    return jstatus;
+  }
+
+  void BatchManager_SLURM::buildSalomeCouplingScript( const char *fileToExecute ) throw(SALOME_Exception)
+  {
+    BEGIN_OF("BatchManager_SLURM::buildSalomeCouplingScript");
+    int status;
+
+    string::size_type p1 = string(fileToExecute).find_last_of("/");
+    string::size_type p2 = string(fileToExecute).find_last_of(".");
+    _fileNameToExecute = string(fileToExecute).substr(p1+1,p2-p1-1);
+
+    _TmpFileName = BuildTemporaryFileName();
+    ofstream tempOutputFile;
+    tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
+    tempOutputFile << "#! /bin/sh -f" << endl ;
+    tempOutputFile << "cd " ;
+    tempOutputFile << _params.applipath << endl ;
+    tempOutputFile << "export PYTHONPATH=~/" ;
+    tempOutputFile << _dirForTmpFiles ;
+    tempOutputFile << ":$PYTHONPATH" << endl ;
+    tempOutputFile << "if test $SLURM_PROCID = 0; then" << endl ;
+    tempOutputFile << "  ./runAppli --terminal --modules=" ;
+    for ( int i = 0 ; i < _params.modulesList.size() ; i++ ) {
+      tempOutputFile << _params.modulesList[i] ;
+      if ( i != _params.modulesList.size()-1 )
+       tempOutputFile << "," ;
+    }
+    tempOutputFile << " --standalone=registry,study,moduleCatalog --killall &" << endl ;
+    tempOutputFile << "  for ((ip=1; ip < ${SLURM_NPROCS} ; ip++))" << endl;
+    tempOutputFile << "  do" << endl ;
+    tempOutputFile << "    arglist=\"$arglist YACS_Server_\"$ip" << endl ;
+    tempOutputFile << "  done" << endl ;
+    tempOutputFile << "  ./runSession waitNS.sh" << endl ;
+    tempOutputFile << "  ./runSession waitContainers.py $arglist" << endl ;
+    tempOutputFile << "  ./runSession python ~/" << _dirForTmpFiles << "/" << _fileNameToExecute << ".py" << endl;
+    tempOutputFile << "  ./runSession killCurrentPort" << endl;
+    tempOutputFile << "else" << endl ;
+    tempOutputFile << "  ./runSession waitNS.sh" << endl ;
+    tempOutputFile << "  ./runSession SALOME_Container 'YACS_Server_'${SLURM_PROCID}" << endl ;
+    tempOutputFile << "fi" << endl ;
+    tempOutputFile.flush();
+    tempOutputFile.close();
+    chmod(_TmpFileName.c_str(), 0x1ED);
+    SCRUTE(_TmpFileName.c_str()) ;
+
+    string command;
+    if( _params.protocol == "rsh" )
+      command = "rcp ";
+    else if( _params.protocol == "ssh" )
+      command = "scp ";
+    else
+      throw SALOME_Exception("Unknown protocol");
+    
+    command += _TmpFileName;
+    command += " ";
+    if (_params.username != ""){
+      command += _params.username;
+      command += "@";
+    }
+    command += _params.hostname;
+    command += ":";
+    command += _dirForTmpFiles ;
+    command += "/runSalome_" ;
+    command += _fileNameToExecute ;
+    command += "_Batch.sh" ;
+    SCRUTE(command.c_str());
+    status = system(command.c_str());
+    if(status)
+      throw SALOME_Exception("Error of connection on remote host");    
+    RmTmpFile();
+    
+    END_OF("BatchManager_SLURM::buildSalomeCouplingScript");
+  }
+
+  void BatchManager_SLURM::buildSalomeBatchScript( const int nbproc ) throw(SALOME_Exception)
+  {
+    BEGIN_OF("BatchManager_SLURM::buildSalomeBatchScript");
+    int status;
+    _TmpFileName = BuildTemporaryFileName();
+    ofstream tempOutputFile;
+    tempOutputFile.open(_TmpFileName.c_str(), ofstream::out );
+
+    tempOutputFile << "#! /bin/sh -f" << endl ;
+    tempOutputFile << "#BSUB -n " << nbproc << endl ;
+    tempOutputFile << "#BSUB -o " << _dirForTmpFiles << "/runSalome.log%J" << endl ;
+    tempOutputFile << "mpirun -srun ~/" << _dirForTmpFiles << "/runSalome_" << _fileNameToExecute << "_Batch.sh" << endl ;
+    tempOutputFile.flush();
+    tempOutputFile.close();
+    chmod(_TmpFileName.c_str(), 0x1ED);
+    SCRUTE(_TmpFileName.c_str()) ;
+
+    string command;
+    if( _params.protocol == "rsh" )
+      command = "rcp ";
+    else if( _params.protocol == "ssh" )
+      command = "scp ";
+    else
+      throw SALOME_Exception("Unknown protocol");
+    command += _TmpFileName;
+    command += " ";
+    if (_params.username != ""){
+      command += _params.username;
+      command += "@";
+    }
+    command += _params.hostname;
+    command += ":";
+    command += _dirForTmpFiles ;
+    command += "/" ;
+    command += _fileNameToExecute ;
+    command += "_Batch.sh" ;
+    SCRUTE(command.c_str());
+    status = system(command.c_str());
+    if(status)
+      throw SALOME_Exception("Error of connection on remote host");    
+
+    RmTmpFile();
+    END_OF("BatchManager_SLURM::buildSalomeBatchScript");
+    
+  }
+
+  int BatchManager_SLURM::submit() throw(SALOME_Exception)
+  {
+    BEGIN_OF("BatchManager_SLURM::submit");
+
+    // define name of log file
+    string logFile="/tmp/logs/";
+    logFile += getenv("USER");
+    logFile += "/batchSalome_";
+
+    srand ( time(NULL) );
+    int ir = rand();
+    ostringstream oss;
+    oss << ir;
+    logFile += oss.str();
+    logFile += ".log";
+
+    string command;
+    int status;
+
+    // define command to submit batch
+    if( _params.protocol == "rsh" )
+      command = "rsh ";
+    else if( _params.protocol == "ssh" )
+      command = "ssh ";
+    else
+      throw SALOME_Exception("Unknown protocol");
+
+    if (_params.username != ""){
+      command += _params.username;
+      command += "@";
+    }
+
+    command += _params.hostname;
+    command += " \"bsub < " ;
+    command += _dirForTmpFiles ;
+    command += "/" ;
+    command += _fileNameToExecute ;
+    command += "_Batch.sh\" > ";
+    command += logFile;
+    SCRUTE(command.c_str());
+    status = system(command.c_str());
+    if(status)
+      throw SALOME_Exception("Error of connection on remote host");
+
+    // read id of submitted job in log file
+    char line[128];
+    FILE *fp = fopen(logFile.c_str(),"r");
+    fgets( line, 128, fp);
+    fclose(fp);
+    
+    string sline(line);
+    int p1 = sline.find("<");
+    int p2 = sline.find(">");
+    string strjob = sline.substr(p1+1,p2-p1-1);
+
+    int id;
+    istringstream iss(strjob);
+    iss >> id;
+
+    END_OF("BatchManager_SLURM::submit");
+    return id;
+  }
+
+}
diff --git a/src/Launcher/BatchLight_BatchManager_SLURM.hxx b/src/Launcher/BatchLight_BatchManager_SLURM.hxx
new file mode 100644 (file)
index 0000000..ed21624
--- /dev/null
@@ -0,0 +1,62 @@
+// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+/*
+ * BatchManager.hxx : 
+ *
+ * Auteur : Bernard SECHER - CEA/DEN
+ * Date   : Juillet 2007
+ * Projet : SALOME
+ *
+ */
+
+#ifndef _BL_BATCHMANAGER_SLURM_H_
+#define _BL_BATCHMANAGER_SLURM_H_
+
+#include <string>
+#include "Utils_SALOME_Exception.hxx"
+#include "BatchLight_BatchManager.hxx"
+
+namespace BatchLight {
+
+  class Job;
+
+  class BatchManager_SLURM : public BatchManager
+  {
+  public:
+    // Constructeur et destructeur
+    BatchManager_SLURM(const batchParams& p) throw(SALOME_Exception); // connexion a la machine host
+    virtual ~BatchManager_SLURM();
+
+    // Methodes pour le controle des jobs : virtuelles pures
+    void deleteJob(const int & jobid); // retire un job du gestionnaire
+    std::string queryJob(const int & jobid); // renvoie l'etat du job
+
+  protected:
+    void buildSalomeCouplingScript( const char *fileToExecute ) throw(SALOME_Exception);
+    void buildSalomeBatchScript( const int nbproc ) throw(SALOME_Exception);
+    int submit() throw(SALOME_Exception);
+
+  private:
+
+  };
+
+}
+
+#endif
diff --git a/src/Launcher/BatchLight_Job.cxx b/src/Launcher/BatchLight_Job.cxx
new file mode 100644 (file)
index 0000000..9762a98
--- /dev/null
@@ -0,0 +1,45 @@
+// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+/*
+ * Job.cxx : 
+ *
+ * Auteur : Bernard SECHER - CEA/DEN
+ * Date   : Juillet 2007
+ * Projet : SALOME
+ *
+ */
+
+#include "BatchLight_Job.hxx"
+using namespace std;
+
+namespace BatchLight {
+
+  // Constructeur
+  Job::Job(const char *fileToExecute, const Engines::FilesList& filesToExport, const Engines::FilesList& filesToImport, const int nbproc) : _fileToExecute(fileToExecute), _filesToExport(filesToExport), _filesToImport(filesToImport), _nbproc(nbproc)
+  {
+    // Nothing to do
+  }
+
+  Job::~Job()
+  {
+    MESSAGE("Job destructor");
+  }
+
+}
diff --git a/src/Launcher/BatchLight_Job.hxx b/src/Launcher/BatchLight_Job.hxx
new file mode 100644 (file)
index 0000000..23ac8f3
--- /dev/null
@@ -0,0 +1,62 @@
+// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+/*
+ * Job.hxx : 
+ *
+ * Auteur : Bernard SECHER - CEA/DEN
+ * Date   : Juillet 2007
+ * Projet : SALOME
+ *
+ */
+
+#ifndef _BL_JOB_H_
+#define _BL_JOB_H_
+
+#include "utilities.h"
+#include <SALOMEconfig.h>
+#include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
+
+namespace BatchLight {
+
+  class Job
+  {
+  public:
+    // Constructeurs et destructeur
+    Job(const char *fileToExecute, const Engines::FilesList& filesToExport, const Engines::FilesList& filesToImport, const int nbproc);
+    virtual ~Job();
+
+    const char *getFileToExecute() const { return _fileToExecute; }
+    const Engines::FilesList getFilesToExportList() const { return _filesToExport; }
+    const Engines::FilesList getFilesToImportList() const { return _filesToImport; }
+    const int getNbProc() const { return _nbproc; }
+    
+  protected:
+    const char* _fileToExecute;
+    const Engines::FilesList _filesToExport;
+    const Engines::FilesList _filesToImport;
+    const int _nbproc;
+
+  private:
+
+  };
+
+}
+
+#endif
index 9c441ebc1528a7e5d1caaaa26b1835f87cee2c92..b0323d754713623799eec77c25d57eb6398f2021 100644 (file)
@@ -36,6 +36,11 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am
 #
 # header files  
 salomeinclude_HEADERS = \
+  BatchLight_BatchManager.hxx \
+  BatchLight_BatchManager_PBS.hxx \
+  BatchLight_BatchManager_SLURM.hxx \
+  BatchLight_Job.hxx \
+       MpiImpl.hxx \
        SALOME_Launcher.hxx
 
 # Scripts to be installed
@@ -93,7 +98,12 @@ COMMON_LIBS =\
 #
 lib_LTLIBRARIES = libSalomeLauncher.la
 libSalomeLauncher_la_SOURCES=\
-       SALOME_Launcher.cxx
+       SALOME_Launcher.cxx \
+  BatchLight_BatchManager.cxx \
+  BatchLight_BatchManager_SLURM.cxx \
+  BatchLight_BatchManager_PBS.cxx \
+  BatchLight_Job.cxx \
+       MpiImpl.cxx
 
 libSalomeLauncher_la_CPPFLAGS =\
        $(COMMON_CPPFLAGS)
diff --git a/src/Launcher/MpiImpl.cxx b/src/Launcher/MpiImpl.cxx
new file mode 100644 (file)
index 0000000..036018b
--- /dev/null
@@ -0,0 +1,212 @@
+// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+/*
+ * BatchManager.cxx : 
+ *
+ * Auteur : Bernard SECHER - CEA/DEN
+ * Date   : Juillet 2007
+ * Projet : SALOME
+ *
+ */
+
+#include <iostream>
+#include <sstream>
+#include <string>
+#include "utilities.h"
+#include "MpiImpl.hxx"
+
+using namespace std;
+
+// Constructor
+MpiImpl::MpiImpl()
+{
+  MESSAGE("MpiImpl constructor");
+}
+
+// Destructor
+MpiImpl::~MpiImpl()
+{
+  MESSAGE("MpiImpl destructor");
+}
+
+// lam implementation
+// Constructor
+MpiImpl_LAM::MpiImpl_LAM() : MpiImpl()
+{
+}
+
+// Destructor
+MpiImpl_LAM::~MpiImpl_LAM()
+{
+  MESSAGE("MpiImpl_LAM destructor");
+}
+
+string MpiImpl_LAM::size()
+{
+  return "${LAMWORLD}";
+}
+
+string MpiImpl_LAM::rank()
+{
+  return "${LAMRANK}";
+}
+
+string MpiImpl_LAM::boot(const string machinefile, const unsigned int nbnodes)
+{
+  ostringstream oss;
+  oss << "lamboot " << machinefile << endl;
+  return oss.str();
+}
+
+string MpiImpl_LAM::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
+{
+  ostringstream oss;
+  oss << "mpirun -np " << nbproc << " " << fileNameToExecute << endl;
+  return oss.str();
+}
+
+string MpiImpl_LAM::halt()
+{
+  ostringstream oss;
+  oss << "lamhalt" << endl;
+  return oss.str();
+}
+
+// mpich1 implementation
+// Constructor
+MpiImpl_MPICH1::MpiImpl_MPICH1() : MpiImpl()
+{
+}
+
+// Destructor
+MpiImpl_MPICH1::~MpiImpl_MPICH1()
+{
+  MESSAGE("MpiImpl_MPICH1 destructor");
+}
+
+string MpiImpl_MPICH1::size()
+{
+  throw SALOME_Exception("mpich1 doesn't work with this batch system to submit salome session");
+}
+
+string MpiImpl_MPICH1::rank()
+{
+  throw SALOME_Exception("mpich1 doesn't work with this batch system to submit salome session");
+}
+
+string MpiImpl_MPICH1::boot(const string machinefile, const unsigned int nbnodes)
+{
+  return "";
+}
+
+string MpiImpl_MPICH1::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
+{
+  ostringstream oss;
+  oss << "mpirun -machinefile " << machinefile << " -np " << nbproc << " " << fileNameToExecute << endl;
+  return oss.str();
+}
+
+string MpiImpl_MPICH1::halt()
+{
+  return "";
+}
+
+// mpich2 implementation
+// Constructor
+MpiImpl_MPICH2::MpiImpl_MPICH2() : MpiImpl()
+{
+}
+
+// Destructor
+MpiImpl_MPICH2::~MpiImpl_MPICH2()
+{
+  MESSAGE("MpiImpl_MPICH2 destructor");
+}
+
+string MpiImpl_MPICH2::size()
+{
+  return "${PMI_SIZE}";
+}
+
+string MpiImpl_MPICH2::rank()
+{
+  return "${PMI_RANK}";
+}
+
+string MpiImpl_MPICH2::boot(const string machinefile, const unsigned int nbnodes)
+{
+  ostringstream oss;
+  oss << "mpdboot -n " << nbnodes << " -f " << machinefile << endl;
+  return oss.str();
+}
+
+string MpiImpl_MPICH2::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
+{
+  ostringstream oss;
+  oss << "mpirun -np " << nbproc << " " << fileNameToExecute << endl;
+  return oss.str();
+}
+
+string MpiImpl_MPICH2::halt()
+{
+  ostringstream oss;
+  oss << "mpdallexit" << endl;
+  return oss.str();
+}
+
+// openmpi implementation
+// Constructor
+MpiImpl_OPENMPI::MpiImpl_OPENMPI() : MpiImpl()
+{
+}
+
+// Destructor
+MpiImpl_OPENMPI::~MpiImpl_OPENMPI()
+{
+  MESSAGE("MpiImpl_OPENMPI destructor");
+}
+
+string MpiImpl_OPENMPI::size()
+{
+  return "${OMPI_MCA_ns_nds_num_procs}";
+}
+
+string MpiImpl_OPENMPI::rank()
+{
+  return "${OMPI_MCA_ns_nds_vpid}";
+}
+
+string MpiImpl_OPENMPI::boot(const string machinefile, const unsigned int nbnodes)
+{
+  return "";
+}
+
+string MpiImpl_OPENMPI::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute)
+{
+  ostringstream oss;
+  oss << "mpirun -hostfile " << machinefile << " -np " << nbproc << " " << fileNameToExecute << endl;
+  return oss.str();
+}
+
+string MpiImpl_OPENMPI::halt()
+{
+  return "";
+}
+
diff --git a/src/Launcher/MpiImpl.hxx b/src/Launcher/MpiImpl.hxx
new file mode 100644 (file)
index 0000000..beeac03
--- /dev/null
@@ -0,0 +1,131 @@
+// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
+// 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+/*
+ * BatchManager.hxx : 
+ *
+ * Auteur : Bernard SECHER - CEA/DEN
+ * Date   : Juillet 2007
+ * Projet : SALOME
+ *
+ */
+
+#ifndef _BL_MPIIMPL_H_
+#define _BL_MPIIMPL_H_
+
+#include <string>
+#include "Utils_SALOME_Exception.hxx"
+#include <SALOMEconfig.h>
+
+class MpiImpl
+{
+public:
+  // Constructeur et destructeur
+  MpiImpl(); // constrcuctor
+  virtual ~MpiImpl(); //Destructor
+  
+  virtual std::string size() = 0; // get number of process of current job
+  virtual std::string rank() = 0; // get process number of current job
+  virtual std::string boot(const std::string machinefile, const unsigned int nbnodes) = 0; // get boot command
+  virtual std::string run(const std::string machinefile, const unsigned int nbproc, const std::string fileNameToExecute) = 0; // get run command
+  virtual std::string halt() = 0; // get stop command
+
+protected:
+
+private:
+
+};
+
+class MpiImpl_LAM : public MpiImpl
+{
+public:
+  // Constructeur et destructeur
+  MpiImpl_LAM(); // constructor
+  virtual ~MpiImpl_LAM(); //Destructor
+
+  std::string size(); // get number of process of current job
+  std::string rank(); // get process number of current job
+  std::string boot( const std::string machinefile, const unsigned int nbnodes); // get boot command
+  std::string run( const std::string machinefile, const unsigned int nbproc, const std::string fileNameToExecute); // get run command
+  std::string halt(); // get stop command
+
+protected:
+  
+private:
+
+};
+
+class MpiImpl_MPICH1 : public MpiImpl
+{
+public:
+  // Constructeur et destructeur
+  MpiImpl_MPICH1(); // constructor
+  virtual ~MpiImpl_MPICH1(); //Destructor
+  
+  std::string size(); // get number of process of current job
+  std::string rank(); // get process number of current job
+  std::string boot( const std::string machinefile, const unsigned int nbnodes); // get boot command
+  std::string run( const std::string machinefile, const unsigned int nbproc, const std::string fileNameToExecute); // get run command
+  std::string halt(); // get stop command
+
+protected:
+  
+private:
+
+};
+
+class MpiImpl_MPICH2 : public MpiImpl
+{
+public:
+  // Constructeur et destructeur
+  MpiImpl_MPICH2(); // constructor
+  virtual ~MpiImpl_MPICH2(); //Destructor
+
+  std::string size(); // get number of process of current job
+  std::string rank(); // get process number of current job
+  std::string boot( const std::string machinefile, const unsigned int nbnodes); // get boot command
+  std::string run( const std::string machinefile, const unsigned int nbproc, const std::string fileNameToExecute); // get run command
+  std::string halt(); // get stop command
+
+protected:
+
+private:
+
+};
+
+class MpiImpl_OPENMPI : public MpiImpl
+{
+public:
+  // Constructeur et destructeur
+  MpiImpl_OPENMPI(); // constructor
+  virtual ~MpiImpl_OPENMPI(); //Destructor
+
+  std::string size(); // get number of process of current job
+  std::string rank(); // get process number of current job
+  std::string boot( const std::string machinefile, const unsigned int nbnodes); // get boot command
+  std::string run( const std::string machinefile, const unsigned int nbproc, const std::string fileNameToExecute); // get run command
+  std::string halt(); // get stop command
+
+protected:
+
+private:
+
+};
+
+#endif
index bb72d3f207ad92f63f4796ff22ec13e6dcbb2695..895c53581b70532adeede7e40b689b70858d961a 100644 (file)
@@ -184,6 +184,7 @@ string SALOME_FileTransferCORBA::getLocalFile(string localFile)
              SCRUTE(toFollow);
              CORBA::Octet *buf = aBlock->get_buffer();
              int nbWri = fwrite(buf, sizeof(CORBA::Octet), toFollow, fp);
+              delete aBlock;
              ASSERT(nbWri == toFollow);
            }
          fclose(fp);
index 2e9b3160dc6f7151a7d79c3c51f36a384d105990..3208d6e8965bd744d6b34fee98b7e492e6f0dbc7 100644 (file)
@@ -413,13 +413,22 @@ CORBA::Boolean SALOME_ModuleCatalog_AcomponentImpl::multistudy()
 
 //----------------------------------------------------------------------
 // Function : implementation type
-// Purpose  : define if a component is implemented in C++ or Python
+// Purpose  : return the implementation type :  C++ (dyn lib), Python (module) or executable
 //----------------------------------------------------------------------
-CORBA::Boolean SALOME_ModuleCatalog_AcomponentImpl::implementation_type()
+SALOME_ModuleCatalog::ImplType SALOME_ModuleCatalog_AcomponentImpl::implementation_type()
 {
   return _Component.implementationType ;
 }
 
+//----------------------------------------------------------------------
+// Function : implementation name
+// Purpose  : return the implementation name to exec if the default one is not convenient
+//----------------------------------------------------------------------
+char* SALOME_ModuleCatalog_AcomponentImpl::implementation_name()
+{
+  return _Component.implname ;
+}
+
 //----------------------------------------------------------------------
 // Function : component_type
 // Purpose  : define the type of the component
index 943d5d02e2237ceb94e112264cc8c7caa0cb5c48..e693d70f40c5d23e933c8e87d39a9e1d43b3b2dd 100644 (file)
@@ -135,11 +135,17 @@ public:
   */
   virtual char* component_icone();
 
-  //! method to define if a component is implemented in C++ or Python
+  //! method to define if a component is implemented in a dyn lib a python module or an executable
   /*!
-    \return true if it's a C++ component 
+    \return an enum SO or PY or EXE
   */
-  virtual CORBA::Boolean implementation_type();
+  virtual SALOME_ModuleCatalog::ImplType implementation_type();
+
+  //! method to obtain the implementation name of the component if the default one is not convenient
+  /*!
+    \return the implementation name to exec
+  */
+  virtual char* implementation_name();
 
 private :
 
index 97c257dedf538bf1161d02e5711b3d283886c7a8..bf3e999521fdcbc694f82826d46f49bdd80fc62e 100644 (file)
@@ -68,6 +68,7 @@ SALOME_ModuleCatalog_Handler::SALOME_ModuleCatalog_Handler(ParserPathPrefixes& p
   test_component_multistudy = "component-multistudy";
   test_component_icon       = "component-icone" ;
   test_component_impltype   = "component-impltype";
+  test_component_implname   = "component-implname";
   test_component_version    = "component-version";
   test_component_comment    = "component-comment";
 
@@ -481,7 +482,11 @@ void SALOME_ModuleCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc)
 
           // Tag test_component_impltype
           if ( !xmlStrcmp(aComponentSubNode->name, (const xmlChar*)test_component_impltype) )
-            _aModule.implementationType = atoi(aContent.c_str());
+            _aModule.implementationType = aContent;
+
+          // Tag test_component_implname
+          if ( !xmlStrcmp(aComponentSubNode->name, (const xmlChar*)test_component_implname) )
+            _aModule.implementationName = aContent;
 
           // Tag test_component_icon
           if ( !xmlStrcmp(aComponentSubNode->name, (const xmlChar*)test_component_icon) )
index 22f7c416af191ca84c653252947ec887a9848d80..50758d6a6e4cef3d8fa676eff6ff28cf7aa1a56d 100644 (file)
@@ -64,6 +64,7 @@ private:
   const char *test_component_multistudy ;
   const char *test_component_icon ;
   const char *test_component_impltype;
+  const char *test_component_implname;
   const char *test_component_version;
   const char *test_component_comment;
   
index 8369f99177c6934a68a3d418e5e7930604b791d6..4a330bf9d34286d4be9260c356fc9105a35072e8 100644 (file)
@@ -96,7 +96,8 @@ struct ParserComponent
   std::string         constraint;
   ParserInterfaces    interfaces;
   ParserPathPrefixes  prefixes;
-  bool                implementationType;
+  std::string         implementationType;
+  std::string         implementationName;
   std::string         version;
   std::string         comment;
 };
index e794b05a5a7350d86042fff8bcc125cd568cbd5a..5e3760e222fd0038923cc3a56c84fe2edf51fdb9 100644 (file)
@@ -96,20 +96,7 @@ SALOME_ModuleCatalogImpl::SALOME_ModuleCatalogImpl(int argc, char** argv, CORBA:
   ComponentTypeConvert[OTHER]
     = SALOME_ModuleCatalog::OTHER;
 
-  // Conversion rules for datastream parameters type and dependency
-  DataStreamTypeConvert["UNKNOWN"] 
-    = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
-  DataStreamTypeConvert["INTEGER"] 
-    = SALOME_ModuleCatalog::DATASTREAM_INTEGER;
-  DataStreamTypeConvert["FLOAT"]   
-    = SALOME_ModuleCatalog::DATASTREAM_FLOAT;
-  DataStreamTypeConvert["DOUBLE"]  
-    = SALOME_ModuleCatalog::DATASTREAM_DOUBLE;
-  DataStreamTypeConvert["STRING"]  
-    = SALOME_ModuleCatalog::DATASTREAM_STRING;
-  DataStreamTypeConvert["BOOLEAN"] 
-    = SALOME_ModuleCatalog::DATASTREAM_BOOLEAN;
-
+  // Conversion rules for datastream parameters dependency
   DataStreamDepConvert["UNDEFINED"] 
     = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
   DataStreamDepConvert["T"]
@@ -759,7 +746,13 @@ void SALOME_ModuleCatalogImpl::duplicate
   C_corba.multistudy = C_parser.multistudy;
   C_corba.icon = CORBA::string_dup(C_parser.icon.c_str());
   C_corba.type = ComponentTypeConvert[C_parser.type];
-  C_corba.implementationType = C_parser.implementationType;
+  if(C_parser.implementationType == "EXE")
+    C_corba.implementationType=SALOME_ModuleCatalog::EXE;
+  else if(C_parser.implementationType == "PY")
+    C_corba.implementationType=SALOME_ModuleCatalog::PY;
+  else
+    C_corba.implementationType=SALOME_ModuleCatalog::SO;
+  C_corba.implname = CORBA::string_dup(C_parser.implementationName.c_str());
 
   unsigned int _length = C_parser.interfaces.size();
   C_corba.interfaces.length(_length);
@@ -880,32 +873,12 @@ void SALOME_ModuleCatalogImpl::duplicate
 (SALOME_ModuleCatalog::ServicesDataStreamParameter & P_corba,
  const ParserDataStreamParameter & P_parser)
 {
-  std::map < std::string, 
-    SALOME_ModuleCatalog::DataStreamType >::const_iterator it_type;
-
   std::map < std::string, 
     SALOME_ModuleCatalog::DataStreamDependency >::const_iterator it_dep;
 
   // duplicate parameter name
   P_corba.Parametername = CORBA::string_dup(P_parser.name.c_str());
   
-  // doesn't work ??? 
-  //   it_type = DataStreamTypeConvert.find(P_parser.type);
-  //   P_corba.Parametertype
-  //     = (it_type == DataStreamTypeConvert.end()) 
-  //     ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
-
-  if(MYDEBUG) SCRUTE(P_parser.type);
-  P_corba.Parametertype = SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
-  for (it_type = DataStreamTypeConvert.begin(); 
-       it_type != DataStreamTypeConvert.end(); 
-       it_type++)
-    if (P_parser.type.compare(it_type->first) == 0) {
-      P_corba.Parametertype = it_type->second;
-      break;
-    }
-  if(MYDEBUG) SCRUTE(P_corba.Parametertype);
-
   // duplicate parameter type
 
   // doesn't work ??? 
@@ -913,6 +886,10 @@ void SALOME_ModuleCatalogImpl::duplicate
   //   P_corba.Parametertype
   //     = (it_type == DataStreamTypeConvert.end()) 
   //     ? it_type->second : SALOME_ModuleCatalog::DATASTREAM_UNKNOWN;
+
+  P_corba.Parametertype = CORBA::string_dup(P_parser.type.c_str());
+
+  // duplicate parameter dependency
   
   if(MYDEBUG) SCRUTE(P_parser.dependency);
   P_corba.Parameterdependency = SALOME_ModuleCatalog::DATASTREAM_UNDEFINED;
index fc4d269feb95f8dd3e596f3b63bbdf1fe2893228..40650ac9f751a2d0312a2de570b0dbe7ff638855 100644 (file)
@@ -217,9 +217,6 @@ private:
   ParserComponents    _personal_module_list ;
   ParserPathPrefixes  _personal_path_list ; 
 
-  std::map <std::string, SALOME_ModuleCatalog::DataStreamType> 
-  DataStreamTypeConvert;
-
   std::map <std::string, SALOME_ModuleCatalog::DataStreamDependency> 
   DataStreamDepConvert;
 
index 6d9d1f962f110b453d4e5f76b279326086c971f9..3021b6c857ca6e97aa489ada3096792c52d3456d 100644 (file)
@@ -66,8 +66,9 @@ void NamingService_WaitForServerReadiness(SALOME_NamingService* NS,
        {
          if (serverName.length() == 0)
            {
-             string dummyadr = NS->getIORaddr(); // to wait for naming service
+             char* dummyadr = NS->getIORaddr(); // to wait for naming service
              found = 1;
+              delete [] dummyadr;
              break; // naming service found
            }
          else
index eec18908d931e1b4abe1764df8c72f1e29eab421..965982293b32d97fd5e03564deb4631bb21248c4 100644 (file)
@@ -1065,7 +1065,7 @@ throw(ServiceUnreachable)
 
       if (binding->binding_type == CosNaming::ncontext)
         {
-          dirList.push_back(CORBA::string_dup(bindingName[0].id));
+          dirList.push_back(bindingName[0].id.in());
         }
     }
 
index 441f4fff0641227bc3e9433f2d6b60a35186189c..bfb70a8df2df41ed61551eb5c86d478daf5fa6d2 100644 (file)
@@ -89,6 +89,7 @@ NSTEST::echo_ptr NSTEST_aFactory_i::createInstance()
   NSTEST_echo_i * anEcho = new NSTEST_echo_i(_num);
   _num++;
   NSTEST::echo_var anEchoRef = anEcho->_this();
+  anEcho->_remove_ref();
   return anEchoRef._retn();
 }
 
@@ -149,6 +150,7 @@ NamingServiceTest::setUp()
   _myFactoryId = _root_poa->activate_object(_myFactory);
   _factoryRef = _myFactory->_this();
   _pman->activate();
+  _myFactory->_remove_ref();
   
 }
 
@@ -182,6 +184,7 @@ NamingServiceTest::testConstructorDefault()
 
   char *root = NS.getIORaddr();
   CORBA::Object_var obj = _orb->string_to_object(root);
+  delete [] root;
   CPPUNIT_ASSERT(!CORBA::is_nil(obj));
 
   CosNaming::NamingContext_var rootContext =
@@ -202,6 +205,7 @@ NamingServiceTest::testConstructorOrb()
   char *root = NS.getIORaddr();
   CORBA::Object_var obj = _orb->string_to_object(root);
   CPPUNIT_ASSERT(!CORBA::is_nil(obj));
+  delete [] root;
 
   CosNaming::NamingContext_var rootContext =
     CosNaming::NamingContext::_narrow(obj);
@@ -1027,7 +1031,9 @@ NamingServiceTest::testCurrentDirectory()
   CPPUNIT_ASSERT(ret);
 
   _NS.Change_Directory(path.c_str());
-  string curdir = _NS.Current_Directory();
+  char* acurdir = _NS.Current_Directory();
+  string curdir = acurdir;
+  free(acurdir);
   CPPUNIT_ASSERT(curdir == path);
 }
 
@@ -1204,6 +1210,7 @@ NamingServiceTest::testGetIorAddr()
 {
   char *root = _NS.getIORaddr();
   CORBA::Object_var obj = _orb->string_to_object(root);
+  delete [] root;
   CPPUNIT_ASSERT(!CORBA::is_nil(obj)); 
 }
 
index f41e7689d4470709d1b5b3457994e230cf26ffcf..5c3a8e712e6871573d8237193eb6726b7b196d65 100644 (file)
@@ -47,6 +47,8 @@ clt.waitLogger("Logger")
 # execute Unit Test
 
 command = ['TestNamingService']
+valgrind = ['valgrind','--leak-check=full']
+#command=valgrind+command #to check memory leaks
 ret = os.spawnvp(os.P_WAIT, command[0], command)
 
 # kill Test process
index 1734d4f10a91ab870ed57f8eff28bd188b76c8cb..18ff73d7fd16de7963a0b2135702c992e1df331f 100644 (file)
@@ -34,6 +34,7 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am
 # header files  
 salomeinclude_HEADERS = SALOME_ParallelComponent_i.hxx \
                        SALOME_ParallelContainer_i.hxx \
+                       SALOME_ParallelContainerProxy_i.hxx \
                        Parallel_Salome_file_i.hxx
 
 #
@@ -75,6 +76,7 @@ lib_LTLIBRARIES = libSalomeParallelContainer.la
 
 libSalomeParallelContainer_la_SOURCES  = SALOME_ParallelComponent_i.cxx \
                                         SALOME_ParallelContainer_i.cxx \
+                                        SALOME_ParallelContainerProxy_i.cxx \
                                         $(top_srcdir)/src/Container/Salome_file_i.cxx \
                                         Parallel_Salome_file_i.cxx
 
index ac06b50057e65b007e42ac82b5168657273dd52e..7c93948637688ece96b5008d858a867389cb0d97 100644 (file)
 #include "Parallel_Salome_file_i.hxx"
 #include "utilities.h"
 
-Parallel_Salome_file_i::Parallel_Salome_file_i(CORBA::ORB_ptr orb, const char * ior) :
-  InterfaceParallel_impl(orb,ior), 
-  Engines::Salome_file_serv(orb,ior),
-  Engines::fileTransfer_serv(orb,ior),
-  Engines::Parallel_Salome_file_serv(orb,ior)
+Parallel_Salome_file_i::Parallel_Salome_file_i(CORBA::ORB_ptr orb, 
+                                              const char * ior,
+                                              int rank) :
+  InterfaceParallel_impl(orb,ior,rank), 
+  Engines::Salome_file_serv(orb,ior,rank),
+  Engines::fileTransfer_serv(orb,ior,rank),
+  Engines::Parallel_Salome_file_serv(orb,ior,rank)
 {
   CORBA::Object_ptr obj = _orb->string_to_object(ior);
   proxy = Engines::Parallel_Salome_file::_narrow(obj);
@@ -168,8 +170,8 @@ Parallel_Salome_file_i::recvFiles_node() {
          // 2 cases :
          // Source file is a Salome_file
          // Source file is a Parallel_Salome_file
-         PaCO::ParallelKernel_var interface_manager = 
-           PaCO::ParallelKernel::_narrow(_fileDistributedSource[file_infos.file_name.in()]);
+         PaCO::InterfaceManager_var interface_manager = 
+           PaCO::InterfaceManager::_narrow(_fileDistributedSource[file_infos.file_name.in()]);
          if (CORBA::is_nil(interface_manager))
            result = getDistributedFile(file_infos.file_name.in());
          else
@@ -245,6 +247,7 @@ Parallel_Salome_file_i::getParallelDistributedFile(std::string file_name) {
       toFollow = aBlock->length();
       CORBA::Octet *buf = aBlock->get_buffer();
       int nbWri = fwrite(buf, sizeof(CORBA::Octet), toFollow, fp);
+      delete aBlock;
       ASSERT(nbWri == toFollow);
     }
     fclose(fp);
index c3814a5c4124861413678c3e8fa736b22ea0aec0..21384fef918d2823b6edc1b5f34da22b2cab639e 100644 (file)
@@ -39,7 +39,9 @@ class CONTAINER_EXPORT Parallel_Salome_file_i:
   public virtual Engines::Parallel_Salome_file_serv
 {
   public:
-    Parallel_Salome_file_i(CORBA::ORB_ptr orb, const char * ior);
+    Parallel_Salome_file_i(CORBA::ORB_ptr orb, 
+                          const char * ior,
+                          int rank);
     virtual ~Parallel_Salome_file_i();
 
     virtual void setFileNode(const char* file_name, CORBA::Long node);
index db60ae5e414d2774d8bd8d531c83db3f4029a5c1..fab45e7032dccba174f5007b1d9c3a63ec02805c 100644 (file)
@@ -44,6 +44,7 @@ int SIGUSR11 = 1000;
 #endif
 
 #include <paco_dummy.h>
+#include <paco_omni.h>
 
 using namespace std;
 
@@ -59,8 +60,10 @@ bool Engines_Parallel_Component_i::_isMultiInstance = false;
  */
 //=============================================================================
 
-Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior) : 
-  InterfaceParallel_impl(orb,ior), Engines::Component_serv(orb,ior), Engines::Parallel_Component_serv(orb,ior)
+Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior, int rank) : 
+  InterfaceParallel_impl(orb,ior,rank), 
+  Engines::Component_serv(orb,ior,rank), 
+  Engines::Parallel_Component_serv(orb,ior,rank)
 {
   //ASSERT(0);
   INFOS("Default Constructor...");
@@ -79,15 +82,15 @@ Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, c
  */
 //=============================================================================
 
-Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior,
+Engines_Parallel_Component_i::Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior, int rank,
                                         PortableServer::POA_ptr poa, 
                                         PortableServer::ObjectId * contId, 
                                         const char *instanceName,
                                         const char *interfaceName,
                                          bool notif) :
-  InterfaceParallel_impl(orb,ior), 
-  Engines::Component_serv(orb,ior),
-  Engines::Parallel_Component_serv(orb,ior),
+  InterfaceParallel_impl(orb,ior,rank), 
+  Engines::Component_serv(orb,ior,rank),
+  Engines::Parallel_Component_serv(orb,ior,rank),
   _instanceName(instanceName),
   _interfaceName(interfaceName),
   _myConnexionToRegistry(0),
@@ -818,34 +821,21 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name,
     // Firstly, we have to create the proxy object
     // of the Salome_file and transmit his
     // reference to the other nodes.
+    Engines::Parallel_Salome_file_proxy_impl * proxy = NULL;
     if (getMyRank() == 0) {
-      Engines::Parallel_Salome_file_proxy_impl * proxy = 
-       new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb));
-      PaCO_operation * proxy_global_ptr =  proxy->getContext("global_paco_context");
-      // We initialize the object with the context of the Parallel component
-      PaCO_operation * compo_global_ptr =  getContext("global_paco_context");
-      //compo_global_ptr->init_context(proxy_global_ptr);
-      proxy_global_ptr->init_context(compo_global_ptr);
-      
-      paco_fabrique_manager* pfm = paco_getFabriqueManager();
-      pfm->register_com("dummy", new paco_dummy_fabrique());
-      proxy_global_ptr->setComFab(NULL);
-      proxy_global_ptr->setLibCom("dummy",NULL);
-      
-      proxy_global_ptr->setTypeClient(true);
-      PaCO::PacoTopology_t client_topo;
-      client_topo.total = 1;
-      proxy_global_ptr->setClientTopo(client_topo);
+      proxy = new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb),
+                                                          new paco_omni_fabrique());
+      proxy->copyGlobalContext(this); 
       PaCO::PacoTopology_t serveur_topo;
       serveur_topo.total = getTotalNode();
-      proxy->setTopo(serveur_topo);
+      proxy->setTopology(serveur_topo);
 
       // We register the CORBA objet into the POA
       CORBA::Object_ptr proxy_ref = proxy->_this();
 
       // We send the reference to all the nodes...
-      CORBA::Object_ptr comp_proxy = _orb->string_to_object(_ior.c_str());
-      Engines::Parallel_Component_var component_proxy = Engines::Parallel_Component::_narrow(comp_proxy);
+      Engines::Parallel_Component_var component_proxy = 
+       Engines::Parallel_Component::_narrow(InterfaceParallel_impl::_proxy);
       component_proxy->send_parallel_proxy_object(proxy_ref);
 
       // Adding proxy into the map
@@ -863,32 +853,35 @@ Engines_Parallel_Component_i::setInputFileToService(const char* service_name,
     for (int i = 0; i < getTotalNode(); i++) {
       if (i ==  getMyRank()) {
        Parallel_Salome_file_i * servant = 
-         new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), proxy_ior.c_str());
-       PaCO_operation * servant_global_ptr = servant->getContext("global_paco_context");
-       
-       // We initialize the object with the context of the Parallel component
-       PaCO_operation * compo_global_ptr =  this->getContext("global_paco_context");
-//     compo_global_ptr->init_context(servant_global_ptr);
-       servant_global_ptr->init_context(compo_global_ptr);
+         new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), 
+                                    proxy_ior.c_str(),
+                                    i);
+       servant->copyGlobalContext(this); 
        
        // We register the CORBA objet into the POA
        servant->POA_PaCO::InterfaceParallel::_this();
 
        // Register the servant
-       servant->deploy(getMyRank());
+       servant->deploy();
 
        // Adding servant to the map
        (*_map)[Salome_file_name] = servant;
       }
 
-      PaCO_operation * compo_global_ptr =  this->getContext("global_paco_context");
-      compo_global_ptr->my_com->paco_barrier();
+      _my_com->paco_barrier();
+      // start parallel object
+      if (getMyRank() == 0) {
+       proxy->start();
+       _my_com->paco_barrier();
+      }
+      else
+       _my_com->paco_barrier();
     }
-
     // Parallel_Salome_file is created and deployed
     delete _proxy;
     _proxy = NULL;
   }
+
   pthread_mutex_unlock(deploy_mutex);
   proxy_ior = (*_IOR_proxy_map)[Salome_file_name];
   CORBA::Object_ptr proxy_ref = _orb->string_to_object(proxy_ior.c_str());
@@ -918,6 +911,7 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name,
 
   // Try to find the Salome_file ...
   _Salome_file_map_it = _map->find(Salome_file_name);
+  Engines::Parallel_Salome_file_proxy_impl * proxy;
   if (_Salome_file_map_it ==  _map->end()) {
 
     // We create a new PaCO++ object.
@@ -928,33 +922,19 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name,
     // of the Salome_file and transmit his
     // reference to the other nodes.
     if (getMyRank() == 0) {
-      Engines::Parallel_Salome_file_proxy_impl * proxy = 
-       new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb));
-      PaCO_operation * proxy_global_ptr =  proxy->getContext("global_paco_context");
-      // We initialize the object with the context of the Parallel component
-      PaCO_operation * compo_global_ptr =  getContext("global_paco_context");
-      //compo_global_ptr->init_context(proxy_global_ptr);
-      proxy_global_ptr->init_context(compo_global_ptr);
-
-      paco_fabrique_manager* pfm = paco_getFabriqueManager();
-      pfm->register_com("dummy", new paco_dummy_fabrique());
-      proxy_global_ptr->setComFab(NULL);
-      proxy_global_ptr->setLibCom("dummy",NULL);
-
-      proxy_global_ptr->setTypeClient(true);
-      PaCO::PacoTopology_t client_topo;
-      client_topo.total = 1;
-      proxy_global_ptr->setClientTopo(client_topo);
+       proxy = new Engines::Parallel_Salome_file_proxy_impl(CORBA::ORB::_duplicate(_orb),
+                                                            new paco_omni_fabrique());
+      proxy->copyGlobalContext(this); 
       PaCO::PacoTopology_t serveur_topo;
       serveur_topo.total = getTotalNode();
-      proxy->setTopo(serveur_topo);
+      proxy->setTopology(serveur_topo);
 
       // We register the CORBA objet into the POA
       CORBA::Object_ptr proxy_ref = proxy->_this();
 
       // We send the reference to all the nodes...
-      CORBA::Object_ptr comp_proxy = _orb->string_to_object(_ior.c_str());
-      Engines::Parallel_Component_var component_proxy = Engines::Parallel_Component::_narrow(comp_proxy);
+      Engines::Parallel_Component_var component_proxy = 
+       Engines::Parallel_Component::_narrow(InterfaceParallel_impl::_proxy);
       component_proxy->send_parallel_proxy_object(proxy_ref);
 
       // Adding proxy into the map
@@ -972,26 +952,29 @@ Engines_Parallel_Component_i::setOutputFileToService(const char* service_name,
     for (int i = 0; i < getTotalNode(); i++) {
       if (i ==  getMyRank()) {
        Parallel_Salome_file_i * servant = 
-         new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), proxy_ior.c_str());
-       PaCO_operation * servant_global_ptr = servant->getContext("global_paco_context");
-       
-       // We initialize the object with the context of the Parallel component
-       PaCO_operation * compo_global_ptr =  this->getContext("global_paco_context");
-//     compo_global_ptr->init_context(servant_global_ptr);
-       servant_global_ptr->init_context(compo_global_ptr);
+         new Parallel_Salome_file_i(CORBA::ORB::_duplicate(_orb), 
+                                    proxy_ior.c_str(),
+                                    i);
+       servant->copyGlobalContext(this); 
        
        // We register the CORBA objet into the POA
        servant->POA_PaCO::InterfaceParallel::_this();
 
        // Register the servant
-       servant->deploy(getMyRank());
+       servant->deploy();
 
        // Adding servant to the map
        (*_map)[Salome_file_name] = servant;
       }
 
-      PaCO_operation * compo_global_ptr =  this->getContext("global_paco_context");
-      compo_global_ptr->my_com->paco_barrier();
+      _my_com->paco_barrier();
+      // start parallel object
+      if (getMyRank() == 0) {
+       proxy->start();
+       _my_com->paco_barrier();
+      }
+      else
+       _my_com->paco_barrier();
     }
 
     // Parallel_Salome_file is created and deployed
index edadf93cea929b8bb650006da6a0fc7dd304d3d2..21886497061249a858d46d3014418801c0c62dcd 100644 (file)
@@ -64,8 +64,8 @@ class CONTAINER_EXPORT Engines_Parallel_Component_i:
   public virtual PortableServer::RefCountServantBase
 {
 public:
-  Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior);
-  Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior,
+  Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior, int rank);
+  Engines_Parallel_Component_i(CORBA::ORB_ptr orb, char * ior, int rank,
                               PortableServer::POA_ptr poa,
                               PortableServer::ObjectId * contId, 
                               const char *instanceName, 
index 4f5d0d2749de547ab403ba68f7ce09dc5dd357aa..d3470b9de5334628228c15060e252beeac41f1b5 100644 (file)
@@ -54,12 +54,12 @@ using namespace std;
 #include <signal.h>
 
 void handler(int t) {
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "SIGSEGV in :" << getpid() << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       while (1) {}
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "SIGSEGV in :" << getpid() << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  while (1) {}
 }
 #endif
 
@@ -78,13 +78,13 @@ sighandler_t setsig(int sig, sighandler_t handler)
 void AttachDebugger()
 {
   if(getenv ("DEBUGGER"))
-    {
-      std::stringstream exec;
-      exec << "$DEBUGGER SALOME_ParallelContainerNodeDummy " << getpid() << "&";
-      std::cerr << exec.str() << std::endl;
-      system(exec.str().c_str());
-      while(1);
-    }
+  {
+    std::stringstream exec;
+    exec << "$DEBUGGER SALOME_ParallelContainerNodeDummy " << getpid() << "&";
+    std::cerr << exec.str() << std::endl;
+    system(exec.str().c_str());
+    while(1);
+  }
 }
 
 void Handler(int theSigId)
@@ -109,107 +109,104 @@ void unexpectedHandler(void)
 
 int main(int argc, char* argv[])
 {
-       INFOS("Launching a parallel container node");
+  INFOS("Launching a parallel container node");
 
-#ifdef _DEBUG_
-//     signal(SIGSEGV, handler);
-#endif
   if(getenv ("DEBUGGER"))
-    {
-      setsig(SIGSEGV,&Handler);
-      set_terminate(&terminateHandler);
-      set_unexpected(&unexpectedHandler);
-    }
-
-       // Initialise the ORB.
-       ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
-       ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
-       CORBA::ORB_var orb = init(0, 0);
-       //CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
-
-       char * containerName = "";
-       if(argc > 1) {
-               containerName = argv[1];
-       }
-
-       char * hostname = "";
-       if(argc > 3) {
-               hostname = argv[3];
-       }
-
-       try {  
-               CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
-               PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
-               PortableServer::POAManager_var pman = root_poa->the_POAManager();
+  {
+    setsig(SIGSEGV,&Handler);
+    set_terminate(&terminateHandler);
+    set_unexpected(&unexpectedHandler);
+  }
+
+  // Initialise the ORB.
+  CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
+
+  std::string containerName("");
+  if(argc > 1) {
+    containerName = argv[1];
+  }
+  std::string hostname("");
+  if(argc > 3) {
+    hostname = argv[3];
+  }
+
+  try {  
+    CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
+    PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
+    PortableServer::POAManager_var pman = root_poa->the_POAManager();
 
 #ifndef WNT
-               // add this container to the kill list
-               char aCommand[100];
-               sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerNode", getpid());
-               system(aCommand);
+    // add this container to the kill list
+    char aCommand[100];
+    sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerNode", getpid());
+    system(aCommand);
 #endif
 
-               SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
-               // Get the proxy
-               string proxyNameInNS = ns->BuildContainerNameForNS(containerName, hostname);
-               obj = ns->Resolve(proxyNameInNS.c_str());
-               char * proxy_ior = orb->object_to_string(obj);
-
-               // Creating a node
-               string name(containerName);
-               string node_name = name + "Node";
-               Engines_Parallel_Container_i * servant = new Engines_Parallel_Container_i(CORBA::ORB::_duplicate(orb), proxy_ior,
-                                                                                                                                                                                                                                                                                                                       root_poa,
-                                                                                                                                                                                                                                                                                                                       (char*) node_name.c_str(),
-                                                                                                                                                                                                                                                                                                                       argc, argv);
-               // PaCO++ init
-               paco_fabrique_manager * pfm = paco_getFabriqueManager();
-               pfm->register_com("dummy", new paco_dummy_fabrique());
-               pfm->register_thread("omni", new paco_omni_fabrique());
-
-               // Global context
-               PaCO_operation * global_ptr = servant->getContext("global_paco_context");
-               global_ptr->setLibCom("dummy",NULL);
-               global_ptr->setLibThread("omni");
-
-               // Activation
-               PortableServer::ObjectId * _id = root_poa->activate_object(servant);
-               servant->set_id(_id);
-               obj = root_poa->id_to_reference(*_id);
-
-               // In the NamingService
-               string hostname = GetHostname();
-               int myid = 0;
-               char buffer [5];
-               snprintf(buffer, 5, "%d", myid);
-               node_name = node_name + buffer;
-               string _containerName = ns->BuildContainerNameForNS((char*) node_name.c_str(),
-                                                                                                                                                                                                                               hostname.c_str());
-               cerr << "---------" << _containerName << "----------" << endl;
-               ns->Register(obj, _containerName.c_str());
-               pman->activate();
-               orb->run();
-       }
-       catch(CORBA::SystemException&)
-       {
-               INFOS("Caught CORBA::SystemException.");
-       }
-       catch(PortableServer::POA::ServantAlreadyActive&)
-       {
-               INFOS("Caught CORBA::ServantAlreadyActiveException");
-       }
-       catch(CORBA::Exception&)
-       {
-               INFOS("Caught CORBA::Exception.");
-       }
-       catch(std::exception& exc)
-       {
-               INFOS("Caught std::exception - "<<exc.what()); 
-       }
-       catch(...)
-       {
-               INFOS("Caught unknown exception.");
-       }
-       return 0 ;
+    SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
+    // Get the proxy
+    string proxyNameInNS = ns->BuildContainerNameForNS(containerName.c_str(), 
+                                                      hostname.c_str());
+    obj = ns->Resolve(proxyNameInNS.c_str());
+    char * proxy_ior = orb->object_to_string(obj);
+
+    // Creating a node
+    string node_name = containerName + "Node";
+    Engines_Parallel_Container_i * servant = new Engines_Parallel_Container_i(CORBA::ORB::_duplicate(orb), 
+                                                                             proxy_ior,
+                                                                             0,
+                                                                             root_poa,
+                                                                             (char*) node_name.c_str(),
+                                                                             argc, argv);
+    // PaCO++ init
+    paco_fabrique_manager * pfm = paco_getFabriqueManager();
+    pfm->register_com("dummy", new paco_dummy_fabrique());
+    pfm->register_thread("omni", new paco_omni_fabrique());
+    servant->setLibCom("dummy", servant);
+    servant->setLibThread("omni");
+
+    // Activation
+    PortableServer::ObjectId * _id = root_poa->activate_object(servant);
+    servant->set_id(_id);
+    obj = root_poa->id_to_reference(*_id);
+
+    // In the NamingService
+    string hostname = GetHostname();
+    int myid = 0;
+    char buffer [5];
+    snprintf(buffer, 5, "%d", myid);
+    node_name = node_name + buffer;
+    string _containerName = ns->BuildContainerNameForNS((char*) node_name.c_str(),
+                                                       hostname.c_str());
+    cerr << "---------" << _containerName << "----------" << endl;
+    ns->Register(obj, _containerName.c_str());
+    pman->activate();
+    orb->run();
+  }
+  catch (PaCO::PACO_Exception& e)
+  {
+    INFOS("Caught PaCO::PACO_Exception");
+    std::cerr << e << std::endl;
+  }
+  catch(CORBA::SystemException&)
+  {
+    INFOS("Caught CORBA::SystemException.");
+  }
+  catch(PortableServer::POA::ServantAlreadyActive&)
+  {
+    INFOS("Caught CORBA::ServantAlreadyActiveException");
+  }
+  catch(CORBA::Exception&)
+  {
+    INFOS("Caught CORBA::Exception.");
+  }
+  catch(std::exception& exc)
+  {
+    INFOS("Caught std::exception - "<<exc.what()); 
+  }
+  catch(...)
+  {
+    INFOS("Caught unknown exception.");
+  }
+  return 0 ;
 }
 
index 4852bcafb2c0f1c45324a69c79a3cbb51c583988..baea9d42140bb94e0e971131b921fb1d830d5909 100644 (file)
@@ -57,21 +57,21 @@ using namespace std;
 #include <signal.h>
 
 void test(int sigval) {
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "SIGSEGV in :" << getpid() << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       while (1) {}
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "SIGSEGV in :" << getpid() << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  while (1) {}
 }
 
 void handler(int t) {
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "SIGSEGV in :" << getpid() << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       while (1) {}
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "SIGSEGV in :" << getpid() << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  while (1) {}
 }
 #endif
 
@@ -90,13 +90,13 @@ sighandler_t setsig(int sig, sighandler_t handler)
 void AttachDebugger()
 {
   if(getenv ("DEBUGGER"))
-    {
-      std::stringstream exec;
-      exec << "$DEBUGGER SALOME_ParallelContainerNodeMpi " << getpid() << "&";
-      std::cerr << exec.str() << std::endl;
-      system(exec.str().c_str());
-      while(1);
-    }
+  {
+    std::stringstream exec;
+    exec << "$DEBUGGER SALOME_ParallelContainerNodeMpi " << getpid() << "&";
+    std::cerr << exec.str() << std::endl;
+    system(exec.str().c_str());
+    while(1);
+  }
 }
 
 void Handler(int theSigId)
@@ -121,40 +121,31 @@ void unexpectedHandler(void)
 
 int main(int argc, char* argv[])
 {
-       INFOS("Launching a parallel Mpi container node");
+  INFOS("Launching a parallel Mpi container node");
 
-#ifdef _DEBUG_
-//     struct sigaction action;
-//     action.sa_handler = &test;
-//     sigaction(SIGSEGV, &action, NULL);
-#endif
-       
-       // MPI Init
-       int provided;
-       MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE ,&provided);
+  // MPI Init
+  int provided;
+  int myid;
+  MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE ,&provided);
+  MPI_Comm_rank(MPI_COMM_WORLD,&myid);
 
   if(getenv ("DEBUGGER"))
-    {
-  std::cerr << "Unexpected: unexpected exception !"  << std::endl;
-      setsig(SIGSEGV,&Handler);
-      set_terminate(&terminateHandler);
-      set_unexpected(&unexpectedHandler);
-    }
-#ifdef _DEBUG_
-       cerr << "Level MPI_THREAD_SINGLE : " << MPI_THREAD_SINGLE << endl;
-       cerr << "Level MPI_THREAD_SERIALIZED : " << MPI_THREAD_SERIALIZED << endl;
-       cerr << "Level MPI_THREAD_FUNNELED : " << MPI_THREAD_FUNNELED << endl;
-       cerr << "Level MPI_THREAD_MULTIPLE : " << MPI_THREAD_MULTIPLE << endl;
-       cerr << "Level provided : " << provided << endl;
-#endif
-       // Initialise the ORB.
-       ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
-       ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
-       CORBA::ORB_var orb = init(0, 0);
-       //CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
-
-       // Code pour choisir le reseau infiniband .....
-/*     string hostname_temp = GetHostname();
+  {
+    std::cerr << "Unexpected: unexpected exception !"  << std::endl;
+    setsig(SIGSEGV,&Handler);
+    set_terminate(&terminateHandler);
+    set_unexpected(&unexpectedHandler);
+  }
+  cerr << "Level MPI_THREAD_SINGLE : " << MPI_THREAD_SINGLE << endl;
+  cerr << "Level MPI_THREAD_SERIALIZED : " << MPI_THREAD_SERIALIZED << endl;
+  cerr << "Level MPI_THREAD_FUNNELED : " << MPI_THREAD_FUNNELED << endl;
+  cerr << "Level MPI_THREAD_MULTIPLE : " << MPI_THREAD_MULTIPLE << endl;
+  cerr << "Level provided : " << provided << endl;
+  // Initialise the ORB.
+  CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
+
+  // Code pour choisir le reseau infiniband .....
+  /*   string hostname_temp = GetHostname();
        hostent * t = gethostbyname(hostname_temp.c_str());
        cerr << " AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA " << t->h_addr << " " << hostname_temp << endl;
        cerr << t->h_addr << endl;
@@ -165,96 +156,99 @@ int main(int argc, char* argv[])
        string com = "giop:tcp:" + ip + ":";
        const char* options[][2] = { { "endPoint", com.c_str() }, { 0, 0 } };
        CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB4", options);
-*/
-       char * containerName = "";
-       if(argc > 1) {
-               containerName = argv[1];
-       }
+       */
+  std::string containerName("");
+  containerName = argv[1];
 
-       char * hostname = "";
-       if(argc > 3) {
-               hostname = argv[3];
-       }
+  std::string hostname("");
+  if(argc > 3) {
+    hostname = argv[3];
+  }
 
-       try {  
-               CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
-               PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
-               PortableServer::POAManager_var pman = root_poa->the_POAManager();
+  try {  
+    CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
+    PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
+    PortableServer::POAManager_var pman = root_poa->the_POAManager();
 
 #ifndef WNT
-               // add this container to the kill list
-               char aCommand[100];
-               sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerNodeMpi", getpid());
-               system(aCommand);
+    // add this container to the kill list
+    char aCommand[100];
+    sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerNodeMpi", getpid());
+    system(aCommand);
 #endif
 
-               SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
-               // On récupère le proxy 
-               string proxyNameInNS = ns->BuildContainerNameForNS(containerName, hostname);
-               obj = ns->Resolve(proxyNameInNS.c_str());
-               char * proxy_ior = orb->object_to_string(obj);
-
-               // Node creation
-               string name(containerName);
-               string node_name = name + "Node";
-               Engines_Parallel_Container_i * servant = new Engines_Parallel_Container_i(CORBA::ORB::_duplicate(orb), proxy_ior,
-                                                                                                                                                                                                                                                                                                                       root_poa,
-                                                                                                                                                                                                                                                                                                                       (char*) node_name.c_str(),
-                                                                                                                                                                                                                                                                                                                       argc, argv);
-               // PaCO++ init
-               paco_fabrique_manager * pfm = paco_getFabriqueManager();
-               pfm->register_com("mpi", new paco_mpi_fabrique());
-               pfm->register_thread("omni", new paco_omni_fabrique());
-
-               // Global context
-               PaCO_operation * global_ptr = servant->getContext("global_paco_context");
-               MPI_Comm group = MPI_COMM_WORLD;
-               global_ptr->setLibCom("mpi", &group);
-               global_ptr->setLibThread("omni");
-
-               // Activation
-               PortableServer::ObjectId * _id = root_poa->activate_object(servant);
-               servant->set_id(_id);
-               obj = root_poa->id_to_reference(*_id);
-
-               // In the NamingService
-               string hostname = GetHostname();
-
-               int myid;
-               MPI_Comm_rank(MPI_COMM_WORLD, &myid);
-               char buffer [5];
-               snprintf(buffer, 5, "%d", myid);
-               node_name = node_name + buffer;
-               string _containerName = ns->BuildContainerNameForNS((char*) node_name.c_str(),
-                                                                                                                                                                                                                               hostname.c_str());
-               cerr << "---------" << _containerName << "----------" << endl;
-               ns->Register(obj, _containerName.c_str());
-               pman->activate();
-               orb->run();
-       }
-       catch(CORBA::SystemException&)
-       {
-               INFOS("Caught CORBA::SystemException.");
-       }
-       catch(PortableServer::POA::ServantAlreadyActive&)
-       {
-               INFOS("Caught CORBA::ServantAlreadyActiveException");
-       }
-       catch(CORBA::Exception&)
-       {
-               INFOS("Caught CORBA::Exception.");
-       }
-       catch(std::exception& exc)
-       {
-               INFOS("Caught std::exception - "<<exc.what()); 
-       }
-       catch(...)
-       {
-               INFOS("Caught unknown exception.");
-       }
-
-       MPI_Finalize();
-
-       return 0 ;
+    SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
+    // On récupère le proxy 
+    string proxyNameInNS = ns->BuildContainerNameForNS(containerName.c_str(), 
+                                                      hostname.c_str());
+    obj = ns->Resolve(proxyNameInNS.c_str());
+    char * proxy_ior = orb->object_to_string(obj);
+
+    // Node creation
+    string node_name = containerName + "Node";
+    Engines_Parallel_Container_i * servant = 
+      new Engines_Parallel_Container_i(CORBA::ORB::_duplicate(orb), 
+                                      proxy_ior,
+                                      myid,
+                                      root_poa,
+                                      (char*) node_name.c_str(),
+                                      argc, argv);
+    // PaCO++ init
+    paco_fabrique_manager * pfm = paco_getFabriqueManager();
+    pfm->register_com("mpi", new paco_mpi_fabrique());
+    pfm->register_thread("omni", new paco_omni_fabrique());
+    MPI_Comm group = MPI_COMM_WORLD;
+    servant->setLibCom("mpi", &group);
+    servant->setLibThread("omni");
+
+    // Activation
+    PortableServer::ObjectId * _id = root_poa->activate_object(servant);
+    servant->set_id(_id);
+    obj = root_poa->id_to_reference(*_id);
+
+    // In the NamingService
+    string hostname = GetHostname();
+
+    int myid;
+    MPI_Comm_rank(MPI_COMM_WORLD, &myid);
+    char buffer [5];
+    snprintf(buffer, 5, "%d", myid);
+    node_name = node_name + buffer;
+    string _containerName = ns->BuildContainerNameForNS(node_name.c_str(),
+                                                       hostname.c_str());
+    cerr << "---------" << _containerName << "----------" << endl;
+    ns->Register(obj, _containerName.c_str());
+    pman->activate();
+    orb->run();
+  }
+  catch (PaCO::PACO_Exception& e)
+  {
+    INFOS("Caught PaCO::PACO_Exception");
+    std::cerr << e << std::endl;
+  }
+  catch(CORBA::SystemException&)
+  {
+    INFOS("Caught CORBA::SystemException.");
+  }
+  catch(PortableServer::POA::ServantAlreadyActive&)
+  {
+    INFOS("Caught CORBA::ServantAlreadyActiveException");
+  }
+  catch(CORBA::Exception&)
+  {
+    INFOS("Caught CORBA::Exception.");
+  }
+  catch(std::exception& exc)
+  {
+    INFOS("Caught std::exception - "<<exc.what()); 
+  }
+  catch(...)
+  {
+    INFOS("Caught unknown exception.");
+  }
+
+  MPI_Finalize();
+
+  return 0 ;
 }
 
index 06e7a59f0f9bb36caf2d3c7868fa7366a7a61815..e8df8733bf1344b160b9e889d16cf39b5be9066b 100644 (file)
@@ -36,7 +36,8 @@
 #endif
 
 // PaCO++ include
-#include "SALOME_ComponentPaCO_Engines_Container_server.h"
+//#include "SALOME_ComponentPaCO_Engines_Container_server.h"
+#include "SALOME_ParallelContainerProxy_i.hxx"
 #include <paco_omni.h>
 #include <paco_dummy.h>
 
 using namespace std;
 
 void handler(int t) {
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "SIGSEGV in :" << getpid() << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       while (1) {}
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "SIGSEGV in :" << getpid() << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  while (1) {}
 }
 #endif
 
 int main(int argc, char* argv[])
 {
-       INFOS("Launching a parallel proxy container");
+  INFOS("Launching a parallel proxy container");
 
 #ifdef DEBUG_PARALLEL
-       signal(SIGSEGV, handler);
+  signal(SIGSEGV, handler);
 #endif
+  // Initialise the ORB.
+  CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
 
-       // Initialise the ORB.
-       ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
-       ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
-       CORBA::ORB_var orb = init(0, 0);
-       //CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
+  std::string containerName("");
+  if(argc > 1) {
+    containerName = argv[1];
+  }
 
-       char *containerName = "";
-       if(argc > 1) {
-               containerName = argv[1];
-       }
-
-       try {  
-               CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
-               ASSERT(!CORBA::is_nil(obj));
-               PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
-               PortableServer::POAManager_var pman = root_poa->the_POAManager();
+  try {  
+    CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
+    ASSERT(!CORBA::is_nil(obj));
+    PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
+    PortableServer::POAManager_var pman = root_poa->the_POAManager();
 
 #ifndef WNT
-               // add this container to the kill list
-               char aCommand[100];
-               sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxy", getpid());
-               system(aCommand);
+    // add this container to the kill list
+    char aCommand[100];
+    sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxyDummy", getpid());
+    system(aCommand);
 #endif
 
-               SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
-               Engines::Container_proxy_impl * proxy = new Engines::Container_proxy_impl(CORBA::ORB::_duplicate(orb)); 
-
-               // PaCO++ code
-               paco_fabrique_manager* pfm = paco_getFabriqueManager();
-               // Global context
-               PaCO_operation * global_ptr =  proxy->getContext("global_paco_context");
-               pfm->register_com("dummy", new paco_dummy_fabrique());
-               global_ptr->setLibCom("dummy", NULL);
-               pfm->register_thread("omnithread", new paco_omni_fabrique());
-               global_ptr->setLibThread("omnithread");
-               global_ptr->setTypeClient(true);
-               // The proxy is a PaCO++ client
-               PaCO::PacoTopology_t client_topo;
-               client_topo.total = 1;
-               global_ptr->setClientTopo(client_topo);
-               // Topo of the parallel object
-               PaCO::PacoTopology_t serveur_topo;
-               serveur_topo.total = 1;
-               proxy->setTopo(serveur_topo);
-
-               PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
-               obj = root_poa->id_to_reference(_id);
-
-               // In the NamingService
-               string hostname = GetHostname();
-               Engines::Container_var pCont = Engines::Container::_narrow(obj);
-               string _containerName = ns->BuildContainerNameForNS(containerName,
-                                                                                                                                                                                                                               hostname.c_str());
-               cerr << "---------" << _containerName << "----------" << endl;
-               ns->Register(pCont, _containerName.c_str());
-               pman->activate();
-               orb->run();
-       }
-       catch(CORBA::SystemException&)
-       {
-               INFOS("Caught CORBA::SystemException.");
-       }
-       catch(PortableServer::POA::ServantAlreadyActive&)
-       {
-               INFOS("Caught CORBA::ServantAlreadyActiveException");
-       }
-       catch(CORBA::Exception&)
-       {
-               INFOS("Caught CORBA::Exception.");
-       }
-       catch(std::exception& exc)
-       {
-               INFOS("Caught std::exception - "<<exc.what()); 
-       }
-       catch(...)
-       {
-               INFOS("Caught unknown exception.");
-       }
-       return 0 ;
+    SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
+//    Engines::Container_proxy_impl * proxy = 
+//      new Engines::Container_proxy_impl(orb,
+//                                     new paco_omni_fabrique());
+
+    Container_proxy_impl_final * proxy = 
+      new Container_proxy_impl_final(orb,
+                                    new paco_omni_fabrique());
+    // PaCO++ code
+    paco_fabrique_manager* pfm = paco_getFabriqueManager();
+    pfm->register_com("dummy", new paco_dummy_fabrique());
+    proxy->setLibCom("dummy", proxy);
+    pfm->register_thread("omnithread", new paco_omni_fabrique());
+    proxy->setLibThread("omnithread");
+    // Topo of the parallel object
+    PaCO::PacoTopology_t serveur_topo;
+    serveur_topo.total = 1;
+    proxy->setTopology(serveur_topo);
+
+    PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
+    obj = root_poa->id_to_reference(_id);
+
+    // In the NamingService
+    string hostname = GetHostname();
+    Engines::Container_var pCont = Engines::Container::_narrow(obj);
+    string _containerName = ns->BuildContainerNameForNS(containerName.c_str(),
+                                                       hostname.c_str());
+    cerr << "---------" << _containerName << "----------" << endl;
+    ns->Register(pCont, _containerName.c_str());
+    pman->activate();
+    orb->run();
+  }
+  catch (PaCO::PACO_Exception& e)
+  {
+    INFOS("Caught PaCO::PACO_Exception");
+    std::cerr << e << std::endl;
+  }
+  catch(CORBA::SystemException&)
+  {
+    INFOS("Caught CORBA::SystemException.");
+  }
+  catch(PortableServer::POA::ServantAlreadyActive&)
+  {
+    INFOS("Caught CORBA::ServantAlreadyActiveException");
+  }
+  catch(CORBA::Exception&)
+  {
+    INFOS("Caught CORBA::Exception.");
+  }
+  catch(std::exception& exc)
+  {
+    INFOS("Caught std::exception - "<<exc.what()); 
+  }
+  catch(...)
+  {
+    INFOS("Caught unknown exception.");
+  }
+  return 0 ;
 }
 
index 1e9739d6da944489d5b28e1b2d3410ad025c6874..f14b09e1805e17755f3cab92cc78b7ae7fa79c03 100644 (file)
@@ -35,7 +35,8 @@
 #include <process.h>
 #endif
 
-#include "SALOME_ComponentPaCO_Engines_Container_server.h"
+//#include "SALOME_ComponentPaCO_Engines_Container_server.h"
+#include "SALOME_ParallelContainerProxy_i.hxx"
 #include <paco_omni.h>
 #include <paco_mpi.h>
 
@@ -54,113 +55,107 @@ using namespace std;
 #include <signal.h>
 
 void handler(int t) {
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "SIGSEGV in :" << getpid() << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-       while (1) {}
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "SIGSEGV in :" << getpid() << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  while (1) {}
 }
 #endif
 
 int main(int argc, char* argv[])
 {
-       INFOS("Launching a parallel Mpi proxy container");
+  INFOS("Launching a parallel Mpi proxy container");
 
 #ifdef DEBUG_PARALLEL
-       signal(SIGSEGV, handler);
+  signal(SIGSEGV, handler);
 #endif
 
-       // MPI Init
-       int provided;
-       MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED ,&provided);
-       
-       // Initialise the ORB.
-       ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
-       ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
-       CORBA::ORB_var orb = init(0, 0);
-       //CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
-
-       char *containerName = "";
-       if(argc > 1) {
-               containerName = argv[1];
-       }
-
-       char * nb_nodes = "";
-       if(argc > 2) {
-               nb_nodes = argv[2];
-       }
-
-       try {  
-               CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
-               ASSERT(!CORBA::is_nil(obj));
-               PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
-               PortableServer::POAManager_var pman = root_poa->the_POAManager();
+  // MPI Init
+  int provided;
+  MPI_Init_thread(&argc, &argv, MPI_THREAD_SERIALIZED ,&provided);
+  CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
+
+  std::string containerName("");
+  containerName = argv[1];
+  int nb_nodes;
+  sscanf(argv[2],"%d",&nb_nodes);
+
+  try {  
+    CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
+    ASSERT(!CORBA::is_nil(obj));
+    PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
+    PortableServer::POAManager_var pman = root_poa->the_POAManager();
 
 #ifndef WNT
-               // add this container to the kill list
-               char aCommand[100];
-               sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxyMpi", getpid());
-               system(aCommand);
+    // add this container to the kill list
+    char aCommand[100];
+    sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxyMpi", getpid());
+    system(aCommand);
 #endif
 
-               SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
-               Engines::Container_proxy_impl * proxy = new Engines::Container_proxy_impl(CORBA::ORB::_duplicate(orb)); 
-
-               // PaCO++ code
-               paco_fabrique_manager* pfm = paco_getFabriqueManager();
-               // Global context
-               PaCO_operation * global_ptr =  proxy->getContext("global_paco_context");
-               pfm->register_com("mpi", new paco_mpi_fabrique());
-               MPI_Comm group = MPI_COMM_WORLD;
-               global_ptr->setLibCom("mpi", &group);
-               pfm->register_thread("omnithread", new paco_omni_fabrique());
-               global_ptr->setLibThread("omnithread");
-               global_ptr->setTypeClient(true);
-               PaCO::PacoTopology_t client_topo;
-               client_topo.total = 1;
-               global_ptr->setClientTopo(client_topo);
-               PaCO::PacoTopology_t serveur_topo;
-               serveur_topo.total = atoi(nb_nodes);
-               proxy->setTopo(serveur_topo);
-
-               // Activation
-               PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
-               obj = root_poa->id_to_reference(_id);
-
-               // in the NamingService
-               string hostname = GetHostname();
-               Engines::Container_var pCont = Engines::Container::_narrow(obj);
-               string _containerName = ns->BuildContainerNameForNS(containerName,
-                                                                                                                                                                                                                               hostname.c_str());
-               cerr << "---------" << _containerName << "----------" << endl;
-               ns->Register(pCont, _containerName.c_str());
-               pman->activate();
-               orb->run();
-       }
-       catch(CORBA::SystemException&)
-       {
-               INFOS("Caught CORBA::SystemException.");
-       }
-       catch(PortableServer::POA::ServantAlreadyActive&)
-       {
-               INFOS("Caught CORBA::ServantAlreadyActiveException");
-       }
-       catch(CORBA::Exception&)
-       {
-               INFOS("Caught CORBA::Exception.");
-       }
-       catch(std::exception& exc)
-       {
-               INFOS("Caught std::exception - "<<exc.what()); 
-       }
-       catch(...)
-       {
-               INFOS("Caught unknown exception.");
-       }
-
-       MPI_Finalize();
-
-       return 0 ;
+    SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
+//    Engines::Container_proxy_impl * proxy = 
+//      new Engines::Container_proxy_impl(orb, 
+//                                     new paco_omni_fabrique());
+    Container_proxy_impl_final * proxy = 
+      new Container_proxy_impl_final(orb, 
+                                    new paco_omni_fabrique());
+
+    // PaCO++ code
+    paco_fabrique_manager* pfm = paco_getFabriqueManager();
+    pfm->register_com("mpi", new paco_mpi_fabrique());
+    MPI_Comm group = MPI_COMM_WORLD;
+    proxy->setLibCom("mpi", &group);
+    pfm->register_thread("omnithread", new paco_omni_fabrique());
+    proxy->setLibThread("omnithread");
+    PaCO::PacoTopology_t serveur_topo;
+    serveur_topo.total = nb_nodes;
+    proxy->setTopology(serveur_topo);
+
+    // Activation
+    PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
+    obj = root_poa->id_to_reference(_id);
+
+    // in the NamingService
+    string hostname = GetHostname();
+    Engines::Container_var pCont = Engines::Container::_narrow(obj);
+    string _containerName = ns->BuildContainerNameForNS(containerName.c_str(),
+                                                       hostname.c_str());
+    cerr << "---------" << _containerName << "----------" << endl;
+    ns->Register(pCont, _containerName.c_str());
+    pman->activate();
+    orb->run();
+  }
+  catch (PaCO::PACO_Exception& e)
+  {
+    INFOS("Caught PaCO::PACO_Exception");
+    std::cerr << e << std::endl;
+  }
+  catch(CORBA::SystemException&)
+  {
+    INFOS("Caught CORBA::SystemException.");
+  }
+  catch(PortableServer::POA::ServantAlreadyActive&)
+  {
+    INFOS("Caught CORBA::ServantAlreadyActiveException");
+  }
+  catch(CORBA::Exception&)
+  {
+    INFOS("Caught CORBA::Exception.");
+  }
+  catch(std::exception& exc)
+  {
+    INFOS("Caught std::exception - "<<exc.what()); 
+  }
+  catch(...)
+  {
+    INFOS("Caught unknown exception.");
+  }
+
+  MPI_Finalize();
+
+  return 0 ;
 }
 
diff --git a/src/ParallelContainer/SALOME_ParallelContainerProxy_i.cxx b/src/ParallelContainer/SALOME_ParallelContainerProxy_i.cxx
new file mode 100644 (file)
index 0000000..c88588c
--- /dev/null
@@ -0,0 +1,43 @@
+//  SALOME_ParallelContainerProxy : implementation of container and engine for Parallel Kernel
+//
+//  Copyright (C) 2008 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//  File   : SALOME_ParallelContainerProxy_i.cxx
+//  Author : André RIBES, EDF
+
+#include "SALOME_ParallelContainerProxy_i.hxx"
+
+Container_proxy_impl_final::Container_proxy_impl_final(CORBA::ORB_ptr orb, 
+                                                      paco_fabrique_thread * fab_thread, 
+                                                      bool is_a_return_proxy) :
+  Engines::Container_proxy_impl(orb, fab_thread, is_a_return_proxy),
+  InterfaceManager_impl(orb, fab_thread, is_a_return_proxy)
+{}
+
+Container_proxy_impl_final:: ~Container_proxy_impl_final() {}
+
+void
+Container_proxy_impl_final::Shutdown()
+{
+  INFOS("Shutdown Parallel Proxy");
+  if(!CORBA::is_nil(_orb))
+    _orb->shutdown(0);
+}
+
diff --git a/src/ParallelContainer/SALOME_ParallelContainerProxy_i.hxx b/src/ParallelContainer/SALOME_ParallelContainerProxy_i.hxx
new file mode 100644 (file)
index 0000000..77d5914
--- /dev/null
@@ -0,0 +1,44 @@
+//  SALOME_ParallelContainerProxy : implementation of container and engine for Parallel Kernel
+//
+//  Copyright (C) 2008 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//  File   : SALOME_ParallelContainerProxy_i.hxx
+//  Author : André RIBES, EDF
+
+#ifndef _SALOME_PARALLEL_CONTAINER_PROXY_I_HXX_
+#define _SALOME_PARALLEL_CONTAINER_PROXY_I_HXX_
+
+#include "utilities.h"
+#include "SALOME_ComponentPaCO_Engines_Container_server.h"
+
+class Container_proxy_impl_final :
+  public Engines::Container_proxy_impl
+{
+  public:
+    Container_proxy_impl_final(CORBA::ORB_ptr orb, 
+                              paco_fabrique_thread * fab_thread, 
+                              bool is_a_return_proxy = false);
+
+    virtual ~Container_proxy_impl_final();
+
+    virtual void Shutdown();
+};
+
+#endif
index 9fbf89e85cf3f768cb21c205de34a90e45fc96ad..937a2274bf9b6717c5032aa8a066aa129521f121 100644 (file)
@@ -50,6 +50,7 @@
 int SIGUSR1 = 1000;
 #endif
 
+#include <paco_omni.h>
 #include "utilities.h"
 using namespace std;
 
@@ -77,8 +78,11 @@ omni_mutex Engines_Parallel_Container_i::_numInstanceMutex ;
  */
 //=============================================================================
 
-Engines_Parallel_Container_i::Engines_Parallel_Container_i (CORBA::ORB_ptr orb, char * ior) : 
-  InterfaceParallel_impl(orb,ior), Engines::Container_serv(orb,ior),
+Engines_Parallel_Container_i::Engines_Parallel_Container_i (CORBA::ORB_ptr orb, 
+                                                           char * ior, 
+                                                           int rank) : 
+  InterfaceParallel_impl(orb,ior,rank), 
+  Engines::Container_serv(orb,ior,rank),
   _numInstance(0)
 {
 }
@@ -89,14 +93,17 @@ Engines_Parallel_Container_i::Engines_Parallel_Container_i (CORBA::ORB_ptr orb,
  */
 //=============================================================================
 
-Engines_Parallel_Container_i::Engines_Parallel_Container_i (CORBA::ORB_ptr orb, char * ior,
+Engines_Parallel_Container_i::Engines_Parallel_Container_i (CORBA::ORB_ptr orb, 
+                                                           char * ior, 
+                                                           int rank,
                                                            PortableServer::POA_ptr poa,
                                                            char *containerName ,
                                                            int argc , char* argv[],
                                                            bool activAndRegist,
                                                            bool isServantAloneInProcess
                                                           ) :
-  InterfaceParallel_impl(orb,ior), Engines::Container_serv(orb,ior),
+  InterfaceParallel_impl(orb,ior,rank), 
+  Engines::Container_serv(orb,ior,rank),
   _numInstance(0),_isServantAloneInProcess(isServantAloneInProcess)
 {
   _pid = (long)getpid();
@@ -257,7 +264,7 @@ Engines_Parallel_Container_i::load_component_Library(const char* componentName)
   }
 
   // To be sure that all the nodes of the component as loaded the library
-  global_paco_context_ptr->my_com->paco_barrier();
+  _my_com->paco_barrier();
 
   return ret;
 }
@@ -652,6 +659,7 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName,
 
     typedef  PortableServer::ObjectId * (*FACTORY_FUNCTION)
       (CORBA::ORB_ptr,
+       paco_fabrique_thread *,
        PortableServer::POA_ptr,
        PortableServer::ObjectId *, 
        const char *,
@@ -680,7 +688,7 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName,
 
       // --- Instanciate required CORBA object
       PortableServer::ObjectId *id ; //not owner, do not delete (nore use var)
-      id = (Component_factory) ( _orb, _poa, _id, instanceName.c_str(), getTotalNode()) ;
+      id = (Component_factory) ( _orb, new paco_omni_fabrique(), _poa, _id, instanceName.c_str(), getTotalNode()) ;
 
       // --- get reference & servant from id
       CORBA::Object_var obj = _poa->id_to_reference(*id);
@@ -704,11 +712,11 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName,
     // in the nameing service.
     _numInstanceMutex.lock() ; // lock on the instance number
     _numInstance++ ;
-//    int numInstance = _numInstance ;
+    //    int numInstance = _numInstance ;
     _numInstanceMutex.unlock() ;
   }
   cerr << "Node " << getMyRank() << " entering in paco_barrier()" << endl;
-  global_paco_context_ptr->my_com->paco_barrier();
+  _my_com->paco_barrier();
   cerr << "Node " << getMyRank() << " quitting paco_barrier()" << endl;
 
   //////////////////////////////////////////////////////////////////////////
@@ -732,7 +740,7 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName,
   string factory_name = aGenRegisterName + string("Engine_factory");
 
   typedef  PortableServer::ObjectId * (*FACTORY_FUNCTION)
-    (CORBA::ORB_ptr, char * ior,
+    (CORBA::ORB_ptr, char *, int,
      PortableServer::POA_ptr, 
      PortableServer::ObjectId *, 
      const char *, 
@@ -758,7 +766,7 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName,
     // --- Instanciate required CORBA object
 
     PortableServer::ObjectId *id ; //not owner, do not delete (nore use var)
-    id = (Component_factory) ( _orb, proxy_ior, _poa, _id, instanceName.c_str(),
+    id = (Component_factory) ( _orb, proxy_ior, getMyRank(), _poa, _id, instanceName.c_str(),
                               aGenRegisterName.c_str() ) ;
 
     // --- get reference & servant from id
@@ -777,11 +785,17 @@ Engines_Parallel_Container_i::createParallelInstance(string genericRegisterName,
   //////////////////////////////////////////////////////////////////////////
   // 3: Deployment Step
 
-  iobject2->deploy(getMyRank());
-  global_paco_context_ptr->my_com->paco_barrier();
+  iobject2->deploy();
+  _my_com->paco_barrier();
   cerr << "--------- createParallelInstance : End Deploy step ----------" << endl;  
+  if (getMyRank() == 0) {
+    PaCO::InterfaceManager_var proxy = PaCO::InterfaceManager::_narrow(iobject);
+    proxy->start();
+    _my_com->paco_barrier();
+  }
+  else
+    _my_com->paco_barrier();
 
-  //  return obj_proxy._retn();
   return iobject._retn();
 }
 
@@ -954,22 +968,22 @@ Engines_Parallel_Container_i::createFileRef(const char* origFileName)
   Engines::fileRef_var theFileRef = Engines::fileRef::_nil();
 
   if (origName[0] != '/')
-    {
-      INFOS("path of file to copy must be an absolute path begining with '/'");
-      return Engines::fileRef::_nil();
-    }
+  {
+    INFOS("path of file to copy must be an absolute path begining with '/'");
+    return Engines::fileRef::_nil();
+  }
 
   if (CORBA::is_nil(_fileRef_map[origName]))
-    {
-      CORBA::Object_var obj=_poa->id_to_reference(*_id);
-      Engines::Container_var pCont = Engines::Container::_narrow(obj);
-      fileRef_i* aFileRef = new fileRef_i(pCont, origFileName);
-      theFileRef = Engines::fileRef::_narrow(aFileRef->_this());
-      _numInstanceMutex.lock() ; // lock to be alone (stl container write)
-      _fileRef_map[origName] = theFileRef;
-      _numInstanceMutex.unlock() ;
-    }
-  
+  {
+    CORBA::Object_var obj=_poa->id_to_reference(*_id);
+    Engines::Container_var pCont = Engines::Container::_narrow(obj);
+    fileRef_i* aFileRef = new fileRef_i(pCont, origFileName);
+    theFileRef = Engines::fileRef::_narrow(aFileRef->_this());
+    _numInstanceMutex.lock() ; // lock to be alone (stl container write)
+    _fileRef_map[origName] = theFileRef;
+    _numInstanceMutex.unlock() ;
+  }
+
   theFileRef =  Engines::fileRef::_duplicate(_fileRef_map[origName]);
   ASSERT(! CORBA::is_nil(theFileRef));
   return theFileRef._retn();
@@ -996,25 +1010,25 @@ Engines_Parallel_Container_i::createSalome_file(const char* origFileName)
 {
   string origName(origFileName);
   if (CORBA::is_nil(_Salome_file_map[origName]))
+  {
+    Salome_file_i* aSalome_file = new Salome_file_i();
+    try 
     {
-      Salome_file_i* aSalome_file = new Salome_file_i();
-      try 
-      {
-       aSalome_file->setLocalFile(origFileName);
-       aSalome_file->recvFiles();
-      }
-      catch (const SALOME::SALOME_Exception& e)
-      {
-       return Engines::Salome_file::_nil();
-      }
-
-      Engines::Salome_file_var theSalome_file = Engines::Salome_file::_nil();
-      theSalome_file = Engines::Salome_file::_narrow(aSalome_file->_this());
-      _numInstanceMutex.lock() ; // lock to be alone (stl container write)
-      _Salome_file_map[origName] = theSalome_file;
-      _numInstanceMutex.unlock() ;
+      aSalome_file->setLocalFile(origFileName);
+      aSalome_file->recvFiles();
     }
-  
+    catch (const SALOME::SALOME_Exception& e)
+    {
+      return Engines::Salome_file::_nil();
+    }
+
+    Engines::Salome_file_var theSalome_file = Engines::Salome_file::_nil();
+    theSalome_file = Engines::Salome_file::_narrow(aSalome_file->_this());
+    _numInstanceMutex.lock() ; // lock to be alone (stl container write)
+    _Salome_file_map[origName] = theSalome_file;
+    _numInstanceMutex.unlock() ;
+  }
+
   Engines::Salome_file_ptr theSalome_file =  
     Engines::Salome_file::_duplicate(_Salome_file_map[origName]);
   ASSERT(!CORBA::is_nil(theSalome_file));
index 962bc9a1dc2f84604269d412b9e7db6023568301..7eaef5c7b42108920abc2095cc137a9003468b1c 100644 (file)
@@ -64,8 +64,8 @@ class CONTAINER_EXPORT Engines_Parallel_Container_i:
   public virtual PortableServer::RefCountServantBase
 {
 public:
-  Engines_Parallel_Container_i(CORBA::ORB_ptr orb, char * ior);
-  Engines_Parallel_Container_i(CORBA::ORB_ptr orb, char * ior,
+  Engines_Parallel_Container_i(CORBA::ORB_ptr orb, char * ior, int rank);
+  Engines_Parallel_Container_i(CORBA::ORB_ptr orb, char * ior, int rank,
                      PortableServer::POA_ptr poa,
                      char * containerName ,
                       int argc, char* argv[],
index 58eb63d01e395dce9a87c2f7d2331e82fb62ede4..0b85c6bfb8286167c4f141a5b0f0b1ff2b395c5a 100755 (executable)
@@ -137,37 +137,47 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc)
          else
            _resource.Alias = "";
 
-         xmlChar* protocol= xmlGetProp(aCurNode, (const xmlChar*)test_protocol);
-         switch ( protocol[0])
-           {
-           case 'r':
-             _resource.Protocol = rsh;
-             break;
-           case 's':
-             _resource.Protocol = ssh;
-             break;
-           default:
-             // If it'not in all theses cases, the protocol is affected to rsh
-             _resource.Protocol = rsh;
-             break;
-           }
-          xmlFree(protocol);
+         if (xmlHasProp(aCurNode, (const xmlChar*)test_protocol))
+            {
+             xmlChar* protocol= xmlGetProp(aCurNode, (const xmlChar*)test_protocol);
+             switch ( protocol[0])
+               {
+               case 'r':
+                 _resource.Protocol = rsh;
+                 break;
+               case 's':
+                 _resource.Protocol = ssh;
+                 break;
+               default:
+                 // If it'not in all theses cases, the protocol is affected to rsh
+                 _resource.Protocol = rsh;
+                 break;
+               }
+              xmlFree(protocol);
+            }
+          else
+            _resource.Protocol = rsh;
          
-         xmlChar* mode=xmlGetProp(aCurNode, (const xmlChar*)test_mode);
-         switch ( mode[0] )
+         if (xmlHasProp(aCurNode, (const xmlChar*)test_mode))
             {
-            case 'i':
-              _resource.Mode = interactive;
-              break;
-           case 'b':
-              _resource.Mode = batch;
-              break;
-            default:
-              // If it'not in all theses cases, the mode is affected to interactive
-              _resource.Mode = interactive;
-              break;
+             xmlChar* mode=xmlGetProp(aCurNode, (const xmlChar*)test_mode);
+             switch ( mode[0] )
+                {
+                case 'i':
+                  _resource.Mode = interactive;
+                  break;
+               case 'b':
+                  _resource.Mode = batch;
+                  break;
+                default:
+                  // If it'not in all theses cases, the mode is affected to interactive
+                  _resource.Mode = interactive;
+                  break;
+                }
+              xmlFree(mode);
             }
-          xmlFree(mode);
+          else
+            _resource.Mode = interactive;
 
          if (xmlHasProp(aCurNode, (const xmlChar*)test_batch))
             {
index d693227a1bcca41baf1622ffc5823a26661ebbce..f282ac73515099a32713646ef29594b46ba6782c 100644 (file)
@@ -1040,9 +1040,9 @@ SALOME_ResourcesManager::BuildCommandToLaunchLocalParallelContainer(const std::s
     //command = "gdb --args ";
     //command = "valgrind --tool=memcheck --log-file=val_log ";
     //command += real_exe_name;
-    
+
     command = real_exe_name;
-    
+
     command += " " + _NS->ContainerName(rtn);
     command += " " + parallelLib;
     command += " " + hostname;
@@ -1050,7 +1050,7 @@ SALOME_ResourcesManager::BuildCommandToLaunchLocalParallelContainer(const std::s
     AddOmninamesParams(command);
   }
 
-  if (parallelLib == "Mpi")
+  else if (parallelLib == "Mpi")
   {
     // Step 1 : check if MPI is started
     if (_MpiStarted == false)
@@ -1084,6 +1084,11 @@ SALOME_ResourcesManager::BuildCommandToLaunchLocalParallelContainer(const std::s
       AddOmninamesParams(command);
     }
   }
+  else
+  {
+    std::string message("Unknown parallelLib" + parallelLib);
+    throw SALOME_Exception(message.c_str());
+  }
 
   // log choice
   if (log == "default")
index e2646765cd08f36797f334a3df1a5393ad1307de..57c00c16f2dd83273167107e2495e47c59bb0e09 100644 (file)
@@ -136,6 +136,8 @@ SALOMEDS_EXPORT
     SALOMEDS_StudyManager_i * aStudyManager_i = new  SALOMEDS_StudyManager_i(orb, root_poa);
     // Activate the objects.  This tells the POA that the objects are ready to accept requests.
     PortableServer::ObjectId_var aStudyManager_iid =  root_poa->activate_object(aStudyManager_i);
+    //give ownership to the poa : the object will be deleted by the poa
+    aStudyManager_i->_remove_ref();
     aStudyManager_i->register_name("/myStudyManager");
   }
   return new SALOMEDS_StudyManager();
index 321b188cf05dc0b5904547d6b3ee67ea7b95d247..da3a87e2e081394ffb304ed5774e9173cfa56a77 100644 (file)
@@ -117,7 +117,7 @@ public:
 class SALOMEDS_DriverFactory_i : public virtual SALOMEDSImpl_DriverFactory 
 {
 protected:  
-  CORBA::ORB_ptr        _orb;
+  CORBA::ORB_var        _orb;
   SALOME_NamingService* _name_service;
 
 public:
index b2d2dd913e172c59f1aa019a8e90543e2a7a84ab..8ecce2d4b4132c3418ea03788aa61f7a29c6fce0 100644 (file)
@@ -161,6 +161,7 @@ int main(int argc, char** argv)
       // ready to accept requests.
       PortableServer::ObjectId_var myStudyManager_iid = poa->activate_object(myStudyManager_i);
       myStudyManager_i->register_name("/myStudyManager");
+      myStudyManager_i->_remove_ref();
        
       // Obtain a POAManager, and tell the POA to start accepting
       // requests on its objects.
index f06c882ba3a32cfee11065fcb46754cab9b7b4aa..7c5abcb944652f5d1509847e304d8e17661f039c 100644 (file)
@@ -87,6 +87,7 @@ SALOMEDS_StudyManager_i::~SALOMEDS_StudyManager_i()
 {
   // Destroy directory to register open studies
   _name_service->Destroy_Directory("/Study");
+  delete _name_service;
   delete _factory;
   delete _impl;
 }
index 41118c5db6bb02f5ae3c32a5033e77d1beef4b4a..a7ec9b17e3f47080db104cae357414e8b9a3f48a 100644 (file)
@@ -54,7 +54,7 @@ class Standard_EXPORT SALOMEDS_StudyManager_i: public POA_SALOMEDS::StudyManager
 {
 private:
 
-  CORBA::ORB_ptr                    _orb;
+  CORBA::ORB_var                    _orb;
   PortableServer::POA_var           _poa;
   SALOMEDSImpl_StudyManager*        _impl;  
   SALOME_NamingService*             _name_service;
index f76e18ef6dd64f277c0e2dfbbd8c798e583b576c..d64f5eafb47c8d1e0c8a6ba6c4c815555ca884f4 100644 (file)
@@ -182,6 +182,7 @@ FileTraceCollector:: ~FileTraceCollector()
          int ret = pthread_join(*_threadId, NULL);
          if (ret) cerr << "error close FileTraceCollector : "<< ret << endl;
          else DEVTRACE("FileTraceCollector destruction OK");
+          delete _threadId;
          _threadId = 0;
          _threadToClose = 0;
        }
index 408c56d879e9ee0874966f93fdc21e0f5a66b013..73163eea427259b939ec0fd08dbe0e8f2f420545 100644 (file)
@@ -188,6 +188,7 @@ SALOMETraceCollector:: ~SALOMETraceCollector()
          int ret = pthread_join(*_threadId, NULL);
          if (ret) cerr << "error close SALOMETraceCollector : "<< ret << endl;
          else DEVTRACE("SALOMETraceCollector destruction OK");
+          delete _threadId;
          _threadId = 0;
          _threadToClose = 0;
        }
index a2544b6cea186c30e0b0626c64a15e4fe55733e7..c48e4afd95ae8cb15c128a7f711ccd5e752bff74 100644 (file)
@@ -34,6 +34,7 @@
 #include <list>
 #include <cassert>
 #include <omniORB4/CORBA.h>
+#include <iostream>
 //# include "utilities.h"
 
 /*!\class DESTRUCTEUR_GENERIQUE_
@@ -111,11 +112,13 @@ public :
     typedef PortableServer::ServantBase TServant;
     if(_PtrObjet){
       if(TServant* aServant = dynamic_cast<TServant*>(_PtrObjet)){
-       //cerr << "DESTRUCTEUR_GENERIQUE_::operator() deleting ServantBase's _PtrObjet" << endl;
+        std::cerr << "WARNING: automatic destruction for servant is no more used. It's too late in exit. Use explicit call" << std::endl;
+  /*
        PortableServer::POA_var aPOA = aServant->_default_POA();
        PortableServer::ObjectId_var anObjectId = aPOA->servant_to_id(aServant);
        aPOA->deactivate_object(anObjectId.in());
        aServant->_remove_ref();
+  */
       }else{
        //cerr << "DESTRUCTEUR_GENERIQUE_::operator() deleting _PtrObjet" << endl;
        TYPE* aPtr = static_cast<TYPE*>(_PtrObjet);
index 1cb869e1192e5f5250b6a1625772d15ebf00cffc..e2649a580f656c416c6ed8170edc5d595ae705e3 100644 (file)
@@ -40,13 +40,16 @@ ORB_INIT::~ORB_INIT()
 {
   if ( ! CORBA::is_nil( _orb ) )
   {
+    std::cerr << "WARNING: orb destroy is no more called at exit. Use explicit call." << std::endl;
     //std::cerr << "appel _orb->destroy()" << std::endl;
+    /*
     try {
       _orb->destroy() ;
     }
     catch(...) {
       MESSAGE("Caught CORBA::Exception.");
     }
+    */
     //std::cerr << "retour _orb->destroy()" << std::endl;
   }
 }