]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
PR: merge from tag mergeto_trunk_16Jan05
authorprascle <prascle>
Mon, 17 Jan 2005 13:24:26 +0000 (13:24 +0000)
committerprascle <prascle>
Mon, 17 Jan 2005 13:24:26 +0000 (13:24 +0000)
57 files changed:
bin/launchConfigureParser.py
bin/runSalome.py
bin/salome.launch
bin/salome/runIDLparser.in
configure.in.base
salome_adm/unix/config_files/check_lsf.m4 [new file with mode: 0755]
salome_adm/unix/config_files/production.m4
salome_adm/unix/make_commence.in
src/Batch/Batch_BatchManager.hxx
src/Batch/Batch_BatchManagerCatalog.hxx
src/Batch/Batch_BatchManager_LSF.cxx [new file with mode: 0644]
src/Batch/Batch_BatchManager_LSF.hxx [new file with mode: 0644]
src/Batch/Batch_FactBatchManager.hxx
src/Batch/Batch_FactBatchManager_LSF.cxx [new file with mode: 0644]
src/Batch/Batch_FactBatchManager_LSF.hxx [new file with mode: 0644]
src/Batch/Batch_FactBatchManager_PBS.cxx
src/Batch/Batch_FactBatchManager_PBS.hxx
src/Batch/Batch_Job.hxx
src/Batch/Batch_JobId.hxx
src/Batch/Batch_JobInfo.hxx
src/Batch/Batch_JobInfo_LSF.cxx [new file with mode: 0644]
src/Batch/Batch_JobInfo_LSF.hxx [new file with mode: 0644]
src/Batch/Batch_Job_LSF.cxx [new file with mode: 0644]
src/Batch/Batch_Job_LSF.hxx [new file with mode: 0644]
src/Batch/Makefile.in
src/Batch_SWIG/libBatch_Swig.i
src/Batch_SWIG/libBatch_Swig_exception.i
src/Batch_SWIG/libBatch_Swig_typemap.i
src/Container/Component_i.cxx
src/Container/Makefile.in
src/Container/SALOME_Container.cxx
src/DataTypeCatalog/Makefile.in
src/DataTypeCatalog/SALOME_DataTypeCatalog_Server.cxx
src/Loader/Makefile.in
src/Loader/SALOME_Session_Loader.cxx
src/Makefile.in
src/ModuleCatalog/Makefile.in
src/ModuleCatalog/SALOME_ModuleCatalog_Server.cxx
src/Registry/Makefile.in
src/Registry/SALOME_Registry_Server.cxx
src/RessourcesCatalog/Makefile.in
src/RessourcesCatalog/SALOME_RessourcesCatalog_Server.cxx
src/SALOMELocalTrace/LocalTraceCollector.cxx
src/SALOMELocalTrace/LocalTraceCollector.hxx
src/SALOMELocalTrace/LocalTrace_WaitForServerReadiness.cxx [deleted file]
src/SALOMELocalTrace/LocalTrace_WaitForServerReadiness.hxx [deleted file]
src/SALOMELocalTrace/Makefile.in
src/SALOMELocalTrace/utilities.h
src/SALOMETraceCollector/LocalTrace_WaitForServerReadiness.cxx [new file with mode: 0644]
src/SALOMETraceCollector/LocalTrace_WaitForServerReadiness.hxx [new file with mode: 0644]
src/SALOMETraceCollector/Makefile.in [new file with mode: 0644]
src/SALOMETraceCollector/SALOMETraceCollector.cxx [new file with mode: 0644]
src/SALOMETraceCollector/SALOMETraceCollector.hxx [new file with mode: 0644]
src/Session/Makefile.in
src/Session/SALOME_Session_Server.cxx
src/TestContainer/Makefile.in
src/TestContainer/TestContainer.cxx

