From: barate Date: Tue, 15 Jan 2013 09:53:08 +0000 (+0000) Subject: Remove deprecated clients LSF, PBS and eSSH X-Git-Url: http://git.salome-platform.org/gitweb/?p=tools%2Flibbatch.git;a=commitdiff_plain;h=840796f17f7f383814fee398ef7c409ef5f197e2 Remove deprecated clients LSF, PBS and eSSH --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 41ec665..fefef0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,8 +28,6 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules/) find_package (PThread REQUIRED) find_package (Makeinfo) -SET (BUILD_LSF_INTERFACE TRUE CACHE BOOL "Build interface for LSF batch system") -SET (BUILD_PBS_INTERFACE TRUE CACHE BOOL "Build interface for PBS batch system") SET (BUILD_LOCAL_SUBMISSION TRUE CACHE BOOL "Build classes for local submission") SET (BUILD_PYTHON_WRAPPING TRUE CACHE BOOL "Generate Python wrapping") SET (TEST_ENABLED FALSE CACHE BOOL "Enable testing") @@ -38,12 +36,6 @@ IF (TEST_ENABLED) ENABLE_TESTING() ENDIF (TEST_ENABLED) -IF (BUILD_LSF_INTERFACE) - find_package (LSF) -ENDIF (BUILD_LSF_INTERFACE) -IF (BUILD_PBS_INTERFACE) - find_package (PBS) -ENDIF (BUILD_PBS_INTERFACE) IF (BUILD_LOCAL_SUBMISSION) find_package (Local) ENDIF (BUILD_LOCAL_SUBMISSION) diff --git a/CMakeModules/FindLSF.cmake b/CMakeModules/FindLSF.cmake deleted file mode 100644 index 1f07877..0000000 --- a/CMakeModules/FindLSF.cmake +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -IF (NOT LSF_FIND_QUIETLY) - MESSAGE(STATUS "Looking for LSF...") -ENDIF (NOT LSF_FIND_QUIETLY) - -FIND_PATH(LSF_INCLUDE_DIR lsf/lsbatch.h) -FIND_LIBRARY(LSF_LIBRARY lsf) -FIND_LIBRARY(LSF_BAT_LIBRARY bat) - -IF (LSF_INCLUDE_DIR AND LSF_LIBRARY AND LSF_BAT_LIBRARY) - SET(LSF_FOUND True) -ENDIF (LSF_INCLUDE_DIR AND LSF_LIBRARY AND LSF_BAT_LIBRARY) - -IF (LSF_FOUND) - - IF (NOT LSF_FIND_QUIETLY) - MESSAGE(STATUS "Found LSF: ${LSF_LIBRARY}") - ENDIF (NOT LSF_FIND_QUIETLY) - -ELSE (LSF_FOUND) - - IF (LSF_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "LSF not found") - ELSE (LSF_FIND_REQUIRED) - IF (NOT LSF_FIND_QUIETLY) - MESSAGE(STATUS "LSF not found") - ENDIF (NOT LSF_FIND_QUIETLY) - ENDIF (LSF_FIND_REQUIRED) - -ENDIF (LSF_FOUND) diff --git a/CMakeModules/FindPBS.cmake b/CMakeModules/FindPBS.cmake deleted file mode 100644 index 5f54a49..0000000 --- a/CMakeModules/FindPBS.cmake +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -IF (NOT PBS_FIND_QUIETLY) - MESSAGE(STATUS "Looking for PBS...") -ENDIF (NOT PBS_FIND_QUIETLY) - -FIND_PATH(PBS_INCLUDE_DIR pbs_ifl.h) -FIND_LIBRARY(PBS_LIBRARY NAMES pbs torque) - -IF (PBS_INCLUDE_DIR AND PBS_LIBRARY) - SET(PBS_FOUND True) -ENDIF (PBS_INCLUDE_DIR AND PBS_LIBRARY) - -IF (PBS_FOUND) - - IF (NOT PBS_FIND_QUIETLY) - MESSAGE(STATUS "Found PBS: ${PBS_LIBRARY}") - ENDIF (NOT PBS_FIND_QUIETLY) - -ELSE (PBS_FOUND) - - IF (PBS_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "PBS not found") - ELSE (PBS_FIND_REQUIRED) - IF (NOT PBS_FIND_QUIETLY) - MESSAGE(STATUS "PBS not found") - ENDIF (NOT PBS_FIND_QUIETLY) - ENDIF (PBS_FIND_REQUIRED) - -ENDIF (PBS_FOUND) diff --git a/CMakeModules/Summary.cmake b/CMakeModules/Summary.cmake index 83e9843..3953944 100644 --- a/CMakeModules/Summary.cmake +++ b/CMakeModules/Summary.cmake @@ -23,26 +23,6 @@ MESSAGE(STATUS "") MESSAGE(STATUS "**************** Summary ****************") MESSAGE(STATUS "") -IF (BUILD_LSF_INTERFACE) - IF (LSF_FOUND) - MESSAGE(STATUS "LSF ................................. Yes") - ELSE (LSF_FOUND) - MESSAGE(STATUS "LSF ........................... Not found") - ENDIF (LSF_FOUND) -ELSE (BUILD_LSF_INTERFACE) - MESSAGE(STATUS "LSF ....................... Not requested") -ENDIF (BUILD_LSF_INTERFACE) - -IF (BUILD_PBS_INTERFACE) - IF (PBS_FOUND) - MESSAGE(STATUS "PBS ................................. Yes") - ELSE (PBS_FOUND) - MESSAGE(STATUS "PBS ........................... Not found") - ENDIF (PBS_FOUND) -ELSE (BUILD_PBS_INTERFACE) - MESSAGE(STATUS "PBS ....................... Not requested") -ENDIF (BUILD_PBS_INTERFACE) - IF (BUILD_LOCAL_SUBMISSION) MESSAGE(STATUS "Local submission .................... Yes") ELSE (BUILD_LOCAL_SUBMISSION) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e3ec577..4ab3b46 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,7 +54,6 @@ add_subdirectory (CCC) add_subdirectory (LSF) add_subdirectory (PBS) add_subdirectory (SGE) -#add_subdirectory (SSH) add_subdirectory (LoadLeveler) add_subdirectory (Slurm) diff --git a/src/LSF/Batch_BatchManager_LSF.cxx b/src/LSF/Batch_BatchManager_LSF.cxx deleted file mode 100644 index 19f9613..0000000 --- a/src/LSF/Batch_BatchManager_LSF.cxx +++ /dev/null @@ -1,201 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * BatchManager_LSF.cxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Mail : mailto:ivan.dutka-malen@der.edf.fr - * Date : Thu Nov 6 10:17:22 2003 - * Projet : Salome 2 - * - */ - -extern "C" { -#include -#include -} -#include -#include -#include -#include -#include "Batch_BatchManager_LSF.hxx" - -using namespace std; - -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; - } - - // Ce manager permet de faire de la reprise - const Batch::JobId - BatchManager_LSF::addJob(const Batch::Job & job, const std::string reference) - { - return JobId(this, reference); - } - - // 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/LSF/Batch_BatchManager_LSF.hxx b/src/LSF/Batch_BatchManager_LSF.hxx deleted file mode 100644 index d906b81..0000000 --- a/src/LSF/Batch_BatchManager_LSF.hxx +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * BatchManager_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_Defines.hxx" - -#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 BATCH_EXPORT 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 - - virtual const Batch::JobId addJob(const Batch::Job & job, const std::string reference); // ajoute un nouveau job sans le soumettre - - protected: - int _connect; // LSF connect id - - private: - -#ifdef SWIG - public: - // Recupere le l'identifiant d'un job deja soumis au BatchManager - //virtual const JobId getJobIdByReference(const string & ref) { return BatchManager::getJobIdByReference(ref); } - virtual const JobId getJobIdByReference(const char * ref) { return BatchManager::getJobIdByReference(ref); } -#endif - - }; - -} - -#endif diff --git a/src/LSF/Batch_FactBatchManager_LSF.cxx b/src/LSF/Batch_FactBatchManager_LSF.cxx deleted file mode 100644 index 93f5434..0000000 --- a/src/LSF/Batch_FactBatchManager_LSF.cxx +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * FactBatchManager_LSF.cxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Date : Septembre 2004 - * Projet : SALOME 2 - * - */ - -#include -#include "Batch_BatchManager_LSF.hxx" -#include "Batch_FactBatchManager_LSF.hxx" -//#include "utilities.h" - -namespace Batch { - - static FactBatchManager_LSF sFBM_LSF; - - // Constructeur - FactBatchManager_LSF::FactBatchManager_LSF() : FactBatchManager("LSF") - { - // Nothing to do - } - - // Destructeur - FactBatchManager_LSF::~FactBatchManager_LSF() - { - // Nothing to do - } - - // Functor - BatchManager * FactBatchManager_LSF::operator() (const char * hostname) const - { - // MESSAGE("Building new BatchManager_LSF on host '" << hostname << "'"); - return new BatchManager_LSF(this, hostname); - } - - -} diff --git a/src/LSF/Batch_FactBatchManager_LSF.hxx b/src/LSF/Batch_FactBatchManager_LSF.hxx deleted file mode 100644 index b6770ce..0000000 --- a/src/LSF/Batch_FactBatchManager_LSF.hxx +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * FactBatchManager_LSF.hxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Date : Septembre 2004 - * Projet : SALOME 2 - * - */ - -#ifndef _FACTBATCHMANAGER_LSF_H_ -#define _FACTBATCHMANAGER_LSF_H_ - -#include "Batch_FactBatchManager.hxx" - -namespace Batch { - - class BatchManager_LSF; - - class FactBatchManager_LSF : public FactBatchManager - { - public: - // Constructeur et destructeur - FactBatchManager_LSF(); - virtual ~FactBatchManager_LSF(); - - virtual BatchManager * operator() (const char * hostname) const; - - protected: - - private: - - }; - -} - -#endif diff --git a/src/LSF/Batch_JobInfo_LSF.cxx b/src/LSF/Batch_JobInfo_LSF.cxx deleted file mode 100644 index 66b84cc..0000000 --- a/src/LSF/Batch_JobInfo_LSF.cxx +++ /dev/null @@ -1,207 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * JobInfo_LSF.cxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Mail : mailto:ivan.dutka-malen@der.edf.fr - * Date : Fri Nov 21 09:42:06 2003 - * Projet : Salome 2 - * - */ - -#include -#include -#include - -#include "Batch_Constants.hxx" -#include "Batch_Parametre.hxx" -#include "Batch_Environnement.hxx" -#include "Batch_RunTimeException.hxx" -#include "Batch_APIInternalFailureException.hxx" -#include "Batch_JobInfo_LSF.hxx" - -using namespace std; - -namespace Batch { - - - - // Constructeurs - JobInfo_LSF::JobInfo_LSF(int id) : JobInfo() - { - struct loadIndexLog * p_ld = new struct loadIndexLog; - struct jobInfoHead * p_jInfoHead = lsb_openjobinfo_a(id, NULL, NULL, NULL, NULL, ALL_JOB); - - int more = p_jInfoHead->numJobs; - if (more != 1) { - char * msg = lsb_sysmsg(); - if (!msg) msg = "unknown"; - throw APIInternalFailureException(string("LSF lsb_openjobinfo error. Reason : ") + msg); - } - - // on remplit une structure contenant elements - struct jobInfoEnt & jobInfo = * lsb_readjobinfo(&more); - - - // On remplit les membres _param et _env - _param[ACCOUNT] = jobInfo.submit.projectName; - _param[CHECKPOINT] = jobInfo.submit.chkpntPeriod != 0; - _param[CKPTINTERVAL] = jobInfo.submit.chkpntPeriod; - _param[CREATIONTIME] = jobInfo.submitTime; - // _param[EGROUP] = jobInfo.; - _param[ELIGIBLETIME] = jobInfo.reserveTime; - _param[ENDTIME] = jobInfo.endTime; - _param[EUSER] = jobInfo.execUsername; - _param[EXECUTABLE] = jobInfo.submit.command; - _param[EXITCODE] = jobInfo.exitStatus; - _param[HOLD] = jobInfo.status & (JOB_STAT_PSUSP | JOB_STAT_SSUSP | JOB_STAT_USUSP); - _param[MAIL] = jobInfo.submit.mailUser; - _param[MAXCPUTIME] = jobInfo.submit.rLimits[LSF_RLIMIT_CPU]; - _param[MAXDISKSIZE] = jobInfo.submit.rLimits[LSF_RLIMIT_FSIZE]; - _param[MAXRAMSIZE] = jobInfo.submit.rLimits[LSF_RLIMIT_SWAP]; - _param[MAXWALLTIME] = jobInfo.submit.rLimits[LSF_RLIMIT_RUN]; - _param[MODIFICATIONTIME] = jobInfo.lastEvent; - _param[NAME] = jobInfo.jName; - _param[NBPROC] = jobInfo.submit.numProcessors; - _param[PID] = jobInfo.jobPid; - _param[QUEUE] = jobInfo.submit.queue; - _param[QUEUEDTIME] = jobInfo.submitTime; - // _param[SERVER] = jobInfo.; - _param[STARTTIME] = jobInfo.startTime; - _param[TEXT] = jobInfo.numReasons ? lsb_pendreason(jobInfo.numReasons, - jobInfo.reasonTb, - p_jInfoHead, - p_ld,0) : ""; - // _param[TMPDIR] = jobInfo.; - _param[USEDCPUTIME] = static_cast(jobInfo.cpuTime); - // _param[USEDDISKSIZE] = jobInfo.; - _param[USEDRAMSIZE] = jobInfo.runRusage.mem; - _param[USEDWALLTIME] = jobInfo.duration * 60L; - _param[USER] = jobInfo.user; - - - ostringstream oss; - int jobid = jobInfo.jobId; - oss << jobid; - _param[ID] = oss.str(); - - - string hosts, sep; - for(int i=0; i < jobInfo.numExHosts; i++, sep="+") { - hosts += jobInfo.exHosts[i]; - hosts += sep; - } - _param[EXECUTIONHOST] = hosts; - - ostringstream status; - - if (IS_PEND(jobInfo.status)) - status << " Job is pending;"; - if (IS_START(jobInfo.status)) - status << " Job is started;"; - if (IS_FINISH(jobInfo.status)) - status << " Job is finished;"; - if (IS_SUSP(jobInfo.status)) - status << " Job is suspended;"; - if (IS_POST_DONE(jobInfo.status)) - status << " Job is post-done;"; - if (IS_POST_ERR(jobInfo.status)) - status << " Job is post-error;"; - - // TODO: Use constants for STATE instead - _param[STATE] = status.str(); - _running = IS_FINISH(jobInfo.status) ? false : true; - - - if (strlen(jobInfo.submit.inFile)) - _param[INFILE] += Couple(jobInfo.submit.inFile, "stdin"); - if (strlen(jobInfo.submit.outFile)) - _param[OUTFILE] += Couple(jobInfo.submit.outFile, "stdout"); - if (strlen(jobInfo.submit.errFile)) - _param[OUTFILE] += Couple(jobInfo.submit.errFile, "stderr"); - - for(int i=0; i < jobInfo.submit.nxf; i++) { - switch (jobInfo.submit.xf[i].options) { - case XF_OP_SUB2EXEC: - _param[INFILE] += Couple(jobInfo.submit.xf[i].subFn, jobInfo.submit.xf[i].execFn); - break; - - case XF_OP_EXEC2SUB: - _param[OUTFILE] += Couple(jobInfo.submit.xf[i].subFn, jobInfo.submit.xf[i].execFn); - break; - - default: - break; - } - } - - - lsb_closejobinfo(); - delete p_ld; - } - - - - // Teste si un job est present en machine - bool JobInfo_LSF::isRunning() const - { - return _running; - } - - - // Destructeur - JobInfo_LSF::~JobInfo_LSF() - { - // Nothing to do - } - - - - // Convertit une date HH:MM:SS en secondes - long JobInfo_LSF::HMStoLong(const string & s) - { - long hour, min, sec; - - sscanf( s.c_str(), "%ld:%ld:%ld", &hour, &min, &sec); - return ( ( ( hour * 60L ) + min ) * 60L ) + sec; - } - - // Methode pour l'interfacage avec Python (SWIG) : affichage en Python - string JobInfo_LSF::__str__() const - { - ostringstream sst; - sst << " -#include -} -#include -#include "Batch_RunTimeException.hxx" -#include "Batch_JobInfo.hxx" - -namespace Batch { - - class JobInfo_LSF : public JobInfo - { - public: - // Constructeurs et destructeur - JobInfo_LSF() : _running(false) {}; - JobInfo_LSF(int id); - virtual ~JobInfo_LSF(); - - // Constructeur par recopie - JobInfo_LSF(const JobInfo_LSF & jinfo) : JobInfo(jinfo) {}; - - // Teste si un job est present en machine - virtual bool isRunning() const; - - // Methodes pour l'interfacage avec Python (SWIG) - // TODO : supprimer ces methodes et transferer leur definitions dans SWIG - std::string __str__() const; // SWIG : affichage en Python - std::string __repr__() const { return __str__(); }; // SWIG : affichage en Python - - protected: - bool _running; // etat du job en machine - - private: - // Convertit une date HH:MM:SS en secondes - long HMStoLong(const std::string &); - - }; - -} - -#endif diff --git a/src/LSF/Batch_Job_LSF.cxx b/src/LSF/Batch_Job_LSF.cxx deleted file mode 100644 index 4a3cd9c..0000000 --- a/src/LSF/Batch_Job_LSF.cxx +++ /dev/null @@ -1,266 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Job_LSF.cxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Mail : mailto:ivan.dutka-malen@der.edf.fr - * Date : Fri Nov 14 11:00:39 2003 - * Projet : Salome 2 - * - */ - -#include -#include -#include -#include -#include - -#include "Batch_Constants.hxx" -#include "Batch_Job_LSF.hxx" - -using namespace std; - -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 - 1); xf.subFn[MAXFILENAMELEN - 1] = 0; - strncpy(xf.execFn, remote.c_str(), MAXFILENAMELEN - 1); xf.execFn[MAXFILENAMELEN - 1] = 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 - 1); xf.subFn[MAXFILENAMELEN - 1] = 0; - strncpy(xf.execFn, remote.c_str(), MAXFILENAMELEN - 1); xf.execFn[MAXFILENAMELEN - 1] = 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/LSF/Batch_Job_LSF.hxx b/src/LSF/Batch_Job_LSF.hxx deleted file mode 100644 index ebaacdc..0000000 --- a/src/LSF/Batch_Job_LSF.hxx +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Job_LSF.hxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Mail : mailto:ivan.dutka-malen@der.edf.fr - * Date : Fri Nov 14 11:00:39 2003 - * Projet : Salome 2 - * - */ - -#ifndef _JOB_LSF_H_ -#define _JOB_LSF_H_ - -extern "C" { - -#include -#include -} -#include -#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 std::string &); - }; - -} - -#endif diff --git a/src/LSF/CMakeLists.txt b/src/LSF/CMakeLists.txt index 7675329..107d8f9 100644 --- a/src/LSF/CMakeLists.txt +++ b/src/LSF/CMakeLists.txt @@ -25,15 +25,6 @@ SET(CLASS_LIST LSF/Batch_BatchManager_eLSF LSF/Batch_JobInfo_eLSF ) -#IF (BUILD_LSF_INTERFACE AND LSF_FOUND) -# SET(CLASS_LIST ${CLASS_LIST} -# LSF/Batch_BatchManager_LSF -# LSF/Batch_FactBatchManager_LSF -# LSF/Batch_Job_LSF -# LSF/Batch_JobInfo_LSF -# ) -#ENDIF (BUILD_LSF_INTERFACE AND LSF_FOUND) - APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST}) IF (TEST_ENABLED) diff --git a/src/PBS/Batch_BatchManager_PBS.cxx b/src/PBS/Batch_BatchManager_PBS.cxx deleted file mode 100644 index 2836571..0000000 --- a/src/PBS/Batch_BatchManager_PBS.cxx +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * BatchManager_PBS.cxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Mail : mailto:ivan.dutka-malen@der.edf.fr - * Date : Thu Nov 6 10:17:22 2003 - * Projet : Salome 2 - * - */ - -extern "C" { -#include -#include -} -#include -#include -#include -#include -//#include "MEDMEM_STRING.hxx" -#include "Batch_BatchManager_PBS.hxx" -using namespace std; - -namespace Batch { - - // Recupere le nom du serveur par defaut -// string BatchManager_PBS::getDefaultServer() { -// string server_name = "localhost"; - -// const char * server_name_path = "@openpbsspooldir@/server_name"; -// ifstream server_name_file(server_name_path); -// if (server_name_file) { -// server_name_file >> server_name; -// server_name_file.close(); -// } - -// return server_name; -// } - - // Constructeur -// BatchManager_PBS::BatchManager_PBS() throw(InvalidArgumentException,ConnexionFailureException) : BatchManager(BatchManager_PBS::getDefaultServer()) -// { -// // On se connecte au serveur PBS -// _connect = pbs_connect(const_cast< char * >(_hostname.c_str())); -// if (_connect < 0) { // si erreur -// char * errmsg = pbs_geterrmsg(_connect); -// string msg = "PBS Server on host \""; -// msg += _hostname; -// msg += "\" : "; -// msg += errmsg ? errmsg : "Reason unknown"; -// throw ConnexionFailureException(msg.c_str()); -// } -// } - - // Constructeur -// BatchManager_PBS::BatchManager_PBS(string host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager(host) -// { -// // On se connecte au serveur PBS -// _connect = pbs_connect(const_cast< char * >(_hostname.c_str())); -// if (_connect < 0) { // si erreur -// char * errmsg = pbs_geterrmsg(_connect); -// string msg = "PBS Server on host \""; -// msg += _hostname; -// msg += "\" : "; -// msg += errmsg ? errmsg : "Reason unknown"; -// throw ConnexionFailureException(msg.c_str()); -// } -// } - BatchManager_PBS::BatchManager_PBS(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager(parent, host) - { - // On se connecte au serveur PBS - _connect = pbs_connect(const_cast< char * >(_hostname.c_str())); - if (_connect < 0) { // si erreur - throw ConnexionFailureException(getErrorMessage("connect").c_str()); - } - } - - // Destructeur - BatchManager_PBS::~BatchManager_PBS() - { - // On se deconnecte du serveur PBS - int rc = pbs_disconnect(_connect); - if (rc < 0) { // si erreur - throw ConnexionFailureException(getErrorMessage("disconnect").c_str()); - } - } - - string BatchManager_PBS::getErrorMessage(const char * operation) const - { - char * msg = pbs_geterrmsg(_connect); - stringstream sstr; - sstr << "PBS " << operation << " error (host \"" << _hostname << "\"): "; - if (msg != NULL) { - sstr << msg; - } else { - sstr << "code = " << pbs_errno << " (" << pbse_to_txt(pbs_errno) << ")"; - } - return sstr.str(); - } - - // Methode pour le controle des jobs : soumet un job au gestionnaire - const JobId BatchManager_PBS::submitJob(const Job & job) - { - Job_PBS jobpbs = job; - char * ref = pbs_submit(_connect, - jobpbs.getAttributesOP(), - jobpbs.getScript(), - jobpbs.getDestination(), - NULL); - if (!ref) { // si erreur - throw APIInternalFailureException(getErrorMessage("submit").c_str()); - } - - JobId id(this, string(ref)); - free(ref); - return id; - } - - // Ce manager permet de faire de la reprise - const Batch::JobId - BatchManager_PBS::addJob(const Batch::Job & job, const std::string reference) - { - return JobId(this, reference); - } - - // Methode pour le controle des jobs : retire un job du gestionnaire - void BatchManager_PBS::deleteJob(const JobId & jobid) - { - char * ref = const_cast< char * >(jobid.getReference().c_str()); - int rc = pbs_deljob(_connect, ref, 0); - if (rc) { // si erreur - throw APIInternalFailureException(getErrorMessage("deljob").c_str()); - } - } - - // Methode pour le controle des jobs : suspend un job en file d'attente - void BatchManager_PBS::holdJob(const JobId & jobid) - { - char * ref = const_cast< char * >(jobid.getReference().c_str()); - int rc = pbs_holdjob(_connect, ref, const_cast< char * >(USER_HOLD), 0); - if (rc) { // si erreur - throw APIInternalFailureException(getErrorMessage("holdjob").c_str()); - } - } - - // Methode pour le controle des jobs : relache un job suspendu - void BatchManager_PBS::releaseJob(const JobId & jobid) - { - char * ref = const_cast< char * >(jobid.getReference().c_str()); - int rc = pbs_rlsjob(_connect, ref, const_cast< char * >(USER_HOLD), 0); - if (rc) { // si erreur - throw APIInternalFailureException(getErrorMessage("rlsjob").c_str()); - } - } - - - // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager_PBS::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env) - { - Job job(param, env); - Job_PBS jobpbs(job); - - char * ref = const_cast< char * >(jobid.getReference().c_str()); - int rc = pbs_alterjob(_connect, - ref, - jobpbs.getAttributes(), - NULL); - if (rc) { // si erreur - throw APIInternalFailureException(getErrorMessage("alterjob").c_str()); - } - - } - - // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager_PBS::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_PBS::alterJob(const JobId & jobid, const Environnement & env) - { - alterJob(jobid, Parametre(), env); - } - - - - // Methode pour le controle des jobs : renvoie l'etat du job - JobInfo BatchManager_PBS::queryJob(const JobId & jobid) - { - char * id = const_cast< char * >(jobid.getReference().c_str()); - JobInfo_PBS ji = JobInfo_PBS(pbs_statjob(_connect, id, 0, 0), true); - return ji; - } - - - -} diff --git a/src/PBS/Batch_BatchManager_PBS.hxx b/src/PBS/Batch_BatchManager_PBS.hxx deleted file mode 100644 index 5419580..0000000 --- a/src/PBS/Batch_BatchManager_PBS.hxx +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * BatchManager_PBS.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_PBS_H_ -#define _BATCHMANAGER_PBS_H_ - -#include "Batch_Defines.hxx" - -#include "Batch_Job.hxx" -#include "Batch_Job.hxx" -#include "Batch_JobId.hxx" -#include "Batch_JobInfo.hxx" -#include "Batch_JobInfo_PBS.hxx" -#include "Batch_Job_PBS.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 BATCH_EXPORT BatchManager_PBS : public BatchManager - { - public: - // Constructeur et destructeur - //BatchManager_PBS() throw(InvalidArgumentException,ConnexionFailureException); // connexion au serveur par defaut - //BatchManager_PBS(std::string host) throw(InvalidArgumentException,ConnexionFailureException); // connexion a la machine host - BatchManager_PBS(const FactBatchManager * parent, const char * host="localhost") throw(InvalidArgumentException,ConnexionFailureException); // connexion a la machine host - virtual ~BatchManager_PBS(); - - // Recupere le nom du serveur par defaut - // static std::string BatchManager_PBS::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 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 - - virtual const Batch::JobId addJob(const Batch::Job & job, const std::string reference); // ajoute un nouveau job sans le soumettre - - - protected: - std::string getErrorMessage(const char * operation) const; - - int _connect; // PBS connect id - - private: - -#ifdef SWIG - public: - // Recupere le l'identifiant d'un job deja soumis au BatchManager - //virtual const JobId getJobIdByReference(const std::string & ref) { return BatchManager::getJobIdByReference(ref); } - virtual const JobId getJobIdByReference(const char * ref) { return BatchManager::getJobIdByReference(ref); } -#endif - - }; - -} - -#endif diff --git a/src/PBS/Batch_FactBatchManager_PBS.cxx b/src/PBS/Batch_FactBatchManager_PBS.cxx deleted file mode 100644 index 9a651c9..0000000 --- a/src/PBS/Batch_FactBatchManager_PBS.cxx +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * FactBatchManager_PBS.cxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Date : Septembre 2004 - * Projet : SALOME 2 - * - */ - -#include "Batch_BatchManager_PBS.hxx" -#include "Batch_FactBatchManager_PBS.hxx" -using namespace std; - -namespace Batch { - - static FactBatchManager_PBS sFBM_PBS; - - // Constructeur - FactBatchManager_PBS::FactBatchManager_PBS() : FactBatchManager("PBS") - { - // Nothing to do - } - - // Destructeur - FactBatchManager_PBS::~FactBatchManager_PBS() - { - // Nothing to do - } - - // Functor - BatchManager * FactBatchManager_PBS::operator() (const char * hostname) const - { - return new BatchManager_PBS(this, hostname); - } - - -} diff --git a/src/PBS/Batch_FactBatchManager_PBS.hxx b/src/PBS/Batch_FactBatchManager_PBS.hxx deleted file mode 100644 index fea48dc..0000000 --- a/src/PBS/Batch_FactBatchManager_PBS.hxx +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * FactBatchManager_PBS.hxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Date : Septembre 2004 - * Projet : SALOME 2 - * - */ - -#ifndef _FACTBATCHMANAGER_PBS_H_ -#define _FACTBATCHMANAGER_PBS_H_ - -#include "Batch_FactBatchManager.hxx" - -namespace Batch { - - class BatchManager_PBS; - - class FactBatchManager_PBS : public FactBatchManager - { - public: - // Constructeur et destructeur - FactBatchManager_PBS(); - virtual ~FactBatchManager_PBS(); - - virtual BatchManager * operator() (const char * hostname) const; - - protected: - - private: - - }; - -} - -#endif diff --git a/src/PBS/Batch_JobInfo_PBS.cxx b/src/PBS/Batch_JobInfo_PBS.cxx deleted file mode 100644 index a7c19e1..0000000 --- a/src/PBS/Batch_JobInfo_PBS.cxx +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * JobInfo_PBS.cxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Mail : mailto:ivan.dutka-malen@der.edf.fr - * Date : Fri Nov 21 09:42:06 2003 - * Projet : Salome 2 - * - */ - -#include -#include -#include -#include - -#include "Batch_Constants.hxx" -#include "Batch_Parametre.hxx" -#include "Batch_Environnement.hxx" -#include "Batch_RunTimeException.hxx" -#include "Batch_JobInfo_PBS.hxx" -using namespace std; - -namespace Batch { - - // Constructeurs - JobInfo_PBS::JobInfo_PBS(struct batch_status * list, bool tobedeleted) : JobInfo() - { - // On ne considere que le premier element de la liste - // Si tout est OK, la liste ne devrait contenir qu'un element - // Sinon on leve une exception. - struct batch_status * p_job = list; - int i; - for(i=0; p_job; p_job = p_job->next) i++; - if (i == 0) throw RunTimeException("Liste vide (le job est absent de la file)"); - if (i > 1) { - ostringstream sst; - sst << "JobInfo_PBS::JobInfo_PBS(struct batch_status * list, bool tobedeleted) : la liste contient " - << i << " elements" << " (1 seul requis)" << endl; - throw RunTimeException(sst.str()); - } - p_job = list; - - // On remplit les membres _param et _env - - if (p_job->name && strlen(p_job->name)) _param[ID] = p_job->name; - if (p_job->text && strlen(p_job->text)) _param[TEXT] = p_job->text; - - for(struct attrl * p_attr = p_job->attribs; p_attr; p_attr = p_attr->next) { - - string name, res, value; - if (p_attr->name && strlen(p_attr->name)) name = p_attr->name; - if (p_attr->resource && strlen(p_attr->resource)) res = p_attr->resource; - if (p_attr->value && strlen(p_attr->value)) value = p_attr->value; - - if (name == ATTR_N) { - _param[NAME] = value; - - } else if (name == ATTR_owner) { - _param[USER] = value; - - } else if (name == ATTR_state) { - string status = value; - if (status == "C") { // Completed - _param[STATE] = FINISHED; - } else if (status == "E") { // Exiting - _param[STATE] = RUNNING; - } else if (status == "H") { // Held - _param[STATE] = PAUSED; - } else if (status == "Q") { // Queued - _param[STATE] = QUEUED; - } else if (status == "R") { // Running - _param[STATE] = RUNNING; - } else if (status == "S") { // Suspend - _param[STATE] = PAUSED; - } else if (status == "T") { // Transiting - _param[STATE] = IN_PROCESS; - } else if (status == "W") { // Waiting - _param[STATE] = PAUSED; - } else { - cerr << "Unknown job state code: " << status << endl; - } - - } else if (name == ATTR_queue) { - _param[QUEUE] = value; - - } else if (name == ATTR_A) { - _param[ACCOUNT] = value; - - } else if (name == ATTR_M) { - _param[MAIL] = value; - - } else if (name == ATTR_c) { - if (!strcmp(value.c_str(), CHECKPOINT_UNSPECIFIED)) _param[CHECKPOINT] = 1L; - else _param[CHECKPOINT] = 0L; - - } else if (name == ATTR_h) { - if (!strcmp(value.c_str(), NO_HOLD)) _param[HOLD] = 0L; - else _param[HOLD] = 1L; - - } else if (name == ATTR_ctime) { - _param[CREATIONTIME] = atol(value.c_str()); - - } else if (name == ATTR_etime) { - _param[ELIGIBLETIME] = atol(value.c_str()); - - } else if (name == ATTR_mtime) { - _param[MODIFICATIONTIME] = atol(value.c_str()); - - } else if (name == ATTR_qtime) { - _param[QUEUEDTIME] = atol(value.c_str()); - - } else if (name == ATTR_exechost) { - _param[EXECUTIONHOST] = value; - - } else if (name == ATTR_session) { - _param[PID] = atol(value.c_str()); - - } else if (name == ATTR_euser) { - _param[EUSER] = value; - - } else if (name == ATTR_egroup) { - _param[EGROUP] = value; - - } else if (name == ATTR_l) { - if (res == "cput") { - _param[MAXCPUTIME] = HMStoLong(value); - - } else if (res == "walltime") { - _param[MAXWALLTIME] = HMStoLong(value); - - } - - } else if (name == ATTR_used) { - if (res == "cput") { - _param[USEDCPUTIME] = HMStoLong(value); - - } else if (res == "walltime") { - _param[USEDWALLTIME] = HMStoLong(value); - - } - - } else if (name == ATTR_v) { - int deb = 0; - int pos = 0; - bool ok = true; - - while (ok) { - pos = value.find(",", deb); - string sub = value.substr(deb, pos-deb); - deb = pos + 1; - if (pos < 0) ok = false; - - int eq = sub.find("="); - _env[sub.substr(0, eq)] = sub.substr(eq+1); - } - - } - } - - - if (tobedeleted) pbs_statfree(list); - } - - // Destructeur - JobInfo_PBS::~JobInfo_PBS() - { - // Nothing to do - } - - // Convertit une date HH:MM:SS en secondes - long JobInfo_PBS::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_PBS::__str__() const - { - ostringstream sst; - sst << " -#include -} -#include -#include "Batch_RunTimeException.hxx" -#include "Batch_JobInfo.hxx" - -namespace Batch { - - class JobInfo_PBS : public JobInfo - { - public: - // Constructeurs et destructeur - JobInfo_PBS() : JobInfo() {}; - JobInfo_PBS(struct batch_status * stat_list, bool tobedeleted = false); - virtual ~JobInfo_PBS(); - - // Constructeur par recopie - JobInfo_PBS(const JobInfo_PBS & jinfo) : JobInfo(jinfo) {}; - - // Methodes pour l'interfacage avec Python (SWIG) - // TODO : supprimer ces methodes et transferer leur definitions dans SWIG - std::string __str__() const; // SWIG : affichage en Python - std::string __repr__() const { return __str__(); }; // SWIG : affichage en Python - - protected: - - private: - // Convertit une date HH:MM:SS en secondes - long HMStoLong(const std::string &); - - }; - -} - -#endif diff --git a/src/PBS/Batch_Job_PBS.cxx b/src/PBS/Batch_Job_PBS.cxx deleted file mode 100644 index 3186262..0000000 --- a/src/PBS/Batch_Job_PBS.cxx +++ /dev/null @@ -1,474 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Job_PBS.cxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Mail : mailto:ivan.dutka-malen@der.edf.fr - * Date : Fri Nov 14 11:00:39 2003 - * Projet : Salome 2 - * - */ - -#include -#include -#include -#include - -#include "Batch_Constants.hxx" -#include "Batch_Job_PBS.hxx" -using namespace std; - -namespace Batch { - - // Ajoute un element (name,resource,value) a la liste chainee d'attributs + operateur - void Job_PBS::setResourceAttributeOP(struct attropl ** attr_list, const char * attr_name, const char * attr_resource, const char * attr_value) - { - // L'element (name,resource,value) existe-t-il deja ? si oui ptr != 0 - struct attropl * ptr = findResourceAttributeOP(*attr_list, attr_name, attr_resource); - - if (!ptr) { // L'element n'existe pas, il faut le creer - if ((ptr = lastAttributeOP(*attr_list))) { // la liste n'est pas vide - ptr->next = new struct attropl; - ptr = ptr->next; - ptr->next = 0; - - } else { // la liste est completement vide - ptr = *attr_list = new struct attropl; - ptr->next = 0; - } - - // On remplit les champs (name,resource,value) - ptr->name = new char[strlen(attr_name) + 1]; - strncpy(ptr->name, attr_name, strlen(attr_name)); - ptr->name[strlen(attr_name)] = 0; - - ptr->resource = new char[strlen(attr_resource) + 1]; - strncpy(ptr->resource, attr_resource, strlen(attr_resource)); - ptr->resource[strlen(attr_resource)] = 0; - - ptr->value = new char[strlen(attr_value) + 1]; - strncpy(ptr->value, attr_value, strlen(attr_value)); - ptr->value[strlen(attr_value)] = 0; - - } else { // L'attribut existe, on change sa valeur - delete[] ptr->value; // On efface la valeur precedente - ptr->value = new char[strlen(attr_value) + 1]; - strncpy(ptr->value, attr_value, strlen(attr_value)); - ptr->value[strlen(attr_value)] = 0; - - } - } - - - // Recherche un element (name,resource,value) dans la liste chainee d'attributs + operateur - struct attropl * Job_PBS::findResourceAttributeOP(struct attropl * attr_list, const char * attr_name, const char * attr_resource) - { - // On parcoure la liste chainee pour trouver l'element dont les champs name et resource coincident - struct attropl * ptr = attr_list; - while (ptr) { - if (!strcmp(ptr->name, attr_name) && !strcmp(ptr->resource, attr_resource)) break; - ptr = ptr->next; - } - return ptr; - } - - - // Recherche le dernier element de la liste chainee d'attributs + operateur - struct attropl * Job_PBS::lastAttributeOP(struct attropl * attr_list) - { - struct attropl * ptr = attr_list; - while (ptr && ptr->next) { - ptr = ptr->next; - } - return ptr; - } - - - // Convertit un objet Parametre en liste chainee d'attributs + operateur - struct attropl * Job_PBS::ParametreToAttributeOPList(struct attropl ** _p_attr_list, Parametre & P) - { - Parametre::iterator it; - string st_second; - for(it=P.begin(); it!=P.end(); it++) { - if ( (*it).first == ACCOUNT ) { - st_second = (*it).second.str(); - setResourceAttributeOP(_p_attr_list, ATTR_A, "", st_second.c_str()); - - - } else if ( (*it).first == CHECKPOINT ) { - setResourceAttributeOP(_p_attr_list, ATTR_c, "", "u"); - - - } else if ( (*it).first == CKPTINTERVAL ) { - // Not significant - - } else if ( (*it).first == EXECUTABLE ) { - // Already done - - } else if ( (*it).first == HOLD ) { - if (static_cast< long >((*it).second)) - setResourceAttributeOP(_p_attr_list, ATTR_h, "", USER_HOLD); - else - setResourceAttributeOP(_p_attr_list, ATTR_h, "", NO_HOLD); - - } else if ( (*it).first == INFILE ) { - Versatile V = (*it).second; - Versatile::iterator Vit; - - string sep = ""; - string stagein; - - for(Vit=V.begin(); Vit!=V.end(); Vit++, sep=",") { - 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 - stagein += sep + remote + "@" + local; - } - - if (stagein.size()) - setResourceAttributeOP(_p_attr_list, ATTR_stagein, "", stagein.c_str()); - - - } else if ( (*it).first == MAIL ) { - st_second = (*it).second.str(); - setResourceAttributeOP(_p_attr_list, ATTR_M, "", st_second.c_str()); - - } else if ( (*it).first == MAXCPUTIME ) { - char attr_value[32]; - long secondes = (*it).second; - long heures = secondes / 3600L; - long minutes = (secondes - 3600L * heures) / 60L; - secondes = secondes % 60L; - sprintf(attr_value, "%02ld:%02ld:%02ld", heures, minutes, secondes); - - setResourceAttributeOP(_p_attr_list, ATTR_l, "cput", attr_value); - - - } else if ( (*it).first == MAXDISKSIZE ) { - - } else if ( (*it).first == MAXRAMSIZE ) { - - } else if ( (*it).first == MAXWALLTIME ) { - char attr_value[32]; - long minutes = (*it).second; - long heures = minutes / 60L; - minutes -= 60L * heures; - sprintf(attr_value, "%02ld:%02ld:00", heures, minutes); - - setResourceAttributeOP(_p_attr_list, ATTR_l, "walltime", attr_value); - - - } else if ( (*it).first == NAME ) { - st_second = (*it).second.str(); - setResourceAttributeOP(_p_attr_list, ATTR_N, "", st_second.c_str()); - - - } else if ( (*it).first == OUTFILE ) { - Versatile V = (*it).second; - Versatile::iterator Vit; - - string sep = ""; - string stageout; - - for(Vit=V.begin(); Vit!=V.end(); Vit++, sep=",") { - CoupleType cpt = *static_cast< CoupleType * >(*Vit); - Couple cp = cpt; - string local = cp.getLocal(); - string remote = cp.getRemote(); - - if (remote == "stdout") - setResourceAttributeOP(_p_attr_list, ATTR_o, "", local.c_str()); - - else if (remote == "stderr") - setResourceAttributeOP(_p_attr_list, ATTR_e, "", local.c_str()); - - else - // 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 - stageout += sep + remote + "@" + local; - } - - if (stageout.size()) - setResourceAttributeOP(_p_attr_list, ATTR_stageout, "", stageout.c_str()); - - } else if ( (*it).first == QUEUE ) { - // Already done - - } else if ( (*it).first == STARTTIME ) { - - } else if ( (*it).first == TMPDIR ) { - - } else if ( (*it).first == USER ) { - st_second = (*it).second.str(); - setResourceAttributeOP(_p_attr_list, ATTR_u, "", st_second.c_str()); - - } - } - return *_p_attr_list; - } - - - // Convertit un objet Environnement en liste chainee d'attributs + operateur - struct attropl * Job_PBS::EnvironnementToAttributeOPList(struct attropl ** _p_attr_list, Environnement & E) - { - Environnement::iterator it; - for(it=E.begin(); it!=E.end(); it++) { - setResourceAttributeOP(_p_attr_list, ATTR_v, (*it).first.c_str(), ( (*it).first + "=" + (*it).second ).c_str()); - } - return *_p_attr_list; - } - - - // Ajoute les variables d'environnement presentes dans tout job PBS - void Job_PBS::addPBSEnvironnement(Environnement & E) - { - char * c; - - c = getenv("HOME"); - if (c) E["PBS_O_HOME"] = c; - - c = getenv("LANG"); - if (c) E["PBS_O_LANG"] = c; - - c = getenv("LOGNAME"); - if (c) E["PBS_O_LOGNAME"] = c; - - c = getenv("PATH"); - if (c) E["PBS_O_PATH"] = c; - - c = getenv("LD_LIBRARY_PATH"); - if (c) E["PBS_O_LD_LIBRARY_PATH"] = c; - - c = getenv("MAIL"); - if (c) E["PBS_O_MAIL"] = c; - - c = getenv("SHELL"); - if (c) E["PBS_O_SHELL"] = c; - - c = getenv("TZ"); - if (c) E["PBS_O_TZ"] = c; - - /* Recuperation du working directory */ - size_t size = 256; - char * buf = 0; - char * rc = 0; - do { - if (buf) delete[] buf; - buf = new char[size]; - rc = getcwd(buf, size); - size += size; - } while (!rc); - E["PBS_O_WORKDIR"] = buf; - delete[] buf; - } - - - // Ajoute un element (name,resource,value) a la liste chainee d'attributs - void Job_PBS::setResourceAttribute(struct attrl ** attr_list, const char * attr_name, const char * attr_resource, const char * attr_value) - { - // L'element (name,resource,value) existe-t-il deja ? si oui ptr != 0 - struct attrl * ptr = findResourceAttribute(*attr_list, attr_name, attr_resource); - - if (!ptr) { // L'attribut n'existe pas, il faut le creer - if ((ptr = lastAttribute(*attr_list))) { // la liste n'est pas vide - ptr->next = new struct attrl; - ptr = ptr->next; - ptr->next = 0; - - } else { // la liste est completement vide - ptr = *attr_list = new struct attrl; - ptr->next = 0; - } - - // On remplit les champs (name,resource,value) - ptr->name = new char[strlen(attr_name) + 1]; - strncpy(ptr->name, attr_name, strlen(attr_name)); - ptr->name[strlen(attr_name)] = 0; - - ptr->resource = new char[strlen(attr_resource) + 1]; - strncpy(ptr->resource, attr_resource, strlen(attr_resource)); - ptr->resource[strlen(attr_resource)] = 0; - - ptr->value = new char[strlen(attr_value) + 1]; - strncpy(ptr->value, attr_value, strlen(attr_value)); - ptr->value[strlen(attr_value)] = 0; - - } else { // L'attribut existe, on change sa valeur - delete[] ptr->value; // On efface la valeur precedente - ptr->value = new char[strlen(attr_value) + 1]; - strncpy(ptr->value, attr_value, strlen(attr_value)); - ptr->value[strlen(attr_value)] = 0; - - } - } - - // Recherche un element (name,resource,value) dans la liste chainee d'attributs - struct attrl * Job_PBS::findResourceAttribute(struct attrl * attr_list, const char * attr_name, const char * attr_resource) - { - // On parcoure la liste chainee pour trouver l'element dont les champs name et resource coincident - struct attrl * ptr = attr_list; - while (ptr) { - if (!strcmp(ptr->name, attr_name) && !strcmp(ptr->resource, attr_resource)) break; - ptr = ptr->next; - } - return ptr; - } - - - // Recherche le dernier element de la liste chainee d'attributs - struct attrl * Job_PBS::lastAttribute(struct attrl * attr_list) - { - struct attrl * ptr = attr_list; - while (ptr && ptr->next) { - ptr = ptr->next; - } - return ptr; - } - - - // Constructeur - Job_PBS::Job_PBS(const Job & job) : _p_attropl(0), _p_attrl(0), _script(0), _destination(0) - { - Parametre P = job.getParametre(); - Parametre::iterator it; - - // On extrait de l'objet Parametre le champ EXECUTABLE qui deviendra le script PBS - if ( (it=P.find(EXECUTABLE)) != P.end()) { - Versatile V = (*it).second; - string st_exe = V.str(); - const char * exe = st_exe.c_str(); - int lg = strlen(exe); - _script = new char[lg + 1]; - for (int ii=0; iinext; - delete[] current_p_attropl->name; - delete[] current_p_attropl->resource; - delete[] current_p_attropl->value; - delete current_p_attropl; - current_p_attropl = next; - } - - // On detruit la liste chainee d'attributs - struct attrl * current_p_attrl = _p_attrl; - while (current_p_attrl) { - struct attrl * next = current_p_attrl->next; - delete[] current_p_attrl->name; - delete[] current_p_attrl->resource; - delete[] current_p_attrl->value; - delete current_p_attrl; - current_p_attrl = next; - } - - // On detruit les champs alloues - delete[] _script; - delete[] _destination; - } - - - // Accesseur - struct attropl * Job_PBS::getAttributesOP() - { - return _p_attropl; - } - - // Accesseur - // Cette methode sert pour les pbs_alter de PBS - // Pbs_alter est bugg� par rapport a la specification ers_all.ps car les - // variables d'environnement ne sont pas supportees (ATTR_v) - struct attrl * Job_PBS::getAttributes() - { - if (_p_attrl == 0) { - - // On remplit la structure attrl a partir de la strucuture attropl - // (elles ne different que par le parametre op, mais elles ne sont pas interchangeables - // dans les appels) - - struct attropl * current_p_attropl = _p_attropl; - while (current_p_attropl) { - if (strcmp(current_p_attropl->name, ATTR_v)) // Bug fix for ATTR_v - setResourceAttribute(&_p_attrl, - current_p_attropl->name, - current_p_attropl->resource, - current_p_attropl->value); - - current_p_attropl = current_p_attropl->next; - } - - } - - return _p_attrl; - } - - // Accesseur - char * Job_PBS::getScript() - { - return _script; - } - - // Accesseur - char * Job_PBS::getDestination() - { - return _destination; - } - -} diff --git a/src/PBS/Batch_Job_PBS.hxx b/src/PBS/Batch_Job_PBS.hxx deleted file mode 100644 index 43a7b54..0000000 --- a/src/PBS/Batch_Job_PBS.hxx +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Job_PBS.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_PBS_H_ -#define _JOB_PBS_H_ - -extern "C" { - -#include -#include -} -#include "Batch_Job.hxx" - -namespace Batch { - - class Job_PBS - { - public: - // Constructeur et destructeur - Job_PBS(const Job & job); - virtual ~Job_PBS(); - - // Accesseurs - struct attropl * getAttributesOP(); - struct attrl * getAttributes(); - char * getScript(); - char * getDestination(); - - protected: - struct attropl * _p_attropl; // liste chainee d'attributs + operateur - struct attrl * _p_attrl; // liste chainee d'attributs - char * _script; // chemin d'acces au script du job - char * _destination; // queue dans laquelle le job est soumis - - private: - // Ajoute un element (name,resource,value) a la liste chainee d'attributs + operateur - void setResourceAttributeOP(struct attropl ** attr_list, const char * attr_name, const char * attr_resource, const char * attr_value); - - // Recherche un element (name,resource,value) dans la liste chainee d'attributs + operateur - struct attropl * findResourceAttributeOP(struct attropl * attr_list, const char * attr_name, const char * attr_resource); - - // Recherche le dernier element de la liste chainee d'attributs + operateur - struct attropl * lastAttributeOP(struct attropl * attr_list); - - // Convertit un objet Parametre en liste chainee d'attributs + operateur - struct attropl * ParametreToAttributeOPList(struct attropl ** _p_attr_list, Parametre & param); - - // Convertit un objet Environnement en liste chainee d'attributs + operateur - struct attropl * EnvironnementToAttributeOPList(struct attropl ** _p_attr_list, Environnement & env); - - // Ajoute les variables d'environnement presentes dans tout job PBS - void addPBSEnvironnement(Environnement & E); - - - // Ajoute un element (name,resource,value) a la liste chainee d'attributs - void setResourceAttribute(struct attrl ** attr_list, const char * attr_name, const char * attr_resource, const char * attr_value); - - // Recherche un element (name,resource,value) dans la liste chainee d'attributs - struct attrl * findResourceAttribute(struct attrl * attr_list, const char * attr_name, const char * attr_resource); - - // Recherche le dernier element de la liste chainee d'attributs - struct attrl * lastAttribute(struct attrl * attr_list); - - }; - -} - -#endif diff --git a/src/PBS/CMakeLists.txt b/src/PBS/CMakeLists.txt index a543f75..745cc56 100644 --- a/src/PBS/CMakeLists.txt +++ b/src/PBS/CMakeLists.txt @@ -25,15 +25,6 @@ SET(CLASS_LIST PBS/Batch_BatchManager_ePBS PBS/Batch_JobInfo_ePBS ) -#IF (BUILD_PBS_INTERFACE AND PBS_FOUND) -# SET(CLASS_LIST ${CLASS_LIST} -# PBS/Batch_BatchManager_PBS -# PBS/Batch_FactBatchManager_PBS -# PBS/Batch_Job_PBS -# PBS/Batch_JobInfo_PBS -# ) -#ENDIF (BUILD_PBS_INTERFACE AND PBS_FOUND) - APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST}) IF (TEST_ENABLED) diff --git a/src/PBS/Test/CMakeLists.txt b/src/PBS/Test/CMakeLists.txt index b03ee03..32dfa9b 100644 --- a/src/PBS/Test/CMakeLists.txt +++ b/src/PBS/Test/CMakeLists.txt @@ -42,9 +42,3 @@ ENDIF (HAS_SSH) IF (HAS_RSH) ADD_TEST(ePBS_RSH Test_ePBS RSH) ENDIF (HAS_RSH) - -#IF (BUILD_PBS_INTERFACE AND PBS_FOUND) -# add_executable(Test_PBS Test_PBS.cxx) -# target_link_libraries(Test_PBS Batch SimpleParser) -# ADD_TEST(PBS Test_PBS) -#ENDIF (BUILD_PBS_INTERFACE AND PBS_FOUND) diff --git a/src/PBS/Test/Test_PBS.cxx b/src/PBS/Test/Test_PBS.cxx deleted file mode 100644 index 905e12f..0000000 --- a/src/PBS/Test/Test_PBS.cxx +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Test_PBS.cxx : - * - * Author : Renaud BARATE - EDF R&D - * Date : September 2009 - * - */ - -#include -#include - -#include -#include -#include -#include -#include - -#include - -using namespace std; -using namespace Batch; - -int main(int argc, char** argv) -{ - cout << "*******************************************************************************************" << endl; - cout << "This program tests the batch submission based on PBS." << endl; - cout << "*******************************************************************************************" << endl; - - // eventually remove any previous result - remove("result.txt"); - - try { - // Parse the test configuration file - SimpleParser parser; - parser.parseTestConfigFile(); - const string & host = parser.getValue("TEST_PBS_HOST"); - const string & user = parser.getValue("TEST_PBS_USER"); - const string & queue = parser.getValue("TEST_PBS_QUEUE"); - int timeout = parser.getValueAsInt("TEST_PBS_TIMEOUT"); - - char * cwd = -#ifdef WIN32 - _getcwd(NULL, 0); -#else - new char [PATH_MAX]; - getcwd(cwd, PATH_MAX); -#endif - string workdir = cwd; - delete [] cwd; - - // Define the job... - Job job; - // ... and its parameters ... - Parametre p; - p[EXECUTABLE] = "test-script.sh"; - p[NAME] = "Test_PBS"; - p[INFILE] = Couple(workdir + "/seta.sh", "seta.sh"); - p[INFILE] += Couple(workdir + "/setb.sh", "setb.sh"); - p[OUTFILE] = Couple(workdir + "/result.txt", "result.txt"); - p[USER] = user; - p[NBPROC] = 1; - p[MAXWALLTIME] = 1; - p[MAXRAMSIZE] = 4; - p[QUEUE] = queue; - job.setParametre(p); - // ... and its environment - Environnement e; - e["MYENVVAR"] = "MYVALUE"; - job.setEnvironnement(e); - cout << job << endl; - - // Get the catalog - BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); - - // Create a BatchManager of type ePBS on localhost - FactBatchManager * fbm = c("PBS"); - BatchManager * bm = (*fbm)(host.c_str()); - - // Submit the job to the BatchManager - JobId jobid = bm->submitJob(job); - cout << jobid.__repr__() << endl; - - // Wait for the end of the job - string state = bm->waitForJobEnd(jobid, timeout); - - if (state == FINISHED || state == FAILED) { - cout << "Job " << jobid.__repr__() << " is done" << endl; - } else { - cerr << "Timeout while executing job" << endl; - return 1; - } - - } catch (GenericException e) { - cerr << "Error: " << e << endl; - return 1; - } catch (ParserException e) { - cerr << "Parser error: " << e.what() << endl; - return 1; - } - - // test the result file - try { - SimpleParser resultParser; - resultParser.parse("result.txt"); - cout << "Result:" << endl << resultParser; - const string & envvar = resultParser.getValue("MYENVVAR"); - int result = resultParser.getValueAsInt("c"); - if (envvar == "MYVALUE" && result == 12) { - cout << "OK, Expected result found." << endl; - return 0; - } else { - cerr << "Error, result is not the expected one (MYENVVAR = MYVALUE, c = 12)." << endl; - return 1; - } - } catch (ParserException e) { - cerr << "Parser error on result file: " << e.what() << endl; - return 1; - } -} diff --git a/src/SSH/Batch_BatchManager_eSSH.cxx b/src/SSH/Batch_BatchManager_eSSH.cxx deleted file mode 100644 index 3fbf336..0000000 --- a/src/SSH/Batch_BatchManager_eSSH.cxx +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * BatchManager_eSSH.cxx : emulation of SSH client - * - * Auteur : André RIBES - EDF R&D - * Date : Octobre 2009 - */ - -#include -#include -#include -#include - -#include -#include -#include - -#ifdef MSVC -#include -#else -#include -#endif - -#include "Batch_Constants.hxx" -#include "Batch_BatchManager_eSSH.hxx" -#include "Batch_JobInfo_eSSH.hxx" - -using namespace std; - -namespace Batch { - - BatchManager_eSSH::BatchManager_eSSH(const FactBatchManager * parent, const char * host, - const char * username, - CommunicationProtocolType protocolType, const char * mpiImpl) - : BatchManager(parent, host), - BatchManager_eClient(parent, host, username, protocolType, mpiImpl), - BatchManager_Local(parent, host, protocolType) - { - // Nothing to do - } - - // Destructeur - BatchManager_eSSH::~BatchManager_eSSH() - { - // Nothing to do - } - - // Methode pour le controle des jobs : soumet un job au gestionnaire - const JobId BatchManager_eSSH::submitJob(const Job & job) - { - // export input files on cluster - std::cerr << "BatchManager_eSSH::submitJob exportInputFiles" << std::endl; - Parametre param = job.getParametre(); - - // Input files copy - exportInputFiles(job); - - // Launch job - // Patch until Local Manager is patched - std::string executable = param[EXECUTABLE].str(); - std::string::size_type p1 = executable.find_last_of("/"); - std::string fileNameToExecute = "./" + executable.substr(p1+1); - Parametre new_param(param); - new_param[INFILE].eraseAll(); - new_param[OUTFILE].eraseAll(); - new_param[EXECUTABLE] = fileNameToExecute; - new_param[EXECUTIONHOST] = _hostname; - Job * j = new Job(new_param); - - - std::cerr << "BatchManager_eSSH::submitJob Local submitJob" << std::endl; - JobId id = BatchManager_Local::submitJob(*j); - delete j; - return id; - } - - // Methode pour le controle des jobs : retire un job du gestionnaire - void BatchManager_eSSH::deleteJob(const JobId & jobid) - { - BatchManager_Local::deleteJob(jobid); - } - - // Methode pour le controle des jobs : renvoie l'etat du job - JobInfo BatchManager_eSSH::queryJob(const JobId & jobid) - { - return BatchManager_Local::queryJob(jobid); - } - - // Methode pour le controle des jobs : suspend un job en file d'attente - void BatchManager_eSSH::holdJob(const JobId & jobid) - { - BatchManager_Local::holdJob(jobid); - } - - // Methode pour le controle des jobs : relache un job suspendu - void BatchManager_eSSH::releaseJob(const JobId & jobid) - { - BatchManager_Local::releaseJob(jobid); - } - - // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager_eSSH::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env) - { - BatchManager_Local::alterJob(jobid, param, env); - } - - // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager_eSSH::alterJob(const JobId & jobid, const Parametre & param) - { - BatchManager_Local::alterJob(jobid, param); - } - - // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager_eSSH::alterJob(const JobId & jobid, const Environnement & env) - { - BatchManager_Local::alterJob(jobid, env); - } - - void BatchManager_eSSH::buildBatchScript(const Job & job) - { - Parametre params = job.getParametre(); - Environnement env = job.getEnvironnement(); - const long nbproc = params[NBPROC]; - const long edt = params[MAXWALLTIME]; - const long mem = params[MAXRAMSIZE]; - const string workDir = params[WORKDIR]; - const std::string dirForTmpFiles = params[TMPDIR]; - const string fileToExecute = params[EXECUTABLE]; - const string home = params[HOMEDIR]; - const std::string queue = params[QUEUE]; - std::string rootNameToExecute; - std::string fileNameToExecute; - std::string filelogtemp; - if( fileToExecute.size() > 0 ){ - string::size_type p1 = fileToExecute.find_last_of("/"); - string::size_type p2 = fileToExecute.find_last_of("."); - rootNameToExecute = fileToExecute.substr(p1+1,p2-p1-1); - -#ifdef MSVC - char fname[_MAX_FNAME]; - char ext[_MAX_EXT]; - _splitpath_s(fileToExecute.c_str(), NULL, 0, NULL, 0, fname, _MAX_FNAME, ext, _MAX_EXT); - string execBaseName = string(fname) + ext; -#else - char* basec=strdup(fileToExecute.c_str()); - string execBaseName = string(basename(basec)); - free(basec); -#endif - - fileNameToExecute = "~/" + dirForTmpFiles + "/" + execBaseName; - - int idx = dirForTmpFiles.find("Batch/"); - filelogtemp = dirForTmpFiles.substr(idx+6, dirForTmpFiles.length()); - } - else{ - rootNameToExecute = "command"; - } - - ofstream tempOutputFile; - std::string TmpFileName = createAndOpenTemporaryFile("SSH-script", tempOutputFile); - - tempOutputFile << "#! /bin/sh -f" << endl; - if (queue != "") - tempOutputFile << "#BSUB -q " << queue << endl; - if( edt > 0 ) - tempOutputFile << "#SSH -l walltime=" << edt*60 << endl ; - if( mem > 0 ) - tempOutputFile << "#SSH -l mem=" << mem << "mb" << endl ; - if( fileToExecute.size() > 0 ){ - tempOutputFile << "#SSH -o " << home << "/" << dirForTmpFiles << "/output.log." << filelogtemp << endl ; - tempOutputFile << "#SSH -e " << home << "/" << dirForTmpFiles << "/error.log." << filelogtemp << endl ; - } - else{ - tempOutputFile << "#SSH -o " << dirForTmpFiles << "/" << env["LOGFILE"] << ".output.log" << endl ; - tempOutputFile << "#SSH -e " << dirForTmpFiles << "/" << env["LOGFILE"] << ".error.log" << endl ; - } - if( workDir.size() > 0 ) - tempOutputFile << "cd " << workDir << endl ; - if( fileToExecute.size() > 0 ){ - tempOutputFile << _mpiImpl->boot("${SSH_NODEFILE}",nbproc); - tempOutputFile << _mpiImpl->run("${SSH_NODEFILE}",nbproc,fileNameToExecute); - tempOutputFile << _mpiImpl->halt(); - } - else{ - tempOutputFile << "source " << env["SOURCEFILE"] << endl ; - tempOutputFile << env["COMMAND"]; - } - - tempOutputFile.flush(); - tempOutputFile.close(); -#ifdef WIN32 - _chmod( -#else - chmod( -#endif - TmpFileName.c_str(), 0x1ED); - cerr << TmpFileName.c_str() << endl; - - int status = Batch::BatchManager_eClient::_protocol.copyFile(TmpFileName, "", "", - dirForTmpFiles + "/" + rootNameToExecute + "_Batch.sh", - _hostname, _username); - if (status) - throw EmulationException("Error of connection on remote host"); - - remove(TmpFileName.c_str()); - } - -} diff --git a/src/SSH/Batch_BatchManager_eSSH.hxx b/src/SSH/Batch_BatchManager_eSSH.hxx deleted file mode 100644 index 29592bf..0000000 --- a/src/SSH/Batch_BatchManager_eSSH.hxx +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * BatchManager_eSSH.hxx : emulation of SSH client - * - * Auteur : André RIBES - EDF R&D - * Date : Octobre 2009 - */ - -#ifndef _BATCHMANAGER_ESSH_H_ -#define _BATCHMANAGER_ESSH_H_ - -#include "Batch_Defines.hxx" -#include "Batch_JobId.hxx" -#include "Batch_JobInfo.hxx" -#include "Batch_FactBatchManager.hxx" -#include "Batch_BatchManager_eClient.hxx" -#include "Batch_BatchManager_Local.hxx" - -namespace Batch { - - class BATCH_EXPORT BatchManager_eSSH : - virtual public BatchManager_eClient, - virtual public BatchManager_Local - { - public: - // Constructeur et destructeur - BatchManager_eSSH(const FactBatchManager * parent, const char * host="localhost", - const char * username="", - CommunicationProtocolType protocolType = SSH, const char * mpiImpl="nompi"); // connexion a la machine host - virtual ~BatchManager_eSSH(); - - // 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 JobInfo queryJob(const JobId & jobid); // renvoie l'etat du job - - // Non implanté... - 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 - - - protected: - void buildBatchScript(const Job & job); - - private: - -#ifdef SWIG - public: - // Recupere le l'identifiant d'un job deja soumis au BatchManager - //virtual const JobId getJobIdByReference(const string & ref) { return BatchManager::getJobIdByReference(ref); } - virtual const JobId getJobIdByReference(const char * ref) { return BatchManager::getJobIdByReference(ref); } -#endif - }; -} - -#endif diff --git a/src/SSH/Batch_FactBatchManager_eSSH.cxx b/src/SSH/Batch_FactBatchManager_eSSH.cxx deleted file mode 100644 index e016473..0000000 --- a/src/SSH/Batch_FactBatchManager_eSSH.cxx +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * FactBatchManager_eSSH.cxx : - * - * Auteur : André RIBES : EDF R&D - * Date : Octobre 2009 - */ - -#include -#include "Batch_BatchManager_eSSH.hxx" -#include "Batch_FactBatchManager_eSSH.hxx" - -// Automatic register in the catalogue... -static Batch::FactBatchManager_eSSH sFBM_eSSH; - -Batch::FactBatchManager_eSSH::FactBatchManager_eSSH() : FactBatchManager_eClient("eSSH") {} - -Batch::FactBatchManager_eSSH::~FactBatchManager_eSSH() {} - -Batch::BatchManager * -Batch::FactBatchManager_eSSH::operator() (const char * hostname) const -{ - return new Batch::BatchManager_eSSH(this, hostname); -} - -Batch::BatchManager_eClient * -Batch::FactBatchManager_eSSH::operator() (const char * hostname, - const char * username, - CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node) const -{ - //protocolType and mpiImpl are ignored. - std::cerr << "[Batch::FactBatchManager_eSSH] creating new Batch::BatchManager_eSSH with hostname = " << hostname << std::endl; - - return new Batch::BatchManager_eSSH(this, hostname, username); -} diff --git a/src/SSH/Batch_FactBatchManager_eSSH.hxx b/src/SSH/Batch_FactBatchManager_eSSH.hxx deleted file mode 100644 index 5f17dd4..0000000 --- a/src/SSH/Batch_FactBatchManager_eSSH.hxx +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * FactBatchManager_eSSH.hxx : - * - * Auteur : André RIBES : EDF R&D - * Date : Octobre 2009 - */ - -#ifndef _FACTBATCHMANAGER_eSSH_H_ -#define _FACTBATCHMANAGER_eSSH_H_ - -#include "Batch_Defines.hxx" - -#include -#include -#include "Batch_BatchManager_eClient.hxx" -#include "Batch_FactBatchManager_eClient.hxx" - -namespace Batch { - - class BatchManager_eSSH; - - class BATCH_EXPORT FactBatchManager_eSSH : public FactBatchManager_eClient - { - public: - FactBatchManager_eSSH(); - virtual ~FactBatchManager_eSSH(); - - virtual BatchManager * operator() (const char * hostname) const; // From FactBacthManager - virtual BatchManager_eClient * operator() (const char * hostname, - const char * username, - CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node = 1) const; // From FactBatchManager_eClient - }; -} - -#endif diff --git a/src/SSH/Batch_JobInfo_eSSH.cxx b/src/SSH/Batch_JobInfo_eSSH.cxx deleted file mode 100644 index afc0538..0000000 --- a/src/SSH/Batch_JobInfo_eSSH.cxx +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * JobInfo_eSSH.cxx : emulation of SSH client - * - * Auteur : André RIBES - EDF R&D - * Date : Octobre 2009 - */ - -#include -#include -#include -#include - -#include "Batch_Constants.hxx" -#include "Batch_Parametre.hxx" -#include "Batch_Environnement.hxx" -#include "Batch_RunTimeException.hxx" -#include "Batch_APIInternalFailureException.hxx" -#include "Batch_JobInfo_eSSH.hxx" - -using namespace std; - -namespace Batch { - - // Constructeurs - JobInfo_eSSH::JobInfo_eSSH(int id, string status) : JobInfo() - { - // On remplit les membres _param et _env - ostringstream oss; - oss << id; - _param[ID] = oss.str(); - _param[STATE] = status; - } - - // Destructeur - JobInfo_eSSH::~JobInfo_eSSH() - { - // Nothing to do - } - - // Methode pour l'interfacage avec Python (SWIG) : affichage en Python - string JobInfo_eSSH::__str__() const - { - ostringstream sst; - sst << "