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
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
--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,...
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':
# 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']
<launchoptions>
<gui>yes</gui>
<logger>no</logger>
+ <!-- <file>atrace.log</file> -->
<xterm>no</xterm>
<portkill>yes</portkill>
<killall>no</killall>
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 $@
#============================================================
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
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
--- /dev/null
+# 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 <path>. 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)
+
+])
+
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
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@
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:
// 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<std::string, FactBatchManager *> * dict() const;
virtual std::string __repr__() const;
--- /dev/null
+/*
+ * 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 <lsf/lsf.h>
+#include <lsf/lsbatch.h>
+}
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#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();
+ }
+
+
+
+}
--- /dev/null
+/*
+ * 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
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;
--- /dev/null
+/*
+ * FactBatchManager_LSF.cxx :
+ *
+ * Auteur : Ivan DUTKA-MALEN - EDF R&D
+ * Date : Septembre 2004
+ * Projet : SALOME 2
+ *
+ */
+
+#include <string>
+#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);
+ }
+
+
+}
--- /dev/null
+/*
+ * 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 <string>
+#include <map>
+#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
}
// 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);
FactBatchManager_PBS();
virtual ~FactBatchManager_PBS();
- virtual BatchManager_PBS * operator() (const char * hostname) const;
+ virtual BatchManager * operator() (const char * hostname) const;
protected:
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
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:
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;
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)
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:
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
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:
--- /dev/null
+/*
+ * 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 <cstdio>
+#include <sstream>
+#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 <more> 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<long>(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 << "<JobInfo_LSF (" << this << ") :" << endl;
+ sst << " ID = " <<_param[ID] << endl;
+
+ sst << " + Parametre :" << endl;
+ Parametre::const_iterator itp;
+ for(itp=_param.begin(); itp!=_param.end(); itp++) {
+ if ( (*itp).first != ID ) {
+ sst << " * " << (*itp).first << " = " << (*itp).second << endl;
+ }
+ }
+ return sst.str();
+ }
+
+
+}
--- /dev/null
+/*
+ * JobInfo_LSF.hxx :
+ *
+ * Auteur : Ivan DUTKA-MALEN - EDF R&D
+ * Mail : mailto:ivan.dutka-malen@der.edf.fr
+ * Date : Fri Nov 21 09:42:05 2003
+ * Projet : Salome 2
+ *
+ */
+
+#ifndef _JOBINFO_LSF_H_
+#define _JOBINFO_LSF_H_
+
+extern "C" {
+
+#include <lsf/lsf.h>
+#include <lsf/lsbatch.h>
+}
+#include <string>
+#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
--- /dev/null
+/*
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <vector>
+#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;
+ }
+
+}
--- /dev/null
+/*
+ * 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 <lsf/lsf.h>
+#include <lsf/lsbatch.h>
+}
+#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
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
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@
#include "Batch_BatchManager.hxx"
#include "Batch_BatchManagerCatalog.hxx"
#include "Batch_FactBatchManager.hxx"
-using namespace Batch;
%}
/* Les classes exportees en Python */
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;
}
# // construction d'un dictionnaire Python a partir d'un objet BatchManagerCatalog C++
-%typemap(out) map<string, Batch::FactBatchManager *> *
+%typemap(out) std::map<std::string, Batch::FactBatchManager *> *
{
$result = PyDict_New();
// on itere sur toutes les clefs de la map
- for(map<string, FactBatchManager *>::const_iterator it=(* $1).begin(); it!=(* $1).end(); it++) {
- string key = (*it).first;
+ for(std::map<std::string, Batch::FactBatchManager *>::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);
}
# // 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");
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;
}
# // 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");
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;
}
# // 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()));
# // 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");
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;
}
# // 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");
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;
}
# // 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());
}
{
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+='=';
//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: "<<cle<<" = "<< value);
}
}
CPPFLAGS+= $(PYTHON_INCLUDES) $(MPI_INCLUDE) $(OCC_INCLUDES)
CXXFLAGS+=$(OCC_CXXFLAGS)
-LDFLAGS+= -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification -lSALOMELocalTrace
+LDFLAGS+= -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification -lSALOMELocalTrace -lSALOMETraceCollector
LIBS += @LDEXPDYNFLAGS@ $(PYTHON_LIBS) $(MPI_LIBS) -lCASCatch
#include "SALOME_NamingService.hxx"
#include "SALOME_Container_i.hxx"
#include "utilities.h"
-#include "LocalTraceCollector.hxx"
+#include "SALOMETraceCollector.hxx"
#ifdef CHECKTIME
#include <Utils_Timer.hxx>
// Initialise the ORB.
ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
CORBA::ORB_var &orb = init( argc , argv ) ;
- LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb);
+ SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
INFOS_COMPILATION;
BEGIN_OF(argv[0]);
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@
#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;
{
// 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;
CPPFLAGS+=$(QT_MT_INCLUDES)
CXXFLAGS+=$(OCC_CXXFLAGS)
-LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace
+LDFLAGS+=$(QT_MT_LIBS) -lSalomeNS -lOpUtil -lSALOMELocalTrace -lSALOMETraceCollector
@CONCLUDE@
#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
/*!
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;
@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 \
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@
#include "SALOME_NamingService.hxx"
#include "SALOME_ModuleCatalog_impl.hxx"
#include "utilities.h"
-#include "LocalTraceCollector.hxx"
+#include "SALOMETraceCollector.hxx"
#include "Utils_SINGLETON.hxx"
#ifdef CHECKTIME
{
// 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;
BIN_SRC =
BIN_SERVER_IDL = SALOME_Registry.idl
-LDFLAGS+= -lSalomeNS -lOpUtil -lSALOMELocalTrace
+LDFLAGS+= -lSalomeNS -lOpUtil -lSALOMELocalTrace -lSALOMETraceCollector
@CONCLUDE@
}
#include "utilities.h"
-#include "LocalTraceCollector.hxx"
+#include "SALOMETraceCollector.hxx"
#include "Utils_ORB_INIT.hxx"
#include "Utils_SINGLETON.hxx"
#include "Utils_SALOME_Exception.hxx"
{
ORB_INIT &init = *SINGLETON_<ORB_INIT>::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)
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@
#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;
{
// 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;
#include <sstream>
#include <fstream>
#include <cstdlib>
-#include <CORBA.h>
using namespace std;
#include "LocalTraceCollector.hxx"
-#include "LocalTrace_WaitForServerReadiness.hxx"
-//#include "SALOME_Log.hxx"
-#include <SALOMEconfig.h>
-#include CORBA_CLIENT_HEADER(Logger)
// Class attributes initialisation, for class method LocalTraceCollector::run
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
{
_fileName = "/tmp/tracetest.log";
_toFile=0;
- _orb = theOrb;
+
if (typeTrace) // caller sets a value different from default=0
_toFile = typeTrace;
else // check environment
if (traceKind)
{
if (strcmp(traceKind,"local")==0) _toFile=0;
- else if (strcmp(traceKind,"with_logger")==0) _toFile=2;
+
else
{
_toFile=1;
// 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)
{
}
}
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;
{
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;
{
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;
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;
}
#define _LOCALTRACECOLLECTOR_HXX_
#include <string>
-#include <CORBA.h>
#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();
static pthread_mutex_t _singletonMutex;
static pthread_t _threadId;
static std::string _fileName;
- static CORBA::ORB_ptr _orb;
};
#endif
+++ /dev/null
-// 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 : LocalTrace_WaitForServerReadiness.cxx
-// Author : Paul RASCLE (EDF)
-// Module : KERNEL
-// $Header$
-
-#include "LocalTrace_WaitForServerReadiness.hxx"
-#include <iostream>
-#include <ctime>
-
-using namespace std;
-
-// ============================================================================
-/*!
- * Wait until a server is registered in naming service.
- * \param serverName name of the server to find.
- * When SALOME_NamingService is available,
- * use NamingService_WaitForServerReadiness instead.
- * This function is needed when macro MESSAGE used by SALOME_NamingService
- * is not available (inside LocalTrace methods, for instance !).
- * Direct access to CORBA Name Service. Look for serverName at Name service
- * Root without extensions.
- */
-// ============================================================================
-
-CORBA::Object_ptr LocalTrace_WaitForServerReadiness(CORBA::ORB_ptr orb,
- string serverName)
-{
- long TIMESleep = 250000000;
- int NumberOfTries = 40;
-
- timespec ts_req;
- ts_req.tv_nsec=TIMESleep;
- ts_req.tv_sec=0;
- timespec ts_rem;
- ts_rem.tv_nsec=0;
- ts_rem.tv_sec=0;
-
- CORBA::Object_var obj;
-
- try
- {
- // NB. You can't use SALOME_NamingService class because
- // it uses MESSAGE macro
- // Otherwise, you will get segmentation fault.
-
- CosNaming::NamingContext_var inc;
- CosNaming::Name name;
- name.length(1);
- name[0].id = CORBA::string_dup(serverName.c_str());
- CORBA::Object_var theObj;
-
- for (int itry=0; itry < NumberOfTries; itry++)
- {
- try
- {
- if(!CORBA::is_nil(orb))
- theObj = orb->resolve_initial_references("NameService");
- if (!CORBA::is_nil(theObj))
- inc = CosNaming::NamingContext::_narrow(theObj);
- }
- catch( CORBA::COMM_FAILURE& )
- {
- cout << "LocalTrace_WaitForServerReadiness: "
- << "CORBA::COMM_FAILURE: "
- << "Unable to contact the Naming Service" << endl;
- }
- catch(...)
- {
- cout << "LocalTrace_WaitForServerReadiness: "
- << "Unknown exception dealing with Naming Service" << endl;
- }
-
- if(!CORBA::is_nil(inc))
- {
- obj = inc->resolve(name);
- if (!CORBA::is_nil(obj))
- {
- cout << "LocalTrace_WaitForServerReadiness: "
- << serverName << " found in CORBA Name Service" << endl;
- break;
- }
- }
- int a = nanosleep(&ts_req,&ts_rem);
- cout << "LocalTrace_WaitForServerReadiness: retry look for"
- << serverName << endl;
- }
- }
- catch (const CosNaming::NamingContext::NotFound&)
- {
- cout << "Caught exception: Naming Service can't found Logger";
- }
- catch (CORBA::COMM_FAILURE&)
- {
- cout << "Caught CORBA::SystemException CommFailure.";
- }
- catch (CORBA::SystemException&)
- {
- cout << "Caught CORBA::SystemException.";
- }
- catch (CORBA::Exception&)
- {
- cout << "Caught CORBA::Exception.";
- }
- catch (...)
- {
- cout << "Caught unknown exception.";
- }
- return obj._retn();
-}
-
+++ /dev/null
-// 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 : LocalTrace_WaitForServerReadiness.hxx
-// Author : Paul RASCLE (EDF)
-// Module : KERNEL
-// $Header$
-
-#ifndef _LOCALTRACE_WAITFORSERVERREADINESS_HXX_
-#define _LOCALTRACE_WAITFORSERVERREADINESS_HXX_
-
-#include <CORBA.h>
-#include <string>
-
-CORBA::Object_ptr LocalTrace_WaitForServerReadiness(CORBA::ORB_ptr theOrb,
- std::string serverName);
-
-#endif
# header files
EXPORT_HEADERS= utilities.h \
LocalTraceBufferPool.hxx \
- LocalTraceCollector.hxx \
- LocalTrace_WaitForServerReadiness.hxx
+ LocalTraceCollector.hxx
EXPORT_PYSCRIPTS =
LIB = libSALOMELocalTrace.la
LIB_SRC = LocalTraceCollector.cxx \
- LocalTraceBufferPool.cxx \
- LocalTrace_WaitForServerReadiness.cxx
+ LocalTraceBufferPool.cxx
-LIB_CLIENT_IDL = Logger.idl
LDFLAGS+=
@CONCLUDE@
#ifndef UTILITIES_H
#define UTILITIES_H
-#include <strstream>
#include <iostream>
#include <sstream>
#include <cstdlib>
--- /dev/null
+// 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 : LocalTrace_WaitForServerReadiness.cxx
+// Author : Paul RASCLE (EDF)
+// Module : KERNEL
+// $Header$
+
+#include "LocalTrace_WaitForServerReadiness.hxx"
+#include <iostream>
+#include <ctime>
+
+using namespace std;
+
+// ============================================================================
+/*!
+ * Wait until a server is registered in naming service.
+ * \param serverName name of the server to find.
+ * When SALOME_NamingService is available,
+ * use NamingService_WaitForServerReadiness instead.
+ * This function is needed when macro MESSAGE used by SALOME_NamingService
+ * is not available (inside LocalTrace methods, for instance !).
+ * Direct access to CORBA Name Service. Look for serverName at Name service
+ * Root without extensions.
+ */
+// ============================================================================
+
+CORBA::Object_ptr LocalTrace_WaitForServerReadiness(CORBA::ORB_ptr orb,
+ string serverName)
+{
+ long TIMESleep = 250000000;
+ int NumberOfTries = 40;
+
+ timespec ts_req;
+ ts_req.tv_nsec=TIMESleep;
+ ts_req.tv_sec=0;
+ timespec ts_rem;
+ ts_rem.tv_nsec=0;
+ ts_rem.tv_sec=0;
+
+ CORBA::Object_var obj;
+
+ try
+ {
+ // NB. You can't use SALOME_NamingService class because
+ // it uses MESSAGE macro
+ // Otherwise, you will get segmentation fault.
+
+ CosNaming::NamingContext_var inc;
+ CosNaming::Name name;
+ name.length(1);
+ name[0].id = CORBA::string_dup(serverName.c_str());
+ CORBA::Object_var theObj;
+
+ for (int itry=0; itry < NumberOfTries; itry++)
+ {
+ try
+ {
+ if(!CORBA::is_nil(orb))
+ theObj = orb->resolve_initial_references("NameService");
+ if (!CORBA::is_nil(theObj))
+ inc = CosNaming::NamingContext::_narrow(theObj);
+ }
+ catch( CORBA::COMM_FAILURE& )
+ {
+ cout << "LocalTrace_WaitForServerReadiness: "
+ << "CORBA::COMM_FAILURE: "
+ << "Unable to contact the Naming Service" << endl;
+ }
+ catch(...)
+ {
+ cout << "LocalTrace_WaitForServerReadiness: "
+ << "Unknown exception dealing with Naming Service" << endl;
+ }
+
+ if(!CORBA::is_nil(inc))
+ {
+ obj = inc->resolve(name);
+ if (!CORBA::is_nil(obj))
+ {
+ cout << "LocalTrace_WaitForServerReadiness: "
+ << serverName << " found in CORBA Name Service" << endl;
+ break;
+ }
+ }
+ int a = nanosleep(&ts_req,&ts_rem);
+ cout << "LocalTrace_WaitForServerReadiness: retry look for"
+ << serverName << endl;
+ }
+ }
+ catch (const CosNaming::NamingContext::NotFound&)
+ {
+ cout << "Caught exception: Naming Service can't found Logger";
+ }
+ catch (CORBA::COMM_FAILURE&)
+ {
+ cout << "Caught CORBA::SystemException CommFailure.";
+ }
+ catch (CORBA::SystemException&)
+ {
+ cout << "Caught CORBA::SystemException.";
+ }
+ catch (CORBA::Exception&)
+ {
+ cout << "Caught CORBA::Exception.";
+ }
+ catch (...)
+ {
+ cout << "Caught unknown exception.";
+ }
+ return obj._retn();
+}
+
--- /dev/null
+// 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 : LocalTrace_WaitForServerReadiness.hxx
+// Author : Paul RASCLE (EDF)
+// Module : KERNEL
+// $Header$
+
+#ifndef _LOCALTRACE_WAITFORSERVERREADINESS_HXX_
+#define _LOCALTRACE_WAITFORSERVERREADINESS_HXX_
+
+#include <CORBA.h>
+#include <string>
+
+CORBA::Object_ptr LocalTrace_WaitForServerReadiness(CORBA::ORB_ptr theOrb,
+ std::string serverName);
+
+#endif
--- /dev/null
+# 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@
--- /dev/null
+// 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 <iostream>
+#include <sstream>
+#include <fstream>
+#include <cstdlib>
+#include <CORBA.h>
+
+using namespace std;
+
+#include "SALOMETraceCollector.hxx"
+#include "LocalTrace_WaitForServerReadiness.hxx"
+//#include "SALOME_Log.hxx"
+#include <SALOMEconfig.h>
+#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="<<traceKind<<endl;
+ if (traceKind)
+ {
+ if (strcmp(traceKind,"local")==0) _toFile=0;
+ else if (strcmp(traceKind,"with_logger")==0) _toFile=2;
+ else
+ {
+ _toFile=1;
+ _fileName = traceKind;
+ }
+ }
+ }
+ //cout <<"_toFile: "<<_toFile<<" _fileName: "<<_fileName<<endl;
+
+ pthread_t traceThread;
+ int bid;
+ int re2 = pthread_create(&traceThread, NULL,
+ SALOMETraceCollector::run, (void *)bid);
+ }
+ ret = pthread_mutex_unlock(&_singletonMutex); // release lock
+ }
+ return _singleton;
+}
+
+// ============================================================================
+/*!
+ * In a separate thread, loop to print traces.
+ * Mutex garantees intialisation on instance method is done and only one run
+ * allowed (double check ...)
+ * Loop until there is no more buffer to print,
+ * and no ask for end from destructor.
+ * Get a buffer. If type = ABORT then exit application with message.
+ */
+// ============================================================================
+
+void* SALOMETraceCollector::run(void *bid)
+{
+ int isOKtoRun = 0;
+ int ret = pthread_mutex_lock(&_singletonMutex); // acquire lock to be alone
+ if (! _threadId) // only one run
+ {
+ isOKtoRun = 1;
+ _threadId = pthread_self();
+ }
+ else cout << "----- Comment est-ce possible de passer la ? -------" <<endl;
+ ret = pthread_mutex_unlock(&_singletonMutex); // release lock
+
+ if (isOKtoRun)
+ {
+ _threadId = pthread_self();
+ LocalTraceBufferPool* myTraceBuffer = LocalTraceBufferPool::instance();
+ LocalTrace_TraceInfo myTrace;
+
+ // 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)
+ {
+ case 1 : // --- trace to file
+ {
+ const char *fileName = _fileName.c_str();
+ traceFile.open(fileName, ios::out | ios::app);
+ if (!traceFile)
+ {
+ cerr << "impossible to open trace file "<< fileName << endl;
+ exit (1);
+ }
+ }
+ 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;
+ }
+
+ // 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;
+}
+
+
--- /dev/null
+// 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 <string>
+#include <CORBA.h>
+#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
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@
#include CORBA_SERVER_HEADER(SALOMEDS)
#include "utilities.h"
-#include "LocalTraceCollector.hxx"
+#include "SALOMETraceCollector.hxx"
#include "SALOME_Session_i.hxx"
ORB_INIT &init = *SINGLETON_<ORB_INIT>::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");
BIN = TestContainer TestLogger
BIN_SRC =
-LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace
+LDFLAGS+= -lSalomeNotification -lSalomeNS -lSalomeContainer -lRegistry -lOpUtil -lSALOMELocalTrace -lSALOMETraceCollector
@CONCLUDE@
#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)
// Initializing omniORB
ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance() ;
CORBA::ORB_var &orb = init( argc , argv ) ;
- LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb);
+ SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
try
{