<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()
# Initialise the ORB
self.orb=CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
# Initialise the Naming Service
- self.initNS(args)
+ self.initNS(args or {})
# --------------------------------------------------------------------------
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):
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")]
include $(top_srcdir)/salome_adm/unix/make_common_starter.am
+if WITH_PACO_PARALLEL
+MAKEFLAGS = -j1
+endif
+
AM_CXXFLAGS = -fPIC
BASEIDL_FILES = \
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 \
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)
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@
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
/*!
Shutdown the Container process.
*/
- oneway void Shutdown();
+ void Shutdown();
/*!
Returns the hostname of the container
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.*/
} ;
*/
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
*/
string name;
string username;
boolean multistudy;
- boolean implementationType;
+ ImplType implementationType;
+ string implname;
string icon;
string constraint;
ListOfDefInterface interfaces;
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
<!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>
<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>
# 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)
+++ /dev/null
-# 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)
-
+++ /dev/null
-// 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());
- }
- }
-
-}
+++ /dev/null
-// 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
+++ /dev/null
-// 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;
- }
-
-}
+++ /dev/null
-// 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
+++ /dev/null
-// 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;
- }
-
-}
+++ /dev/null
-// 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
+++ /dev/null
-// 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");
- }
-
-}
+++ /dev/null
-// 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
pthread_mutex_t BatchManagerCatalog::_mutex = PTHREAD_MUTEX_INITIALIZER;
std::map<string, FactBatchManager *> * BatchManagerCatalog::_p_catalog = 0;
+ BatchManagerCatalog BatchManagerCatalog::theCatalog;
// Constructeur
BatchManagerCatalog::BatchManagerCatalog()
// Destructeur
BatchManagerCatalog::~BatchManagerCatalog()
{
- // Nothing to do
+ delete BatchManagerCatalog::_p_catalog;
}
// Functor
virtual std::string __repr__() const;
protected:
+ static BatchManagerCatalog theCatalog;
static std::map<std::string, FactBatchManager *> * _p_catalog;
static pthread_mutex_t _mutex;
_sec = p_tm->tm_sec;
} else {
- char c;
+// char c;
// istringstream ist(s);
// ist >> _day >> c
// >> _month >> c
*
*/
-#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 {
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;
}
} else { // un scalaire
- char ch[2] = {0, 0};
+// char ch[2] = {0, 0};
string st;
Couple cp;
// PyObject * tuple;
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 = \
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 \
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
#
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)
+++ /dev/null
-// 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 "";
-}
-
+++ /dev/null
-// 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
delete _myConnexionToRegistry;
_myConnexionToRegistry = 0 ;
_poa->deactivate_object(*_id) ;
- CORBA::release(_poa) ;
delete(_id) ;
//SCRUTE(pd_refCount);
_thisObj->_remove_ref();
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);
}
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);
}
//=============================================================================
//=============================================================================
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,
{
_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());
}
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();
}
}
{
MESSAGE("Container_i::~Container_i()");
delete _id;
+ if(_NS)
+ delete _NS;
}
//=============================================================================
if(_isServantAloneInProcess)
{
MESSAGE("Effective Shutdown of container Begins...");
- LocalTraceBufferPool* bp1 = LocalTraceBufferPool::instance();
- bp1->deleteInstance(bp1);
if(!CORBA::is_nil(_orb))
_orb->shutdown(0);
}
instanceName.c_str(),
studyId);
string iors = PyString_AsString(result);
+ Py_DECREF(result);
SCRUTE(iors);
Py_RELEASE_NEW_THREAD;
{
CORBA::Object_var obj = _orb->string_to_object(iors.c_str());
iobject = Engines::Component::_narrow( obj ) ;
+ _listInstances_map[instanceName] = iobject;
}
return iobject._retn();
}
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);
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')
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)
#-------------------------------------------------------------------------
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 ;
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]);
// 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
#endif
HandleServerSideSignals(orb);
-
+
+ PyGILState_STATE gstate = PyGILState_Ensure();
+ //Delete python container that destroy orb from python (pyCont._orb.destroy())
+ Py_Finalize();
}
catch(CORBA::SystemException&)
{
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 *
#-------------------------------------------------------------------------
+ def __del__(self ):
+ self._orb.destroy()
+
def import_component(self, componentName):
MESSAGE( "SALOME_Container_i::import_component" )
ret=0
_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();
}
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));
}
}
}
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
const Engines::MachineList& possibleComputers)
{
CORBA::Object_var obj;
+ PaCO::InterfaceManager_var proxy;
Engines::Container_ptr ret = Engines::Container::_nil();
Engines::MachineParameters params(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 == "") {
// 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)
{
}
INFOS("[FindOrStartParallelContainer] node " << name << " deployed");
}
-
else {
INFOS("[FindOrStartParallelContainer] Currently parallel containers are launched only on the local host");
}
}
- }
- return ret;
+}
+return ret;
}
#else
//=============================================================================
{
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());
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) ;
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,
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);
_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
# define DF_EXPORT
#endif
-#include <iostream.h>
+#include <iostream>
#include <stdio.h>
#include <boost/shared_ptr.hpp>
#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)
{
}
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;
}
{
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;
{
CORBA::Boolean rtn_bool = false;
PaCO::InterfaceParallel_var node = PaCO::InterfaceParallel::_narrow(ref);
- node->deploy(getMyRank());
+ node->deploy();
rtn_bool = true;
return rtn_bool;
}
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,
#--------------------------------------------------------------------------
-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
--- /dev/null
+// 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());
+ }
+ }
+
+}
--- /dev/null
+// 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
--- /dev/null
+// 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;
+ }
+
+}
--- /dev/null
+// 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
--- /dev/null
+// 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;
+ }
+
+}
--- /dev/null
+// 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
--- /dev/null
+// 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");
+ }
+
+}
--- /dev/null
+// 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
#
# 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
#
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)
--- /dev/null
+// 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 "";
+}
+
--- /dev/null
+// 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
SCRUTE(toFollow);
CORBA::Octet *buf = aBlock->get_buffer();
int nbWri = fwrite(buf, sizeof(CORBA::Octet), toFollow, fp);
+ delete aBlock;
ASSERT(nbWri == toFollow);
}
fclose(fp);
//----------------------------------------------------------------------
// 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
*/
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 :
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";
// 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) )
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;
std::string constraint;
ParserInterfaces interfaces;
ParserPathPrefixes prefixes;
- bool implementationType;
+ std::string implementationType;
+ std::string implementationName;
std::string version;
std::string comment;
};
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"]
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);
(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 ???
// 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;
ParserComponents _personal_module_list ;
ParserPathPrefixes _personal_path_list ;
- std::map <std::string, SALOME_ModuleCatalog::DataStreamType>
- DataStreamTypeConvert;
-
std::map <std::string, SALOME_ModuleCatalog::DataStreamDependency>
DataStreamDepConvert;
{
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
if (binding->binding_type == CosNaming::ncontext)
{
- dirList.push_back(CORBA::string_dup(bindingName[0].id));
+ dirList.push_back(bindingName[0].id.in());
}
}
NSTEST_echo_i * anEcho = new NSTEST_echo_i(_num);
_num++;
NSTEST::echo_var anEchoRef = anEcho->_this();
+ anEcho->_remove_ref();
return anEchoRef._retn();
}
_myFactoryId = _root_poa->activate_object(_myFactory);
_factoryRef = _myFactory->_this();
_pman->activate();
+ _myFactory->_remove_ref();
}
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 =
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);
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);
}
{
char *root = _NS.getIORaddr();
CORBA::Object_var obj = _orb->string_to_object(root);
+ delete [] root;
CPPUNIT_ASSERT(!CORBA::is_nil(obj));
}
# 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
# header files
salomeinclude_HEADERS = SALOME_ParallelComponent_i.hxx \
SALOME_ParallelContainer_i.hxx \
+ SALOME_ParallelContainerProxy_i.hxx \
Parallel_Salome_file_i.hxx
#
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
#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);
// 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
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);
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);
#endif
#include <paco_dummy.h>
+#include <paco_omni.h>
using namespace std;
*/
//=============================================================================
-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...");
*/
//=============================================================================
-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),
// 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
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());
// 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.
// 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
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
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,
#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
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)
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 ;
}
#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
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)
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;
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 ;
}
#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 ;
}
#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>
#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 ;
}
--- /dev/null
+// 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);
+}
+
--- /dev/null
+// 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
int SIGUSR1 = 1000;
#endif
+#include <paco_omni.h>
#include "utilities.h"
using namespace std;
*/
//=============================================================================
-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)
{
}
*/
//=============================================================================
-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();
}
// 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;
}
typedef PortableServer::ObjectId * (*FACTORY_FUNCTION)
(CORBA::ORB_ptr,
+ paco_fabrique_thread *,
PortableServer::POA_ptr,
PortableServer::ObjectId *,
const char *,
// --- 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);
// 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;
//////////////////////////////////////////////////////////////////////////
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 *,
// --- 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
//////////////////////////////////////////////////////////////////////////
// 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();
}
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();
{
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));
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[],
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))
{
//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;
AddOmninamesParams(command);
}
- if (parallelLib == "Mpi")
+ else if (parallelLib == "Mpi")
{
// Step 1 : check if MPI is started
if (_MpiStarted == false)
AddOmninamesParams(command);
}
}
+ else
+ {
+ std::string message("Unknown parallelLib" + parallelLib);
+ throw SALOME_Exception(message.c_str());
+ }
// log choice
if (log == "default")
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();
class SALOMEDS_DriverFactory_i : public virtual SALOMEDSImpl_DriverFactory
{
protected:
- CORBA::ORB_ptr _orb;
+ CORBA::ORB_var _orb;
SALOME_NamingService* _name_service;
public:
// 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.
{
// Destroy directory to register open studies
_name_service->Destroy_Directory("/Study");
+ delete _name_service;
delete _factory;
delete _impl;
}
{
private:
- CORBA::ORB_ptr _orb;
+ CORBA::ORB_var _orb;
PortableServer::POA_var _poa;
SALOMEDSImpl_StudyManager* _impl;
SALOME_NamingService* _name_service;
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;
}
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;
}
#include <list>
#include <cassert>
#include <omniORB4/CORBA.h>
+#include <iostream>
//# include "utilities.h"
/*!\class DESTRUCTEUR_GENERIQUE_
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);
{
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;
}
}