ACLOCAL_AMFLAGS = -I salome_adm/unix/config_files
-SUBDIRS = salome_adm $(IDLDIR) src doc bin resources
+if WITHONLYLAUNCHER
+ SUBDIRS = src resources
+else
+ SUBDIRS = salome_adm $(IDLDIR) src doc bin resources
+endif
DIST_SUBDIRS= salome_adm idl src doc bin resources
#
#clean appli
-rm -rf bin lib share doc env.d envd getAppliPath.py searchFreePort.sh runAppli runConsole runSession runRemote.sh runTests SalomeApp.xml *.pyc *~ .bashrc
+rm -rf bin lib share doc idl env.d envd getAppliPath.py searchFreePort.sh runAppli runConsole runSession runRemote.sh runTests SalomeApp.xml *.pyc *~ .bashrc
esac],[corba_gen=true])
AM_CONDITIONAL(CORBA_GEN, test x$corba_gen = xtrue)
+# ---- option to build only launcher, resources manager and batch classes
+AC_ARG_WITH(onlylauncher,
+ --with-onlylauncher,
+ WITHONLYLAUNCHER="yes",WITHONLYLAUNCHER="no")
+AM_CONDITIONAL(WITHONLYLAUNCHER, test x$WITHONLYLAUNCHER = xyes)
+
# ----------------------------------------------------------------------------
echo
AM_PATH_PYTHON(2.3)
CHECK_SWIG
+echo
+echo ---------------------------------------------
+echo Testing libxml2
+echo ---------------------------------------------
+echo
+
+CHECK_LIBXML
+
+if test x$WITHONLYLAUNCHER = xno; then
echo
echo ---------------------------------------------
echo testing HDF5
CHECK_BOOST
-echo
-echo ---------------------------------------------
-echo Testing libxml2
-echo ---------------------------------------------
-echo
-
-CHECK_LIBXML
-
fi
# --- end test corba
# ----------------------------------------------------------------------------
+fi
+# --- end test ONLYLAUNCHER
+# ----------------------------------------------------------------------------
+
echo
echo ============================================================
echo testing parallel products
# --------------------------------------
-if test x$corba_gen = xtrue; then
- basic_mandatory_products="cc_ok threads_ok python_ok swig_ok hdf5_ok"
+if test x$WITHONLYLAUNCHER = xno; then
+ if test x$corba_gen = xtrue; then
+ basic_mandatory_products="cc_ok threads_ok python_ok swig_ok hdf5_ok libxml_ok"
+ else
+ basic_mandatory_products="cc_ok threads_ok hdf5_ok libxml_ok"
+ fi
else
- basic_mandatory_products="cc_ok threads_ok hdf5_ok"
+ basic_mandatory_products="cc_ok threads_ok libxml_ok"
fi
echo --- General mandatory products - Light configuration:
check_fatal_error $basic_mandatory_products
echo
-corba_mandatory_products="omniORB_ok omniORBpy_ok boost_ok libxml_ok"
-if test x$corba_gen = xtrue; then
- echo --- CORBA mandatory products - default configuration:
- summary $corba_mandatory_products
- check_fatal_error $corba_mandatory_products
-else
- echo --- CORBA products not required - option --disable-corba-gen
- if test x"$WITH_BATCH" = xyes; then
- echo --- BATCH mode mandatory products - default configuration:
- summary "python_ok"
- check_fatal_error "python_ok"
- else
+if test x$WITHONLYLAUNCHER = xno; then
+ corba_mandatory_products="omniORB_ok omniORBpy_ok boost_ok"
+ if test x$corba_gen = xtrue; then
+ echo --- CORBA mandatory products - default configuration:
+ summary $corba_mandatory_products
+ check_fatal_error $corba_mandatory_products
+ else
+ echo --- CORBA products not required - option --disable-corba-gen
+ if test x"$WITH_BATCH" = xyes; then
+ echo --- BATCH mode mandatory products - default configuration:
+ summary "python_ok"
+ check_fatal_error "python_ok"
+ else
echo --- Python not required - option --enable-batch=no
+ fi
fi
fi
echo
summary $htmldoc_products
echo
+if test x$WITHONLYLAUNCHER = xno; then
echo
echo "Default ORB : $DEFAULT_ORB"
echo
+fi
dnl generals files which could be included in every makefile
AC_SUBST(SETX) SETX="set -x"
fi
+if test x$WITHONLYLAUNCHER = xno; then
+echo
+echo ---------------------------------------------
+echo copying resource files, shell scripts, and
+echo xml files
+echo ---------------------------------------------
+echo
+
+
+mkdir -p bin/salome
+cd bin/salome
+for i in `find $ROOT_SRCDIR/bin`
+do
+ local_bin=`echo $i | sed -e "s,$ROOT_SRCDIR/bin,.,"`
+ case "$local_bin" in
+ *.in | *~) ;;
+ . | */CVS | */CVS/* | ./salome) ;;
+ ./appliskel |./appliskel/env.d) $INSTALL -d $local_bin ; echo $local_bin ;;
+ *) $INSTALL $i $local_bin; echo $local_bin ;;
+ esac
+done
+cd $ROOT_BUILDDIR
+
+AC_OUTPUT_COMMANDS([ \
+ chmod +x ./bin/*; \
+ chmod +x ./bin/salome/* \
+])
+fi
+
echo
echo ---------------------------------------------
echo generating Makefiles and configure files
./src/Utils/Makefile \
./src/Utils/Test/Makefile \
])
-
*/
interface SalomeLauncher
{
+ long submitJob( in string xmlExecuteFile,
+ in string clusterName ) raises (SALOME::SALOME_Exception);
long submitSalomeJob( in string fileToExecute,
in FilesList filesToExport,
in FilesList filesToImport,
in BatchParameters batch_params,
in MachineParameters params ) raises (SALOME::SALOME_Exception);
- string querySalomeJob( in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception);
- void deleteSalomeJob( in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception);
- void getResultSalomeJob( in string directory, in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception);
+ string queryJob( in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception);
+ void deleteJob( in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception);
+ void getResultsJob( in string directory, in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception);
boolean testBatch(in MachineParameters params) raises (SALOME::SALOME_Exception);
DEPRECATED_FILES=
-dist_salomeres_DATA=\
+if WITHONLYLAUNCHER
+ dist_salomeres_DATA=\
+ CatalogResources.xml
+else
+ dist_salomeres_DATA=\
CatalogResources.xml \
config \
channel.cfg \
KERNELCatalog.xml \
SALOMEDS_Resources \
$(DEPRECATED_FILES)
+endif
// Second step : copy fileToExecute into
// batch tmp files directory
- command = copy_command;
- command += string(params[EXECUTABLE]);
- command += " ";
- if(_username != ""){
- command += _username;
- command += "@";
- }
- command += _hostname;
- command += ":";
- command += string(params[TMPDIR]);
- cerr << command.c_str() << endl;
- status = system(command.c_str());
- if(status) {
- std::ostringstream oss;
- oss << status;
- std::string ex_mess("Error of connection on remote host ! status = ");
- ex_mess += oss.str();
- throw EmulationException(ex_mess.c_str());
+ string executeFile = params[EXECUTABLE];
+ if( executeFile.size() > 0 ){
+ command = copy_command;
+ command += string(params[EXECUTABLE]);
+ command += " ";
+ if(_username != ""){
+ command += _username;
+ command += "@";
+ }
+ command += _hostname;
+ command += ":";
+ command += string(params[TMPDIR]);
+ cerr << command.c_str() << endl;
+ status = system(command.c_str());
+ if(status) {
+ std::ostringstream oss;
+ oss << status;
+ std::string ex_mess("Error of connection on remote host ! status = ");
+ ex_mess += oss.str();
+ throw EmulationException(ex_mess.c_str());
+ }
}
// Third step : copy filesToExportList into
return new MpiImpl_OPENMPI();
else if(mpiImpl == "slurm")
return new MpiImpl_SLURM();
+ else if(mpiImpl == "nompi")
+ throw EmulationException("you must specified an mpi implementation for batch manager");
else{
ostringstream oss;
oss << mpiImpl << " : not yet implemented";
{
public:
// Constructeur et destructeur
- BatchManager_eClient(const Batch::FactBatchManager * parent, const char* host="localhost", const char* protocol="ssh", const char* mpiImpl="indif");
+ BatchManager_eClient(const Batch::FactBatchManager * parent, const char* host="localhost", const char* protocol="ssh", const char* mpiImpl="mpich1");
virtual ~BatchManager_eClient();
void importOutputFiles( const Job & job, const std::string directory ) throw(EmulationException);
Parametre params = job.getParametre();
const std::string dirForTmpFiles = params[TMPDIR];
const string fileToExecute = params[EXECUTABLE];
- string::size_type p1 = fileToExecute.find_last_of("/");
- string::size_type p2 = fileToExecute.find_last_of(".");
- std::string fileNameToExecute = fileToExecute.substr(p1+1,p2-p1-1);
+ std::string fileNameToExecute;
+ if( fileToExecute.size() > 0 ){
+ string::size_type p1 = fileToExecute.find_last_of("/");
+ string::size_type p2 = fileToExecute.find_last_of(".");
+ fileNameToExecute = fileToExecute.substr(p1+1,p2-p1-1);
+ }
+ else
+ fileNameToExecute = "command";
// export input files on cluster
exportInputFiles(job);
#ifndef WIN32 //TODO: need for porting on Windows
int status;
Parametre params = job.getParametre();
+ Environnement env = job.getEnvironnement();
const int nbproc = params[NBPROC];
const long edt = params[MAXWALLTIME];
const long mem = params[MAXRAMSIZE];
const string workDir = params[WORKDIR];
const std::string dirForTmpFiles = params[TMPDIR];
const string fileToExecute = params[EXECUTABLE];
- string::size_type p1 = fileToExecute.find_last_of("/");
- string::size_type p2 = fileToExecute.find_last_of(".");
- std::string rootNameToExecute = fileToExecute.substr(p1+1,p2-p1-1);
- std::string fileNameToExecute = "~/" + dirForTmpFiles + "/" + string(basename(fileToExecute.c_str()));
-
- int idx = dirForTmpFiles.find("Batch/");
- std::string filelogtemp = dirForTmpFiles.substr(idx+6, dirForTmpFiles.length());
+ const string home = params[HOMEDIR];
+ std::string rootNameToExecute;
+ std::string fileNameToExecute;
+ std::string filelogtemp;
+ if( fileToExecute.size() > 0 ){
+ string::size_type p1 = fileToExecute.find_last_of("/");
+ string::size_type p2 = fileToExecute.find_last_of(".");
+ rootNameToExecute = fileToExecute.substr(p1+1,p2-p1-1);
+ fileNameToExecute = "~/" + dirForTmpFiles + "/" + string(basename(fileToExecute.c_str()));
+
+ int idx = dirForTmpFiles.find("Batch/");
+ filelogtemp = dirForTmpFiles.substr(idx+6, dirForTmpFiles.length());
+ }
+ else{
+ rootNameToExecute = "command";
+ }
std::string TmpFileName = BuildTemporaryFileName();
ofstream tempOutputFile;
if( mem > 0 )
tempOutputFile << "#BSUB -M " << mem*1024 << endl ;
tempOutputFile << "#BSUB -n " << nbproc << endl ;
- tempOutputFile << "#BSUB -o runSalome.output.log." << filelogtemp << endl ;
- tempOutputFile << "#BSUB -e runSalome.error.log." << filelogtemp << endl ;
+ if( fileToExecute.size() > 0 ){
+ tempOutputFile << "#BSUB -o " << home << "/" << dirForTmpFiles << "/output.log." << filelogtemp << endl ;
+ tempOutputFile << "#BSUB -e " << home << "/" << dirForTmpFiles << "/error.log." << filelogtemp << endl ;
+ }
+ else{
+ tempOutputFile << "#BSUB -o " << dirForTmpFiles << "/" << env["LOGFILE"] << ".output.log" << endl ;
+ tempOutputFile << "#BSUB -e " << dirForTmpFiles << "/" << env["LOGFILE"] << ".error.log" << endl ;
+ }
if( workDir.size() > 0 )
tempOutputFile << "cd " << workDir << endl ;
- tempOutputFile << _mpiImpl->boot("",nbproc);
- tempOutputFile << _mpiImpl->run("",nbproc,fileNameToExecute);
- tempOutputFile << _mpiImpl->halt();
+ if( fileToExecute.size() > 0 ){
+ tempOutputFile << _mpiImpl->boot("",nbproc);
+ tempOutputFile << _mpiImpl->run("",nbproc,fileNameToExecute);
+ tempOutputFile << _mpiImpl->halt();
+ }
+ else{
+ tempOutputFile << "source " << env["SOURCEFILE"] << endl ;
+ tempOutputFile << env["COMMAND"];
+ }
+
tempOutputFile.flush();
tempOutputFile.close();
#ifdef WIN32
{
public:
// Constructeur et destructeur
- BatchManager_eLSF(const FactBatchManager * parent, const char * host="localhost", const char * protocol="ssh", const char * mpiImpl="indif") throw(InvalidArgumentException,ConnexionFailureException); // connexion a la machine host
+ BatchManager_eLSF(const FactBatchManager * parent, const char * host="localhost", const char * protocol="ssh", const char * mpiImpl="nompi") throw(InvalidArgumentException,ConnexionFailureException); // connexion a la machine host
virtual ~BatchManager_eLSF();
// Recupere le nom du serveur par defaut
#ifndef WIN32 //TODO: need for porting on Windows
int status;
Parametre params = job.getParametre();
+ Environnement env = job.getEnvironnement();
const long nbproc = params[NBPROC];
const long edt = params[MAXWALLTIME];
const long mem = params[MAXRAMSIZE];
const std::string dirForTmpFiles = params[TMPDIR];
const string fileToExecute = params[EXECUTABLE];
const string home = params[HOMEDIR];
- string::size_type p1 = fileToExecute.find_last_of("/");
- string::size_type p2 = fileToExecute.find_last_of(".");
- std::string rootNameToExecute = fileToExecute.substr(p1+1,p2-p1-1);
- std::string fileNameToExecute = "~/" + dirForTmpFiles + "/" + string(basename(fileToExecute.c_str()));
-
- int idx = dirForTmpFiles.find("Batch/");
- std::string filelogtemp = dirForTmpFiles.substr(idx+6, dirForTmpFiles.length());
+ std::string rootNameToExecute;
+ std::string fileNameToExecute;
+ std::string filelogtemp;
+ if( fileToExecute.size() > 0 ){
+ string::size_type p1 = fileToExecute.find_last_of("/");
+ string::size_type p2 = fileToExecute.find_last_of(".");
+ rootNameToExecute = fileToExecute.substr(p1+1,p2-p1-1);
+ fileNameToExecute = "~/" + dirForTmpFiles + "/" + string(basename(fileToExecute.c_str()));
+
+ int idx = dirForTmpFiles.find("Batch/");
+ filelogtemp = dirForTmpFiles.substr(idx+6, dirForTmpFiles.length());
+ }
+ else{
+ rootNameToExecute = "command";
+ }
std::string TmpFileName = BuildTemporaryFileName();
ofstream tempOutputFile;
tempOutputFile << "#PBS -l walltime=" << edt*60 << endl ;
if( mem > 0 )
tempOutputFile << "#PBS -l mem=" << mem << "mb" << endl ;
- tempOutputFile << "#PBS -o " << home << "/" << dirForTmpFiles << "/runSalome.output.log." << filelogtemp << endl ;
- tempOutputFile << "#PBS -e " << home << "/" << dirForTmpFiles << "/runSalome.error.log." << filelogtemp << endl ;
+ if( fileToExecute.size() > 0 ){
+ tempOutputFile << "#PBS -o " << home << "/" << dirForTmpFiles << "/output.log." << filelogtemp << endl ;
+ tempOutputFile << "#PBS -e " << home << "/" << dirForTmpFiles << "/error.log." << filelogtemp << endl ;
+ }
+ else{
+ tempOutputFile << "#PBS -o " << dirForTmpFiles << "/" << env["LOGFILE"] << ".output.log" << endl ;
+ tempOutputFile << "#PBS -e " << dirForTmpFiles << "/" << env["LOGFILE"] << ".error.log" << endl ;
+ }
if( workDir.size() > 0 )
tempOutputFile << "cd " << workDir << endl ;
- tempOutputFile << _mpiImpl->boot("${PBS_NODEFILE}",nbproc);
- tempOutputFile << _mpiImpl->run("${PBS_NODEFILE}",nbproc,fileNameToExecute);
- tempOutputFile << _mpiImpl->halt();
+ if( fileToExecute.size() > 0 ){
+ tempOutputFile << _mpiImpl->boot("${PBS_NODEFILE}",nbproc);
+ tempOutputFile << _mpiImpl->run("${PBS_NODEFILE}",nbproc,fileNameToExecute);
+ tempOutputFile << _mpiImpl->halt();
+ }
+ else{
+ tempOutputFile << "source " << env["SOURCEFILE"] << endl ;
+ tempOutputFile << env["COMMAND"];
+ }
+
tempOutputFile.flush();
tempOutputFile.close();
#ifdef WIN32
{
public:
// Constructeur et destructeur
- BatchManager_ePBS(const FactBatchManager * parent, const char * host="localhost", const char * protocol="ssh", const char * mpiImpl="indif") throw(InvalidArgumentException,ConnexionFailureException); // connexion a la machine host
+ BatchManager_ePBS(const FactBatchManager * parent, const char * host="localhost", const char * protocol="ssh", const char * mpiImpl="nompi") throw(InvalidArgumentException,ConnexionFailureException); // connexion a la machine host
virtual ~BatchManager_ePBS();
// Recupere le nom du serveur par defaut
--- /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_eSGE.cxx : emulation of SGE client
+ *
+ * Auteur : Bernard SECHER - CEA DEN
+ * Mail : mailto:bernard.secher@cea.fr
+ * Date : Thu Apr 24 10:17:22 2008
+ * Projet : PAL Salome
+ *
+ */
+
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <sys/stat.h>
+#include "Batch_BatchManager_eSGE.hxx"
+
+using namespace std;
+
+namespace Batch {
+
+ BatchManager_eSGE::BatchManager_eSGE(const FactBatchManager * parent, const char * host, const char * protocol, const char * mpiImpl) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager_eClient(parent,host,protocol,mpiImpl)
+ {
+ // Nothing to do
+ }
+
+ // Destructeur
+ BatchManager_eSGE::~BatchManager_eSGE()
+ {
+ // Nothing to do
+ }
+
+ // Methode pour le controle des jobs : soumet un job au gestionnaire
+ const JobId BatchManager_eSGE::submitJob(const Job & job)
+ {
+ int status;
+ Parametre params = job.getParametre();
+ const std::string dirForTmpFiles = params[TMPDIR];
+ const string fileToExecute = params[EXECUTABLE];
+ string::size_type p1 = fileToExecute.find_last_of("/");
+ string::size_type p2 = fileToExecute.find_last_of(".");
+ std::string fileNameToExecute = fileToExecute.substr(p1+1,p2-p1-1);
+
+ // export input files on cluster
+ exportInputFiles(job);
+
+ // build batch script for job
+ buildBatchScript(job);
+
+ // 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;
+
+ // define command to submit batch
+ command = _protocol;
+ command += " ";
+
+ if(_username != ""){
+ command += _username;
+ command += "@";
+ }
+
+ command += _hostname;
+ command += " \"cd " ;
+ command += dirForTmpFiles ;
+ command += "; qsub " ;
+ command += fileNameToExecute ;
+ command += "_Batch.sh\" > ";
+ command += logFile;
+ cerr << command.c_str() << endl;
+ status = system(command.c_str());
+ if(status)
+ throw EmulationException("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 strjob;
+ istringstream iss(line);
+ iss >> strjob >> strjob >> strjob;
+
+ JobId id(this, strjob);
+ return id;
+ }
+
+ // Methode pour le controle des jobs : retire un job du gestionnaire
+ void BatchManager_eSGE::deleteJob(const JobId & jobid)
+ {
+ int status;
+ int ref;
+ istringstream iss(jobid.getReference());
+ iss >> ref;
+
+ // define command to submit batch
+ string command;
+ command = _protocol;
+ command += " ";
+
+ if (_username != ""){
+ command += _username;
+ command += "@";
+ }
+
+ command += _hostname;
+ command += " \"qdel " ;
+ command += iss.str();
+ command += "\"";
+ cerr << command.c_str() << endl;
+ status = system(command.c_str());
+ if(status)
+ throw EmulationException("Error of connection on remote host");
+
+ cerr << "jobId = " << ref << "killed" << endl;
+ }
+
+ // Methode pour le controle des jobs : suspend un job en file d'attente
+ void BatchManager_eSGE::holdJob(const JobId & jobid)
+ {
+ throw EmulationException("Not yet implemented");
+ }
+
+ // Methode pour le controle des jobs : relache un job suspendu
+ void BatchManager_eSGE::releaseJob(const JobId & jobid)
+ {
+ throw EmulationException("Not yet implemented");
+ }
+
+
+ // Methode pour le controle des jobs : modifie un job en file d'attente
+ void BatchManager_eSGE::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env)
+ {
+ throw EmulationException("Not yet implemented");
+ }
+
+ // Methode pour le controle des jobs : modifie un job en file d'attente
+ void BatchManager_eSGE::alterJob(const JobId & jobid, const Parametre & param)
+ {
+ alterJob(jobid, param, Environnement());
+ }
+
+ // Methode pour le controle des jobs : modifie un job en file d'attente
+ void BatchManager_eSGE::alterJob(const JobId & jobid, const Environnement & env)
+ {
+ alterJob(jobid, Parametre(), env);
+ }
+
+ // Methode pour le controle des jobs : renvoie l'etat du job
+ JobInfo BatchManager_eSGE::queryJob(const JobId & jobid)
+ {
+ int id;
+ istringstream iss(jobid.getReference());
+ iss >> id;
+
+ // define name of log file
+ string logFile="/tmp/logs/";
+ logFile += getenv("USER");
+ logFile += "/batchSalome_";
+
+ ostringstream oss;
+ oss << this << "_" << id;
+ logFile += oss.str();
+ logFile += ".log";
+
+ string command;
+ int status;
+
+ // define command to submit batch
+ command = _protocol;
+ command += " ";
+
+ if (_username != ""){
+ command += _username;
+ command += "@";
+ }
+
+ command += _hostname;
+ command += " \"qstat | grep " ;
+ command += iss.str();
+ command += "\" > ";
+ command += logFile;
+ cerr << command.c_str() << endl;
+ status = system(command.c_str());
+ if(status && status != 256)
+ throw EmulationException("Error of connection on remote host");
+
+ JobInfo_eSGE ji = JobInfo_eSGE(id,logFile);
+ return ji;
+ }
+
+ // Methode pour le controle des jobs : teste si un job est present en machine
+ bool BatchManager_eSGE::isRunning(const JobId & jobid)
+ {
+ throw EmulationException("Not yet implemented");
+ }
+
+ void BatchManager_eSGE::buildBatchScript(const Job & job) throw(EmulationException)
+ {
+ int status;
+ Parametre params = job.getParametre();
+ Environnement env = job.getEnvironnement();
+ const long nbproc = params[NBPROC];
+ const long edt = params[MAXWALLTIME];
+ const long mem = params[MAXRAMSIZE];
+ const string workDir = params[WORKDIR];
+ const std::string dirForTmpFiles = params[TMPDIR];
+ const string fileToExecute = params[EXECUTABLE];
+ const string home = params[HOMEDIR];
+ std::string rootNameToExecute;
+ std::string fileNameToExecute;
+ std::string filelogtemp;
+ if( fileToExecute.size() > 0 ){
+ string::size_type p1 = fileToExecute.find_last_of("/");
+ string::size_type p2 = fileToExecute.find_last_of(".");
+ rootNameToExecute = fileToExecute.substr(p1+1,p2-p1-1);
+ fileNameToExecute = "~/" + dirForTmpFiles + "/" + string(basename(fileToExecute.c_str()));
+
+ int idx = dirForTmpFiles.find("Batch/");
+ filelogtemp = dirForTmpFiles.substr(idx+6, dirForTmpFiles.length());
+ }
+ else{
+ rootNameToExecute = "command";
+ }
+
+ std::string TmpFileName = BuildTemporaryFileName();
+ ofstream tempOutputFile;
+ tempOutputFile.open(TmpFileName.c_str(), ofstream::out );
+
+ tempOutputFile << "#! /bin/sh -f" << endl;
+ tempOutputFile << "#$ -pe mpich " << nbproc << endl;
+ if( edt > 0 )
+ tempOutputFile << "#$ -l h_rt=" << getWallTime(edt) << endl ;
+ if( mem > 0 )
+ tempOutputFile << "#$ -l h_vmem=" << mem << "M" << endl ;
+ if( fileToExecute.size() > 0 ){
+ tempOutputFile << "#$ -o " << home << "/" << dirForTmpFiles << "/output.log." << filelogtemp << endl ;
+ tempOutputFile << "#$ -e " << home << "/" << dirForTmpFiles << "/error.log." << filelogtemp << endl ;
+ }
+ else{
+ tempOutputFile << "#$ -o " << dirForTmpFiles << "/" << env["LOGFILE"] << ".output.log" << endl ;
+ tempOutputFile << "#$ -e " << dirForTmpFiles << "/" << env["LOGFILE"] << ".error.log" << endl ;
+ }
+ if( workDir.size() > 0 )
+ tempOutputFile << "cd " << workDir << endl ;
+ if( fileToExecute.size() > 0 ){
+ tempOutputFile << _mpiImpl->boot("",nbproc);
+ tempOutputFile << _mpiImpl->run("${TMPDIR}/machines",nbproc,fileNameToExecute);
+ tempOutputFile << _mpiImpl->halt();
+ }
+ else{
+ tempOutputFile << "source " << env["SOURCEFILE"] << endl ;
+ tempOutputFile << env["COMMAND"];
+ }
+
+ tempOutputFile.flush();
+ tempOutputFile.close();
+ chmod(TmpFileName.c_str(), 0x1ED);
+ cerr << TmpFileName.c_str() << endl;
+
+ string command;
+ if( _protocol == "rsh" )
+ command = "rcp ";
+ else if( _protocol == "ssh" )
+ command = "scp ";
+ else
+ throw EmulationException("Unknown protocol");
+ command += TmpFileName;
+ command += " ";
+ if(_username != ""){
+ command += _username;
+ command += "@";
+ }
+ command += _hostname;
+ command += ":";
+ command += dirForTmpFiles ;
+ command += "/" ;
+ command += rootNameToExecute ;
+ command += "_Batch.sh" ;
+ cerr << command.c_str() << endl;
+ status = system(command.c_str());
+ if(status)
+ throw EmulationException("Error of connection on remote host");
+
+ RmTmpFile(TmpFileName);
+
+ }
+
+ std::string BatchManager_eSGE::getWallTime(const long edt)
+ {
+ long h, m;
+ h = edt / 60;
+ m = edt - h*60;
+ ostringstream oss;
+ if( m >= 10 )
+ oss << h << ":" << m;
+ else
+ oss << h << ":0" << m;
+ return oss.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_eSGE.hxx : emulation of SGE client
+ *
+ * Auteur : Bernard SECHER - CEA DEN
+ * Mail : mailto:bernard.secher@cea.fr
+ * Date : Thu Apr 24 10:17:22 2008
+ * Projet : PAL Salome
+ *
+ */
+
+#ifndef _BATCHMANAGER_eLSF_H_
+#define _BATCHMANAGER_eLSF_H_
+
+#include "Batch_JobId.hxx"
+#include "Batch_JobInfo.hxx"
+#include "Batch_JobInfo_eSGE.hxx"
+#include "Batch_InvalidArgumentException.hxx"
+#include "Batch_ConnexionFailureException.hxx"
+#include "Batch_APIInternalFailureException.hxx"
+#include "Batch_NotYetImplementedException.hxx"
+#include "Batch_BatchManager.hxx"
+#include "Batch_BatchManager_eClient.hxx"
+
+namespace Batch {
+
+ class Job;
+ class JobId;
+ class JobInfo;
+ class FactBatchManager;
+
+ class BatchManager_eSGE : public BatchManager_eClient
+ {
+ public:
+ // Constructeur et destructeur
+ BatchManager_eSGE(const FactBatchManager * parent, const char * host="localhost", const char * protocol="ssh", const char * mpiImpl="nompi") throw(InvalidArgumentException,ConnexionFailureException); // connexion a la machine host
+ virtual ~BatchManager_eSGE();
+
+ // Recupere le nom du serveur par defaut
+ // static string BatchManager_LSF::getDefaultServer();
+
+ // Methodes pour le controle des jobs
+ virtual const JobId submitJob(const Job & job); // soumet un job au gestionnaire
+ virtual void deleteJob(const JobId & jobid); // retire un job du gestionnaire
+ virtual void holdJob(const JobId & jobid); // suspend un job en file d'attente
+ virtual void releaseJob(const JobId & jobid); // relache un job suspendu
+ virtual void alterJob(const JobId & jobid, const Parametre & param, const Environnement & env); // modifie un job en file d'attente
+ virtual void alterJob(const JobId & jobid, const Parametre & param); // modifie un job en file d'attente
+ virtual void alterJob(const JobId & jobid, const Environnement & env); // modifie un job en file d'attente
+ virtual JobInfo queryJob(const JobId & jobid); // renvoie l'etat du job
+ virtual bool isRunning(const JobId & jobid); // teste si un job est present en machine
+
+ virtual void setParametre(const JobId & jobid, const Parametre & param) { return alterJob(jobid, param); } // modifie un job en file d'attente
+ virtual void setEnvironnement(const JobId & jobid, const Environnement & env) { return alterJob(jobid, env); } // modifie un job en file d'attente
+
+
+ protected:
+ void buildBatchScript(const Job & job) throw(EmulationException);
+ std::string getWallTime(const long edt);
+
+ private:
+
+#ifdef SWIG
+ public:
+ // Recupere le l'identifiant d'un job deja soumis au BatchManager
+ //virtual const JobId getJobIdByReference(const string & ref) { return BatchManager::getJobIdByReference(ref); }
+ virtual const JobId getJobIdByReference(const char * ref) { return BatchManager::getJobIdByReference(ref); }
+#endif
+
+ };
+
+}
+
+#endif
#include <string>
#include <sstream>
+#include <iostream>
#include "Batch_BatchManagerCatalog.hxx"
#include "Batch_FactBatchManager.hxx"
-#include "utilities.h"
using namespace std;
namespace Batch {
*/
ostringstream msg;
msg << "FactBatchManager of type '" << type << "' inserted into catalog";
- MESSAGE(msg.str().c_str());
+ cerr << msg.str().c_str() << endl;
//#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
+//
+/*
+ * FactBatchManager_eSGE.cxx :
+ *
+ * Auteur : Bernard SECHER - CEA DEN
+ * Date : Avril 2008
+ * Projet : PAL Salome
+ *
+ */
+
+#include <string>
+#include "Batch_BatchManager_eSGE.hxx"
+#include "Batch_FactBatchManager_eSGE.hxx"
+//#include "utilities.h"
+
+namespace Batch {
+
+ static FactBatchManager_eSGE sFBM_eSGE;
+
+ // Constructeur
+ FactBatchManager_eSGE::FactBatchManager_eSGE() : FactBatchManager_eClient("eSGE")
+ {
+ // Nothing to do
+ }
+
+ // Destructeur
+ FactBatchManager_eSGE::~FactBatchManager_eSGE()
+ {
+ // Nothing to do
+ }
+
+ // Functor
+ BatchManager * FactBatchManager_eSGE::operator() (const char * hostname) const
+ {
+ // MESSAGE("Building new BatchManager_SGE on host '" << hostname << "'");
+ return new BatchManager_eSGE(this, hostname);
+ }
+
+ BatchManager_eClient * FactBatchManager_eSGE::operator() (const char * hostname, const char * protocol, const char * mpiImpl) const
+ {
+ // MESSAGE("Building new BatchManager_SGE on host '" << hostname << "'");
+ return new BatchManager_eSGE(this, hostname, protocol, mpiImpl);
+ }
+
+
+}
--- /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
+//
+/*
+ * FactBatchManager_eSGE.hxx :
+ *
+ * Auteur : Bernard SECHER : CEA DEN
+ * Date : Avril 2008
+ * Projet : PAL Salome
+ *
+ */
+
+#ifndef _FACTBATCHMANAGER_eSGE_H_
+#define _FACTBATCHMANAGER_eSGE_H_
+
+using namespace std;
+#include <string>
+#include <map>
+#include "Batch_BatchManager_eClient.hxx"
+#include "Batch_FactBatchManager_eClient.hxx"
+
+namespace Batch {
+
+ class BatchManager_eSGE;
+
+ class FactBatchManager_eSGE : public FactBatchManager_eClient
+ {
+ public:
+ // Constructeur et destructeur
+ FactBatchManager_eSGE();
+ virtual ~FactBatchManager_eSGE();
+
+ virtual BatchManager * operator() (const char * hostname) const;
+ virtual BatchManager_eClient * operator() (const char * hostname, const char * protocol, const char * mpiImpl) const;
+
+ protected:
+
+ 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
+//
+/*
+ * JobInfo_eSGE.cxx : emulation of SGE client
+ *
+ * Auteur : Bernard SECHER - CEA DEN
+ * Mail : mailto:bernard.secher@cea.fr
+ * Date : Thu Apr 24 10:17:22 2008
+ * Projet : PAL Salome
+ *
+ */
+
+#include <cstdio>
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include "Batch_Parametre.hxx"
+#include "Batch_Environnement.hxx"
+#include "Batch_RunTimeException.hxx"
+#include "Batch_APIInternalFailureException.hxx"
+#include "Batch_JobInfo_eSGE.hxx"
+
+using namespace std;
+
+namespace Batch {
+
+
+
+ // Constructeurs
+ JobInfo_eSGE::JobInfo_eSGE(int id, string logFile) : JobInfo()
+ {
+ // On remplit les membres _param et _env
+ ostringstream oss;
+ oss << id;
+ _param[ID] = oss.str();
+
+ // read of log file
+ char line[128];
+ ifstream fp(logFile.c_str(),ios::in);
+
+ string status;
+ string sline;
+ fp.getline(line,80,'\n');
+ sline = string(line);
+
+ if( sline.length() > 0 ){
+ istringstream iss(sline);
+ iss >> status >> status >> status >> status >> status;
+ }
+ else
+ status = "e";
+
+ _param[STATE] = status;
+
+ if( status.find("r") != string::npos)
+ _running = true;
+
+ }
+
+ // Teste si un job est present en machine
+ bool JobInfo_eSGE::isRunning() const
+ {
+ return _running;
+ }
+
+
+ // Destructeur
+ JobInfo_eSGE::~JobInfo_eSGE()
+ {
+ // Nothing to do
+ }
+
+ // Convertit une date HH:MM:SS en secondes
+ long JobInfo_eSGE::HMStoLong(const string & s)
+ {
+ long hour, min, sec;
+
+ sscanf( s.c_str(), "%ld:%ld:%ld", &hour, &min, &sec);
+ return ( ( ( hour * 60L ) + min ) * 60L ) + sec;
+ }
+
+ // Methode pour l'interfacage avec Python (SWIG) : affichage en Python
+ string JobInfo_eSGE::__str__() const
+ {
+ ostringstream sst;
+ sst << "<JobInfo_eSGE (" << this << ") :" << endl;
+ sst << " ID = " <<_param[ID] << endl;
+ sst << " STATE = " <<_param[STATE] << endl;
+
+ return sst.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
+//
+/*
+ * JobInfo_eSGE.hxx : emulation of SGE client
+ *
+ * Auteur : Bernard SECHER - CEA DEN
+ * Mail : mailto:bernard.secher@cea.fr
+ * Date : Thu Apr 24 10:17:22 2008
+ * Projet : PAL Salome
+ *
+ */
+
+#ifndef _JOBINFO_SGE_H_
+#define _JOBINFO_SGE_H_
+
+#include <string>
+#include "Batch_RunTimeException.hxx"
+#include "Batch_JobInfo.hxx"
+
+namespace Batch {
+
+ class JobInfo_eSGE : public JobInfo
+ {
+ public:
+ // Constructeurs et destructeur
+ JobInfo_eSGE() : _running(false) {};
+ JobInfo_eSGE(int id,std::string logFile);
+ virtual ~JobInfo_eSGE();
+
+ // Constructeur par recopie
+ JobInfo_eSGE(const JobInfo_eSGE & jinfo) : JobInfo(jinfo) {};
+
+ // Teste si un job est present en machine
+ virtual bool isRunning() const;
+
+ // Methodes pour l'interfacage avec Python (SWIG)
+ // TODO : supprimer ces methodes et transferer leur definitions dans SWIG
+ std::string __str__() const; // SWIG : affichage en Python
+ std::string __repr__() const { return __str__(); }; // SWIG : affichage en Python
+
+ protected:
+ bool _running; // etat du job en machine
+
+ private:
+ // Convertit une date HH:MM:SS en secondes
+ long HMStoLong(const std::string &);
+
+ };
+
+}
+
+#endif
Batch_JobInfo_ePBS.hxx \
MpiImpl.hxx \
Batch_Defines.hxx
+ Batch_BatchManager_eSGE.hxx \
+ Batch_FactBatchManager_eSGE.hxx \
+ Batch_JobInfo_eSGE.hxx \
+ MpiImpl.hxx
LIB_SRC = \
Batch_BatchManager_ePBS.cxx \
Batch_FactBatchManager_ePBS.cxx \
Batch_JobInfo_ePBS.cxx \
+ Batch_BatchManager_eSGE.cxx \
+ Batch_FactBatchManager_eSGE.cxx \
+ Batch_JobInfo_eSGE.cxx \
MpiImpl.cxx
LIB_CPPFLAGS = \
- ${PYTHON_INCLUDES} \
+ ${PYTHON_INCLUDES}
+if !WITHONLYLAUNCHER
+ LIB_CPPFLAGS += \
-I$(srcdir)/../Basics \
-I$(srcdir)/../SALOMELocalTrace \
-I$(top_builddir)/salome_adm/unix
+ -I$(top_builddir)/salome_adm/unix
+endif
-LIB_LIBADD = \
+LIB_LIBADD =
+if !WITHONLYLAUNCHER
+ LIB_LIBADD += \
../SALOMELocalTrace/libSALOMELocalTrace.la \
../Basics/libSALOMEBasics.la
-
+endif
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Batch_Job_Local.cxx \
Batch_IOMutex.cxx
-LIB_CPPFLAGS += -DHAVE_CONFIG_H
+if !WITHONLYLAUNCHER
+ LIB_CPPFLAGS += -DHAVE_CONFIG_H
+endif
endif
string MpiImpl_MPICH1::size()
{
- throw MpiImplException("mpich1 doesn't work with this batch system to submit salome session");
+ return "${MPIRUN_NPROCS}";
}
string MpiImpl_MPICH1::rank()
{
- throw MpiImplException("mpich1 doesn't work with this batch system to submit salome session");
+ return "${MPIRUN_RANK}";
}
string MpiImpl_MPICH1::boot(const string machinefile, const unsigned int nbnodes)
std::string batch_type = _batch_descr.batch.in();
// Basic test
- if (batch_type == "slurm")
+ if (batch_type == "lsf")
{
- INFOS("test_jobsubmit_simple not yet implemented for slurm... return OK");
+ INFOS("test_jobsubmit_simple not yet implemented for lsf... return OK");
+ result = "OK";
+ return result;
+ }
+ if (batch_type == "sge")
+ {
+ INFOS("test_jobsubmit_simple not yet implemented for sge... return OK");
result = "OK";
return result;
}
mpiImpl = new MpiImpl_MPICH2();
else if(mpi_type == "openmpi")
mpiImpl = new MpiImpl_OPENMPI();
+ else if(mpi_type == "slurm")
+ mpiImpl = new MpiImpl_SLURM();
else
{
result += "Error MPI impl not supported : " + mpi_type;
return result;
}
- // SLURM not yet implemented...
- if (batch_type == "slurm")
+ // LSF et SGE not yet implemented...
+ if (batch_type == "lsf")
+ {
+ INFOS("test_jobsubmit_simple not yet implemented for lsf... return OK");
+ result = "OK";
+ return result;
+ }
+
+ if (batch_type == "sge")
{
- INFOS("test_jobsubmit_simple not yet implemented for slurm... return OK");
+ INFOS("test_jobsubmit_simple not yet implemented for sge... return OK");
result = "OK";
return result;
}
#include "Batch_FactBatchManager_eLSF.hxx"
#include "Batch_FactBatchManager_ePBS.hxx"
#include "Batch_BatchManager_eClient.hxx"
-
+#include "Batch_FactBatchManager_eSGE.hxx"
+#include "SALOME_Launcher_Handler.hxx"
+#include "Launcher.hxx"
#include <iostream>
#include <sstream>
#include <sys/stat.h>
Launcher_cpp::Launcher_cpp()
{
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "Launcher_cpp constructor" << endl;
+ cout << "Launcher_cpp constructor" << endl;
#endif
}
Launcher_cpp::~Launcher_cpp()
{
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "Launcher_cpp destructor" << endl;
+ cout << "Launcher_cpp destructor" << endl;
#endif
std::map < string, Batch::BatchManager_eClient * >::const_iterator it1;
for(it1=_batchmap.begin();it1!=_batchmap.end();it1++)
delete it2->second;
}
+//=============================================================================
+/*! CORBA Method:
+ * Submit a batch job on a cluster and returns the JobId
+ * \param xmlExecuteFile : to define the execution on the batch cluster
+ * \param clusterName : name of the batch cluster
+ */
+//=============================================================================
+long Launcher_cpp::submitJob( const std::string xmlExecuteFile,
+ const std::string clusterName) throw(LauncherException)
+{
+#if defined(_DEBUG_) || defined(_DEBUG)
+ cout << "BEGIN OF Launcher_cpp::submitJob" << endl;
+#endif
+ long jobId;
+ vector<string> aMachineList;
+
+ if(!_ResManager)
+ throw LauncherException("You must set Resources Manager to Launcher!!");
+
+ // verify if cluster is in resources catalog
+ machineParams params;
+ params.hostname = clusterName;
+ vector<string> aCompoList ;
+ try{
+ aMachineList = _ResManager->GetFittingResources(params, aCompoList);
+ }
+ catch(const ResourcesException &ex){
+ throw LauncherException(ex.msg.c_str());
+ }
+ if (aMachineList.size() == 0)
+ throw LauncherException("This cluster is not in resources catalog");
+
+ // Parsing xml file
+ ParseXmlFile(xmlExecuteFile);
+
+ // verify if clustername is in xml file
+ map<std::string,MachineParameters>::const_iterator it1 = _launch.MachinesList.find(clusterName);
+ if(it1 == _launch.MachinesList.end())
+ throw LauncherException("This cluster is not in xml file");
+
+ ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]);
+ string cname(p.Alias);
+#if defined(_DEBUG_) || defined(_DEBUG)
+ cout << "Choose cluster: " << cname << endl;
+#endif
+
+ // search batch manager for that cluster in map or instanciate one
+ map < string, Batch::BatchManager_eClient * >::const_iterator it2 = _batchmap.find(cname);
+ if(it2 == _batchmap.end())
+ {
+ _batchmap[cname] = FactoryBatchManager(p);
+ // TODO: Add a test for the cluster !
+ }
+
+ try{
+
+ // directory on cluster to put files to execute
+ string remotedir = _launch.MachinesList[clusterName].WorkDirectory;
+ // local directory to get files to execute and to put results
+ string localdir = _launch.RefDirectory;
+
+ int idx1 = xmlExecuteFile.find_last_of("/");
+ if(idx1 == string::npos) idx1 = -1;
+ int idx2 = xmlExecuteFile.find(".xml");
+ string logfile = xmlExecuteFile.substr(idx1+1,idx2-idx1-1);
+ string ologfile = logfile + ".output.log";
+ string elogfile = logfile + ".error.log";
+
+ // create and submit job on cluster
+ Batch::Parametre param;
+ param[USER] = p.UserName;
+ param[EXECUTABLE] = "";
+ for(int i=0; i<_launch.InputFile.size();i++)
+ param[INFILE] += Batch::Couple( localdir + "/" + _launch.InputFile[i], remotedir + "/" + _launch.InputFile[i] );
+ for(int i=0; i<_launch.OutputFile.size();i++)
+ param[OUTFILE] += Batch::Couple( localdir + "/" + _launch.OutputFile[i], remotedir + "/" + _launch.OutputFile[i] );
+ param[OUTFILE] += Batch::Couple( localdir + "/" + ologfile, remotedir + "/" + ologfile );
+ param[OUTFILE] += Batch::Couple( localdir + "/" + elogfile, remotedir + "/" + elogfile );
+ param[NBPROC] = _launch.NbOfProcesses;
+ param[WORKDIR] = remotedir;
+ param[TMPDIR] = remotedir;
+ param[MAXWALLTIME] = getWallTime("");
+ param[MAXRAMSIZE] = getRamSize("");
+ param[HOMEDIR] = "";
+
+ Batch::Environnement env;
+ env["COMMAND"] = _launch.Command;
+ env["SOURCEFILE"] = _launch.MachinesList[clusterName].EnvFile;
+ env["LOGFILE"] = logfile;
+
+ Batch::Job* job = new Batch::Job(param,env);
+
+ // submit job on cluster
+ Batch::JobId jid = _batchmap[cname]->submitJob(*job);
+
+ // get job id in long
+ istringstream iss(jid.getReference());
+ iss >> jobId;
+
+ _jobmap[ pair<string,long>(cname,jobId) ] = job;
+ }
+ catch(const Batch::EmulationException &ex){
+ throw LauncherException(ex.msg.c_str());
+ }
+
+ return jobId;
+}
+
//=============================================================================
/*! CORBA Method:
* Submit a batch job on a cluster and returns the JobId
const machineParams& params) throw(LauncherException)
{
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "BEGIN OF Launcher_cpp::submitSalomeJob" << endl;
+ cout << "BEGIN OF Launcher_cpp::submitSalomeJob" << endl;
#endif
long jobId;
vector<string> aMachineList;
+ if(!_ResManager)
+ throw LauncherException("You must set Resources Manager to Launcher!!");
+
// check batch params
if ( !check(batch_params) )
throw LauncherException("Batch parameters are bad (see informations above)");
ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]);
string clustername(p.Alias);
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "Choose cluster: " << clustername << endl;
+ cout << "Choose cluster: " << clustername << endl;
#endif
// search batch manager for that cluster in map or instanciate one
for(int i=0;i<filesToExport.size();i++)
param[INFILE] += Batch::Couple( filesToExport[i], getRemoteFile(tmpdir,filesToExport[i]) );
-
ostringstream file_name_output;
- file_name_output << "~/" << tmpdir << "/" << "runSalome.output.log*";
+ file_name_output << "~/" << tmpdir << "/" << "output.log*";
ostringstream file_name_error;
- file_name_error << "~/" << tmpdir << "/" << "runSalome.error.log*";
+ file_name_error << "~/" << tmpdir << "/" << "error.log*";
ostringstream file_container_log;
file_container_log << "~/" << tmpdir << "/" << "YACS_Server*";
param[OUTFILE] = Batch::Couple( "", file_name_output.str());
* \param params : Constraints for the choice of the batch cluster
*/
//=============================================================================
-string Launcher_cpp::querySalomeJob( long id,
- const machineParams& params) throw(LauncherException)
+string Launcher_cpp::queryJob( long id,
+ const machineParams& params) throw(LauncherException)
{
+ if(!_ResManager)
+ throw LauncherException("You must set Resources Manager to Launcher!!");
+
// find a cluster matching params structure
vector<string> aCompoList ;
vector<string> aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ;
if(it == _batchmap.end())
throw LauncherException("no batchmanager for that cluster");
- ostringstream oss;
- oss << id;
- Batch::JobId jobId( _batchmap[clustername], oss.str() );
+ Batch::Parametre par;
+ try{
+ ostringstream oss;
+ oss << id;
+ Batch::JobId jobId( _batchmap[clustername], oss.str() );
+
+ Batch::JobInfo jinfo = jobId.queryJob();
+ par = jinfo.getParametre();
+ }
+ catch(const Batch::EmulationException &ex){
+ throw LauncherException(ex.msg.c_str());
+ }
- Batch::JobInfo jinfo = jobId.queryJob();
- Batch::Parametre par = jinfo.getParametre();
return par[STATE];
}
+string Launcher_cpp::queryJob( long id,
+ const std::string clusterName)
+{
+ machineParams params;
+ params.hostname = clusterName;
+ return queryJob(id,params);
+}
+
//=============================================================================
/*! CORBA Method:
* Delete a batch job on a cluster
* \param params : Constraints for the choice of the batch cluster
*/
//=============================================================================
-void Launcher_cpp::deleteSalomeJob( const long id,
- const machineParams& params) throw(LauncherException)
+void Launcher_cpp::deleteJob( const long id,
+ const machineParams& params) throw(LauncherException)
{
+ if(!_ResManager)
+ throw LauncherException("You must set Resources Manager to Launcher!!");
+
// find a cluster matching params structure
vector<string> aCompoList ;
vector<string> aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ;
jobId.deleteJob();
}
+void Launcher_cpp::deleteJob( long id,
+ const std::string clusterName)
+{
+ machineParams params;
+ params.hostname = clusterName;
+ deleteJob(id,params);
+}
+
//=============================================================================
/*! CORBA Method:
* Get result files of job on a cluster
* \param params : Constraints for the choice of the batch cluster
*/
//=============================================================================
-void Launcher_cpp::getResultSalomeJob( const string directory,
- const long id,
- const machineParams& params) throw(LauncherException)
+void Launcher_cpp::getResultsJob( const string directory,
+ const long id,
+ const machineParams& params) throw(LauncherException)
{
+ if(!_ResManager)
+ throw LauncherException("You must set Resources Manager to Launcher!!");
+
vector<string> aCompoList ;
vector<string> aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ;
ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]);
_batchmap[clustername]->importOutputFiles( *job, directory );
}
+void Launcher_cpp::getResultsJob( const std::string directory,
+ long id,
+ const std::string clusterName)
+{
+ machineParams params;
+ params.hostname = clusterName;
+ getResultsJob(directory,id,params);
+}
+
//=============================================================================
/*!
* Factory to instanciate the good batch manager for choosen cluster.
case slurm:
mpi = "slurm";
break;
+ case nompi:
+ throw LauncherException("you must specified an mpi implementation for batch manager");
+ break;
default:
- mpi = "indif";
+ throw LauncherException("unknown mpi implementation");
break;
}
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "Instanciation of batch manager" << endl;
+ cout << "Instanciation of batch manager" << endl;
#endif
switch( params.Batch ){
case pbs:
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "Instantiation of PBS batch manager" << endl;
+ cout << "Instantiation of PBS batch manager" << endl;
#endif
fact = new Batch::FactBatchManager_ePBS;
break;
case lsf:
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "Instantiation of LSF batch manager" << endl;
+ cout << "Instantiation of LSF batch manager" << endl;
#endif
fact = new Batch::FactBatchManager_eLSF;
break;
+ case sge:
+#if defined(_DEBUG_) || defined(_DEBUG)
+ cout << "Instantiation of SGE batch manager" << endl;
+#endif
+ fact = new Batch::FactBatchManager_eSGE;
+ break;
default:
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "BATCH = " << params.Batch << endl;
+ cout << "BATCH = " << params.Batch << endl;
#endif
throw LauncherException("no batchmanager for that cluster");
}
tempOutputFile.close();
chmod(TmpFileName.c_str(), 0x1ED);
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << TmpFileName.c_str() << endl;
+ cout << TmpFileName.c_str() << endl;
#endif
delete mpiImpl;
return new MpiImpl_OPENMPI();
case slurm:
return new MpiImpl_SLURM();
- case indif:
- throw LauncherException("you must specify a mpi implementation in CatalogResources.xml file");
+ case nompi:
+ throw LauncherException("you must specified an mpi implementation for batch manager");
+ break;
default:
ostringstream oss;
oss << mpi << " : not yet implemented";
{
bool rtn = true;
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "Job parameters are :" << endl;
- cerr << "Directory : $HOME/Batch/$date" << endl;
+ cout << "Job parameters are :" << endl;
+ cout << "Directory : $HOME/Batch/$date" << endl;
#endif
// check expected_during_time (check the format)
edt_info = "No value given";
}
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "Expected during time : " << edt_info << endl;;
+ cout << "Expected during time : " << edt_info << endl;;
#endif
// check memory (check the format)
mem_info = "No value given";
}
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "Memory : " << mem_info << endl;
+ cout << "Memory : " << mem_info << endl;
#endif
// check nb_proc
nb_proc_info = nb_proc_value.str();
}
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "Nb of processors : " << nb_proc_info << endl;
+ cout << "Nb of processors : " << nb_proc_info << endl;
#endif
return rtn;
return 0;
}
-std::string
-Launcher_cpp::getHomeDir(const ParserResourcesType& p, const std::string& tmpdir)
+void Launcher_cpp::ParseXmlFile(string xmlExecuteFile)
{
- std::string home;
- std::string command;
- int idx = tmpdir.find("Batch/");
- std::string filelogtemp = tmpdir.substr(idx+6, tmpdir.length());
- filelogtemp = "/tmp/logs" + filelogtemp + "_home";
-
- if( p.Protocol == rsh )
- command = "rsh ";
- else if( p.Protocol == ssh )
- command = "ssh ";
- else
- throw LauncherException("Unknown protocol");
- if (p.UserName != ""){
- command += p.UserName;
- command += "@";
+ SALOME_Launcher_Handler* handler = new SALOME_Launcher_Handler(_launch);
+
+ const char* aFilePath = xmlExecuteFile.c_str();
+ FILE* aFile = fopen(aFilePath, "r");
+
+ if (aFile != NULL)
+ {
+ xmlDocPtr aDoc = xmlReadFile(aFilePath, NULL, 0);
+
+ if (aDoc != NULL)
+ handler->ProcessXmlDocument(aDoc);
+ else{
+#if defined(_DEBUG_) || defined(_DEBUG)
+ cout << "ResourcesManager_cpp: could not parse file "<< aFilePath << endl;
+#endif
+ }
+
+ // Free the document
+ xmlFreeDoc(aDoc);
+
+ fclose(aFile);
}
- command += p.Alias;
- command += " 'echo $HOME' > ";
- command += filelogtemp;
+ else{
#if defined(_DEBUG_) || defined(_DEBUG)
- std::cerr << command.c_str() << std::endl;
+ cout << "Launcher_cpp: file "<<aFilePath<<" is not readable." << endl;
#endif
- int status = system(command.c_str());
- if(status)
- throw LauncherException("Error of launching home command on remote host");
-
- std::ifstream file_home(filelogtemp.c_str());
- std::getline(file_home, home);
- file_home.close();
- return home;
+ }
+
+ delete handler;
+
+}
+
+std::string Launcher_cpp::getHomeDir(const ParserResourcesType& p, const std::string& tmpdir)
+{
+ std::string home;
+ std::string command;
+ int idx = tmpdir.find("Batch/");
+ std::string filelogtemp = tmpdir.substr(idx+6, tmpdir.length());
+ filelogtemp = "/tmp/logs" + filelogtemp + "_home";
+
+ if( p.Protocol == rsh )
+ command = "rsh ";
+ else if( p.Protocol == ssh )
+ command = "ssh ";
+ else
+ throw LauncherException("Unknown protocol");
+ if (p.UserName != ""){
+ command += p.UserName;
+ command += "@";
+ }
+ command += p.Alias;
+ command += " 'echo $HOME' > ";
+ command += filelogtemp;
+#if defined(_DEBUG_) || defined(_DEBUG)
+ cout << command.c_str() << endl;
+#endif
+ int status = system(command.c_str());
+ if(status)
+ throw LauncherException("Error of launching home command on remote host");
+
+ std::ifstream file_home(filelogtemp.c_str());
+ std::getline(file_home, home);
+ file_home.close();
+ return home;
}
#include <SALOME_ResourcesCatalog_Parser.hxx>
#include "ResourcesManager.hxx"
+#include "SALOME_Launcher_Parser.hxx"
#include <string>
#include <vector>
Launcher_cpp();
~Launcher_cpp();
+ long submitJob(const std::string xmlExecuteFile,
+ const std::string clusterName) throw(LauncherException);
+
long submitSalomeJob(const std::string fileToExecute ,
const std::vector<std::string>& filesToExport ,
const std::vector<std::string>& filesToImport ,
const batchParams& batch_params,
const machineParams& params) throw(LauncherException);
- std::string querySalomeJob( const long jobId, const machineParams& params) throw(LauncherException);
- void deleteSalomeJob( const long jobId, const machineParams& params) throw(LauncherException);
- void getResultSalomeJob( const std::string directory, const long jobId, const machineParams& params ) throw(LauncherException);
+ std::string queryJob( const long jobId, const machineParams& params) throw(LauncherException);
+ std::string queryJob( const long jobId, const std::string clusterName);
+ void deleteJob( const long jobId, const machineParams& params) throw(LauncherException);
+ void deleteJob( const long jobId, const std::string clusterName);
+ void getResultsJob( const std::string directory, const long jobId, const machineParams& params ) throw(LauncherException);
+ void getResultsJob( const std::string directory, const long jobId, const std::string clusterName );
void SetResourcesManager( ResourcesManager_cpp* rm ) { _ResManager = rm; }
bool check(const batchParams& batch_params);
long getWallTime(std::string edt);
long getRamSize(std::string mem);
+ void ParseXmlFile(std::string xmlExecuteFile);
+
+ //! will contain the informations on the data type catalog(after parsing)
+ ParserLauncherType _launch;
+
};
#endif
#
# header files
salomeinclude_HEADERS = \
- BatchTest.hxx \
- SALOME_Launcher.hxx \
- SALOME_Launcher_defs.hxx \
- Launcher.hxx
+ SALOME_Launcher_Parser.hxx \
+ SALOME_Launcher_Handler.hxx \
+ BatchTest.hxx \
+ SALOME_Launcher_defs.hxx \
+ SALOME_Launcher.hxx \
+ Launcher.hxx
# Scripts to be installed
dist_salomescript_DATA =
# Libraries targets
# ===============================================================
#
-lib_LTLIBRARIES = libLauncher.la libSalomeLauncher.la
+if WITHONLYLAUNCHER
+ lib_LTLIBRARIES = libLauncher.la
+else
+ lib_LTLIBRARIES = libLauncher.la libSalomeLauncher.la
+endif
libSalomeLauncher_la_SOURCES=\
- BatchTest.cxx \
- SALOME_Launcher.cxx
+ BatchTest.cxx \
+ SALOME_Launcher.cxx
libSalomeLauncher_la_CPPFLAGS =\
$(COMMON_CPPFLAGS)
$(COMMON_LIBS) libLauncher.la
libLauncher_la_SOURCES=\
+ SALOME_Launcher_Parser.cxx \
+ SALOME_Launcher_Handler.cxx \
Launcher.cxx
libLauncher_la_CPPFLAGS =\
- $(COMMON_CPPFLAGS) \
+ -I$(srcdir)/../Batch \
-I$(srcdir)/../ResourcesManager \
@MPI_INCLUDES@ \
@LIBXML_INCLUDES@
# Executables targets
# ===============================================================
#
-bin_PROGRAMS = SALOME_LauncherServer
+if !WITHONLYLAUNCHER
+ bin_PROGRAMS = SALOME_LauncherServer
+endif
SALOME_LauncherServer_SOURCES =\
SALOME_LauncherServer.cxx
}
+//=============================================================================
+/*! CORBA Method:
+ * Submit a batch job on a cluster and returns the JobId
+ * \param xmlExecuteFile : .xml to parse to execute on the batch cluster
+ * \param clusterName : cluster name
+ */
+//=============================================================================
+CORBA::Long SALOME_Launcher::submitJob(const char * xmlExecuteFile,
+ const char * clusterName)
+{
+ CORBA::Long jobId;
+
+ try{
+ jobId = _l.submitJob(xmlExecuteFile,clusterName);
+ }
+ catch(const LauncherException &ex){
+ INFOS(ex.msg.c_str());
+ THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
+ }
+ return jobId;
+}
+
//=============================================================================
/*! CORBA Method:
* Submit a batch job on a cluster and returns the JobId
rtn = true;
}
}
- catch(const SALOME_Exception &ex){
- INFOS(ex.what());
- THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR);
+ catch(const LauncherException &ex){
+ INFOS(ex.msg.c_str());
+ THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
}
return rtn;
}
* \param params : Constraints for the choice of the batch cluster
*/
//=============================================================================
-char* SALOME_Launcher::querySalomeJob( const CORBA::Long jobId,
- const Engines::MachineParameters& params)
+char* SALOME_Launcher::queryJob( const CORBA::Long jobId,
+ const Engines::MachineParameters& params)
{
string status;
machineParams p;
p.mem_mb = params.mem_mb;
try{
- status = _l.querySalomeJob(jobId,p);
+ status = _l.queryJob(jobId,p);
}
catch(const LauncherException &ex){
- INFOS("Caught exception.");
+ INFOS(ex.msg.c_str());
THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM);
}
return CORBA::string_dup(status.c_str());
* \param params : Constraints for the choice of the batch cluster
*/
//=============================================================================
-void SALOME_Launcher::deleteSalomeJob( const CORBA::Long jobId,
- const Engines::MachineParameters& params)
+void SALOME_Launcher::deleteJob( const CORBA::Long jobId,
+ const Engines::MachineParameters& params)
{
machineParams p;
p.hostname = params.hostname;
p.mem_mb = params.mem_mb;
try{
- _l.deleteSalomeJob(jobId,p);
+ _l.deleteJob(jobId,p);
}
catch(const LauncherException &ex){
INFOS("Caught exception.");
* \param params : Constraints for the choice of the batch cluster
*/
//=============================================================================
-void SALOME_Launcher::getResultSalomeJob( const char *directory,
- const CORBA::Long jobId,
- const Engines::MachineParameters& params)
+void SALOME_Launcher::getResultsJob( const char *directory,
+ const CORBA::Long jobId,
+ const Engines::MachineParameters& params)
{
machineParams p;
p.hostname = params.hostname;
p.mem_mb = params.mem_mb;
try{
- _l.getResultSalomeJob( directory, jobId, p );
+ _l.getResultsJob( directory, jobId, p );
}
catch(const LauncherException &ex){
INFOS("Caught exception.");
SALOME_Launcher(CORBA::ORB_ptr orb, PortableServer::POA_var poa);
~SALOME_Launcher();
+ CORBA::Long submitJob(const char * xmlExecuteFile,
+ const char * clusterName);
+
CORBA::Long submitSalomeJob(const char * fileToExecute ,
const Engines::FilesList& filesToExport ,
const Engines::FilesList& filesToImport ,
char* querySalomeJob( CORBA::Long jobId, const Engines::MachineParameters& params);
void deleteSalomeJob( CORBA::Long jobId, const Engines::MachineParameters& params);
void getResultSalomeJob( const char * directory, CORBA::Long jobId, const Engines::MachineParameters& params );
+ char* queryJob( const CORBA::Long jobId, const Engines::MachineParameters& params);
+ void deleteJob( const CORBA::Long jobId, const Engines::MachineParameters& params);
+ void getResultsJob( const char * directory, const CORBA::Long jobId, const Engines::MachineParameters& params );
CORBA::Boolean testBatch(const Engines::MachineParameters& params);
--- /dev/null
+// SALOME ResourcesCatalog : implementation of catalog resources parsing (SALOME_ModuleCatalog.idl)
+//
+// Copyright (C) 2003 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
+//
+//
+//
+// File : SALOME_Laucher_Handler.cxx
+// Author : Bernard Secher
+// Module : SALOME
+//$Header$
+
+#include "SALOME_Launcher_Handler.hxx"
+#include <iostream>
+#include <map>
+
+using namespace std;
+
+#ifdef _DEBUG_
+static int MYDEBUG = 1;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//=============================================================================
+/*!
+ * Constructor
+ * \param listOfResources: map of ParserResourcesType to fill when parsing
+ */
+//=============================================================================
+
+SALOME_Launcher_Handler::SALOME_Launcher_Handler(ParserLauncherType& launch):
+ _launch(launch)
+{
+ //XML tags initialisation
+ test_machine_list = "machine-list";
+ test_main = "main";
+
+ test_machine = "machine";
+ test_env_file = "env-file";
+ test_work_directory = "work-directory";
+ test_ref_directory = "ref-directory";
+ test_nb_processes = "nb-processes";
+ test_input_file = "input-file";
+ test_output_file = "output-file";
+ test_command = "command";
+
+}
+
+//=============================================================================
+/*!
+ * Destructor
+ */
+//=============================================================================
+
+SALOME_Launcher_Handler::~SALOME_Launcher_Handler()
+{
+ // cout << "SALOME_Launcher_Handler destruction") << endl;
+}
+
+//=============================================================================
+/*!
+ * Retrieves DS after the file parse.
+ */
+//=============================================================================
+
+const ParserLauncherType&
+SALOME_Launcher_Handler::GetLauncherAfterParsing() const
+{
+ return _launch;
+}
+
+//=============================================================================
+/*!
+ * Processes XML document and fills the list of resources
+ */
+//=============================================================================
+
+void SALOME_Launcher_Handler::ProcessXmlDocument(xmlDocPtr theDoc)
+{
+// if (MYDEBUG) cout << "Begin parse document" << endl;
+
+ // Empty private elements
+ _launch.Clear();
+
+ // Get the document root node
+ xmlNodePtr aCurNode = xmlDocGetRootElement(theDoc);
+
+ aCurNode = aCurNode->xmlChildrenNode;
+
+ // Processing the document nodes
+ while(aCurNode != NULL){
+ if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_machine_list) ){
+ xmlNodePtr aCurNode2 = aCurNode->xmlChildrenNode;
+ while(aCurNode2 != NULL){
+ if ( !xmlStrcmp(aCurNode2->name,(const xmlChar*)test_machine) ){
+ _machp.Clear();
+ xmlChar* name = xmlNodeGetContent(aCurNode2);
+ string clusterName = (const char*)name;
+ xmlFree(name);
+
+ if (xmlHasProp(aCurNode2, (const xmlChar*)test_env_file)){
+ xmlChar* envfile = xmlGetProp(aCurNode2, (const xmlChar*)test_env_file);
+ _machp.EnvFile = (const char*)envfile;
+ xmlFree(envfile);
+ }
+
+ if (xmlHasProp(aCurNode2, (const xmlChar*)test_work_directory)){
+ xmlChar* workdirectory = xmlGetProp(aCurNode2, (const xmlChar*)test_work_directory);
+ _machp.WorkDirectory = (const char*)workdirectory;
+ xmlFree(workdirectory);
+ }
+ _launch.MachinesList[clusterName]=_machp ;
+ }
+ aCurNode2 = aCurNode2->next;
+ }
+ }
+
+ if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_ref_directory) ){
+ xmlChar* refdirectory = xmlNodeGetContent(aCurNode);
+ _launch.RefDirectory = (const char*)refdirectory;
+ xmlFree(refdirectory);
+ }
+
+ if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_nb_processes) ){
+ xmlChar* nbofprocesses = xmlNodeGetContent(aCurNode);
+ _launch.NbOfProcesses = atoi((const char*)nbofprocesses);
+ xmlFree(nbofprocesses);
+ }
+
+ if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_input_file) ){
+ xmlChar* inputfile = xmlNodeGetContent(aCurNode);
+ _launch.InputFile.push_back((const char*)inputfile);
+ xmlFree(inputfile);
+ }
+
+ if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_output_file) ){
+ xmlChar* outputfile = xmlNodeGetContent(aCurNode);
+ _launch.OutputFile.push_back((const char*)outputfile);
+ xmlFree(outputfile);
+ }
+
+ if ( !xmlStrcmp(aCurNode->name,(const xmlChar*)test_command) ){
+ xmlChar* command = xmlNodeGetContent(aCurNode);
+ _launch.Command = (const char*)command;
+ xmlFree(command);
+ }
+
+ aCurNode = aCurNode->next;
+ }
+
+}
--- /dev/null
+// SALOME ResourcesCatalog : implementation of catalog resources parsing (SALOME_ModuleCatalog.idl)
+//
+// Copyright (C) 2003 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
+//
+//
+//
+// File : SALOME_Launcher_Handler.hxx
+// Author : Bernard SECHER
+// Module : SALOME
+//$Header$
+
+#ifndef SALOME_LAUNCHER_HANDLER
+#define SALOME_LAUNCHER_HANDLER
+
+#include "SALOME_Launcher_Parser.hxx"
+
+#include <string>
+#include <vector>
+
+#include <libxml/parser.h>
+
+class SALOME_Launcher_Handler
+{
+
+public :
+ SALOME_Launcher_Handler(ParserLauncherType& launch);
+
+ virtual ~SALOME_Launcher_Handler();
+
+ const ParserLauncherType& GetLauncherAfterParsing() const;
+
+ void ProcessXmlDocument(xmlDocPtr theDoc);
+
+private :
+ ParserLauncherType& _launch;
+ MachineParameters _machp;
+
+ const char *test_machine_list;
+ const char *test_main;
+
+ const char *test_machine;
+ const char *test_env_file;
+ const char *test_work_directory;
+ const char *test_ref_directory;
+ const char *test_nb_processes;
+ const char *test_input_file;
+ const char *test_output_file;
+ const char *test_command;
+
+};
+
+#endif // SALOME_LAUNCHER_HANDLER
--- /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
+//
+#include "SALOME_Launcher_Parser.hxx"
+#include <iostream>
+#include <sstream>
+
+#define NULL_VALUE 0
+
+using namespace std;
+
+void MachineParameters::Clear()
+{
+ EnvFile = "";
+ WorkDirectory = "";
+}
+
+void MachineParameters::Print() const
+{
+ ostringstream oss;
+ oss << " EnvFile: " << EnvFile
+ << " WorkDirectory: " << WorkDirectory << endl;
+
+ cout << oss.str();
+}
+
+void ParserLauncherType::Print() const
+{
+ ostringstream oss;
+ oss << endl <<
+ "RefDirectory: " << RefDirectory << endl <<
+ "NbOfProcesses: " << NbOfProcesses << endl <<
+ "InputFile: ";
+ for(int i=0; i <InputFile.size();i++)
+ oss << InputFile[i] << " ";
+ oss << endl << "OutputFile: ";
+ for(int i=0; i <OutputFile.size();i++)
+ oss << OutputFile[i] << " ";
+ oss << endl <<
+ "Command: " << Command << endl <<
+ "Machines: " << endl;
+
+ cout << oss.str();
+
+ std::map < string, MachineParameters >::const_iterator it;
+ for(it=MachinesList.begin();it!=MachinesList.end();it++){
+ cout << " " << it->first;
+ it->second.Print();
+ }
+
+}
+
+void ParserLauncherType::Clear()
+{
+ MachinesList.clear();
+ RefDirectory = "";
+ NbOfProcesses = 1;
+ InputFile.clear();
+ OutputFile.clear();
+ Command = "";
+}
--- /dev/null
+// SALOME ResourcesCatalog : implementation of catalog resources parsing (SALOME_ModuleCatalog.idl)
+//
+// Copyright (C) 2003 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
+//
+//
+//
+// File : SALOME_Launcher_Parser.hxx
+// Author : Bernard Secher
+// Module : SALOME
+//$Header$
+
+#ifndef SALOME_LAUNCHER_PARSER
+#define SALOME_LAUNCHER_PARSER
+
+#include <string>
+#include <vector>
+#include <map>
+#include <iostream>
+
+struct MachineParameters
+ {
+ std::string EnvFile;
+ std::string WorkDirectory;
+ void Print() const;
+ void Clear();
+ };
+
+struct ParserLauncherType
+ {
+ std::map<std::string,MachineParameters> MachinesList;
+ std::string RefDirectory;
+ long NbOfProcesses;
+ std::vector<std::string> InputFile;
+ std::vector<std::string> OutputFile;
+ std::string Command;
+
+ void Print() const;
+ void Clear();
+ };
+
+#endif //SALOME_LAUNCHER_PARSER
# check_cppunit for example with CPPUNIT_IS_OK.
#
+if WITHONLYLAUNCHER
+ SUBDIRS = Batch Batch_SWIG ResourcesManager Launcher
+else
+
SUBDIRS = $(SUBDIR_BASE)
if WITH_BATCH
endif
endif
if WITH_PACO_PARALLEL
-SUBDIRS += $(SUBDIR_PARALLEL)
+ SUBDIRS += $(SUBDIR_PARALLEL)
endif
+endif
EXTRA_DIST = win32pm
# Libraries targets
# ===============================================================
#
-lib_LTLIBRARIES = libResourcesManager.la libSalomeResourcesManager.la
+if WITHONLYLAUNCHER
+ lib_LTLIBRARIES = libResourcesManager.la
+else
+ lib_LTLIBRARIES = libResourcesManager.la libSalomeResourcesManager.la
+endif
libSalomeResourcesManager_la_SOURCES =\
SALOME_ResourcesManager.cxx
_path_resources(xmlFilePath)
{
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "ResourcesManager_cpp constructor" << endl;
+ cout << "ResourcesManager_cpp constructor" << endl;
#endif
}
*/
//=============================================================================
-ResourcesManager_cpp::ResourcesManager_cpp()
+ResourcesManager_cpp::ResourcesManager_cpp() throw(ResourcesException)
{
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "ResourcesManager_cpp constructor" << endl;
+ cout << "ResourcesManager_cpp constructor" << endl;
#endif
_isAppliSalomeDefined = (getenv("APPLI") != 0);
+ if(!getenv("KERNEL_ROOT_DIR"))
+ throw ResourcesException("you must define KERNEL_ROOT_DIR environment variable!!");
if (_isAppliSalomeDefined)
{
ParseXmlFile();
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "ResourcesManager_cpp constructor end";
+ cout << "ResourcesManager_cpp constructor end";
#endif
}
ResourcesManager_cpp::~ResourcesManager_cpp()
{
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "ResourcesManager_cpp destructor" << endl;
+ cout << "ResourcesManager_cpp destructor" << endl;
#endif
}
ResourcesManager_cpp::GetFittingResources(const machineParams& params,
const std::vector<std::string>& componentList) throw(ResourcesException)
{
-//#if defined(_DEBUG_) || defined(_DEBUG)
-// cerr << "ResourcesManager_cpp::GetFittingResources" << endl;
-//#endif
vector <std::string> vec;
ParseXmlFile();
#endif
if (hostname[0] != '\0'){
-//#if defined(_DEBUG_) || defined(_DEBUG)
-// cerr << "ResourcesManager_cpp::GetFittingResources : hostname specified" << endl;
-//#endif
if ( strcmp(hostname, "localhost") == 0 ||
strcmp(hostname, Kernel_Utils::GetHostname().c_str()) == 0 )
// --- params.hostname is in the list of resources so return it.
vec.push_back(hostname);
}
+
else if (_resourcesBatchList.find(hostname) != _resourcesBatchList.end())
{
// --- params.hostname is in the list of resources so return it.
vec.push_back(hostname);
}
+
else
{
// Cas d'un cluster: nombre de noeuds > 1
if( (*iter).second.DataForSort._nbOfNodes > 1 ){
if( strncmp(hostname,(*iter).first.c_str(),strlen(hostname)) == 0 ){
vec.push_back((*iter).first.c_str());
-//#if defined(_DEBUG_) || defined(_DEBUG)
-// cerr << "SALOME_ResourcesManager_cpp::GetFittingResources vector["
-// << cpt << "] = " << (*iter).first.c_str() << endl ;
-//#endif
cpt++;
}
}
if(cpt==0){
// --- user specified an unknown hostame so notify him.
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "ResourcesManager_cpp::GetFittingResources : SALOME_Exception" << endl;
+ cout << "ResourcesManager_cpp::GetFittingResources : SALOME_Exception" << endl;
#endif
throw ResourcesException("unknown host");
}
if (aFile == NULL)
{
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "Error opening file !" << endl;
+ cout << "Error opening file !" << endl;
#endif
return;
}
fclose(aFile);
#if defined(_DEBUG_) || defined(_DEBUG)
- cerr << "WRITING DONE!" << endl;
+ cout << "WRITING DONE!" << endl;
#endif
}
if (aDoc != NULL)
handler->ProcessXmlDocument(aDoc);
-#if defined(_DEBUG_) || defined(_DEBUG)
else
- cerr << "ResourcesManager_cpp: could not parse file "<< aFilePath << endl;
+#if defined(_DEBUG_) || defined(_DEBUG)
+ cout << "ResourcesManager_cpp: could not parse file "<< aFilePath << endl;
#endif
// Free the document
fclose(aFile);
}
-#if defined(_DEBUG_) || defined(_DEBUG)
else
- cerr << "ResourcesManager_cpp: file "<<aFilePath<<" is not readable." << endl;
+#if defined(_DEBUG_) || defined(_DEBUG)
+ cout << "ResourcesManager_cpp: file "<<aFilePath<<" is not readable." << endl;
#endif
delete handler;
public:
ResourcesManager_cpp(const char *xmlFilePath);
- ResourcesManager_cpp();
+ ResourcesManager_cpp() throw(ResourcesException);
~ResourcesManager_cpp();
_resource.Batch = pbs;
else if (aBatch == "lsf")
_resource.Batch = lsf;
+ else if (aBatch == "sge")
+ _resource.Batch = sge;
else
_resource.Batch = none;
}
else if (anMpi == "slurm")
_resource.mpi = slurm;
else
- _resource.mpi = indif;
+ _resource.mpi = nompi;
}
if (xmlHasProp(aCurNode, (const xmlChar*)test_user_name))
case lsf:
xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "lsf");
break;
- case slurm:
- xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "slurm");
+ case sge:
+ xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "sge");
break;
default:
xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "");
case openmpi:
xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "openmpi");
break;
+ case slurm:
+ xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "slurm");
+ break;
default:
xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "");
}
case lsf:
xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "lsf");
break;
- case slurm:
- xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "slurm");
+ case sge:
+ xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "sge");
break;
default:
xmlNewProp(node, BAD_CAST test_batch, BAD_CAST "");
case openmpi:
xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "openmpi");
break;
+ case slurm:
+ xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "slurm");
+ break;
default:
xmlNewProp(node, BAD_CAST test_mpi, BAD_CAST "");
}
Protocol = rsh;
Mode = interactive;
Batch = none;
- mpi = indif;
+ mpi = nompi;
UserName = "";
AppliPath = "";
ModulesList.clear();
enum AccessModeType {interactive, batch};
-enum BatchType {none, pbs, lsf};
+enum BatchType {none, pbs, lsf, sge};
-enum MpiImplType {indif, lam, mpich1, mpich2, openmpi, slurm};
+enum MpiImplType {nompi, lam, mpich1, mpich2, openmpi, slurm};
class RESOURCESMANAGER_EXPORT ResourceDataToSort
{
p_ptr->nb_proc_per_node = resource.DataForSort._nbOfProcPerNode;
p_ptr->nb_node = resource.DataForSort._nbOfNodes;
- if( resource.mpi == indif )
- p_ptr->mpiImpl = "indif";
- else if( resource.mpi == lam )
+ if( resource.mpi == lam )
p_ptr->mpiImpl = "lam";
else if( resource.mpi == mpich1 )
p_ptr->mpiImpl = "mpich1";
else if( resource.mpi == slurm )
p_ptr->mpiImpl = "slurm";
- p_ptr->isMPI=false;
- if(resource.mpi != indif )
- p_ptr->isMPI=true;
-
if( resource.Batch == pbs )
p_ptr->batch = "pbs";
else if( resource.Batch == lsf )
p_ptr->batch = "lsf";
+ else if( resource.Batch == sge )
+ p_ptr->batch = "sge";
p_ptr->nb_component_nodes=1;