index b673049e990ae8787e1f92cd3ea6b97261f6315a..71781540164a504094444c0075af96fb1a22137b 100755 (executable)
@@ -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':
index 9cb2cfc675f12c7c16cabf2936d5b73378f6d86c..d7ba78d8d888bb800a35a498622b538e0241ccfb 100755 (executable)
@@ -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']
index 1b5bbdd1b579140b8b69c8f1ffbaa0ac1493ba6c..92c5eab6de7aa2368bb556b8fd546c2d795278e5 100644 (file)
@@ -2,6 +2,7 @@
        <launchoptions>
                <gui>yes</gui>
                <logger>no</logger>
+               <!-- <file>atrace.log</file> -->
                <xterm>no</xterm>
                <portkill>yes</portkill>
                <killall>no</killall>
index 085ac77d8145c89e857b2e0e7da1f15c254c3872..79e309eb2231493f5aa62c2019646a91500c564a 100644 (file)
@@ -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 $@
 #============================================================
index 8c0768b44b1863bed16f1fd123c726fa5297665d..a382869d9935947fedfaf121d9f1bf66730bd8a4 100644 (file)
@@ -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 (executable)
index 0000000..5fb9e0b
--- /dev/null
@@ -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 <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)
+
+])
+
index e3da0539b890d86d2665320df4c629ff51083847..dfa8b39e9a1f8b56fef844b997792dcbd6a546fd 100644 (file)
@@ -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
index cabebbd71ede02950cdc008bd1b9a76f5916a7d2..77747e2b817073799c45d4643c0246468f3cb02d 100644 (file)
@@ -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@
index c132a575a13ede62ac0bf798ba4e2a84ffe9df46..60d80e37673f8e684a5d33487483660698332818 100644 (file)
@@ -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:
 
index 1857fa0599a94ec3d5181047cc4a51de12fe2f90..46daa59d563981ca0a0fb85ef03864eed1c0d563 100644 (file)
@@ -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<std::string, FactBatchManager *> * 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 (file)
index 0000000..76f9074
--- /dev/null
@@ -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 <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();
+  }
+
+
+
+}
diff --git a/src/Batch/Batch_BatchManager_LSF.hxx b/src/Batch/Batch_BatchManager_LSF.hxx
new file mode 100644 (file)
index 0000000..9b93c66
--- /dev/null
@@ -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
index 2a662d73ca4b92072ecd0c3c9cf3401f038baba9..389976e112d1d94e9be8e20b1dd6df69be8d8de8 100644 (file)
@@ -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 (file)
index 0000000..6dada01
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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);
+  }
+
+
+}
diff --git a/src/Batch/Batch_FactBatchManager_LSF.hxx b/src/Batch/Batch_FactBatchManager_LSF.hxx
new file mode 100644 (file)
index 0000000..de59dba
--- /dev/null
@@ -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 <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
index d2ded29ca780ad7b2198e007d36218258d023943..81ba4901cf338dc3a9275f89cc164944943538ad 100644 (file)
@@ -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);
index fdf053c1b116a448e5c48f23c0471e03ce42251d..1ee9e50ad2792defe4a3e22cba1e64b2689f3620 100644 (file)
@@ -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:
 
index 66fdf04947b1fc9c9b72ca521853868c7a6291df..7f2ab9abb8cf19e73a83172fcf2f99c8121dfe1a 100644 (file)
@@ -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:
 
