From b9d614a9b0642314cda41b09f92912483034922f Mon Sep 17 00:00:00 2001 From: prascle Date: Mon, 17 Jan 2005 13:24:26 +0000 Subject: [PATCH] PR: merge from tag mergeto_trunk_16Jan05 --- bin/launchConfigureParser.py | 12 +- bin/runSalome.py | 2 + bin/salome.launch | 1 + bin/salome/runIDLparser.in | 4 +- configure.in.base | 18 +- salome_adm/unix/config_files/check_lsf.m4 | 76 +++++ salome_adm/unix/config_files/production.m4 | 12 +- salome_adm/unix/make_commence.in | 6 + src/Batch/Batch_BatchManager.hxx | 24 +- src/Batch/Batch_BatchManagerCatalog.hxx | 6 +- src/Batch/Batch_BatchManager_LSF.cxx | 170 +++++++++++ src/Batch/Batch_BatchManager_LSF.hxx | 75 +++++ src/Batch/Batch_FactBatchManager.hxx | 2 +- src/Batch/Batch_FactBatchManager_LSF.cxx | 39 +++ src/Batch/Batch_FactBatchManager_LSF.hxx | 39 +++ src/Batch/Batch_FactBatchManager_PBS.cxx | 2 +- src/Batch/Batch_FactBatchManager_PBS.hxx | 2 +- src/Batch/Batch_Job.hxx | 18 +- src/Batch/Batch_JobId.hxx | 18 +- src/Batch/Batch_JobInfo.hxx | 12 +- src/Batch/Batch_JobInfo_LSF.cxx | 180 +++++++++++ src/Batch/Batch_JobInfo_LSF.hxx | 55 ++++ src/Batch/Batch_Job_LSF.cxx | 241 +++++++++++++++ src/Batch/Batch_Job_LSF.hxx | 43 +++ src/Batch/Makefile.in | 53 +++- src/Batch_SWIG/libBatch_Swig.i | 1 - src/Batch_SWIG/libBatch_Swig_exception.i | 4 +- src/Batch_SWIG/libBatch_Swig_typemap.i | 56 ++-- src/Container/Component_i.cxx | 6 +- src/Container/Makefile.in | 2 +- src/Container/SALOME_Container.cxx | 4 +- src/DataTypeCatalog/Makefile.in | 2 +- .../SALOME_DataTypeCatalog_Server.cxx | 4 +- src/Loader/Makefile.in | 2 +- src/Loader/SALOME_Session_Loader.cxx | 4 +- src/Makefile.in | 2 +- src/ModuleCatalog/Makefile.in | 2 +- .../SALOME_ModuleCatalog_Server.cxx | 4 +- src/Registry/Makefile.in | 2 +- src/Registry/SALOME_Registry_Server.cxx | 4 +- src/RessourcesCatalog/Makefile.in | 2 +- .../SALOME_RessourcesCatalog_Server.cxx | 4 +- src/SALOMELocalTrace/LocalTraceCollector.cxx | 63 +--- src/SALOMELocalTrace/LocalTraceCollector.hxx | 4 +- src/SALOMELocalTrace/Makefile.in | 7 +- src/SALOMELocalTrace/utilities.h | 1 - .../LocalTrace_WaitForServerReadiness.cxx | 0 .../LocalTrace_WaitForServerReadiness.hxx | 0 src/SALOMETraceCollector/Makefile.in | 52 ++++ .../SALOMETraceCollector.cxx | 279 ++++++++++++++++++ .../SALOMETraceCollector.hxx | 54 ++++ src/Session/Makefile.in | 2 +- src/Session/SALOME_Session_Server.cxx | 4 +- src/TestContainer/Makefile.in | 2 +- src/TestContainer/TestContainer.cxx | 4 +- 55 files changed, 1500 insertions(+), 187 deletions(-) create mode 100755 salome_adm/unix/config_files/check_lsf.m4 create mode 100644 src/Batch/Batch_BatchManager_LSF.cxx create mode 100644 src/Batch/Batch_BatchManager_LSF.hxx create mode 100644 src/Batch/Batch_FactBatchManager_LSF.cxx create mode 100644 src/Batch/Batch_FactBatchManager_LSF.hxx create mode 100644 src/Batch/Batch_JobInfo_LSF.cxx create mode 100644 src/Batch/Batch_JobInfo_LSF.hxx create mode 100644 src/Batch/Batch_Job_LSF.cxx create mode 100644 src/Batch/Batch_Job_LSF.hxx rename src/{SALOMELocalTrace => SALOMETraceCollector}/LocalTrace_WaitForServerReadiness.cxx (100%) rename src/{SALOMELocalTrace => SALOMETraceCollector}/LocalTrace_WaitForServerReadiness.hxx (100%) create mode 100644 src/SALOMETraceCollector/Makefile.in create mode 100644 src/SALOMETraceCollector/SALOMETraceCollector.cxx create mode 100644 src/SALOMETraceCollector/SALOMETraceCollector.hxx diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index b673049e9..717815401 100755 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -159,9 +159,12 @@ else: for aKey in ("containers","embedded","key","modules","standalone"): if not args.has_key(aKey): args[aKey]=[] -for aKey in ("gui","logger","xterm","portkill","killall"): +for aKey in ("gui","logger","file","xterm","portkill","killall"): if not args.has_key(aKey): args[aKey]=0 +if args["file"]: + afile=args["file"] + args["file"]=[afile] args["appname"] = appname ### searching for my port @@ -237,7 +240,7 @@ except: opterror=0 for opt in opts: - if not opt in ("h","g","l","x","m","e","s","c","p","k","t"): + if not opt in ("h","g","l","f","x","m","e","s","c","p","k","t"): print "command line error: -", opt opterror=1 @@ -250,7 +253,8 @@ if opts.has_key("h"): --help or -h : print this help --gui or -g : lancement du GUI --terminal -t : launching without gui (to deny --gui) - --logger or -l : redirection des messages dans un fichier + --logger or -l : redirection des messages via CORBA + --file=filename or -l=filename: redirection des messages dans un fichier --xterm or -x : les serveurs ouvrent une fenêtre xterm et les messages sont affichés dans cette fenêtre --modules=module1,module2,... : où modulen est le nom d'un module Salome à charger dans le catalogue or -m=module1,module2,... @@ -279,6 +283,8 @@ for opt in opts: args['gui'] = 1 elif opt == 'l': args['logger'] = 1 + elif opt == 'f': + args['file'] = opts['f'] elif opt == 'x': args['xterm'] = 1 elif opt == 'm': diff --git a/bin/runSalome.py b/bin/runSalome.py index 9cb2cfc67..d7ba78d8d 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -121,6 +121,8 @@ def set_env(args, modules_list, modules_root_dir): # special path for logger lib if needeed os.environ["SALOME_trace"]="local" + if args['file']: + os.environ["SALOME_trace"]=args['file'][0] if args['logger']: os.environ["SALOME_trace"]="with_logger" locdir=os.environ['PWD'] diff --git a/bin/salome.launch b/bin/salome.launch index 1b5bbdd1b..92c5eab6d 100644 --- a/bin/salome.launch +++ b/bin/salome.launch @@ -2,6 +2,7 @@ yes no + no yes no diff --git a/bin/salome/runIDLparser.in b/bin/salome/runIDLparser.in index 085ac77d8..79e309eb2 100644 --- a/bin/salome/runIDLparser.in +++ b/bin/salome/runIDLparser.in @@ -37,9 +37,9 @@ fi cd $DIR -PYTHONPATH=${PYTHONPATH}:${SALOME_HOME_DIR}/bin +#PYTHONPATH=${PYTHONPATH}:${SALOME_HOME_DIR}/bin #============================================================ # omiidl ==================================================== -omniidl -bIDLparser -I ${SALOME_SRC_DIR}/idl $@ +omniidl -bIDLparser -I ${KERNEL_ROOT_DIR}/idl $@ #============================================================ diff --git a/configure.in.base b/configure.in.base index 8c0768b44..a382869d9 100644 --- a/configure.in.base +++ b/configure.in.base @@ -186,6 +186,22 @@ openpbs_ok=no CHECK_OPENPBS dnl openpbs_ok is set to yes by CHECK_OPENPBS +dnl +dnl --------------------------------------------- +dnl testing LSF +dnl --------------------------------------------- +dnl + +echo +echo --------------------------------------------- +echo testing LSF +echo --------------------------------------------- +echo + +lsf_ok=no +CHECK_LSF +dnl lsf_ok is set to yes by CHECK_LSF + echo echo --------------------------------------------- echo testing LEX \& YACC @@ -340,7 +356,7 @@ echo --------------------------------------------- echo echo Configure -variables="cc_ok boost_ok lex_yacc_ok mpi_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok med2_ok omniORB_ok occ_ok sip_ok pyqt_ok qwt_ok doxygen_ok graphviz_ok openpbs_ok" +variables="cc_ok boost_ok lex_yacc_ok mpi_ok python_ok swig_ok threads_ok OpenGL_ok qt_ok vtk_ok hdf5_ok med2_ok omniORB_ok occ_ok sip_ok pyqt_ok qwt_ok doxygen_ok graphviz_ok openpbs_ok lsf_ok" for var in $variables do diff --git a/salome_adm/unix/config_files/check_lsf.m4 b/salome_adm/unix/config_files/check_lsf.m4 new file mode 100755 index 000000000..5fb9e0b10 --- /dev/null +++ b/salome_adm/unix/config_files/check_lsf.m4 @@ -0,0 +1,76 @@ +# Check for LSF +AC_DEFUN([CHECK_LSF], +[ + AC_ARG_WITH([lsf], + AC_HELP_STRING([--with-lsf[[[[[=path] ]]]]], + [tell configure script to use LSF that is located at . Default is no. If path is not given, it is automaticaly determined from LSF_ENVDIR variable.]), + [], + [withval=no]) + + AC_MSG_CHECKING([for LSF]) + + if test ! "x$withval" = "xno" + then + if test "x$withval" = "xyes" + then + if test ! "x$LSF_ENVDIR" = "x" + then + test -f "$LSF_ENVDIR/lsf.conf" && . "$LSF_ENVDIR/lsf.conf" + LSF=$LSF_TOP + else + dnl some default values ... + LSF=/usr + LSF_INCLUDEDIR=$LSF/include + LSF_LIBDIR=$LSF/lib + fi + else + LSF=$withval + LSF_INCLUDEDIR=$LSF/include + LSF_LIBDIR=$LSF/lib + fi + + AC_MSG_RESULT([$LSF]) + + dnl INCLUDE directory + + LSF_INCLUDES="-I${LSF_INCLUDEDIR}" + saved_CPPFLAGS=${CPPFLAGS} + CPPFLAGS="${CPPFLAGS} ${LSF_INCLUDES}" + AC_CHECK_HEADER([lsf/lsbatch.h], [lsf_header_found=yes], [lsf_header_found=no], []) + test x${lsf_header_found} = xno && AC_MSG_WARN([LSF include file not found]) + CPPFLAGS=${saved_CPPFLAGS} + AC_SUBST(LSF_INCLUDES) + + dnl LIB directory + + LSF_LDFLAGS="-L${LSF_LIBDIR}" + LSF_LIBS="" + saved_LDFLAGS=${LDFLAGS} + saved_LIBS=${LIBS} + LDFLAGS="${LDFLAGS} ${LSF_LDFLAGS}" + lsf_lib_found=yes + AC_CHECK_LIB([lsf], [ls_load], [lsf_libs="-llsf ${lsf_libs}"], [lsf_lib_found=no], []) + AC_CHECK_LIB([bat], [lsb_init], [lsf_libs="-lbat ${lsf_libs}"], [lsf_lib_found=no], [-llsf]) + test x${lsf_lib_found} = xno && AC_MSG_WARN([LSF library not found]) + LIBS="${LSF_LIBS} ${LIBS}" + LDFLAGS=${saved_LDFLAGS} + LIBS=${saved_LIBS} + AC_SUBST(LSF_LDFLAGS) + AC_SUBST(LSF_LIBS) + + test x${lsf_lib_found} = xyes && test x${lsf_header_found} = xyes && WITH_LSF=yes + + else + WITH_LSF=no + + AC_MSG_RESULT([no]) + + fi + + dnl AM_CONDITIONAL(WITH_LSF, test $WITH_LSF = 1) + + lsf_ok=$WITH_LSF + AC_SUBST(WITH_LSF) + +]) + diff --git a/salome_adm/unix/config_files/production.m4 b/salome_adm/unix/config_files/production.m4 index e3da0539b..dfa8b39e9 100644 --- a/salome_adm/unix/config_files/production.m4 +++ b/salome_adm/unix/config_files/production.m4 @@ -53,15 +53,15 @@ no) enable_production=no ;; esac], enable_production=AC_ENABLE_PRODUCTION_DEFAULT)dnl -# supprimer car ne marche qu'avec compilo gnu -# CXXVERSION=`$CXX --version` -# if test "X$CXXVERSION" != "X2.95.3"; then -# CXXFLAGS="${CXXFLAGS} -fmessage-length=0 " -# fi +AC_CXX_OPTION(-Wno-deprecated,CXXFLAGS) +AC_CXX_OPTION(-Wparentheses,CXXFLAGS) +AC_CXX_OPTION(-Wreturn-type,CXXFLAGS) +AC_CXX_OPTION(-Wmissing-declarations,CXXFLAGS) +AC_CXX_OPTION(-fmessage-length=0,CXXFLAGS) +AC_CXX_OPTION(-Wunused,CXXFLAGS) if test "X$enable_production" = "Xyes"; then CFLAGS="$CFLAGS -O" -# CXXFLAGS="$CXXFLAGS -O -Wuninitialized " AC_CXX_OPTION(-Wuninitialized,CXXFLAGS) CXXFLAGS="$CXXFLAGS -O " fi diff --git a/salome_adm/unix/make_commence.in b/salome_adm/unix/make_commence.in index cabebbd71..77747e2b8 100644 --- a/salome_adm/unix/make_commence.in +++ b/salome_adm/unix/make_commence.in @@ -46,6 +46,12 @@ OPENPBS_INCLUDES = @OPENPBS_INCLUDES@ OPENPBS_LIBDIR = @OPENPBS_LIBDIR@ OPENPBS_LIBS = @OPENPBS_LIBS@ +# LSF + +LSF_INCLUDES = @LSF_INCLUDES@ +LSF_LIBDIR = @LSF_LDFLAGS@ +LSF_LIBS = @LSF_LIBS@ + # JAVA #JAVA_INCLUDES = @JAVA_INCLUDES@ diff --git a/src/Batch/Batch_BatchManager.hxx b/src/Batch/Batch_BatchManager.hxx index c132a575a..60d80e376 100644 --- a/src/Batch/Batch_BatchManager.hxx +++ b/src/Batch/Batch_BatchManager.hxx @@ -29,28 +29,28 @@ namespace Batch { public: // Constructeur et destructeur //BatchManager(std::string host="localhost") throw(InvalidArgumentException); // connexion a la machine host - BatchManager(const FactBatchManager * parent, const char * host="localhost") throw(InvalidArgumentException); // connexion a la machine host + BatchManager(const Batch::FactBatchManager * parent, const char * host="localhost") throw(InvalidArgumentException); // connexion a la machine host virtual ~BatchManager(); virtual std::string __repr__() const; // Recupere le l'identifiant d'un job deja soumis au BatchManager //virtual const JobId getJobIdByReference(const std::string & ref); - virtual const JobId getJobIdByReference(const char * ref); + virtual const Batch::JobId getJobIdByReference(const char * ref); // Methodes pour le controle des jobs : virtuelles pures - virtual const JobId submitJob(const Job & job) = 0; // soumet un job au gestionnaire - virtual void deleteJob(const JobId & jobid) = 0; // retire un job du gestionnaire - virtual void holdJob(const JobId & jobid) = 0; // suspend un job en file d'attente - virtual void releaseJob(const JobId & jobid) = 0; // relache un job suspendu - virtual void alterJob(const JobId & jobid, const Parametre & param, const Environnement & env) = 0; // modifie un job en file d'attente - virtual void alterJob(const JobId & jobid, const Parametre & param) = 0; // modifie un job en file d'attente - virtual void alterJob(const JobId & jobid, const Environnement & env) = 0; // modifie un job en file d'attente - virtual JobInfo queryJob(const JobId & jobid) = 0; // renvoie l'etat du job + virtual const Batch::JobId submitJob(const Batch::Job & job) = 0; // soumet un job au gestionnaire + virtual void deleteJob(const Batch::JobId & jobid) = 0; // retire un job du gestionnaire + virtual void holdJob(const Batch::JobId & jobid) = 0; // suspend un job en file d'attente + virtual void releaseJob(const Batch::JobId & jobid) = 0; // relache un job suspendu + virtual void alterJob(const Batch::JobId & jobid, const Batch::Parametre & param, const Batch::Environnement & env) = 0; // modifie un job en file d'attente + virtual void alterJob(const Batch::JobId & jobid, const Batch::Parametre & param) = 0; // modifie un job en file d'attente + virtual void alterJob(const Batch::JobId & jobid, const Batch::Environnement & env) = 0; // modifie un job en file d'attente + virtual Batch::JobInfo queryJob(const Batch::JobId & jobid) = 0; // renvoie l'etat du job protected: std::string _hostname; // serveur ou tourne le BatchManager - std::map< const std::string, const JobId * > jobid_map; // table des jobs deja soumis - const FactBatchManager * _parent; + std::map< const std::string, const Batch::JobId * > jobid_map; // table des jobs deja soumis + const Batch::FactBatchManager * _parent; private: diff --git a/src/Batch/Batch_BatchManagerCatalog.hxx b/src/Batch/Batch_BatchManagerCatalog.hxx index 1857fa059..46daa59d5 100644 --- a/src/Batch/Batch_BatchManagerCatalog.hxx +++ b/src/Batch/Batch_BatchManagerCatalog.hxx @@ -26,9 +26,9 @@ namespace Batch { // Destructeur virtual ~BatchManagerCatalog(); - static FactBatchManager * getFactBatchManager(const char * type); - static void addFactBatchManager(const char * type, FactBatchManager * pFBM); - virtual FactBatchManager * operator() (const char * type) const; + static Batch::FactBatchManager * getFactBatchManager(const char * type); + static void addFactBatchManager(const char * type, Batch::FactBatchManager * pFBM); + virtual Batch::FactBatchManager * operator() (const char * type) const; virtual std::map * dict() const; virtual std::string __repr__() const; diff --git a/src/Batch/Batch_BatchManager_LSF.cxx b/src/Batch/Batch_BatchManager_LSF.cxx new file mode 100644 index 000000000..76f90745c --- /dev/null +++ b/src/Batch/Batch_BatchManager_LSF.cxx @@ -0,0 +1,170 @@ +/* + * BatchManager_LSF.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Thu Nov 6 10:17:22 2003 + * Projet : Salome 2 + * + */ + +extern "C" { +#include +#include +} +#include +#include +#include +#include "Batch_BatchManager_LSF.hxx" + +namespace Batch { + + BatchManager_LSF::BatchManager_LSF(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager(parent, host) + { + // On se connecte au serveur LSF + _connect = lsb_init("Salome2 Batch library"); + if (_connect < 0) { // si erreur + char * errmsg = lsb_sysmsg(); + string msg = "LSF Server on host \""; + msg += _hostname; + msg += "\" : "; + msg += errmsg ? errmsg : "Reason unknown"; + throw ConnexionFailureException(msg.c_str()); + } + } + + // Destructeur + BatchManager_LSF::~BatchManager_LSF() + { + // Nothing to do + } + + // Methode pour le controle des jobs : soumet un job au gestionnaire + const JobId BatchManager_LSF::submitJob(const Job & job) + { + Job_LSF joblsf = job; + struct submitReply reply; + int ref = lsb_submit(joblsf.getSubmitStruct(), + &reply); + if (ref < 0) { // si erreur + char * msg = lsb_sysmsg(); + if (!msg) msg = "unknown"; + throw APIInternalFailureException(string("LSF submit error. Reason : ") + msg); + } + + ostringstream oss; + oss << ref; + JobId id(this, oss.str()); + return id; + } + + // Methode pour le controle des jobs : retire un job du gestionnaire + void BatchManager_LSF::deleteJob(const JobId & jobid) + { + int ref; + istringstream iss(jobid.getReference()); + iss >> ref; + int rc = lsb_deletejob(ref, 0, 0); + if (rc < 0) { // si erreur + char * msg = lsb_sysmsg(); + if (!msg) msg = "unknown"; + throw APIInternalFailureException(string("LSF deljob error. Reason : ") + msg); + } + } + + // Methode pour le controle des jobs : suspend un job en file d'attente + void BatchManager_LSF::holdJob(const JobId & jobid) + { + int ref; + istringstream iss(jobid.getReference()); + iss >> ref; + int rc = lsb_signaljob(ref, SIGSTOP); + if (rc < 0) { // si erreur + char * msg = lsb_sysmsg(); + if (!msg) msg = "unknown"; + throw APIInternalFailureException(string("LSF signaljob error. Reason : ") + msg); + } + } + + // Methode pour le controle des jobs : relache un job suspendu + void BatchManager_LSF::releaseJob(const JobId & jobid) + { + int ref; + istringstream iss(jobid.getReference()); + iss >> ref; + int rc = lsb_signaljob(ref, SIGCONT); + if (rc < 0) { // si erreur + char * msg = lsb_sysmsg(); + if (!msg) msg = "unknown"; + throw APIInternalFailureException(string("LSF signaljob error. Reason : ") + msg); + } + } + + + // Methode pour le controle des jobs : modifie un job en file d'attente + void BatchManager_LSF::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env) + { + int ref; + istringstream iss(jobid.getReference()); + iss >> ref; + + Job_LSF joblsf = Job(param, env); + struct submitReply reply; + ref = lsb_modify(joblsf.getSubmitStruct(), + &reply, + ref); + if (ref < 0) { // si erreur + ostringstream msg_sst; + char * msg = lsb_sysmsg(); + if (!msg) msg = "unknown"; + msg_sst << msg << endl; +// msg_sst << "BadJobId = " << (long) reply.badJobId << endl +// << "BadJobName = " << reply.badJobName << endl +// << "BadReqIndx = " << reply.badReqIndx << endl; + throw APIInternalFailureException(string("LSF modify error. Reason : ") + msg_sst.str()); + } + } + + // Methode pour le controle des jobs : modifie un job en file d'attente + void BatchManager_LSF::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_LSF::alterJob(const JobId & jobid, const Environnement & env) + { + alterJob(jobid, Parametre(), env); + } + + + + // Methode pour le controle des jobs : renvoie l'etat du job + JobInfo BatchManager_LSF::queryJob(const JobId & jobid) + { + int id; + istringstream iss(jobid.getReference()); + iss >> id; + + JobInfo_LSF ji = JobInfo_LSF(id); + + return ji; + } + + + + // Methode pour le controle des jobs : teste si un job est present en machine + bool BatchManager_LSF::isRunning(const JobId & jobid) + { + int id; + istringstream iss(jobid.getReference()); + iss >> id; + + JobInfo_LSF ji = JobInfo_LSF(id); + + return ji.isRunning(); + } + + + +} diff --git a/src/Batch/Batch_BatchManager_LSF.hxx b/src/Batch/Batch_BatchManager_LSF.hxx new file mode 100644 index 000000000..9b93c66e6 --- /dev/null +++ b/src/Batch/Batch_BatchManager_LSF.hxx @@ -0,0 +1,75 @@ +/* + * BatchManager_LSF.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Thu Nov 6 10:17:22 2003 + * Projet : Salome 2 + * + */ + +#ifndef _BATCHMANAGER_LSF_H_ +#define _BATCHMANAGER_LSF_H_ + + +#include "Batch_Job.hxx" +#include "Batch_Job.hxx" +#include "Batch_JobId.hxx" +#include "Batch_JobInfo.hxx" +#include "Batch_JobInfo_LSF.hxx" +#include "Batch_Job_LSF.hxx" +#include "Batch_InvalidArgumentException.hxx" +#include "Batch_ConnexionFailureException.hxx" +#include "Batch_APIInternalFailureException.hxx" +#include "Batch_NotYetImplementedException.hxx" +#include "Batch_BatchManager.hxx" + +namespace Batch { + + class Job; + class JobId; + class JobInfo; + class FactBatchManager; + + class BatchManager_LSF : public BatchManager + { + public: + // Constructeur et destructeur + BatchManager_LSF(const FactBatchManager * parent, const char * host="localhost") throw(InvalidArgumentException,ConnexionFailureException); // connexion a la machine host + virtual ~BatchManager_LSF(); + + // 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: + int _connect; // LSF connect id + + 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 diff --git a/src/Batch/Batch_FactBatchManager.hxx b/src/Batch/Batch_FactBatchManager.hxx index 2a662d73c..389976e11 100644 --- a/src/Batch/Batch_FactBatchManager.hxx +++ b/src/Batch/Batch_FactBatchManager.hxx @@ -24,7 +24,7 @@ namespace Batch { FactBatchManager(const std::string & type); virtual ~FactBatchManager(); - virtual BatchManager * operator() (const char * hostname) const = 0; + virtual Batch::BatchManager * operator() (const char * hostname) const = 0; std::string getType() const; std::string __repr__() const; diff --git a/src/Batch/Batch_FactBatchManager_LSF.cxx b/src/Batch/Batch_FactBatchManager_LSF.cxx new file mode 100644 index 000000000..6dada01fe --- /dev/null +++ b/src/Batch/Batch_FactBatchManager_LSF.cxx @@ -0,0 +1,39 @@ +/* + * FactBatchManager_LSF.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2004 + * Projet : SALOME 2 + * + */ + +#include +#include "Batch_BatchManager_LSF.hxx" +#include "Batch_FactBatchManager_LSF.hxx" +//#include "utilities.h" + +namespace Batch { + + static FactBatchManager_LSF sFBM_LSF; + + // Constructeur + FactBatchManager_LSF::FactBatchManager_LSF() : FactBatchManager("LSF") + { + // Nothing to do + } + + // Destructeur + FactBatchManager_LSF::~FactBatchManager_LSF() + { + // Nothing to do + } + + // Functor + BatchManager * FactBatchManager_LSF::operator() (const char * hostname) const + { + // MESSAGE("Building new BatchManager_LSF on host '" << hostname << "'"); + return new BatchManager_LSF(this, hostname); + } + + +} diff --git a/src/Batch/Batch_FactBatchManager_LSF.hxx b/src/Batch/Batch_FactBatchManager_LSF.hxx new file mode 100644 index 000000000..de59dbab5 --- /dev/null +++ b/src/Batch/Batch_FactBatchManager_LSF.hxx @@ -0,0 +1,39 @@ +/* + * FactBatchManager_LSF.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2004 + * Projet : SALOME 2 + * + */ + +#ifndef _FACTBATCHMANAGER_LSF_H_ +#define _FACTBATCHMANAGER_LSF_H_ + +using namespace std; +#include +#include +#include "Batch_FactBatchManager.hxx" + +namespace Batch { + + class BatchManager_LSF; + + class FactBatchManager_LSF : public FactBatchManager + { + public: + // Constructeur et destructeur + FactBatchManager_LSF(); + virtual ~FactBatchManager_LSF(); + + virtual BatchManager * operator() (const char * hostname) const; + + protected: + + private: + + }; + +} + +#endif diff --git a/src/Batch/Batch_FactBatchManager_PBS.cxx b/src/Batch/Batch_FactBatchManager_PBS.cxx index d2ded29ca..81ba4901c 100644 --- a/src/Batch/Batch_FactBatchManager_PBS.cxx +++ b/src/Batch/Batch_FactBatchManager_PBS.cxx @@ -30,7 +30,7 @@ namespace Batch { } // Functor - BatchManager_PBS * FactBatchManager_PBS::operator() (const char * hostname) const + BatchManager * FactBatchManager_PBS::operator() (const char * hostname) const { MESSAGE("Building new BatchManager_PBS on host '" << hostname << "'"); return new BatchManager_PBS(this, hostname); diff --git a/src/Batch/Batch_FactBatchManager_PBS.hxx b/src/Batch/Batch_FactBatchManager_PBS.hxx index fdf053c1b..1ee9e50ad 100644 --- a/src/Batch/Batch_FactBatchManager_PBS.hxx +++ b/src/Batch/Batch_FactBatchManager_PBS.hxx @@ -23,7 +23,7 @@ namespace Batch { FactBatchManager_PBS(); virtual ~FactBatchManager_PBS(); - virtual BatchManager_PBS * operator() (const char * hostname) const; + virtual BatchManager * operator() (const char * hostname) const; protected: diff --git a/src/Batch/Batch_Job.hxx b/src/Batch/Batch_Job.hxx index 66fdf0494..7f2ab9abb 100644 --- a/src/Batch/Batch_Job.hxx +++ b/src/Batch/Batch_Job.hxx @@ -21,21 +21,21 @@ namespace Batch { public: // Constructeurs et destructeur Job(); - Job(Parametre param); - Job(Environnement env); - Job(Parametre param, Environnement env); + Job(Batch::Parametre param); + Job(Batch::Environnement env); + Job(Batch::Parametre param, Batch::Environnement env); virtual ~Job() {} // Operateur pour l'affichage sur un stream friend std::ostream & operator <<(std::ostream & os, const Job & job); // Accesseurs - Parametre getParametre() const; - void setParametre(const Parametre &); + Batch::Parametre getParametre() const; + void setParametre(const Batch::Parametre &); // Accesseurs - Environnement getEnvironnement() const; - void setEnvironnement(const Environnement &); + Batch::Environnement getEnvironnement() const; + void setEnvironnement(const Batch::Environnement &); // Methodes pour l'interfacage avec Python (SWIG) // TODO : supprimer ces methodes et transferer leur definitions dans SWIG @@ -43,8 +43,8 @@ namespace Batch { std::string __repr__() const { return __str__(); }; // SWIG : affichage en Python protected: - Parametre _param; // table des parametres batch du job - Environnement _env; // table des variables d'environnement + Batch::Parametre _param; // table des parametres batch du job + Batch::Environnement _env; // table des variables d'environnement private: diff --git a/src/Batch/Batch_JobId.hxx b/src/Batch/Batch_JobId.hxx index be14e7f9e..e8cfe50d1 100644 --- a/src/Batch/Batch_JobId.hxx +++ b/src/Batch/Batch_JobId.hxx @@ -28,13 +28,13 @@ namespace Batch { virtual ~JobId(); // Constructeur avec le pointeur sur le BatchManager associe et avec une reference - JobId(BatchManager *, std::string ref); + JobId(Batch::BatchManager *, std::string ref); // Operateur d'affectation entre objets - virtual JobId & operator =(const JobId &); + virtual JobId & operator =(const Batch::JobId &); // Constructeur par recopie - JobId(const JobId &); + JobId(const Batch::JobId &); // Accesseur pour la reference interne virtual std::string getReference() const; @@ -43,11 +43,11 @@ namespace Batch { virtual void deleteJob() const; // retire un job du gestionnaire virtual void holdJob() const; // suspend un job en file d'attente virtual void releaseJob() const; // relache un job suspendu - virtual void alterJob(const Parametre & param, const Environnement & env) const; // modifie un job en file d'attente - virtual void alterJob(const Parametre & param) const; // modifie un job en file d'attente - virtual void alterJob(const Environnement & env) const; // modifie un job en file d'attente - virtual void setParametre(const Parametre & param) { return alterJob(param); } // modifie un job en file d'attente - virtual void setEnvironnement(const Environnement & env) { return alterJob(env); } // modifie un job en file d'attente + virtual void alterJob(const Batch::Parametre & param, const Batch::Environnement & env) const; // modifie un job en file d'attente + virtual void alterJob(const Batch::Parametre & param) const; // modifie un job en file d'attente + virtual void alterJob(const Batch::Environnement & env) const; // modifie un job en file d'attente + virtual void setParametre(const Batch::Parametre & param) { return alterJob(param); } // modifie un job en file d'attente + virtual void setEnvironnement(const Batch::Environnement & env) { return alterJob(env); } // modifie un job en file d'attente virtual Batch::JobInfo queryJob() const; // renvoie l'etat du job // Methodes pour l'interfacage avec Python (SWIG) @@ -56,7 +56,7 @@ namespace Batch { std::string __repr__() const { return __str__(); }; // SWIG : affichage en Python protected: - BatchManager * _p_batchmanager; // pointeur sur le BatchManager qui controle le job + Batch::BatchManager * _p_batchmanager; // pointeur sur le BatchManager qui controle le job std::string _reference; // reference du job au sein du BatchManager private: diff --git a/src/Batch/Batch_JobInfo.hxx b/src/Batch/Batch_JobInfo.hxx index 7cdca6535..e9c251c94 100644 --- a/src/Batch/Batch_JobInfo.hxx +++ b/src/Batch/Batch_JobInfo.hxx @@ -26,14 +26,14 @@ namespace Batch { virtual ~JobInfo(); // Constructeur par recopie - JobInfo(const JobInfo & jinfo) : _param(jinfo._param), _env(jinfo._env) {}; + JobInfo(const Batch::JobInfo & jinfo) : _param(jinfo._param), _env(jinfo._env) {}; // Operateur pour l'affichage sur un stream - friend std::ostream & operator <<(std::ostream & os, const JobInfo & ji); + friend std::ostream & operator <<(std::ostream & os, const Batch::JobInfo & ji); // Accesseurs - virtual Parametre getParametre() const; - virtual Environnement getEnvironnement() const; + virtual Batch::Parametre getParametre() const; + virtual Batch::Environnement getEnvironnement() const; // Methodes pour l'interfacage avec Python (SWIG) // TODO : supprimer ces methodes et transferer leur definitions dans SWIG @@ -41,8 +41,8 @@ namespace Batch { std::string __repr__() const { return __str__(); }; // SWIG : affichage en Python protected: - Parametre _param; // parametres du job - Environnement _env; // variables d'environnement du job + Batch::Parametre _param; // parametres du job + Batch::Environnement _env; // variables d'environnement du job private: diff --git a/src/Batch/Batch_JobInfo_LSF.cxx b/src/Batch/Batch_JobInfo_LSF.cxx new file mode 100644 index 000000000..acb1f4b81 --- /dev/null +++ b/src/Batch/Batch_JobInfo_LSF.cxx @@ -0,0 +1,180 @@ +/* + * JobInfo_LSF.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Fri Nov 21 09:42:06 2003 + * Projet : Salome 2 + * + */ + +#include +#include +#include "Batch_Parametre.hxx" +#include "Batch_Environnement.hxx" +#include "Batch_RunTimeException.hxx" +#include "Batch_APIInternalFailureException.hxx" +#include "Batch_JobInfo_LSF.hxx" + +namespace Batch { + + + + // Constructeurs + JobInfo_LSF::JobInfo_LSF(int id) : JobInfo() + { + struct loadIndexLog * p_ld = new struct loadIndexLog; + struct jobInfoHead * p_jInfoHead = lsb_openjobinfo_a(id, NULL, NULL, NULL, NULL, ALL_JOB); + + int more = p_jInfoHead->numJobs; + if (more != 1) { + char * msg = lsb_sysmsg(); + if (!msg) msg = "unknown"; + throw APIInternalFailureException(string("LSF lsb_openjobinfo error. Reason : ") + msg); + } + + // on remplit une structure contenant elements + struct jobInfoEnt & jobInfo = * lsb_readjobinfo(&more); + + + // On remplit les membres _param et _env + _param[ACCOUNT] = jobInfo.submit.projectName; + _param[CHECKPOINT] = jobInfo.submit.chkpntPeriod != 0; + _param[CKPTINTERVAL] = jobInfo.submit.chkpntPeriod; + _param[CREATIONTIME] = jobInfo.submitTime; + // _param[EGROUP] = jobInfo.; + _param[ELIGIBLETIME] = jobInfo.reserveTime; + _param[ENDTIME] = jobInfo.endTime; + _param[EUSER] = jobInfo.execUsername; + _param[EXECUTABLE] = jobInfo.submit.command; + _param[EXITCODE] = jobInfo.exitStatus; + _param[HOLD] = jobInfo.status & (JOB_STAT_PSUSP | JOB_STAT_SSUSP | JOB_STAT_USUSP); + _param[MAIL] = jobInfo.submit.mailUser; + _param[MAXCPUTIME] = jobInfo.submit.rLimits[LSF_RLIMIT_CPU]; + _param[MAXDISKSIZE] = jobInfo.submit.rLimits[LSF_RLIMIT_FSIZE]; + _param[MAXRAMSIZE] = jobInfo.submit.rLimits[LSF_RLIMIT_SWAP]; + _param[MAXWALLTIME] = jobInfo.submit.rLimits[LSF_RLIMIT_RUN]; + _param[MODIFICATIONTIME] = jobInfo.lastEvent; + _param[NAME] = jobInfo.jName; + _param[NBPROC] = jobInfo.submit.numProcessors; + _param[PID] = jobInfo.jobPid; + _param[QUEUE] = jobInfo.submit.queue; + _param[QUEUEDTIME] = jobInfo.submitTime; + // _param[SERVER] = jobInfo.; + _param[STARTTIME] = jobInfo.startTime; + _param[TEXT] = jobInfo.numReasons ? lsb_pendreason(jobInfo.numReasons, + jobInfo.reasonTb, + p_jInfoHead, + p_ld) : ""; + // _param[TMPDIR] = jobInfo.; + _param[USEDCPUTIME] = static_cast(jobInfo.cpuTime); + // _param[USEDDISKSIZE] = jobInfo.; + _param[USEDRAMSIZE] = jobInfo.runRusage.mem; + _param[USEDWALLTIME] = jobInfo.duration * 60L; + _param[USER] = jobInfo.user; + + + ostringstream oss; + int jobid = jobInfo.jobId; + oss << jobid; + _param[ID] = oss.str(); + + + string hosts, sep; + for(int i=0; i < jobInfo.numExHosts; i++, sep="+") { + hosts += jobInfo.exHosts[i]; + hosts += sep; + } + _param[EXECUTIONHOST] = hosts; + + ostringstream status; + + if (IS_PEND(jobInfo.status)) + status << " Job is pending;"; + if (IS_START(jobInfo.status)) + status << " Job is started;"; + if (IS_FINISH(jobInfo.status)) + status << " Job is finished;"; + if (IS_SUSP(jobInfo.status)) + status << " Job is suspended;"; + if (IS_POST_DONE(jobInfo.status)) + status << " Job is post-done;"; + if (IS_POST_ERR(jobInfo.status)) + status << " Job is post-error;"; + + _param[STATE] = status.str(); + _running = IS_FINISH(jobInfo.status) ? false : true; + + + if (strlen(jobInfo.submit.inFile)) + _param[INFILE] += Couple(jobInfo.submit.inFile, "stdin"); + if (strlen(jobInfo.submit.outFile)) + _param[OUTFILE] += Couple(jobInfo.submit.outFile, "stdout"); + if (strlen(jobInfo.submit.errFile)) + _param[OUTFILE] += Couple(jobInfo.submit.errFile, "stderr"); + + for(int i=0; i < jobInfo.submit.nxf; i++) { + switch (jobInfo.submit.xf[i].options) { + case XF_OP_SUB2EXEC: + _param[INFILE] += Couple(jobInfo.submit.xf[i].subFn, jobInfo.submit.xf[i].execFn); + break; + + case XF_OP_EXEC2SUB: + _param[OUTFILE] += Couple(jobInfo.submit.xf[i].subFn, jobInfo.submit.xf[i].execFn); + break; + + default: + break; + } + } + + + lsb_closejobinfo(); + delete p_ld; + } + + + + // Teste si un job est present en machine + bool JobInfo_LSF::isRunning() const + { + return _running; + } + + + // Destructeur + JobInfo_LSF::~JobInfo_LSF() + { + // Nothing to do + } + + + + // Convertit une date HH:MM:SS en secondes + long JobInfo_LSF::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_LSF::__str__() const + { + ostringstream sst; + sst << " +#include +} +#include +#include "Batch_RunTimeException.hxx" +#include "Batch_JobInfo.hxx" + +namespace Batch { + + class JobInfo_LSF : public JobInfo + { + public: + // Constructeurs et destructeur + JobInfo_LSF() : _running(false) {}; + JobInfo_LSF(int id); + virtual ~JobInfo_LSF(); + + // Constructeur par recopie + JobInfo_LSF(const JobInfo_LSF & 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 + string __str__() const; // SWIG : affichage en Python + 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 string &); + + }; + +} + +#endif diff --git a/src/Batch/Batch_Job_LSF.cxx b/src/Batch/Batch_Job_LSF.cxx new file mode 100644 index 000000000..91466145c --- /dev/null +++ b/src/Batch/Batch_Job_LSF.cxx @@ -0,0 +1,241 @@ +/* + * Job_LSF.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Fri Nov 14 11:00:39 2003 + * Projet : Salome 2 + * + */ + +#include +#include +#include +#include +#include +#include "Batch_Job_LSF.hxx" + +namespace Batch { + + + // Constructeur + Job_LSF::Job_LSF(const Job & job) : _p_submit(0) + { + Parametre P = job.getParametre(); + _p_submit = ParametreToSubmitStruct(P); + } + + + // Destructeur + Job_LSF::~Job_LSF() + { + if (_p_submit) { + if (_p_submit->jobName) delete [] _p_submit->jobName; + if (_p_submit->queue) delete [] _p_submit->queue; + if (_p_submit->askedHosts) { + delete [] *(_p_submit->askedHosts); + delete [] _p_submit->askedHosts; + } + if (_p_submit->resReq) delete [] _p_submit->resReq; + if (_p_submit->hostSpec) delete [] _p_submit->hostSpec; + if (_p_submit->dependCond) delete [] _p_submit->dependCond; + if (_p_submit->timeEvent) delete [] _p_submit->timeEvent; + if (_p_submit->inFile) delete [] _p_submit->inFile; + if (_p_submit->outFile) delete [] _p_submit->outFile; + if (_p_submit->errFile) delete [] _p_submit->errFile; + if (_p_submit->command) delete [] _p_submit->command; + if (_p_submit->newCommand) delete [] _p_submit->newCommand; + if (_p_submit->chkpntDir) delete [] _p_submit->chkpntDir; + if (_p_submit->xf) delete [] _p_submit->xf; + if (_p_submit->preExecCmd) delete [] _p_submit->preExecCmd; + if (_p_submit->mailUser) delete [] _p_submit->mailUser; + if (_p_submit->projectName) delete [] _p_submit->projectName; + if (_p_submit->loginShell) delete [] _p_submit->loginShell; + if (_p_submit->exceptList) delete [] _p_submit->exceptList; + delete _p_submit; + } + } + + + // Accesseur + struct submit * Job_LSF::getSubmitStruct() + { + return _p_submit; + } + + + char * Job_LSF::string2char(const string & s) + { + char * ch = new char [s.size() + 1]; + memset(ch, 0, s.size() + 1); + strncat(ch, s.c_str(), s.size()); + return ch; + } + + + struct submit * Job_LSF::ParametreToSubmitStruct(const Parametre & P) + { + if (! _p_submit) _p_submit = new struct submit; + + memset( (void *) _p_submit, 0, sizeof(struct submit)); + + struct submit & sub = * _p_submit; + sub.options = 0; + sub.options2 = 0; + + sub.beginTime = 0; // job can run as soon as possible (default) + sub.termTime = 0; // job can run as long as it wishes (default) + + sub.numProcessors = 1; // job can run on one single processor (default) + sub.maxNumProcessors = 1; // job can run on one single processor (default) + + for(int i = 0; i< LSF_RLIM_NLIMITS; i++) sub.rLimits[i] = DEFAULT_RLIMIT; + + typedef std::vector< struct xFile > XFTAB; + XFTAB xf_tab; + + string st_second; + for(Parametre::const_iterator it = P.begin(); it != P.end(); it++) { + if ( (*it).first == ACCOUNT ) { + sub.options |= SUB_PROJECT_NAME; + st_second = (*it).second.str(); + sub.projectName = string2char(st_second); + + } else if ( (*it).first == CHECKPOINT ) { + if (static_cast< long >((*it).second)) + sub.options |= SUB_CHKPNT_PERIOD; + else + sub.options &= ~ SUB_CHKPNT_PERIOD; + + } else if ( (*it).first == CKPTINTERVAL ) { + sub.chkpntPeriod = static_cast< long >((*it).second); + + } else if ( (*it).first == EXECUTABLE ) { + st_second = (*it).second.str(); + sub.command = string2char(st_second); + + } else if ( (*it).first == EXECUTIONHOST ) { + sub.options |= SUB_HOST; + if (! sub.numAskedHosts) { + sub.numAskedHosts = 1; + sub.askedHosts = new char* [1]; + } + st_second = (*it).second.str(); + sub.askedHosts[0] = string2char(st_second); + + } else if ( (*it).first == HOLD ) { + if (static_cast< long >((*it).second)) + sub.options2 |= SUB2_HOLD; + else + sub.options2 &= ~ SUB2_HOLD; + + } else if ( (*it).first == INFILE ) { + Versatile V = (*it).second; + Versatile::iterator Vit; + + for(Vit=V.begin(); Vit!=V.end(); Vit++) { + CoupleType cpt = *static_cast< CoupleType * >(*Vit); + Couple cp = cpt; + string local = cp.getLocal(); + string remote = cp.getRemote(); + + // ATTENTION : les notions de fichier "local" ou "remote" sont inverses de celle de PBS qui a un point de vue serveur et non pas utilisateur + if (remote == "stdin"){ + sub.options |= SUB_IN_FILE; + sub.inFile = string2char(local); + + } else { + struct xFile xf; + strncpy(xf.subFn, local.c_str(), MAXFILENAMELEN); xf.subFn[MAXFILENAMELEN] = 0; + strncpy(xf.execFn, remote.c_str(), MAXFILENAMELEN); xf.execFn[MAXFILENAMELEN] = 0; + xf.options = XF_OP_SUB2EXEC; + xf_tab.push_back(xf); + } + } + + } else if ( (*it).first == MAIL ) { + sub.options |= SUB_MAIL_USER; + st_second = (*it).second.str(); + sub.mailUser = string2char(st_second); + + } else if ( (*it).first == MAXCPUTIME ) { + sub.rLimits[LSF_RLIMIT_CPU] = static_cast< long >((*it).second); + + } else if ( (*it).first == MAXDISKSIZE ) { + sub.rLimits[LSF_RLIMIT_FSIZE] = static_cast< long >((*it).second); + + } else if ( (*it).first == MAXRAMSIZE ) { + sub.rLimits[LSF_RLIMIT_SWAP] = static_cast< long >((*it).second); + + } else if ( (*it).first == MAXWALLTIME ) { + sub.rLimits[LSF_RLIMIT_RUN] = static_cast< long >((*it).second); + + } else if ( (*it).first == NAME ) { + sub.options |= SUB_JOB_NAME; + st_second = (*it).second.str(); + sub.jobName = string2char(st_second); + + } else if ( (*it).first == NBPROC ) { + sub.numProcessors = static_cast< long >((*it).second); + sub.maxNumProcessors = static_cast< long >((*it).second); + + } else if ( (*it).first == OUTFILE ) { + Versatile V = (*it).second; + Versatile::iterator Vit; + + for(Vit=V.begin(); Vit!=V.end(); Vit++) { + CoupleType cpt = *static_cast< CoupleType * >(*Vit); + Couple cp = cpt; + string local = cp.getLocal(); + string remote = cp.getRemote(); + + // ATTENTION : les notions de fichier "local" ou "remote" sont inverses de celle de PBS qui a un point de vue serveur et non pas utilisateur + if (remote == "stdout"){ + sub.options |= SUB_OUT_FILE; + sub.outFile = string2char(local); + + } else if (remote == "stderr"){ + sub.options |= SUB_ERR_FILE; + sub.errFile = string2char(local); + + } else { + struct xFile xf; + strncpy(xf.subFn, local.c_str(), MAXFILENAMELEN); xf.subFn[MAXFILENAMELEN] = 0; + strncpy(xf.execFn, remote.c_str(), MAXFILENAMELEN); xf.execFn[MAXFILENAMELEN] = 0; + xf.options = XF_OP_EXEC2SUB; + xf_tab.push_back(xf); + } + } + + + } else if ( (*it).first == QUEUE ) { + sub.options |= SUB_QUEUE; + st_second = (*it).second.str(); + sub.queue = string2char(st_second); + + } else if ( (*it).first == STARTTIME ) { + sub.beginTime = static_cast< long >((*it).second); + + } else if ( (*it).first == TMPDIR ) { + // TODO + + } else if ( (*it).first == USER ) { + // TODO + + } + } + + + // Transfert de fichiers en entree et sortie + sub.options |= SUB_OTHER_FILES; + sub.nxf = xf_tab.size(); + sub.xf = new struct xFile [sub.nxf]; + int ixf = 0; + for(XFTAB::const_iterator it_xf=xf_tab.begin(); it_xf != xf_tab.end(); it_xf++, ixf++) + sub.xf[ixf] = *it_xf; // *it_xf == xf_tab[ixf] + + + return _p_submit; + } + +} diff --git a/src/Batch/Batch_Job_LSF.hxx b/src/Batch/Batch_Job_LSF.hxx new file mode 100644 index 000000000..d10d7f2ab --- /dev/null +++ b/src/Batch/Batch_Job_LSF.hxx @@ -0,0 +1,43 @@ +/* + * Job_LSF.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Fri Nov 14 11:00:39 2003 + * Projet : Salome 2 + * + */ + +#ifndef _JOB_LSF_H_ +#define _JOB_LSF_H_ + +extern "C" { + +#include +#include +} +#include "Batch_Job.hxx" + +namespace Batch { + + class Job_LSF + { + public: + // Constructeur et destructeur + Job_LSF(const Job & job); + virtual ~Job_LSF(); + + // Accesseurs + struct submit * getSubmitStruct(); + + protected: + struct submit * _p_submit; // structure pour soumettre les jobs + + private: + struct submit * ParametreToSubmitStruct(const Parametre & P); + char * string2char(const string &); + }; + +} + +#endif diff --git a/src/Batch/Makefile.in b/src/Batch/Makefile.in index 703e6c7e1..6b83960e3 100644 --- a/src/Batch/Makefile.in +++ b/src/Batch/Makefile.in @@ -66,13 +66,6 @@ EXPORT_HEADERS = \ Batch_TypeMismatchException.hxx \ Batch_Versatile.hxx -# Specialisation pour OpenPBS -EXPORT_HEADERS += \ - Batch_BatchManager_PBS.hxx \ - Batch_FactBatchManager_PBS.hxx \ - Batch_JobInfo_PBS.hxx \ - Batch_Job_PBS.hxx - # Libraries targets @@ -109,22 +102,58 @@ LIB_SRC = \ Batch_TypeMismatchException.cxx \ Batch_Versatile.cxx +LIB_SERVER_IDL = + + +CPPFLAGS += $(PYTHON_INCLUDES) +CXXFLAGS += $(PYTHON_INCLUDES) +LDFLAGS += +LIBS += -lSALOMELocalTrace + + + # Specialisation pour OpenPBS +ifeq (@WITHOPENPBS@,yes) +EXPORT_HEADERS += \ + Batch_BatchManager_PBS.hxx \ + Batch_FactBatchManager_PBS.hxx \ + Batch_JobInfo_PBS.hxx \ + Batch_Job_PBS.hxx + LIB_SRC += \ Batch_BatchManager_PBS.cxx \ Batch_FactBatchManager_PBS.cxx \ Batch_JobInfo_PBS.cxx \ Batch_Job_PBS.cxx -LIB_SERVER_IDL = +CPPFLAGS += $(OPENPBS_INCLUDES) +CXXFLAGS += $(OPENPBS_INCLUDES) +LDFLAGS += $(OPENPBS_LIBDIR) +LIBS += $(OPENPBS_LIBS) +endif + -CPPFLAGS += $(PYTHON_INCLUDES) $(OPENPBS_INCLUDES) -CXXFLAGS += $(PYTHON_INCLUDES) $(OPENPBS_INCLUDES) +# Specialisation pour LSF +ifeq (@WITH_LSF@,yes) +EXPORT_HEADERS += \ + Batch_BatchManager_LSF.hxx \ + Batch_FactBatchManager_LSF.hxx \ + Batch_JobInfo_LSF.hxx \ + Batch_Job_LSF.hxx + +LIB_SRC += \ + Batch_BatchManager_LSF.cxx \ + Batch_FactBatchManager_LSF.cxx \ + Batch_JobInfo_LSF.cxx \ + Batch_Job_LSF.cxx -LDFLAGS += $(OPENPBS_LIBDIR) +CPPFLAGS += $(LSF_INCLUDES) +CXXFLAGS += $(LSF_INCLUDES) +LDFLAGS += $(LSF_LIBDIR) +LIBS += $(LSF_LIBS) +endif -LIBS += $(OPENPBS_LIBS) -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/Batch_SWIG/libBatch_Swig.i b/src/Batch_SWIG/libBatch_Swig.i index 1f82f0dfa..92a802741 100644 --- a/src/Batch_SWIG/libBatch_Swig.i +++ b/src/Batch_SWIG/libBatch_Swig.i @@ -36,7 +36,6 @@ #include "Batch_BatchManager.hxx" #include "Batch_BatchManagerCatalog.hxx" #include "Batch_FactBatchManager.hxx" -using namespace Batch; %} /* Les classes exportees en Python */ diff --git a/src/Batch_SWIG/libBatch_Swig_exception.i b/src/Batch_SWIG/libBatch_Swig_exception.i index 880ae9085..06a9d0a52 100644 --- a/src/Batch_SWIG/libBatch_Swig_exception.i +++ b/src/Batch_SWIG/libBatch_Swig_exception.i @@ -11,8 +11,8 @@ try { $action } - catch (GenericException & ex) { - string msg = ex.type + " : " + ex.message; + catch (Batch::GenericException & ex) { + std::string msg = ex.type + " : " + ex.message; PyErr_SetString(PyExc_RuntimeWarning, msg.c_str()); return NULL; } diff --git a/src/Batch_SWIG/libBatch_Swig_typemap.i b/src/Batch_SWIG/libBatch_Swig_typemap.i index 9116e8798..4c701c709 100644 --- a/src/Batch_SWIG/libBatch_Swig_typemap.i +++ b/src/Batch_SWIG/libBatch_Swig_typemap.i @@ -22,13 +22,13 @@ # // construction d'un dictionnaire Python a partir d'un objet BatchManagerCatalog C++ -%typemap(out) map * +%typemap(out) std::map * { $result = PyDict_New(); // on itere sur toutes les clefs de la map - for(map::const_iterator it=(* $1).begin(); it!=(* $1).end(); it++) { - string key = (*it).first; + for(std::map::const_iterator it=(* $1).begin(); it!=(* $1).end(); it++) { + std::string key = (*it).first; PyObject * obj = SWIG_NewPointerObj((void *) (*it).second, SWIGTYPE_p_Batch__FactBatchManager, 0); PyDict_SetItem($result, PyString_FromString(key.c_str()), obj); } @@ -36,22 +36,22 @@ # // construction d'un dictionnaire Python a partir d'un objet Parametre C++ -%typemap(out) Parametre +%typemap(out) Batch::Parametre { $result = PyDict_New(); // on itere sur toutes les clefs de la map, et on passe par la classe PyVersatile // qui convertit un Versatile en PyObject et vice versa - for(Parametre::const_iterator it=$1.begin(); it!=$1.end(); it++) { - string key = (*it).first; - PyVersatile PyV = (*it).second; + for(Batch::Parametre::const_iterator it=$1.begin(); it!=$1.end(); it++) { + std::string key = (*it).first; + Batch::PyVersatile PyV = (*it).second; PyDict_SetItem($result, PyString_FromString(key.c_str()), PyV); } } # // construction d'un objet Parametre C++ a partir d'un dictionnaire Python -%typemap(in) Parametre & (Parametre PM) +%typemap(in) Batch::Parametre & (Batch::Parametre PM) { if (!PyDict_Check($input)) { PyErr_SetString(PyExc_ValueError,"Expected a dictionnary"); @@ -64,16 +64,16 @@ PyObject *key, *value; int pos = 0; while (PyDict_Next($input, &pos, &key, &value)) { - string mk = PyString_AsString(key); - PyVersatile PyV = value; + std::string mk = PyString_AsString(key); + Batch::PyVersatile PyV = value; PyV.setName(mk); PM[mk] = PyV; } $1 = &PM; // $1 est une reference donc on lui passe une adresse } - catch (GenericException & ex) { - string msg = ex.type + " : " + ex.message; + catch (Batch::GenericException & ex) { + std::string msg = ex.type + " : " + ex.message; PyErr_SetString(PyExc_RuntimeWarning, msg.c_str()); return NULL; } @@ -85,7 +85,7 @@ # // construction d'un objet Parametre C++ a partir d'un dictionnaire Python -%typemap(in) Parametre (Parametre PM) +%typemap(in) Batch::Parametre (Batch::Parametre PM) { if (!PyDict_Check($input)) { PyErr_SetString(PyExc_ValueError,"Expected a dictionnary"); @@ -98,16 +98,16 @@ PyObject *key, *value; int pos = 0; while (PyDict_Next($input, &pos, &key, &value)) { - string mk = PyString_AsString(key); - PyVersatile PyV = value; + std::string mk = PyString_AsString(key); + Batch::PyVersatile PyV = value; PyV.setName(mk); PM[mk] = PyV; } $1 = PM; } - catch (GenericException & ex) { - string msg = ex.type + " : " + ex.message; + catch (Batch::GenericException & ex) { + std::string msg = ex.type + " : " + ex.message; PyErr_SetString(PyExc_RuntimeWarning, msg.c_str()); return NULL; } @@ -119,14 +119,14 @@ # // construction d'un dictionnaire Python a partir d'un objet Environnement C++ -%typemap(out) Environnement +%typemap(out) Batch::Environnement { $result = PyDict_New(); // on itere sur toutes les clefs de la map - for(Environnement::const_iterator it=$1.begin(); it!=$1.end(); it++) { - string key = (*it).first; - string val = (*it).second; + for(Batch::Environnement::const_iterator it=$1.begin(); it!=$1.end(); it++) { + std::string key = (*it).first; + std::string val = (*it).second; PyDict_SetItem($result, PyString_FromString(key.c_str()), PyString_FromString(val.c_str())); @@ -135,7 +135,7 @@ # // construction d'un objet Environnement C++ a partir d'un dictionnaire Python -%typemap(in) Environnement & (Environnement E) +%typemap(in) Batch::Environnement & (Batch::Environnement E) { if (!PyDict_Check($input)) { PyErr_SetString(PyExc_ValueError,"Expected a dictionnary"); @@ -146,8 +146,8 @@ PyObject *key, *value; int pos = 0; while (PyDict_Next($input, &pos, &key, &value)) { - string mk = PyString_AsString(key); - string val = PyString_AsString(value); + std::string mk = PyString_AsString(key); + std::string val = PyString_AsString(value); E[mk] = val; } @@ -157,7 +157,7 @@ # // construction d'un objet Environnement C++ a partir d'un dictionnaire Python -%typemap(in) Environnement (Environnement E) +%typemap(in) Batch::Environnement (Batch::Environnement E) { if (!PyDict_Check($input)) { PyErr_SetString(PyExc_ValueError,"Expected a dictionnary"); @@ -168,8 +168,8 @@ PyObject *key, *value; int pos = 0; while (PyDict_Next($input, &pos, &key, &value)) { - string mk = PyString_AsString(key); - string val = PyString_AsString(value); + std::string mk = PyString_AsString(key); + std::string val = PyString_AsString(value); E[mk] = val; } @@ -179,7 +179,7 @@ # // construction d'une string Python a partir d'une string STL -%typemap(python,out) string +%typemap(python,out) std::string { $result = PyString_FromString($1.c_str()); } diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index 0e28bd47d..880bb0438 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -193,6 +193,10 @@ void Engines_Component_i::beginService(const char *serviceName) { const char* value; (*it).second >>= value; + // --- todo: replace __GNUC__ test by an autoconf macro AC_CHECK_FUNC... +#if defined __GNUC__ + int ret = setenv(cle.c_str(), value, overwrite); +#else //CCRT porting : setenv not defined in stdlib.h std::string s(cle); s+='='; @@ -200,7 +204,7 @@ void Engines_Component_i::beginService(const char *serviceName) //char* cast because 1st arg of linux putenv function is not a const char* !!! int ret=putenv((char *)s.c_str()); //End of CCRT porting - //int ret = setenv(cle.c_str(), value, overwrite); +#endif MESSAGE("--- setenv: "< @@ -61,7 +61,7 @@ int main(int argc, char* argv[]) // Initialise the ORB. ORB_INIT &init = *SINGLETON_::Instance() ; CORBA::ORB_var &orb = init( argc , argv ) ; - LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb); + SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); INFOS_COMPILATION; BEGIN_OF(argv[0]); diff --git a/src/DataTypeCatalog/Makefile.in b/src/DataTypeCatalog/Makefile.in index 5759b3b46..f5bd3bc35 100644 --- a/src/DataTypeCatalog/Makefile.in +++ b/src/DataTypeCatalog/Makefile.in @@ -54,6 +54,6 @@ BIN_SERVER_IDL = SALOME_DataTypeCatalog.idl CPPFLAGS+= $(QT_MT_INCLUDES) CXXFLAGS+= -LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace +LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace -lSALOMETraceCollector @CONCLUDE@ diff --git a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx index 988cd8961..d79829163 100644 --- a/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx +++ b/src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx @@ -30,7 +30,7 @@ #include "SALOME_NamingService.hxx" #include "SALOME_DataTypeCatalog_impl.hxx" #include "utilities.h" -#include "LocalTraceCollector.hxx" +#include "SALOMETraceCollector.hxx" #include "Utils_SINGLETON.hxx" using namespace std; @@ -38,7 +38,7 @@ int main(int argc,char **argv) { // initialize the ORB CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv); - LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb); + SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); try { CosNaming::NamingContext_var _rootContext, catalogContext; diff --git a/src/Loader/Makefile.in b/src/Loader/Makefile.in index 972c503b6..99c98ab06 100644 --- a/src/Loader/Makefile.in +++ b/src/Loader/Makefile.in @@ -31,7 +31,7 @@ BIN_CLIENT_IDL = SALOME_Session.idl \ CPPFLAGS+=$(QT_MT_INCLUDES) CXXFLAGS+=$(OCC_CXXFLAGS) -LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace +LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace -lSALOMETraceCollector @CONCLUDE@ diff --git a/src/Loader/SALOME_Session_Loader.cxx b/src/Loader/SALOME_Session_Loader.cxx index 0db216d3c..4456b95ed 100644 --- a/src/Loader/SALOME_Session_Loader.cxx +++ b/src/Loader/SALOME_Session_Loader.cxx @@ -18,7 +18,7 @@ #include "Utils_SINGLETON.hxx" #include "SALOME_NamingService.hxx" #include "utilities.h" -#include "LocalTraceCollector.hxx" +#include "SALOMETraceCollector.hxx" //! CORBA client for SALOME Session server : launch GUI /*! @@ -32,7 +32,7 @@ using namespace std; int main(int argc, char **argv) { CORBA::ORB_ptr orb = CORBA::ORB_init(argc,argv) ; - LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb); + SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); //VRV: T2.4 - Trace management improvement QApplication myQApp(argc, argv) ; InquireServersGUI myIS; diff --git a/src/Makefile.in b/src/Makefile.in index d97b5e791..8f779b462 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -33,7 +33,7 @@ VPATH=.:@srcdir@ @COMMENCE@ ifeq (@WITHIHM@,yes) -SUBDIRS = MSG2QM SALOMELocalTrace Logger Utils CASCatch PatchQt \ +SUBDIRS = MSG2QM SALOMELocalTrace SALOMETraceCollector Logger Utils CASCatch PatchQt \ GenericObj MEDWrapper NamingService Registry \ ModuleCatalog DataTypeCatalog RessourcesCatalog \ Notification NOTIFICATION_SWIG \ diff --git a/src/ModuleCatalog/Makefile.in b/src/ModuleCatalog/Makefile.in index 3d9a203c8..0ba61bbaa 100644 --- a/src/ModuleCatalog/Makefile.in +++ b/src/ModuleCatalog/Makefile.in @@ -62,6 +62,6 @@ LIB_CLIENT_IDL = SALOME_ModuleCatalog.idl BIN_SERVER_IDL = SALOME_ModuleCatalog.idl CPPFLAGS+= $(QT_MT_INCLUDES) -LDFLAGS+= $(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace +LDFLAGS+= $(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace -lSALOMETraceCollector @CONCLUDE@ diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx index 942c8f33d..9a5fb15ce 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx @@ -29,7 +29,7 @@ #include "SALOME_NamingService.hxx" #include "SALOME_ModuleCatalog_impl.hxx" #include "utilities.h" -#include "LocalTraceCollector.hxx" +#include "SALOMETraceCollector.hxx" #include "Utils_SINGLETON.hxx" #ifdef CHECKTIME @@ -41,7 +41,7 @@ int main(int argc,char **argv) { // initialize the ORB CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv); - LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb); + SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); try { CosNaming::NamingContext_var _rootContext, catalogContext; diff --git a/src/Registry/Makefile.in b/src/Registry/Makefile.in index 2219e4235..cbcbf3931 100644 --- a/src/Registry/Makefile.in +++ b/src/Registry/Makefile.in @@ -53,6 +53,6 @@ BIN = SALOME_Registry_Server BIN_SRC = BIN_SERVER_IDL = SALOME_Registry.idl -LDFLAGS+= -lSalomeNS -lOpUtil -lSALOMELocalTrace +LDFLAGS+= -lSalomeNS -lOpUtil -lSALOMELocalTrace -lSALOMETraceCollector @CONCLUDE@ diff --git a/src/Registry/SALOME_Registry_Server.cxx b/src/Registry/SALOME_Registry_Server.cxx index 510366547..d47523a93 100644 --- a/src/Registry/SALOME_Registry_Server.cxx +++ b/src/Registry/SALOME_Registry_Server.cxx @@ -36,7 +36,7 @@ extern "C" } #include "utilities.h" -#include "LocalTraceCollector.hxx" +#include "SALOMETraceCollector.hxx" #include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" #include "Utils_SALOME_Exception.hxx" @@ -54,7 +54,7 @@ int main( int argc , char **argv ) { ORB_INIT &init = *SINGLETON_::Instance() ; CORBA::ORB_var &orb = init( argc , argv ) ; - LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb); + SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); BEGIN_OF( argv[0] ) INFOS_COMPILATION SCRUTE(argc) diff --git a/src/RessourcesCatalog/Makefile.in b/src/RessourcesCatalog/Makefile.in index c129dad04..b43546776 100644 --- a/src/RessourcesCatalog/Makefile.in +++ b/src/RessourcesCatalog/Makefile.in @@ -54,7 +54,7 @@ BIN_SERVER_IDL = SALOME_RessourcesCatalog.idl CPPFLAGS+= $(QT_MT_INCLUDES) CXXFLAGS+= -LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace +LDFLAGS+= $(QT_MT_LIBS) $(OGL_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace -lSALOMETraceCollector @CONCLUDE@ diff --git a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx index f8018d340..b52c63b67 100644 --- a/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx +++ b/src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx @@ -30,7 +30,7 @@ #include "SALOME_NamingService.hxx" #include "SALOME_RessourcesCatalog_impl.hxx" #include "utilities.h" -#include "LocalTraceCollector.hxx" +#include "SALOMETraceCollector.hxx" #include "Utils_SINGLETON.hxx" using namespace std; @@ -38,7 +38,7 @@ int main(int argc,char **argv) { // initialize the ORB CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv); - LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb); + SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); try { CosNaming::NamingContext_var _rootContext, catalogContext; diff --git a/src/SALOMELocalTrace/LocalTraceCollector.cxx b/src/SALOMELocalTrace/LocalTraceCollector.cxx index 0cb334b40..37c2557ec 100644 --- a/src/SALOMELocalTrace/LocalTraceCollector.cxx +++ b/src/SALOMELocalTrace/LocalTraceCollector.cxx @@ -28,15 +28,10 @@ #include #include #include -#include using namespace std; #include "LocalTraceCollector.hxx" -#include "LocalTrace_WaitForServerReadiness.hxx" -//#include "SALOME_Log.hxx" -#include -#include CORBA_CLIENT_HEADER(Logger) // Class attributes initialisation, for class method LocalTraceCollector::run @@ -46,23 +41,20 @@ int LocalTraceCollector::_threadToClose = 0; pthread_t LocalTraceCollector::_threadId = 0; // used to control single run int LocalTraceCollector::_toFile = 0; std::string LocalTraceCollector::_fileName = ""; -CORBA::ORB_ptr LocalTraceCollector::_orb = 0; // ============================================================================ /*! * guarantees a unique object instance of the class (singleton thread safe) * a separate thread for loop to print traces is launched. - * \param typeTrace 0=standard out, 1=file(/tmp/tracetest.log), 2=CORBA log + * \param typeTrace 0=standard out, 1=file(/tmp/tracetest.log) * If typeTrace=0, checks environment for "SALOME_trace". Test values in * the following order: * - "local" standard out - * - "with_logger" CORBA log * - anything else is kept as a file name */ // ============================================================================ -LocalTraceCollector* LocalTraceCollector::instance(CORBA::ORB_ptr theOrb, - int typeTrace) +LocalTraceCollector* LocalTraceCollector::instance(int typeTrace) { if (_singleton == 0) // no need of lock when singleton already exists { @@ -74,7 +66,7 @@ LocalTraceCollector* LocalTraceCollector::instance(CORBA::ORB_ptr theOrb, _fileName = "/tmp/tracetest.log"; _toFile=0; - _orb = theOrb; + if (typeTrace) // caller sets a value different from default=0 _toFile = typeTrace; else // check environment @@ -84,7 +76,7 @@ LocalTraceCollector* LocalTraceCollector::instance(CORBA::ORB_ptr theOrb, if (traceKind) { if (strcmp(traceKind,"local")==0) _toFile=0; - else if (strcmp(traceKind,"with_logger")==0) _toFile=2; + else { _toFile=1; @@ -135,11 +127,9 @@ void* LocalTraceCollector::run(void *bid) // if trace in file requested, opens a file with append mode // so, several processes can share the same file - // if CORBA collection requested, wait for Logger server readiness + ofstream traceFile; - SALOME_Logger::Logger_var m_pInterfaceLogger; - CORBA::Object_var obj; switch (_toFile) { @@ -154,24 +144,7 @@ void* LocalTraceCollector::run(void *bid) } } break; - case 2 : // --- trace collection via CORBA - obj = LocalTrace_WaitForServerReadiness(_orb,"Logger"); - if (!CORBA::is_nil(obj)) - m_pInterfaceLogger = SALOME_Logger::Logger::_narrow(obj); - if (CORBA::is_nil(m_pInterfaceLogger)) - { - cerr << "Logger server not found ! Abort" << endl; - cerr << flush ; - exit(1); - } - else - { - CORBA::String_var LogMsg = - CORBA::string_dup("\n---Init logger trace---\n"); - m_pInterfaceLogger->putMessage(LogMsg); - //cout << " Logger server found" << endl; - } - break; + case 0 : ; // --- trace to standard output default : // --- on standard output, too break; @@ -187,17 +160,6 @@ void* LocalTraceCollector::run(void *bid) { switch (_toFile) { - case 2 : // --- trace collection via CORBA - { - stringstream abortMessage(""); - abortMessage << "INTERRUPTION from thread " - << myTrace.threadId << " : " << myTrace.trace; - CORBA::String_var LogMsg = - CORBA::string_dup(abortMessage.str().c_str()); - m_pInterfaceLogger->putMessage(LogMsg); - exit(1); - } - break; case 1 : // --- trace to file traceFile << "INTERRUPTION from thread " << myTrace.threadId << " : " << myTrace.trace; @@ -217,16 +179,6 @@ void* LocalTraceCollector::run(void *bid) { switch (_toFile) { - case 2 : // --- trace collection via CORBA - { - stringstream aMessage(""); - aMessage << "th. " << myTrace.threadId - << " " << myTrace.trace; - CORBA::String_var LogMsg = - CORBA::string_dup(aMessage.str().c_str()); - m_pInterfaceLogger->putMessage(LogMsg); - } - break; case 1 : // --- trace to file traceFile << "th. " << myTrace.threadId << " " << myTrace.trace; @@ -252,14 +204,15 @@ void* LocalTraceCollector::run(void *bid) LocalTraceCollector:: ~LocalTraceCollector() { + LocalTraceBufferPool* myTraceBuffer = LocalTraceBufferPool::instance(); _threadToClose = 1; + myTraceBuffer->insert(NORMAL_MESS,"end of trace "); //needed to wake up thread if (_threadId) { int ret = pthread_join(_threadId, NULL); if (ret) cout << "error close LocalTraceCollector : "<< ret << endl; else cout << "LocalTraceCollector destruction OK" << endl; } - LocalTraceBufferPool* myTraceBuffer = LocalTraceBufferPool::instance(); delete myTraceBuffer; } diff --git a/src/SALOMELocalTrace/LocalTraceCollector.hxx b/src/SALOMELocalTrace/LocalTraceCollector.hxx index 90101efd3..bad917721 100644 --- a/src/SALOMELocalTrace/LocalTraceCollector.hxx +++ b/src/SALOMELocalTrace/LocalTraceCollector.hxx @@ -28,13 +28,12 @@ #define _LOCALTRACECOLLECTOR_HXX_ #include -#include #include "LocalTraceBufferPool.hxx" class LocalTraceCollector { public: - static LocalTraceCollector* instance(CORBA::ORB_ptr theOrb, int typeTrace=0); + static LocalTraceCollector* instance(int typeTrace=0); static void *run(void *bid); ~LocalTraceCollector(); @@ -48,7 +47,6 @@ class LocalTraceCollector static pthread_mutex_t _singletonMutex; static pthread_t _threadId; static std::string _fileName; - static CORBA::ORB_ptr _orb; }; #endif diff --git a/src/SALOMELocalTrace/Makefile.in b/src/SALOMELocalTrace/Makefile.in index 5928c6409..8d2beb1d5 100644 --- a/src/SALOMELocalTrace/Makefile.in +++ b/src/SALOMELocalTrace/Makefile.in @@ -37,8 +37,7 @@ VPATH=.:@srcdir@:@top_srcdir@/idl # header files EXPORT_HEADERS= utilities.h \ LocalTraceBufferPool.hxx \ - LocalTraceCollector.hxx \ - LocalTrace_WaitForServerReadiness.hxx + LocalTraceCollector.hxx EXPORT_PYSCRIPTS = @@ -46,10 +45,8 @@ EXPORT_PYSCRIPTS = LIB = libSALOMELocalTrace.la LIB_SRC = LocalTraceCollector.cxx \ - LocalTraceBufferPool.cxx \ - LocalTrace_WaitForServerReadiness.cxx + LocalTraceBufferPool.cxx -LIB_CLIENT_IDL = Logger.idl LDFLAGS+= @CONCLUDE@ diff --git a/src/SALOMELocalTrace/utilities.h b/src/SALOMELocalTrace/utilities.h index 28696612b..40238630f 100644 --- a/src/SALOMELocalTrace/utilities.h +++ b/src/SALOMELocalTrace/utilities.h @@ -31,7 +31,6 @@ #ifndef UTILITIES_H #define UTILITIES_H -#include #include #include #include diff --git a/src/SALOMELocalTrace/LocalTrace_WaitForServerReadiness.cxx b/src/SALOMETraceCollector/LocalTrace_WaitForServerReadiness.cxx similarity index 100% rename from src/SALOMELocalTrace/LocalTrace_WaitForServerReadiness.cxx rename to src/SALOMETraceCollector/LocalTrace_WaitForServerReadiness.cxx diff --git a/src/SALOMELocalTrace/LocalTrace_WaitForServerReadiness.hxx b/src/SALOMETraceCollector/LocalTrace_WaitForServerReadiness.hxx similarity index 100% rename from src/SALOMELocalTrace/LocalTrace_WaitForServerReadiness.hxx rename to src/SALOMETraceCollector/LocalTrace_WaitForServerReadiness.hxx diff --git a/src/SALOMETraceCollector/Makefile.in b/src/SALOMETraceCollector/Makefile.in new file mode 100644 index 000000000..394805883 --- /dev/null +++ b/src/SALOMETraceCollector/Makefile.in @@ -0,0 +1,52 @@ +# SALOMELocalTrace : log on local machine +# +# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Paul RASCLE (EDF) +# Module : SALOME +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= SALOMETraceCollector.hxx \ + LocalTrace_WaitForServerReadiness.hxx + +EXPORT_PYSCRIPTS = + +# Libraries targets + +LIB = libSALOMETraceCollector.la +LIB_SRC = SALOMETraceCollector.cxx \ + LocalTrace_WaitForServerReadiness.cxx + +LIB_CLIENT_IDL = Logger.idl +LDFLAGS+= + +@CONCLUDE@ diff --git a/src/SALOMETraceCollector/SALOMETraceCollector.cxx b/src/SALOMETraceCollector/SALOMETraceCollector.cxx new file mode 100644 index 000000000..933670635 --- /dev/null +++ b/src/SALOMETraceCollector/SALOMETraceCollector.cxx @@ -0,0 +1,279 @@ +// Copyright (C) 2004 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 : LocalTraceCollector.cxx +// Author : Paul RASCLE (EDF) +// Module : KERNEL +// $Header$ + +#include +#include +#include +#include +#include + +using namespace std; + +#include "SALOMETraceCollector.hxx" +#include "LocalTrace_WaitForServerReadiness.hxx" +//#include "SALOME_Log.hxx" +#include +#include CORBA_CLIENT_HEADER(Logger) + +// Class attributes initialisation, for class method SALOMETraceCollector::run + +SALOMETraceCollector* SALOMETraceCollector::_singleton = 0; +pthread_mutex_t SALOMETraceCollector::_singletonMutex; +int SALOMETraceCollector::_threadToClose = 0; +pthread_t SALOMETraceCollector::_threadId = 0; // used to control single run +int SALOMETraceCollector::_toFile = 0; +std::string SALOMETraceCollector::_fileName = ""; +CORBA::ORB_ptr SALOMETraceCollector::_orb = 0; + +// ============================================================================ +/*! + * guarantees a unique object instance of the class (singleton thread safe) + * a separate thread for loop to print traces is launched. + * \param typeTrace 0=standard out, 1=file(/tmp/tracetest.log), 2=CORBA log + * If typeTrace=0, checks environment for "SALOME_trace". Test values in + * the following order: + * - "local" standard out + * - "with_logger" CORBA log + * - anything else is kept as a file name + */ +// ============================================================================ + +SALOMETraceCollector* SALOMETraceCollector::instance(CORBA::ORB_ptr theOrb, + int typeTrace) +{ + if (_singleton == 0) // no need of lock when singleton already exists + { + int ret; + ret = pthread_mutex_lock(&_singletonMutex); // acquire lock to be alone + if (_singleton == 0) // another thread may have got + { // the lock after the first test + _singleton = new SALOMETraceCollector(); + + _fileName = "/tmp/tracetest.log"; + _toFile=0; + _orb = theOrb; + if (typeTrace) // caller sets a value different from default=0 + _toFile = typeTrace; + else // check environment + { + char* traceKind = getenv("SALOME_trace"); + //cout<<"SALOME_trace="<putMessage(LogMsg); + //cout << " Logger server found" << endl; + } + break; + case 0 : ; // --- trace to standard output + default : // --- on standard output, too + break; + } + + // Loop until there is no more buffer to print, + // and no ask for end from destructor. + + while ((!_threadToClose) || myTraceBuffer->toCollect() ) + { + int fullBuf = myTraceBuffer->retrieve(myTrace); + if (myTrace.traceType == ABORT_MESS) + { + switch (_toFile) + { + case 2 : // --- trace collection via CORBA + { + stringstream abortMessage(""); + abortMessage << "INTERRUPTION from thread " + << myTrace.threadId << " : " << myTrace.trace; + CORBA::String_var LogMsg = + CORBA::string_dup(abortMessage.str().c_str()); + m_pInterfaceLogger->putMessage(LogMsg); + exit(1); + } + break; + case 1 : // --- trace to file + traceFile << "INTERRUPTION from thread " << myTrace.threadId + << " : " << myTrace.trace; + traceFile.close(); + // no break here ! + case 0 : // --- trace to standard output + default : // --- on standard output, too + cout << flush ; + cerr << "INTERRUPTION from thread " << myTrace.threadId + << " : " << myTrace.trace; + cerr << flush ; + exit(1); + break; + } + } + else + { + switch (_toFile) + { + case 2 : // --- trace collection via CORBA + { + stringstream aMessage(""); + aMessage << "th. " << myTrace.threadId + << " " << myTrace.trace; + CORBA::String_var LogMsg = + CORBA::string_dup(aMessage.str().c_str()); + m_pInterfaceLogger->putMessage(LogMsg); + } + break; + case 1 : // --- trace to file + traceFile << "th. " << myTrace.threadId + << " " << myTrace.trace; + break; + case 0 : // --- trace to standard output + default : // --- on standard output, too + cout << "th. " << myTrace.threadId << " " << myTrace.trace; + break; + } + } + } + + if (_toFile==1) traceFile.close(); + } + pthread_exit(NULL); +} + +// ============================================================================ +/*! + * Destructor: wait until printing thread ends (SALOMETraceCollector::run) + */ +// ============================================================================ + +SALOMETraceCollector:: ~SALOMETraceCollector() +{ + LocalTraceBufferPool* myTraceBuffer = LocalTraceBufferPool::instance(); + _threadToClose = 1; + myTraceBuffer->insert(NORMAL_MESS,"end of trace "); //needed to wake up thread + if (_threadId) + { + int ret = pthread_join(_threadId, NULL); + if (ret) cout << "error close SALOMETraceCollector : "<< ret << endl; + else cout << "SALOMETraceCollector destruction OK" << endl; + } + delete myTraceBuffer; +} + +// ============================================================================ +/*! + * Constructor: no need of LocalTraceBufferPool object initialization here, + * thread safe singleton used in LocalTraceBufferPool::instance() + */ +// ============================================================================ + +SALOMETraceCollector::SALOMETraceCollector() +{ + _threadId=0; +} + + diff --git a/src/SALOMETraceCollector/SALOMETraceCollector.hxx b/src/SALOMETraceCollector/SALOMETraceCollector.hxx new file mode 100644 index 000000000..846c4adf2 --- /dev/null +++ b/src/SALOMETraceCollector/SALOMETraceCollector.hxx @@ -0,0 +1,54 @@ +// Copyright (C) 2004 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 : SALOMETraceCollector.hxx +// Author : Paul RASCLE (EDF) +// Module : KERNEL +// $Header$ + +#ifndef _SALOMETRACECOLLECTOR_HXX_ +#define _SALOMETRACECOLLECTOR_HXX_ + +#include +#include +#include "LocalTraceBufferPool.hxx" + +class SALOMETraceCollector +{ + public: + static SALOMETraceCollector* instance(CORBA::ORB_ptr theOrb, int typeTrace=0); + static void *run(void *bid); + ~SALOMETraceCollector(); + + protected: + SALOMETraceCollector(); + + private: + static int _threadToClose; + static int _toFile; + static SALOMETraceCollector* _singleton; + static pthread_mutex_t _singletonMutex; + static pthread_t _threadId; + static std::string _fileName; + static CORBA::ORB_ptr _orb; +}; + +#endif diff --git a/src/Session/Makefile.in b/src/Session/Makefile.in index 01c587221..45ce4c82b 100644 --- a/src/Session/Makefile.in +++ b/src/Session/Makefile.in @@ -53,7 +53,7 @@ BIN_CLIENT_IDL = SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Component.idl SALOM CPPFLAGS+=$(QT_MT_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) $(HDF5_INCLUDES) CXXFLAGS+=$(OCC_CXXFLAGS) -LDFLAGS+=$(QT_MT_LIBS) $(HDF5_LIBS) -lSalomeHDFPersist -lSalomeNS -lSalomeGUI -lSalomeObject -lSalomeLifeCycleCORBA -lqsplitterP -lOpUtil -lPlot2d -lSalomeVTKFilter -lSALOMELocalTrace -lSalomeContainer -lRegistry -lSalomeNotification -lSalomeDS -lTOOLSDS -lSalomeGenericObj -lSalomeCatalog -lEvent -lSalomePrs $(CAS_LDPATH) -lTKBO -lCASCatch +LDFLAGS+=$(QT_MT_LIBS) $(HDF5_LIBS) -lSalomeHDFPersist -lSalomeNS -lSalomeGUI -lSalomeObject -lSalomeLifeCycleCORBA -lqsplitterP -lOpUtil -lPlot2d -lSalomeVTKFilter -lSALOMELocalTrace -lSALOMETraceCollector -lSalomeContainer -lRegistry -lSalomeNotification -lSalomeDS -lTOOLSDS -lSalomeGenericObj -lSalomeCatalog -lEvent -lSalomePrs $(CAS_LDPATH) -lTKBO -lCASCatch @CONCLUDE@ diff --git a/src/Session/SALOME_Session_Server.cxx b/src/Session/SALOME_Session_Server.cxx index 33d3440a3..17a971859 100644 --- a/src/Session/SALOME_Session_Server.cxx +++ b/src/Session/SALOME_Session_Server.cxx @@ -55,7 +55,7 @@ #include CORBA_SERVER_HEADER(SALOMEDS) #include "utilities.h" -#include "LocalTraceCollector.hxx" +#include "SALOMETraceCollector.hxx" #include "SALOME_Session_i.hxx" @@ -96,7 +96,7 @@ int main(int argc, char **argv) ORB_INIT &init = *SINGLETON_::Instance() ; int orbArgc = 1; CORBA::ORB_var &orb = init( orbArgc , argv ) ; - LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb); + SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); try { CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); diff --git a/src/TestContainer/Makefile.in b/src/TestContainer/Makefile.in index 8ee409d99..b16797b1f 100644 --- a/src/TestContainer/Makefile.in +++ b/src/TestContainer/Makefile.in @@ -45,7 +45,7 @@ LIB_CLIENT_IDL = SALOME_Component.idl SALOME_TestComponent.idl BIN = TestContainer TestLogger BIN_SRC = -LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace +LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace -lSALOMETraceCollector @CONCLUDE@ diff --git a/src/TestContainer/TestContainer.cxx b/src/TestContainer/TestContainer.cxx index 7766bb46e..e8492fb6e 100644 --- a/src/TestContainer/TestContainer.cxx +++ b/src/TestContainer/TestContainer.cxx @@ -39,7 +39,7 @@ #include "Utils_SINGLETON.hxx" #include "Utils_SALOME_Exception.hxx" #include "Utils_CommException.hxx" -#include "LocalTraceCollector.hxx" +#include "SALOMETraceCollector.hxx" using namespace std; static ostream& operator<<(ostream& os, const CORBA::Exception& e) @@ -66,7 +66,7 @@ int main (int argc, char * argv[]) // Initializing omniORB ORB_INIT &init = *SINGLETON_::Instance() ; CORBA::ORB_var &orb = init( argc , argv ) ; - LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb); + SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); try { -- 2.39.2