index be14e7f9e7153bf8a725aafb339eefe6fe408d22..e8cfe50d127fd893359ff9f03fa8eac11f83e356 100644 (file)
@@ -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:
index 7cdca65355bd382b881d868fab0af88a4eb122ef..e9c251c94ec3254729a3f3f68c1ced707da5b641 100644 (file)
@@ -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 (file)
index 0000000..acb1f4b
--- /dev/null
@@ -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 <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();
+  }
+
+
+}
diff --git a/src/Batch/Batch_JobInfo_LSF.hxx b/src/Batch/Batch_JobInfo_LSF.hxx
new file mode 100644 (file)
index 0000000..60fa05f
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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
diff --git a/src/Batch/Batch_Job_LSF.cxx b/src/Batch/Batch_Job_LSF.cxx
new file mode 100644 (file)
index 0000000..9146614
--- /dev/null
@@ -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 <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;
+  }
+
+}
diff --git a/src/Batch/Batch_Job_LSF.hxx b/src/Batch/Batch_Job_LSF.hxx
new file mode 100644 (file)
index 0000000..d10d7f2
--- /dev/null
@@ -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 <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
index 703e6c7e15fae87e857bcbeb60b230454a4c796b..6b83960e3c7b60ae5c244e2514997ec3b166752a 100644 (file)
@@ -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@
index 1f82f0dfae433311fef65dd79ca2e3ecc11edcbd..92a8027413b2101fdef9bc7d952a9d2a1dece12b 100644 (file)
@@ -36,7 +36,6 @@
 #include "Batch_BatchManager.hxx"
 #include "Batch_BatchManagerCatalog.hxx"
 #include "Batch_FactBatchManager.hxx"
-using namespace Batch;
 %}
 
 /* Les classes exportees en Python */
index 880ae908589d6d9535dfd86d8f8057e988993472..06a9d0a52b3d9ecaf320b2ee3e6444f8a5b54ce2 100644 (file)
@@ -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;
     }
index 9116e87984ec1530d446245828c8b9d24c875d11..4c701c709df4afb016e23520e48cc6cabb915502 100644 (file)
 
 
 # // 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;
   }
@@ -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");
        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());
 }
index 0e28bd47d681594b02c1b2674c8702db82cd086d..880bb043829df4650e0c48abf2d38cae72918b05 100644 (file)
@@ -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: "<<cle<<" = "<< value);
        }
     }
index 30881439020ec773099f02f82b04a34c1591c2d3..5cd3980a522bc6324e712cdf28995cfc7f540f5f 100644 (file)
@@ -54,7 +54,7 @@ BIN_SERVER_IDL = SALOME_Component.idl
 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
 
index 02b2acce44006dfa262a76052d749ad8d235602e..646480535f34b818bd2960e1703ea120254eb82c 100644 (file)
@@ -35,7 +35,7 @@
 #include "SALOME_NamingService.hxx"
 #include "SALOME_Container_i.hxx"
 #include "utilities.h"
-#include "LocalTraceCollector.hxx"
+#include "SALOMETraceCollector.hxx"
 
 #ifdef CHECKTIME
 #include <Utils_Timer.hxx>
@@ -61,7 +61,7 @@ int main(int argc, char* argv[])
   // 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]);
     
index 5759b3b468fbadaf55f86727ca6a22041b0c1df4..f5bd3bc353d5d298e4e4795a76710ce6bab8f2f7 100644 (file)
@@ -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@
index 988cd896161285eec27e70914d055af93a47b6cf..d7982916387bc649f68447b8d3df53512fb0f717 100644 (file)
@@ -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;
index 972c503b66a45b9d9762329874e57a4c26277bf2..99c98ab060a4a376b12dbcb0b490a0eaa8e47054 100644 (file)
@@ -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@
index 0db216d3c63524247f2032b54dd5e58cc1afded0..4456b95ed10b6a19c2bda376085e455542dd948b 100644 (file)
@@ -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;
index d97b5e791e3291965affc8017dad030349a491ee..8f779b4625c6e85d6eb24081c5d24bf21d9b9b0b 100644 (file)
@@ -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 \
index 3d9a203c89d273b94246c2667f4e94149d7e7cf6..0ba61bbaabba6be257d4b23c912af01bbca999a6 100644 (file)
@@ -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@
index 942c8f33d108fc7bb7ed2c25c0d94667c387a6d0..9a5fb15ce66863b288c6bf55a43b56a79ab951c6 100644 (file)
@@ -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;
index 2219e42352da22cd6783650484bd5122a6d95d13..cbcbf39316181a8d79cc72710e6ed892df89e885 100644 (file)
@@ -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@
index 51036654786859e09a261e2124dfbc65645049f4..d47523a9328a64e2618b2479a02513bf5119e641 100644 (file)
@@ -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_<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) 
index c129dad04db3cd5646bf7387fdaa74165438a6e6..b43546776fe645f77269af3d9c88748be8dc09fd 100644 (file)
@@ -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@
 
index f8018d340dd3956f0caced2f7df376ae8e76487c..b52c63b672bda7cd8765f13a2afa2de3c40ac288 100644 (file)
@@ -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;
index 0cb334b402b9ae5e64078bfc72499911e15b22e7..37c2557ece6f470c2083c61bdfb2f34c995e80a4 100644 (file)
 #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
 
@@ -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;
 }
 
index 90101efd3df0fa3366be5d016ae55f81c231e547..bad9177213dd5f59913e42da1af115b77a874473 100644 (file)
 #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();
 
@@ -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/LocalTrace_WaitForServerReadiness.cxx b/src/SALOMELocalTrace/LocalTrace_WaitForServerReadiness.cxx
deleted file mode 100644 (file)
index 75a0952..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-//  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();
-}
-
diff --git a/src/SALOMELocalTrace/LocalTrace_WaitForServerReadiness.hxx b/src/SALOMELocalTrace/LocalTrace_WaitForServerReadiness.hxx
deleted file mode 100644 (file)
index a5e1c9a..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-//  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
index 5928c6409a25da56f2e84762c815565b6f1e37b3..8d2beb1d55106531213902af2129b8f1f5d5fa61 100644 (file)
@@ -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@
index 28696612bdf078508c8c8960eba9a7006c525632..40238630f67bf6d49af0bf362f883b2f12253f9a 100644 (file)
@@ -31,7 +31,6 @@
 #ifndef UTILITIES_H
 #define UTILITIES_H
 
-#include <strstream>
 #include <iostream>
 #include <sstream>
 #include <cstdlib>
diff --git a/src/SALOMETraceCollector/LocalTrace_WaitForServerReadiness.cxx b/src/SALOMETraceCollector/LocalTrace_WaitForServerReadiness.cxx
new file mode 100644 (file)
index 0000000..75a0952
--- /dev/null
@@ -0,0 +1,131 @@
+//  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();
+}
+
diff --git a/src/SALOMETraceCollector/LocalTrace_WaitForServerReadiness.hxx b/src/SALOMETraceCollector/LocalTrace_WaitForServerReadiness.hxx
new file mode 100644 (file)
index 0000000..a5e1c9a
--- /dev/null
@@ -0,0 +1,36 @@
+//  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
diff --git a/src/SALOMETraceCollector/Makefile.in b/src/SALOMETraceCollector/Makefile.in
new file mode 100644 (file)
index 0000000..3948058
--- /dev/null
@@ -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 (file)
index 0000000..9336706
--- /dev/null
@@ -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 <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;
+}
+
+
diff --git a/src/SALOMETraceCollector/SALOMETraceCollector.hxx b/src/SALOMETraceCollector/SALOMETraceCollector.hxx
new file mode 100644 (file)
index 0000000..846c4ad
--- /dev/null
@@ -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 <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
index 01c5872213ed99e30936b984278c4ad25d51c276..45ce4c82b7ea57224c6bb960a9cc70d5562af5f4 100644 (file)
@@ -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@
index 33d3440a3e61cb287b6fc9b6a485cee02256088b..17a9718598616bf14d34ba49484d8af36baffc53 100644 (file)
@@ -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_<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");
index 8ee409d994cf8305a6dc254d3b9181a064bfbe48..b16797b1f79cb20a82f36d66f7c04801975c76c6 100644 (file)
@@ -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@
index 7766bb46ec9eaa09f5848417c62d023c30eccec9..e8492fb6e94c77cfa2f00e17346f97a63bc5dcee 100644 (file)
@@ -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_<ORB_INIT>::Instance() ;
   CORBA::ORB_var &orb = init( argc , argv ) ;
-  LocalTraceCollector *myThreadTrace = LocalTraceCollector::instance(orb);
+  SALOMETraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb);
 
   try
     {