From f52e8524c7f4ba4849499d6fd1ec99b372acc0f0 Mon Sep 17 00:00:00 2001 From: barate Date: Thu, 9 Apr 2009 13:30:47 +0000 Subject: [PATCH] Initial import: adding files --- Batch_config.h.in | 47 + CMakeLists.txt | 76 + CMakeModules/FindLSF.cmake | 49 + CMakeModules/FindLocal.cmake | 41 + CMakeModules/FindMakeinfo.cmake | 47 + CMakeModules/FindPBS.cmake | 51 + CMakeModules/FindPLATFORM.cmake | 64 + CMakeModules/FindPython.cmake | 92 + CMakeModules/FindSWIG.cmake | 50 + CMakeModules/Summary.cmake | 70 + COPYING | 503 ++ INSTALL | 134 + doc/Batch.texi | 4892 +++++++++++++++++ doc/CMakeLists.txt | 32 + doc/version.texi | 4 + src/CMakeLists.txt | 87 + .../Batch_APIInternalFailureException.cxx | 37 + .../Batch_APIInternalFailureException.hxx | 51 + src/Core/Batch_BatchManager.cxx | 149 + src/Core/Batch_BatchManager.hxx | 85 + src/Core/Batch_BatchManagerCatalog.cxx | 99 + src/Core/Batch_BatchManagerCatalog.hxx | 75 + src/Core/Batch_BatchManager_eClient.cxx | 254 + src/Core/Batch_BatchManager_eClient.hxx | 70 + src/Core/Batch_BoolType.cxx | 66 + src/Core/Batch_BoolType.hxx | 69 + src/Core/Batch_CharType.cxx | 66 + src/Core/Batch_CharType.hxx | 70 + src/Core/Batch_ConnexionFailureException.cxx | 37 + src/Core/Batch_ConnexionFailureException.hxx | 53 + src/Core/Batch_Couple.cxx | 63 + src/Core/Batch_Couple.hxx | 76 + src/Core/Batch_CoupleType.cxx | 73 + src/Core/Batch_CoupleType.hxx | 72 + src/Core/Batch_Date.cxx | 195 + src/Core/Batch_Date.hxx | 68 + src/Core/Batch_DateType.cxx | 74 + src/Core/Batch_DateType.hxx | 74 + src/Core/Batch_Defines.hxx | 42 + src/Core/Batch_EmulationException.cxx | 35 + src/Core/Batch_EmulationException.hxx | 48 + src/Core/Batch_Environnement.cxx | 38 + src/Core/Batch_Environnement.hxx | 48 + src/Core/Batch_FactBatchManager.cxx | 68 + src/Core/Batch_FactBatchManager.hxx | 63 + src/Core/Batch_FactBatchManager_eClient.cxx | 50 + src/Core/Batch_FactBatchManager_eClient.hxx | 60 + src/Core/Batch_GenericException.cxx | 37 + src/Core/Batch_GenericException.hxx | 55 + src/Core/Batch_GenericType.cxx | 65 + src/Core/Batch_GenericType.hxx | 72 + src/Core/Batch_IntType.cxx | 72 + src/Core/Batch_IntType.hxx | 69 + src/Core/Batch_InvalidArgumentException.cxx | 37 + src/Core/Batch_InvalidArgumentException.hxx | 53 + src/Core/Batch_InvalidKeyException.cxx | 38 + src/Core/Batch_InvalidKeyException.hxx | 57 + src/Core/Batch_Job.cxx | 117 + src/Core/Batch_Job.hxx | 78 + src/Core/Batch_JobId.cxx | 137 + src/Core/Batch_JobId.hxx | 91 + src/Core/Batch_JobInfo.cxx | 96 + src/Core/Batch_JobInfo.hxx | 79 + src/Core/Batch_ListIsFullException.cxx | 37 + src/Core/Batch_ListIsFullException.hxx | 50 + src/Core/Batch_LongType.cxx | 71 + src/Core/Batch_LongType.hxx | 69 + src/Core/Batch_MapKey.cxx | 42 + src/Core/Batch_MapKey.hxx | 69 + src/Core/Batch_MpiImpl.cxx | 277 + src/Core/Batch_MpiImpl.hxx | 170 + src/Core/Batch_NotYetImplementedException.cxx | 37 + src/Core/Batch_NotYetImplementedException.hxx | 52 + src/Core/Batch_Parametre.cxx | 295 + src/Core/Batch_Parametre.hxx | 159 + src/Core/Batch_RunTimeException.cxx | 37 + src/Core/Batch_RunTimeException.hxx | 51 + src/Core/Batch_StringType.cxx | 66 + src/Core/Batch_StringType.hxx | 67 + src/Core/Batch_TypeMismatchException.cxx | 36 + src/Core/Batch_TypeMismatchException.hxx | 51 + src/Core/Batch_Versatile.cxx | 323 ++ src/Core/Batch_Versatile.hxx | 122 + src/Core/CMakeLists.txt | 60 + src/LSF/Batch_BatchManager_LSF.cxx | 194 + src/LSF/Batch_BatchManager_LSF.hxx | 97 + src/LSF/Batch_BatchManager_eLSF.cxx | 362 ++ src/LSF/Batch_BatchManager_eLSF.hxx | 96 + src/LSF/Batch_FactBatchManager_LSF.cxx | 60 + src/LSF/Batch_FactBatchManager_LSF.hxx | 57 + src/LSF/Batch_FactBatchManager_eLSF.cxx | 63 + src/LSF/Batch_FactBatchManager_eLSF.hxx | 63 + src/LSF/Batch_JobInfo_LSF.cxx | 204 + src/LSF/Batch_JobInfo_LSF.hxx | 76 + src/LSF/Batch_JobInfo_eLSF.cxx | 107 + src/LSF/Batch_JobInfo_eLSF.hxx | 72 + src/LSF/Batch_Job_LSF.cxx | 264 + src/LSF/Batch_Job_LSF.hxx | 65 + src/LSF/CMakeLists.txt | 38 + src/Local/Batch_BatchManager_Local.cxx | 825 +++ src/Local/Batch_BatchManager_Local.hxx | 174 + src/Local/Batch_BatchManager_Local_RSH.cxx | 150 + src/Local/Batch_BatchManager_Local_RSH.hxx | 82 + src/Local/Batch_BatchManager_Local_SH.cxx | 120 + src/Local/Batch_BatchManager_Local_SH.hxx | 82 + src/Local/Batch_BatchManager_Local_SSH.cxx | 153 + src/Local/Batch_BatchManager_Local_SSH.hxx | 82 + src/Local/Batch_FactBatchManager_Local.cxx | 60 + src/Local/Batch_FactBatchManager_Local.hxx | 57 + .../Batch_FactBatchManager_Local_RSH.cxx | 60 + .../Batch_FactBatchManager_Local_RSH.hxx | 57 + src/Local/Batch_FactBatchManager_Local_SH.cxx | 60 + src/Local/Batch_FactBatchManager_Local_SH.hxx | 57 + .../Batch_FactBatchManager_Local_SSH.cxx | 60 + .../Batch_FactBatchManager_Local_SSH.hxx | 57 + src/Local/Batch_IOMutex.cxx | 38 + src/Local/Batch_IOMutex.hxx | 47 + src/Local/Batch_JobInfo_Local.cxx | 54 + src/Local/Batch_JobInfo_Local.hxx | 60 + src/Local/Batch_Job_Local.cxx | 106 + src/Local/Batch_Job_Local.hxx | 71 + src/Local/CMakeLists.txt | 39 + src/Local/Test/CMakeLists.txt | 59 + src/Local/Test/Test_Local_RSH.cxx | 108 + src/Local/Test/Test_Local_SH.cxx | 107 + src/Local/Test/Test_Local_SSH.cxx | 109 + src/Local/Test/Test_Local_config.h.in | 27 + src/Local/Test/seta.sh | 3 + src/Local/Test/setb.sh | 3 + src/Local/Test/test-script.sh | 8 + src/PBS/Batch_BatchManager_PBS.cxx | 216 + src/PBS/Batch_BatchManager_PBS.hxx | 98 + src/PBS/Batch_BatchManager_ePBS.cxx | 345 ++ src/PBS/Batch_BatchManager_ePBS.hxx | 96 + src/PBS/Batch_FactBatchManager_PBS.cxx | 58 + src/PBS/Batch_FactBatchManager_PBS.hxx | 57 + src/PBS/Batch_FactBatchManager_ePBS.cxx | 66 + src/PBS/Batch_FactBatchManager_ePBS.hxx | 63 + src/PBS/Batch_JobInfo_PBS.cxx | 198 + src/PBS/Batch_JobInfo_PBS.hxx | 72 + src/PBS/Batch_JobInfo_ePBS.cxx | 118 + src/PBS/Batch_JobInfo_ePBS.hxx | 71 + src/PBS/Batch_Job_PBS.cxx | 472 ++ src/PBS/Batch_Job_PBS.hxx | 96 + src/PBS/CMakeLists.txt | 40 + src/PBS/Test/CMakeLists.txt | 49 + src/PBS/Test/Test_PBS_config.h.in | 26 + src/PBS/Test/Test_ePBS.cxx | 126 + src/PBS/Test/seta.sh | 3 + src/PBS/Test/setb.sh | 3 + src/PBS/Test/test-script.sh | 8 + src/Python/Batch_PyVersatile.cxx | 202 + src/Python/Batch_PyVersatile.hxx | 69 + src/Python/CMakeLists.txt | 41 + src/Python/Test/CMakeLists.txt | 36 + src/Python/Test/Test_Python_Local_SH.py | 99 + src/Python/Test/config.py.in | 24 + src/Python/Test/seta.sh | 3 + src/Python/Test/setb.sh | 3 + src/Python/Test/test-script.sh | 8 + src/Python/libBatch_Swig.i | 84 + src/Python/libBatch_Swig_exception.i | 45 + src/Python/libBatch_Swig_typemap.i | 247 + src/SGE/Batch_BatchManager_eSGE.cxx | 343 ++ src/SGE/Batch_BatchManager_eSGE.hxx | 95 + src/SGE/Batch_FactBatchManager_eSGE.cxx | 66 + src/SGE/Batch_FactBatchManager_eSGE.hxx | 61 + src/SGE/Batch_JobInfo_eSGE.cxx | 113 + src/SGE/Batch_JobInfo_eSGE.hxx | 72 + src/SGE/CMakeLists.txt | 29 + 170 files changed, 20575 insertions(+) create mode 100644 Batch_config.h.in create mode 100644 CMakeLists.txt create mode 100644 CMakeModules/FindLSF.cmake create mode 100644 CMakeModules/FindLocal.cmake create mode 100644 CMakeModules/FindMakeinfo.cmake create mode 100644 CMakeModules/FindPBS.cmake create mode 100644 CMakeModules/FindPLATFORM.cmake create mode 100644 CMakeModules/FindPython.cmake create mode 100644 CMakeModules/FindSWIG.cmake create mode 100644 CMakeModules/Summary.cmake create mode 100644 COPYING create mode 100644 INSTALL create mode 100644 doc/Batch.texi create mode 100644 doc/CMakeLists.txt create mode 100644 doc/version.texi create mode 100644 src/CMakeLists.txt create mode 100644 src/Core/Batch_APIInternalFailureException.cxx create mode 100644 src/Core/Batch_APIInternalFailureException.hxx create mode 100644 src/Core/Batch_BatchManager.cxx create mode 100644 src/Core/Batch_BatchManager.hxx create mode 100644 src/Core/Batch_BatchManagerCatalog.cxx create mode 100644 src/Core/Batch_BatchManagerCatalog.hxx create mode 100644 src/Core/Batch_BatchManager_eClient.cxx create mode 100644 src/Core/Batch_BatchManager_eClient.hxx create mode 100644 src/Core/Batch_BoolType.cxx create mode 100644 src/Core/Batch_BoolType.hxx create mode 100644 src/Core/Batch_CharType.cxx create mode 100644 src/Core/Batch_CharType.hxx create mode 100644 src/Core/Batch_ConnexionFailureException.cxx create mode 100644 src/Core/Batch_ConnexionFailureException.hxx create mode 100644 src/Core/Batch_Couple.cxx create mode 100644 src/Core/Batch_Couple.hxx create mode 100644 src/Core/Batch_CoupleType.cxx create mode 100644 src/Core/Batch_CoupleType.hxx create mode 100644 src/Core/Batch_Date.cxx create mode 100644 src/Core/Batch_Date.hxx create mode 100644 src/Core/Batch_DateType.cxx create mode 100644 src/Core/Batch_DateType.hxx create mode 100644 src/Core/Batch_Defines.hxx create mode 100644 src/Core/Batch_EmulationException.cxx create mode 100644 src/Core/Batch_EmulationException.hxx create mode 100644 src/Core/Batch_Environnement.cxx create mode 100644 src/Core/Batch_Environnement.hxx create mode 100644 src/Core/Batch_FactBatchManager.cxx create mode 100644 src/Core/Batch_FactBatchManager.hxx create mode 100644 src/Core/Batch_FactBatchManager_eClient.cxx create mode 100644 src/Core/Batch_FactBatchManager_eClient.hxx create mode 100644 src/Core/Batch_GenericException.cxx create mode 100644 src/Core/Batch_GenericException.hxx create mode 100644 src/Core/Batch_GenericType.cxx create mode 100644 src/Core/Batch_GenericType.hxx create mode 100644 src/Core/Batch_IntType.cxx create mode 100644 src/Core/Batch_IntType.hxx create mode 100644 src/Core/Batch_InvalidArgumentException.cxx create mode 100644 src/Core/Batch_InvalidArgumentException.hxx create mode 100644 src/Core/Batch_InvalidKeyException.cxx create mode 100644 src/Core/Batch_InvalidKeyException.hxx create mode 100644 src/Core/Batch_Job.cxx create mode 100644 src/Core/Batch_Job.hxx create mode 100644 src/Core/Batch_JobId.cxx create mode 100644 src/Core/Batch_JobId.hxx create mode 100644 src/Core/Batch_JobInfo.cxx create mode 100644 src/Core/Batch_JobInfo.hxx create mode 100644 src/Core/Batch_ListIsFullException.cxx create mode 100644 src/Core/Batch_ListIsFullException.hxx create mode 100644 src/Core/Batch_LongType.cxx create mode 100644 src/Core/Batch_LongType.hxx create mode 100644 src/Core/Batch_MapKey.cxx create mode 100644 src/Core/Batch_MapKey.hxx create mode 100644 src/Core/Batch_MpiImpl.cxx create mode 100644 src/Core/Batch_MpiImpl.hxx create mode 100644 src/Core/Batch_NotYetImplementedException.cxx create mode 100644 src/Core/Batch_NotYetImplementedException.hxx create mode 100644 src/Core/Batch_Parametre.cxx create mode 100644 src/Core/Batch_Parametre.hxx create mode 100644 src/Core/Batch_RunTimeException.cxx create mode 100644 src/Core/Batch_RunTimeException.hxx create mode 100644 src/Core/Batch_StringType.cxx create mode 100644 src/Core/Batch_StringType.hxx create mode 100644 src/Core/Batch_TypeMismatchException.cxx create mode 100644 src/Core/Batch_TypeMismatchException.hxx create mode 100644 src/Core/Batch_Versatile.cxx create mode 100644 src/Core/Batch_Versatile.hxx create mode 100644 src/Core/CMakeLists.txt create mode 100644 src/LSF/Batch_BatchManager_LSF.cxx create mode 100644 src/LSF/Batch_BatchManager_LSF.hxx create mode 100644 src/LSF/Batch_BatchManager_eLSF.cxx create mode 100644 src/LSF/Batch_BatchManager_eLSF.hxx create mode 100644 src/LSF/Batch_FactBatchManager_LSF.cxx create mode 100644 src/LSF/Batch_FactBatchManager_LSF.hxx create mode 100644 src/LSF/Batch_FactBatchManager_eLSF.cxx create mode 100644 src/LSF/Batch_FactBatchManager_eLSF.hxx create mode 100644 src/LSF/Batch_JobInfo_LSF.cxx create mode 100644 src/LSF/Batch_JobInfo_LSF.hxx create mode 100644 src/LSF/Batch_JobInfo_eLSF.cxx create mode 100644 src/LSF/Batch_JobInfo_eLSF.hxx create mode 100644 src/LSF/Batch_Job_LSF.cxx create mode 100644 src/LSF/Batch_Job_LSF.hxx create mode 100644 src/LSF/CMakeLists.txt create mode 100644 src/Local/Batch_BatchManager_Local.cxx create mode 100644 src/Local/Batch_BatchManager_Local.hxx create mode 100644 src/Local/Batch_BatchManager_Local_RSH.cxx create mode 100644 src/Local/Batch_BatchManager_Local_RSH.hxx create mode 100644 src/Local/Batch_BatchManager_Local_SH.cxx create mode 100644 src/Local/Batch_BatchManager_Local_SH.hxx create mode 100644 src/Local/Batch_BatchManager_Local_SSH.cxx create mode 100644 src/Local/Batch_BatchManager_Local_SSH.hxx create mode 100644 src/Local/Batch_FactBatchManager_Local.cxx create mode 100644 src/Local/Batch_FactBatchManager_Local.hxx create mode 100644 src/Local/Batch_FactBatchManager_Local_RSH.cxx create mode 100644 src/Local/Batch_FactBatchManager_Local_RSH.hxx create mode 100644 src/Local/Batch_FactBatchManager_Local_SH.cxx create mode 100644 src/Local/Batch_FactBatchManager_Local_SH.hxx create mode 100644 src/Local/Batch_FactBatchManager_Local_SSH.cxx create mode 100644 src/Local/Batch_FactBatchManager_Local_SSH.hxx create mode 100644 src/Local/Batch_IOMutex.cxx create mode 100644 src/Local/Batch_IOMutex.hxx create mode 100644 src/Local/Batch_JobInfo_Local.cxx create mode 100644 src/Local/Batch_JobInfo_Local.hxx create mode 100644 src/Local/Batch_Job_Local.cxx create mode 100644 src/Local/Batch_Job_Local.hxx create mode 100644 src/Local/CMakeLists.txt create mode 100644 src/Local/Test/CMakeLists.txt create mode 100644 src/Local/Test/Test_Local_RSH.cxx create mode 100644 src/Local/Test/Test_Local_SH.cxx create mode 100644 src/Local/Test/Test_Local_SSH.cxx create mode 100644 src/Local/Test/Test_Local_config.h.in create mode 100644 src/Local/Test/seta.sh create mode 100644 src/Local/Test/setb.sh create mode 100755 src/Local/Test/test-script.sh create mode 100644 src/PBS/Batch_BatchManager_PBS.cxx create mode 100644 src/PBS/Batch_BatchManager_PBS.hxx create mode 100644 src/PBS/Batch_BatchManager_ePBS.cxx create mode 100644 src/PBS/Batch_BatchManager_ePBS.hxx create mode 100644 src/PBS/Batch_FactBatchManager_PBS.cxx create mode 100644 src/PBS/Batch_FactBatchManager_PBS.hxx create mode 100644 src/PBS/Batch_FactBatchManager_ePBS.cxx create mode 100644 src/PBS/Batch_FactBatchManager_ePBS.hxx create mode 100644 src/PBS/Batch_JobInfo_PBS.cxx create mode 100644 src/PBS/Batch_JobInfo_PBS.hxx create mode 100644 src/PBS/Batch_JobInfo_ePBS.cxx create mode 100644 src/PBS/Batch_JobInfo_ePBS.hxx create mode 100644 src/PBS/Batch_Job_PBS.cxx create mode 100644 src/PBS/Batch_Job_PBS.hxx create mode 100644 src/PBS/CMakeLists.txt create mode 100644 src/PBS/Test/CMakeLists.txt create mode 100644 src/PBS/Test/Test_PBS_config.h.in create mode 100644 src/PBS/Test/Test_ePBS.cxx create mode 100644 src/PBS/Test/seta.sh create mode 100644 src/PBS/Test/setb.sh create mode 100755 src/PBS/Test/test-script.sh create mode 100644 src/Python/Batch_PyVersatile.cxx create mode 100644 src/Python/Batch_PyVersatile.hxx create mode 100644 src/Python/CMakeLists.txt create mode 100644 src/Python/Test/CMakeLists.txt create mode 100644 src/Python/Test/Test_Python_Local_SH.py create mode 100644 src/Python/Test/config.py.in create mode 100644 src/Python/Test/seta.sh create mode 100644 src/Python/Test/setb.sh create mode 100755 src/Python/Test/test-script.sh create mode 100644 src/Python/libBatch_Swig.i create mode 100644 src/Python/libBatch_Swig_exception.i create mode 100644 src/Python/libBatch_Swig_typemap.i create mode 100644 src/SGE/Batch_BatchManager_eSGE.cxx create mode 100644 src/SGE/Batch_BatchManager_eSGE.hxx create mode 100644 src/SGE/Batch_FactBatchManager_eSGE.cxx create mode 100644 src/SGE/Batch_FactBatchManager_eSGE.hxx create mode 100644 src/SGE/Batch_JobInfo_eSGE.cxx create mode 100644 src/SGE/Batch_JobInfo_eSGE.hxx create mode 100644 src/SGE/CMakeLists.txt diff --git a/Batch_config.h.in b/Batch_config.h.in new file mode 100644 index 0000000..4ad5d1e --- /dev/null +++ b/Batch_config.h.in @@ -0,0 +1,47 @@ +// Copyright (C) 2007-2008 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 +// + +#ifndef BATCH_CONFIG_H +#define BATCH_CONFIG_H + +/* A path to a rcp-like command */ +#define RCP "@RCP@" + +/* A path to a rm-like command */ +#define RM "@RM@" + +/* A path to a cp-like command */ +#define CP "@CP@" + +/* A path to a rsh-like command */ +#define RSH "@RSH@" + +/* A path to a scp-like command */ +#define SCP "@SCP@" + +/* A path to a sh-like command */ +#define SH "@SH@" + +/* A path to a ssh-like command */ +#define SSH "@SSH@" + +#endif diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..0fa11d8 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,76 @@ +# Copyright (C) 2007-2008 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 +# + +project (libBatch) + +cmake_minimum_required (VERSION 2.4) +set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules/) + +ENABLE_TESTING() + +find_package (PLATFORM) +find_package (Threads) +IF (NOT CMAKE_USE_PTHREADS_INIT) + MESSAGE(FATAL_ERROR "Mandatory library pthread not found") +ENDIF (NOT CMAKE_USE_PTHREADS_INIT) +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") + +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) +IF (BUILD_PYTHON_WRAPPING) + FIND_PACKAGE(Python) + FIND_PACKAGE(SWIG) +ENDIF (BUILD_PYTHON_WRAPPING) + +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Batch_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/Batch_config.h) + +INCLUDE(Summary) + +add_subdirectory (src) + +IF (Makeinfo_FOUND) + add_subdirectory (doc) +ENDIF (Makeinfo_FOUND) + +SET(CPACK_GENERATOR TGZ) +SET(CPACK_SOURCE_GENERATOR TGZ) +SET(CPACK_PACKAGE_VERSION_MAJOR 1) +SET(CPACK_PACKAGE_VERSION_MINOR 0) +SET(CPACK_PACKAGE_VERSION_PATCH 0) +SET(CPACK_SOURCE_IGNORE_FILES /\\\\.;/CVS/;~) +SET(CPACK_SOURCE_PACKAGE_FILE_NAME + ${PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}) +INCLUDE(CPack) + +MARK_AS_ADVANCED(CMAKE_BACKWARDS_COMPATIBILITY EXECUTABLE_OUTPUT_PATH) diff --git a/CMakeModules/FindLSF.cmake b/CMakeModules/FindLSF.cmake new file mode 100644 index 0000000..1c673f4 --- /dev/null +++ b/CMakeModules/FindLSF.cmake @@ -0,0 +1,49 @@ +# Copyright (C) 2007-2008 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) + +SET(LSF_FOUND ${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/FindLocal.cmake b/CMakeModules/FindLocal.cmake new file mode 100644 index 0000000..9967f33 --- /dev/null +++ b/CMakeModules/FindLocal.cmake @@ -0,0 +1,41 @@ +# Copyright (C) 2007-2008 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 +# + +MACRO(FIND_LOCAL_COMMAND VAR COMMAND) + FIND_PROGRAM(${VAR} ${COMMAND}) + IF (${VAR}) + MESSAGE(STATUS "${COMMAND} found : ${${VAR}}") + ELSE (${VAR}) + MESSAGE(STATUS "${COMMAND} not found, local submission might not work properly") + SET(${VAR} /bin/false) + ENDIF (${VAR}) + MARK_AS_ADVANCED(${VAR}) +ENDMACRO(FIND_LOCAL_COMMAND) + +MESSAGE(STATUS "Looking for commands needed for local submission...") +FIND_LOCAL_COMMAND(RM rm) +FIND_LOCAL_COMMAND(SH sh) +FIND_LOCAL_COMMAND(CP cp) +FIND_LOCAL_COMMAND(RSH rsh) +FIND_LOCAL_COMMAND(RCP rcp) +FIND_LOCAL_COMMAND(SSH ssh) +FIND_LOCAL_COMMAND(SCP scp) diff --git a/CMakeModules/FindMakeinfo.cmake b/CMakeModules/FindMakeinfo.cmake new file mode 100644 index 0000000..8ac9963 --- /dev/null +++ b/CMakeModules/FindMakeinfo.cmake @@ -0,0 +1,47 @@ +# Copyright (C) 2007-2008 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 Makeinfo_FIND_QUIETLY) + MESSAGE(STATUS "Looking for Makeinfo...") +ENDIF (NOT Makeinfo_FIND_QUIETLY) + +FIND_PROGRAM(MAKEINFO_EXECUTABLE makeinfo DOC "Makeinfo executable") + +SET(Makeinfo_FOUND ${MAKEINFO_EXECUTABLE}) + +IF (Makeinfo_FOUND) + + IF (NOT Makeinfo_FIND_QUIETLY) + MESSAGE(STATUS "Found Makeinfo: ${MAKEINFO_EXECUTABLE}") + ENDIF (NOT Makeinfo_FIND_QUIETLY) + +ELSE (Makeinfo_FOUND) + + IF (Makeinfo_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Makeinfo not found") + ELSE (Makeinfo_FIND_REQUIRED) + IF (NOT Makeinfo_FIND_QUIETLY) + MESSAGE(STATUS "Makeinfo not found") + ENDIF (NOT Makeinfo_FIND_QUIETLY) + ENDIF (Makeinfo_FIND_REQUIRED) + +ENDIF (Makeinfo_FOUND) diff --git a/CMakeModules/FindPBS.cmake b/CMakeModules/FindPBS.cmake new file mode 100644 index 0000000..9fc9455 --- /dev/null +++ b/CMakeModules/FindPBS.cmake @@ -0,0 +1,51 @@ +# Copyright (C) 2007-2008 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 +# + +INCLUDE (CheckIncludeFile) +INCLUDE (CheckLibraryExists) + +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 pbs) + +SET(PBS_FOUND ${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/FindPLATFORM.cmake b/CMakeModules/FindPLATFORM.cmake new file mode 100644 index 0000000..28fd288 --- /dev/null +++ b/CMakeModules/FindPLATFORM.cmake @@ -0,0 +1,64 @@ +# Copyright (C) 2007-2008 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 +# +MARK_AS_ADVANCED(ISSUE) +FIND_FILE(ISSUE issue /etc) +IF(ISSUE) + SET(WINDOWS 0) +ELSE() + SET(WINDOWS 1) +ENDIF(ISSUE) + +IF(WINDOWS) + SET(MACHINE WINDOWS) + SET(PLATFORM_CPPFLAGS) + SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -DWNT) + SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -DPPRO_NT) + SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} /W0) + # # SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -DWNT -D_CRT_SECURE_NO_WARNINGS) + # # SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -D_WIN32_WINNT=0x0500) + # SET(RM del) +ELSE(WINDOWS) + SET(MACHINE PCLINUX) + SET(PLATFORM_CPPFLAGS) + # SET(RM /bin/rm) +ENDIF(WINDOWS) + +IF(WINDOWS) + SET(CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE}) + IF(CMAKE_BUILD_TYPE STREQUAL Release) + MARK_AS_ADVANCED(CLEAR CMAKE_CONFIGURATION_TYPES) + SET(CMAKE_CONFIGURATION_TYPES Release CACHE STRING "compilation types" FORCE) + ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) +ENDIF(WINDOWS) + +IF(WINDOWS) + SET(CMAKE_INSTALL_PREFIX_ENV $ENV{CMAKE_INSTALL_PREFIX}) + IF(CMAKE_INSTALL_PREFIX_ENV) + SET(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX_ENV} CACHE PATH "installation prefix" FORCE) + ENDIF(CMAKE_INSTALL_PREFIX_ENV) +ENDIF(WINDOWS) + +## SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -D_DEBUG_) + +#SET(RCP rcp) +#SET(RSH rsh) +#SET(RCP rcp) diff --git a/CMakeModules/FindPython.cmake b/CMakeModules/FindPython.cmake new file mode 100644 index 0000000..94eb648 --- /dev/null +++ b/CMakeModules/FindPython.cmake @@ -0,0 +1,92 @@ +# Copyright (C) 2007-2008 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 +# + +# We use a custom FindPYTHON.cmake because the one shipped with cmake doesn't search +# properly for the version number. + +IF (NOT Python_FIND_QUIETLY) + MESSAGE(STATUS "Looking for Python...") +ENDIF (NOT Python_FIND_QUIETLY) + +IF(WINDOWS) + IF(CMAKE_BUILD_TYPE STREQUAL Release) + FIND_PROGRAM(PYTHON_EXECUTABLE python) + ELSE(CMAKE_BUILD_TYPE STREQUAL Release) + FIND_PROGRAM(PYTHON_EXECUTABLE python_d) + ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) +ELSE(WINDOWS) + FIND_PROGRAM(PYTHON_EXECUTABLE python DOC "Python interpreter") +ENDIF(WINDOWS) + +EXECUTE_PROCESS( + COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(sys.version[:3])" + OUTPUT_VARIABLE PYTHON_VERSION + ) + +SET(PYTHON_ROOT ${PYTHON_EXECUTABLE}) +GET_FILENAME_COMPONENT(PYTHON_ROOT ${PYTHON_ROOT} PATH) +GET_FILENAME_COMPONENT(PYTHON_ROOT ${PYTHON_ROOT} PATH) + +FIND_PATH(PYTHON_INCLUDE_PATH Python.h + PATHS ${PYTHON_ROOT}/include ${PYTHON_ROOT}/include/python${PYTHON_VERSION} + DOC "Python include path") + +IF(WINDOWS) + STRING(REPLACE "." "" PYTHON_VERSION_WITHOUT_DOT ${PYTHON_VERSION}) + IF(CMAKE_BUILD_TYPE STREQUAL Release) + FIND_LIBRARY(PYTHON_LIBRARIES python${PYTHON_VERSION_WITHOUT_DOT} ${PYTHON_ROOT}/libs DOC "Python libraries") + ELSE(CMAKE_BUILD_TYPE STREQUAL Release) + FIND_LIBRARY(PYTHON_LIBRARIES python${PYTHON_VERSION_WITHOUT_DOT}_d ${PYTHON_ROOT}/libs DOC "Python libraries") + ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) +ELSE(WINDOWS) + FIND_LIBRARY(PYTHON_LIBRARIES python${PYTHON_VERSION} ${PYTHON_ROOT}/lib DOC "Python libraries") +ENDIF(WINDOWS) + +SET(PYTHON_INCLUDES -I${PYTHON_INCLUDE_PATH}) +SET(PYTHON_LIBS ${PYTHON_LIBRARIES}) + +IF(WINDOWS) + IF(CMAKE_BUILD_TYPE STREQUAL Release) + ELSE(CMAKE_BUILD_TYPE STREQUAL Release) + SET(PYTHON_INCLUDES ${PYTHON_INCLUDES} -DHAVE_DEBUG_PYTHON) + ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) +ENDIF(WINDOWS) + +SET(Python_FOUND ${PYTHON_EXECUTABLE} AND ${PYTHON_LIBRARIES} AND ${PYTHON_INCLUDE_PATH}) + +IF (Python_FOUND) + + IF (NOT Python_FIND_QUIETLY) + MESSAGE(STATUS "Found Python: ${PYTHON_EXECUTABLE} (version ${PYTHON_VERSION})") + ENDIF (NOT Python_FIND_QUIETLY) + +ELSE (Python_FOUND) + + IF (Python_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Python not found") + ELSE (Python_FIND_REQUIRED) + IF (NOT Python_FIND_QUIETLY) + MESSAGE(STATUS "Python not found") + ENDIF (NOT Python_FIND_QUIETLY) + ENDIF (Python_FIND_REQUIRED) + +ENDIF (Python_FOUND) diff --git a/CMakeModules/FindSWIG.cmake b/CMakeModules/FindSWIG.cmake new file mode 100644 index 0000000..53329c5 --- /dev/null +++ b/CMakeModules/FindSWIG.cmake @@ -0,0 +1,50 @@ +# Copyright (C) 2007-2008 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 +# + +# We use a custom FindSWIG.cmake because the one shipped with cmake doesn't search +# properly in the $PATH env var. + +IF (NOT SWIG_FIND_QUIETLY) + MESSAGE(STATUS "Looking for SWIG...") +ENDIF (NOT SWIG_FIND_QUIETLY) + +FIND_PROGRAM(SWIG_EXECUTABLE NAMES swig swig-1.3 DOC "SWIG executable") + +SET(SWIG_FOUND ${SWIG_EXECUTABLE}) + +IF (SWIG_FOUND) + + IF (NOT SWIG_FIND_QUIETLY) + MESSAGE(STATUS "Found SWIG: ${SWIG_EXECUTABLE}") + ENDIF (NOT SWIG_FIND_QUIETLY) + +ELSE (SWIG_FOUND) + + IF (SWIG_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "SWIG not found") + ELSE (SWIG_FIND_REQUIRED) + IF (NOT SWIG_FIND_QUIETLY) + MESSAGE(STATUS "SWIG not found") + ENDIF (NOT SWIG_FIND_QUIETLY) + ENDIF (SWIG_FIND_REQUIRED) + +ENDIF (SWIG_FOUND) diff --git a/CMakeModules/Summary.cmake b/CMakeModules/Summary.cmake new file mode 100644 index 0000000..ed5e764 --- /dev/null +++ b/CMakeModules/Summary.cmake @@ -0,0 +1,70 @@ +# Copyright (C) 2007-2008 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 +# + +MESSAGE("") +MESSAGE("**************** Summary ****************") +MESSAGE("") +IF (BUILD_LSF_INTERFACE) + IF (LSF_FOUND) + MESSAGE("LSF ................................. Yes") + ELSE (LSF_FOUND) + MESSAGE("LSF ........................... Not found") + ENDIF (LSF_FOUND) +ELSE (BUILD_LSF_INTERFACE) + MESSAGE("LSF ....................... Not requested") +ENDIF (BUILD_LSF_INTERFACE) + +IF (BUILD_PBS_INTERFACE) + IF (PBS_FOUND) + MESSAGE("PBS ................................. Yes") + ELSE (PBS_FOUND) + MESSAGE("PBS ........................... Not found") + ENDIF (PBS_FOUND) +ELSE (BUILD_PBS_INTERFACE) + MESSAGE("PBS ....................... Not requested") +ENDIF (BUILD_PBS_INTERFACE) + +IF (BUILD_LOCAL_SUBMISSION) + MESSAGE("Local submission .................... Yes") +ELSE (BUILD_LOCAL_SUBMISSION) + MESSAGE("Local submission .......... Not requested") +ENDIF (BUILD_LOCAL_SUBMISSION) + +IF (BUILD_PYTHON_WRAPPING) + IF (PYTHON_INCLUDE_PATH AND PYTHON_LIBRARIES AND SWIG_FOUND) + MESSAGE("Python wrapping ..................... Yes") + ELSE (PYTHON_INCLUDE_PATH AND PYTHON_LIBRARIES AND SWIG_FOUND) + MESSAGE("Python wrapping ............... Not found") + ENDIF (PYTHON_INCLUDE_PATH AND PYTHON_LIBRARIES AND SWIG_FOUND) +ELSE (BUILD_PYTHON_WRAPPING) + MESSAGE("Python wrapping ........... Not requested") +ENDIF (BUILD_PYTHON_WRAPPING) + +IF (Makeinfo_FOUND) + MESSAGE("Makeinfo ............................ Yes") +ELSE (Makeinfo_FOUND) + MESSAGE("Makeinfo ...................... Not found") +ENDIF (Makeinfo_FOUND) + +MESSAGE("") +MESSAGE("************** End Summary **************") +MESSAGE("") diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..f1ae095 --- /dev/null +++ b/COPYING @@ -0,0 +1,503 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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, or (at your option) any later version. + + 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 + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..d0a4c60 --- /dev/null +++ b/INSTALL @@ -0,0 +1,134 @@ +# Copyright (C) 2007-2008 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 +# + + +-------------------------------- Quick install -------------------------------- + + +This library is based on CMake build system (http://www.cmake.org/), which +means that you must have CMake installed on your system (minimum version 2.4) +in order to build and install libBatch. + +You can then go to the directory where you extracted libBatch package and type: + +$ cmake +$ make +$ make install + +That's all! + + +--------------------- Detailed installation instructions ---------------------- + + +1. Prerequisites + + +First of all, you have to check (or install if needed) the dependant software +programs on your system. These programs are: + +- CMake build system version 2.4 or newer (http://www.cmake.org/) +- C++ compiler with standard libraries +- pthread library + +Other products are optional and used to build libBatch interfaces to various +batch systems and to generate wrappings and documentation: + +- LSF headers and libraries (to build the interface to LSF batch system) +- OpenPBS headers and libraries (to build the interface to OpenPBS) +- Several Unix remote control commands like ssh and scp (for local submission) +- Python and SWIG (to build Python wrappings) +- makeinfo (to generate the documentation) + + +2. Building and installing the library + + +To build the library, you will have to extract the source package in a +directory where you have write permissions (probably done since you're reading +this file). You can then build the library directly in the source tree, but it +is strongly advised to use an independant build tree. For that, just go to the +directory where you extracted libBatch and type for instance: + +$ mkdir ../libBatch-build +$ cd ../libBatch-build + +After that, you will just need to run cmake to generate the Makefiles and to +run make and make install: + +$ cmake ../libBatch-X.X.X (X's are version numbers) +$ make +$ make install + +Note that CMake will look for the prerequisites and optional products in the +standard directories and environment variables. To change this behavior, you +can either preset the environment variables CMAKE_INCLUDE_PATH and +CMAKE_LIBRARY_PATH (see CMake documentation for more details) or use CMake +graphical interface. For this, run cmake one time to populate the cache and +then run ccmake: + +$ cmake ../libBatch-X.X.X (X's are version numbers) +$ ccmake ../libBatch-X.X.X (X's are version numbers) + +You will then be able to change several variables to control the way libBatch +is built (i.e. install path, products path, components to install, ...). Then +run make and make install like before to build and install the library. + +Also note that you won't be able to install libBatch in the default directory +if you don't have administrators rights on your machine (and anyway, it's not +advised to install anything manually in the /usr directory). To specify the +installation directory, you can either use the graphical interface or directly +type on cmake command line: + +$ cmake ../libBatch-X.X.X -DCMAKE_INSTALL_PREFIX= + + +3. Testing + + +The build system creates a test target that can be used to automatically test +some features of the library. The test coverage for this library is currently +quite poor. Remember that since the tests use connections to remote batch +systems, the first causes of failure are network and authentication errors. To +run the tests, you will first have to set several variables in the cache +(execution host, ...), with ccmake for instance. Then to execute those tests, +just go to your build directory and type: + +$ make test + +The tests will be run successively and a summary will show you how many of them +passed without error. Note that several tests need passwordless SSH +authentication to succeed. You can configure this authentication with ssh-agent +for instance. If one or several tests failed, you can find more detailed +results in the file /Testing/Temporary/LastTest.log + + +4. Building source and binary packages (for developers) + + +You can directly build source or binary tgz packages for libBatch with CPack +(included with CMake) packaging process. For this, just go to your build +directory and type: + +$ cmake ../libBatch-X.X.X (X's are version numbers) +$ make package (for binary package) +$ make package_source (for source package) diff --git a/doc/Batch.texi b/doc/Batch.texi new file mode 100644 index 0000000..d8bc55c --- /dev/null +++ b/doc/Batch.texi @@ -0,0 +1,4892 @@ +\input texinfo @c -*-texinfo-*- +@c %**start of header +@setfilename Batch.info +@settitle Documentation de Batch +@setchapternewpage odd +@iftex +@afourpaper +@end iftex + +@include version.texi + +@dircategory Bibliotheque de classes Batch +@direntry +* Batch: (Batch); Documentation de la bibliotheque de classes Batch. +@end direntry + +@c %**end of header + + + +@titlepage +@sp 10 +@comment The title is printed in a large font. +@title Bibliotheque de classes Batch +@subtitle Documentation - version @value{VERSION} +@subtitle @value{UPDATED} +@author Ivan DUTKA-MALEN - EDF R&D + +@c The following two commands start the copyright page. +@page +@vskip 0pt plus 1filll +Copyright @copyright{} 2003-2004 EDF R&D sous licence GPL +@end titlepage + +@contents + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Top, Description, Index , (dir) +@comment node-name, next, previous, up +@ifinfo +Copyright @copyright{} 2003-2004 EDF R&D sous licence GPL +@end ifinfo + +@unnumbered Introduction + +Ceci est la documentation de la bibliotheque de classes Batch version +@value{VERSION}. + +Ce manuel est normalement disponible sous la forme de fichiers +@file{.info}, PostScript @file{.ps}, PDF @file{.pdf} et HTML +@file{.html}. Merci a Texinfo. + + +@menu +* Description:: Le batch, c'est quoi ? Ca sert a quoi ? +* Classes:: Une description des classes internes. +* Utilisation:: Comment on s'en sert ? Quelques exemples. +* Installation de la bibliotheque:: Comment ca s'installe ? +* Divers:: D'autres petits details. +* Index:: Index generaux. +@end menu + + + + + + + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Description, Classes, Top, Top +@comment node-name, next, previous, up +@chapter Description Generale +@cindex description + +Dans le domaine du batch, nombreux sont les gestionnaires qui sont +apparus et se sont popularises en fonction des plates-formes et des +constructeurs. On peut notamment citer NQS, le premier de tous, LSF, +LoadLeveler, PBS (et ses derives OpenPBS et PBS Pro), etc. qui se +prevalent tous d'une compatibilite avec NQS. + +Si l'ensemble de ces produits offrent les fonctionnalites de base de +NQS, a savoir soumission, controle, destruction, modification, etc. de +travaux batch, ils se distinguent tous par leur incompatibilite mutuelle +et par les syntaxes de fichiers et les appels de fonction specifiques +qu'ils ont developpes. + +Or il est interessant de pouvoir acceder d'une facon homogene et +generique aux fonctionnalites de ces gestionnaires quitte a se +restreindre a un sous-ensemble minimal mais essentiel de leurs +possibilites. + +La bibliotheque de classes Batch fournit ce moyen de soumettre et +controler des travaux batch depuis une machine cliente sans s'occuper du +type de gestionnaire present sur le serveur sur lequel se deroule +l'execution du travail. Seul doit etre precise le nom du serveur sur +lequel sera soumis le travail batch et le type de gestionnaire qui s'y +trouve. Tout le reste est generique et ne depend plus de l'implementation. + + + + + + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classes, Terminologie, Description, Top +@comment node-name, next, previous, up +@chapter Classes Internes +@cindex classe + +Les classes de la bibliotheque reposent sur des concepts issus du monde +de la gestion de batch, qui meritent d'etre reprecises pour ne pas +introduire d'ambiguite semantique dans le discours. + +@menu +* Terminologie:: Description des termes employes. +* Classes generiques:: Les classes communes a tous les gestionnaires. +* Classes specifiques:: Les classes d'implementation. +@end menu + + + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Terminologie, Batch, Classes, Classes +@comment node-name, next, previous, up +@section Terminologie +@cindex terminologie + +Pour les non-inities aux mysteres de la gestion de batch, un petit +glossaire des termes employes dans cette documentation, assaisonne a la +sauce de la bibliotheque de classes Batch. + +@menu +* Batch:: Gestion par lots, execution differee. +* BatchManager:: Gestionnaire de batch. +* Job:: Travail. +* Parametre:: Configuration de l'execution. +* Environnement:: Environnement d'execution. +* JobId:: Identifiant de travail. +* JobInfo:: Informations sur le travail. +@end menu + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Batch, BatchManager, Terminologie, Terminologie +@comment node-name, next, previous, up +@subsection Batch +@cindex batch + +Le traitement batch (batch processing en anglais), ou traitement par +lot, fait reference au mode de sequencage et d'utilisation des +ressources d'un calculateur tel qu'il a ete premierement employe dans +les debuts de l'ere informatique. Mais il faut preciser que cette +anteriorite ne condamne pas le traitement batch aux oubliettes au motif +d'une quelconque obsolescence. Si le traitement par lot a vu le jour et +existe encore aujourd'hui, c'est parce qu'il repond de maniere +satisfaisante a une certaine utilisation des ressources d'un +calculateur, et que cette utilisation est encore d'actualite. Present +depuis plus de quarante ans, le batch est encore largement utilise sur +les grands serveurs, et le sera vraisemblablement pour quelques annees +encore. + +Le traitement par lot se distingue de l'execution interactive par le +fait que les travaux a effectuer sont places dans une file d'attente +avec une indication pour chaque lot des ressources dont il doit disposer +pour aboutir correctement. Une fois les travaux inscrits dans la file, +c'est au systeme de traitement batch (@xref{BatchManager}.) de veiller a +leur bonne execution en leur fournissant les ressources demandees. Tout +travail qui ne disposerait pas des ressources adequates ne peut pas etre +active. + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node BatchManager, Job, Batch, Terminologie +@comment node-name, next, previous, up +@subsection Batch Manager +@cindex batch manager +@cindex gestionnaire + +Le role du gestionnaire de batch, ou batch manager en anglais, est +d'executer et eventuellement d'ordonner les travaux places en file +d'attente en leur allouant exclusivement les ressources necessaires a +leur execution. Son objectif est d'optimiser les ressources du systeme +dont il a la charge de maniere a ecouler le maximum de travaux en un +minimum de temps et un minimum de ressources materielles. + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Job, Parametre, BatchManager, Terminologie +@comment node-name, next, previous, up +@subsection Job +@cindex Job +@cindex travail + +Le travail, ou job en anglais, est l'unite elementaire de traitement qui +peut etre soumis au gestionnaire de batch. Il peut s'agir d'une simple +commande systeme, comme d'une application ou bien meme de l'enchainement +complexe mais indivisible de plusieurs applications ou commandes. + +Pour s'executer correctement, c'est-a-dire sans erreur, le job doit +disposer de certaines ressources --- de la memoire, du temps, de +l'espace disque @dots{} --- pendant toute la duree de son +execution. C'est au gestionnaire de batch (@xref{BatchManager}.) de +garantir au job la presence et la persistence de ces ressources pendant +l'execution du job. + +Par contre c'est a l'utilisateur qui soumet le job d'informer le +gestionnaire de batch des ressources necessaires au job. Pour des +raisons evidentes de bonne gestion des ressources, le job ne peut +consommer plus de ressources que celles qu'il a demande et obtenu du +gestionnaire de batch sans etre arrete ou reclasse. + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Parametre, Environnement, Job, Terminologie +@comment node-name, next, previous, up +@subsection Parametre +@cindex parametre + +Le premier type de ressource necessaire a un job concerne les elements +materiels ou temporels, en un mot, physiques. Parmi ces ressources, on +trouve le temps de calcul, le temps de presence en machine, l'espace +disque, la quantite de memoire vive, l'architecture du calculateur, etc. + +Dans la terminologie de la bibliotheque de classes Batch, tous ces +elements ont ete regroupes sous le terme de @emph{Parametre}. + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Environnement, JobId, Parametre, Terminologie +@comment node-name, next, previous, up +@subsection Environnement +@cindex environnement + +Le second type de ressource necessaire a un job concerne les elements +logiciels. Cela se traduit le plus souvent, et particulierement, dans +les systemes Unix par la notion de variable d'environnement. Lorsque le +job s'execute, il doit pouvoir trouver l'ensemble des commandes et des +applications auquel il souhaite faire appel. Les variables +d'environnement decrivent donc les localisations des ces +programmes. Elles peuvent egalement contenir des informations influant +sur le comportement des programmes. + +Dans la terminologie de la bibliotheque de classes Batch, tous ces +elements on ete regroupes sous le terme de @emph{Environnement}. + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node JobId, JobInfo, Environnement, Terminologie +@comment node-name, next, previous, up +@subsection JobId +@cindex jobid +@cindex identifier + +Si un job (@xref{Job}.) decrit les actions qui doivent etre effectues +par le systeme sous le controle du gestionnaire de batch, il est clair +qu'il est possible de soumettre plusieurs fois de suite le meme job, et +par la-meme d'executer plusieurs fois (et parfois simultanement) ces +memes actions. On a donc plusieurs instances du meme job qui sont +presentes en machine. Chaque instance peut etre distinguee des autres +par un identifiant unique qui lui est propre : c'est le @emph{jobId}. + +Le JobId est determine par le gestionnaire de batch au moment de la +soumission. + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node JobInfo, Classes generiques, JobId, Terminologie +@comment node-name, next, previous, up +@subsection JobInfo +@cindex jobinfo + + +Des qu'un job (@xref{Job}.) est soumis donc des qu'il dispose d'un +JobId (@xref{JobId}.), il est possible d'interroger le gestionnaire de +batch pour etre informe de son comportement, de son evolution au sein du +systeme pendant son execution. + +On peut ainsi connaitre les parametres reellement consommes par rapport +aux parametres alloues, ainsi que l'environnement d'execution du job. + +Le JobInfo est une structure qui collecte ses informations sur l'etat du +job. + + + + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classes generiques, Namespace, JobInfo, Classes +@comment node-name, next, previous, up +@section Classes generiques +@cindex classes generiques + +Schematiquement, les classes composant la bibliotheque sont regroupees +en trois categories. Celles appartenant au groupe @emph{Types de base} +ne servent que de support au fonctionnement des classes de plus haut +niveau, egalement appellees @emph{Classes utilisateur}. Seules ces +dernieres sont vraiment interessantes pour l'utilisateur de la +bibliotheque. Les exceptions sont regroupees dans une categorie qui leur +est propre. + +@menu +* Namespace:: Espace de noms pour la bibliotheque. +* Types de base:: Les classes elementaires. +* Classes utilisateur:: Les classes de haut-niveau. +* Exceptions:: Les exceptions de la bibliotheque. +@end menu + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Namespace, Types de base, Classes generiques, Classes generiques +@comment node-name, next, previous, up +@subsection Namespace +@cindex namespace + +Toutes les classes de la bibliotheque sont regroupees dans un unique +namespace nomme @emph{Batch} afin de ne pas introduire de conflit avec +d'autres classes de meme nom. + +Ainsi lorsque par exemple on cite la classe @emph{BatchManager}, il +faudra declarer un objet @emph{Batch::BatchManager} ou bien faire appel +au namespace @emph{Batch} en C++. En Python, les objets sont regroupes +dans un module nomme @emph{libBatch_Swig}. + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Types de base, Classe Couple, Namespace, Classes generiques +@comment node-name, next, previous, up +@subsection Types de base +@cindex types de base + +Les classes decrites ici sont toutes utilisees ou utilisables par les +classes utilisateur de la bibliotheque, et en particulier par la classe +Versatile. @xref{Classe Versatile}. + +Ces classes implementent sous forme d'objet les types de base du langage +C++. Ainsi la classe @emph{Booltype} implemente le type de base +@emph{bool}. Certains types de base n'existant pas dans le langage ont +ete crees et encapsules dans une classe : c'est le cas notamment du type +de base @emph{Date} et de la classe @emph{DateType}, et du type de base +@emph{Couple} et de la classe @emph{CoupleType}. + +Tous les classes heritent de la classe generique @emph{GenericType}. + +@menu +-- Types de base -- + +* Classe Couple:: Association de fichiers. +* Classe Date:: Type elementaire de date. + +-- Classes d'implementation des types de base -- + +* Classe GenericType:: Classe-mere de tous les types. +* Classe BoolType:: Encapsulation du type bool. +* Classe CharType:: Encapsulation du type char. +* Classe CoupleType:: Encapsulation du type Couple. +* Classe DateType:: Encapsulation du type Date. +* Classe IntType:: Encapsulation du type int. +* Classe LongType:: Encapsulation du type long. +* Classe StringType:: Encapsulation du type string. + +@end menu + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe Couple, Classe Date, Types de base, Types de base +@comment node-name, next, previous, up +@page +@subsubsection Couple +@findex Couple + +La classe @emph{Couple} implemente le comportement d'un couple de deux +chaines de type @emph{string} qui sont respectivement nommees +@emph{local} et @emph{remote}. + +Cette classe est utilisee essentiellement pour la designation des +fichiers a transferer lors des soumissions de travaux, d'ou les noms +employes. + +@cartouche +Il faut toutefois faire attention a designer correctement ce qui est +local ou distant. Ainsi dans la bibliotheque de classes Batch, on a +adopte la convention qu'un fichier dit @emph{local} est celui present +sur la machine qui execute la bibliotheque de classes Batch, alors qu'un +fichier dit @emph{remote} (ou distant) est celui present sur le serveur +du gestionnaire de batch. +L'approche est donc clairement orientee utilisateur plutot que serveur. +@end cartouche + +@itemize @bullet{} +@item Entete + +@example +class Couple +@{ + public: + // Constructeur standard + Couple(const string & local, const string & remote); + + // Constructeur par recopie + Couple(const Couple & C); + + // Operateur pour l'affichage sur un stream + friend ostream & operator << (ostream & os, const Couple & cp); + + // Operateur d'affectation + virtual Couple & operator =(const Couple &); + + // Conversion en chaine + virtual string str() const; + + // Accesseurs + virtual string getLocal() const; + virtual string getRemote() const; + + protected: + string _local; // chemin d'acces au fichier local + string _remote; // chemin d'acees au fichier distant + + private: + +@}; +@end example +@end itemize + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe Date, Classe GenericType, Classe Couple, Types de base +@comment node-name, next, previous, up +@page +@subsubsection Date +@findex Date + +La classe @emph{Date} sert a stocker n'importe quelle information de +temps et peut la representer sous une forme plus lisible a l'utilisateur +que le traditionnel appel a la fonction @emph{ctime}. @xref{(*manpages*)ctime}. + +@itemize @bullet{} +@item Entete + +@example +class Date +@{ + public: + // Constructeur standard (a partir d'une valeur epoch) + Date(const long l=0); + + // Constructeur a partir d'une chaine hh:mm:ss + Date(const string s); + + // Operateurs portant sur les Dates + virtual Date & operator =(long l); + virtual Date & operator +(long l); + virtual Date & operator -(long l); + virtual Date & operator +=(long l); + virtual Date & operator -=(long l); + virtual Date & operator =(const string & s); + + // Conversions en types standards + virtual string str() const; + virtual long epoch() const; + + protected: + int _day, _month, _year; + int _hour, _min, _sec; + + private: + +@}; +@end example +@end itemize + + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe GenericType, Classe BoolType, Classe Date, Types de base +@comment node-name, next, previous, up +@page +@subsubsection GenericType +@findex GenericType + +La classe @emph{GenericType} est la classe-mere de toutes les classes +utilisees par la classe @emph{Versatile}. @xref{Classe Versatile}. + +Elle definit une interface que @emph{Versatile} utilise pour controler +les objets : constructeur simple et destructeur, operateur sur +@emph{ostream}, conversion en chaine et surtout methode @emph{clone}. + +La methode @emph{clone} permet de recuperer un nouvel objet identique au +premier qui sera automatiquement alloue sur le tas par un appel a +@emph{new}. Il est important de noter ici que le nouvel objet @strong{DEVRA} +etre desalloue par un appel a @emph{delete}. Cette desallocation est a +la charge de l'utilisateur de l'objet sans quoi une fuite memoire en +resultera. + +@itemize @bullet{} +@item Entete + +@example +class GenericType +@{ + public: + // Constructeur et destructeur + GenericType(); + virtual ~GenericType(); + + // Operateur pour l'affichage sur un stream + friend ostream & operator << (ostream & os, + const GenericType & obj); + + // Conversion en chaine + virtual string affiche() const; + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + virtual GenericType * clone() const; + + // Retourne le nombre d'objets GenericType et al. + static int getNb(); + + protected: + + private: + static int _nb; // nombre total d'objets GenericType et al. + +@}; +@end example +@end itemize + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe BoolType, Classe CharType, Classe GenericType, Types de base +@comment node-name, next, previous, up +@page +@subsubsection BoolType +@findex BoolType + +Cette classe encapsule le type C++ @emph{bool} dans un objet herite de +@emph{GenericType} de maniere a pouvoir le stocker aisement dans un +objet de classe @emph{Versatile}. + +@itemize @bullet{} +@item Entete + +@example +class BoolType : public GenericType +@{ + public: + // Constructeur + BoolType(const bool b=false); + + // Conversion en chaine + virtual string affiche() const; + + // Operateur d'affectation + virtual BoolType & operator =(bool); + + // Conversion en bool + virtual operator bool() const; + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + virtual GenericType * clone() const; + + protected: + bool _data; + + private: + +@}; +@end example +@end itemize + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe CharType, Classe CoupleType, Classe BoolType, Types de base +@comment node-name, next, previous, up +@page +@subsubsection CharType +@findex CharType + +Cette classe encapsule le type C++ @emph{char} dans un objet herite de +@emph{GenericType} de maniere a pouvoir le stocker aisement dans un +objet de classe @emph{Versatile}. + + +@itemize @bullet{} +@item Entete + +@example +class CharType : public GenericType +@{ + public: + // Constructeur + CharType(const char c=0); + + // Conversion en chaine + virtual string affiche() const; + + // Operateur d'affectation + virtual CharType & operator =(char); + + // Conversion en char + virtual operator char() const; + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + virtual GenericType * clone() const; + + protected: + char _data; + + private: + +@}; +@end example +@end itemize + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe CoupleType, Classe DateType, Classe CharType, Types de base +@comment node-name, next, previous, up +@page +@subsubsection CoupleType +@findex CoupleType + +Cette classe encapsule le type interne @emph{Couple} dans un objet herite de +@emph{GenericType} de maniere a pouvoir le stocker aisement dans un +objet de classe @emph{Versatile}. + + +@itemize @bullet{} +@item Entete + +@example +class CoupleType : public GenericType +@{ + public: + // Constructeur + CoupleType(const Couple & C); + + // Conversion en chaine + virtual string affiche() const; + virtual operator string() const; + + // Operateur d'affectation + virtual CoupleType & operator =(const Couple & C); + + // Conversion en char + virtual operator Couple() const; + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + virtual GenericType * clone() const; + + protected: + Couple _data; + + private: + +@}; +@end example +@end itemize + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe DateType, Classe IntType, Classe CoupleType, Types de base +@comment node-name, next, previous, up +@page +@subsubsection DateType +@findex DateType + +Cette classe encapsule le type interne @emph{Date} dans un objet herite de +@emph{GenericType} de maniere a pouvoir le stocker aisement dans un +objet de classe @emph{Versatile}. + + +@itemize @bullet{} +@item Entete + +@example +class DateType : public GenericType +@{ + public: + // Constructeur + DateType(const Date & d); + + // Conversion en chaine + virtual string affiche() const; + + // Operateur d'affectation + virtual DateType & operator =(const Date &); + + // Conversion en Date + virtual operator Date() const; + + // Conversion en long + virtual operator long() const; + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + virtual GenericType * clone() const; + + protected: + Date _data; + + private: +@}; +@end example +@end itemize + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe IntType, Classe LongType, Classe DateType, Types de base +@comment node-name, next, previous, up +@page +@subsubsection IntType +@findex IntType + +Cette classe encapsule le type C++ @emph{int} dans un objet herite de +@emph{GenericType} de maniere a pouvoir le stocker aisement dans un +objet de classe @emph{Versatile}. + + +@itemize @bullet{} +@item Entete + +@example +class IntType : public GenericType +@{ + public: + // Constructeur + IntType(const int i=0); + + // Conversion en chaine + virtual string affiche() const; + + // Operateur d'affectation + virtual IntType & operator =(int); + + // Conversion en int + virtual operator int() const; + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + virtual GenericType * clone() const; + + protected: + int _data; + + private: + +@}; +@end example +@end itemize + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe LongType, Classe StringType, Classe IntType, Types de base +@comment node-name, next, previous, up +@page +@subsubsection LongType +@findex LongType + +Cette classe encapsule le type C++ @emph{long} dans un objet herite de +@emph{GenericType} de maniere a pouvoir le stocker aisement dans un +objet de classe @emph{Versatile}. + +@itemize @bullet{} +@item Entete + +@example +class LongType : public GenericType +@{ + public: + // Constructeur + LongType(const long l=0L); + + // Conversion en chaine + virtual string affiche() const; + + // Operateur d'affectation + virtual LongType & operator =(long); + + // Conversion en long + virtual operator long() const; + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + virtual GenericType * clone() const; + + protected: + long _data; + + private: + +@}; +@end example +@end itemize + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe StringType, Classes utilisateur, Classe LongType, Types de base +@comment node-name, next, previous, up +@page +@subsubsection StringType +@findex StringType + +Cette classe encapsule le type C++ @emph{string} de la STL dans un objet +herite de @emph{GenericType} de maniere a pouvoir le stocker aisement +dans un objet de classe @emph{Versatile}. + +@itemize @bullet{} +@item Entete + +@example +class StringType : public GenericType +@{ + public: + // Constructeur + StringType(const string & s=""); + + // Conversion en chaine + virtual string affiche() const; + virtual operator string() const; + + // Operateur d'affectation + virtual StringType & operator =(string); + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + virtual GenericType * clone() const; + + protected: + string _data; + + private: + +@}; +@end example +@end itemize + + + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classes utilisateur, Exemple, Classe StringType, Classes generiques +@comment node-name, next, previous, up +@page +@subsection Classes utilisateur +@cindex classes utilisateur + +Les classes dites classes utilisateur sont en realite les classes de +plus haut niveau de la biliotheque de classes Batch. Ces classes +remplissent les unes avec les autres l'ensemble des fonctionnalites +proposees par la bibliotheque. L'utilisateur trouvera donc dans cette +section la description des possibilites de la bibliotheque et le moyen +de les mettre en oeuvre. + +La premiere section montre un exemple complet de soumission et de +controle d'un job soumis a travers les classes de la biliotheque. Les +sections suivantes reprennent les elements de l'exemple pour le +detailler et le completer. + +@menu +* Exemple:: Exemple simple mais complet d'utilisation. +* Classe BatchManagerCatalog:: Description de la classe BatchManagerCatalog. +* Classe FactBatchManager:: Description de la classe FactBatchManager. +* Classe BatchManager:: Description de la classe BatchManager. +* Classe Environnement:: Description de la classe Environnement. +* Classe Job:: Description de la classe Job. +* Classe JobId:: Description de la classe JobId. +* Classe JobInfo:: Description de la classe JobInfo. +* Classe Parametre:: Description de la classe Parametre. +* Classe Versatile:: Description de la classe Versatile. +@end menu + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Exemple, Classe BatchManagerCatalog, Classes utilisateur, Classes utilisateur +@comment node-name, next, previous, up +@page +@subsubsection Exemple +@cindex exemple + +Cet exemple decrit le processus type de creation et de soumission d'un +job a travers les classes de la bibliotheque. + +Il faut toutefois penser que les appels aux methodes peuvent lever des +exceptions qu'il faudra intercepter et gerer. @xref{Exceptions}. + +@example + @dots{} + + // On recupere l'instance du catalogue de gestionnaires de batch + Batch::BatchManagerCatalog cata = Batch::BatchManagerCatalog::getInstance(); + + // On cree un BatchManager qui se connecte au veritable gestionnaire + // de batch + Batch::BatchManager & bm = (* cata("PBS"))("monserver.mondomaine.fr"); + + // Pour fabriquer un Job, on doit d'abord creer un objet Parametre et + // un objet Environnement qui contiennent respectivement la liste des + // parametres du job au sein du gestionnaire de batch et la liste des + // variables d'environnement necessaires au fonctionnement du job + Batch::Parametre param; + + param[EXECUTABLE] = "/home/user/mon_application/executable"; + param[NAME] = "MonJob"; + param[ACCOUNT] = "MonProjet"; // code d'imputation/facturation + param[MAXCPUTIME] = 360L; // 6min + param[MAXWALLTIME] = 480L; // 8min + param[INFILE] = Batch::Couple("/tmp/infich1", rempath+"/infich1"); + param[OUTFILE] = Batch::Couple("/tmp/outfich1", rempath+"/outfich1"); + param[OUTFILE] += Batch::Couple("stderr", path + "/STDERR"); + param[OUTFILE] += Batch::Couple("stdout", path + "/STDOUT"); + param[MAIL] = "user@@domaine.fr"; + param[USER] = "user"; + + Batch::Environnement env; + env["DEBUG"] = "3"; // un niveau de debug exige par l'application + env["MYAPP_FILE"] = "/home/user/mon_application/data/mydatafile"; + + // Creation du job + Batch::Job job(param, env); + + // On soumet le Job au BatchManager qui le relaie jusqu'au veritable + // gestionnaire de batch sur le serveur. En retour on obtient un + // identifiant unique de notre job (JobId). + const Batch::JobId jobid = bm.submitJob(job); + + // On interroge le BatchManager pour connaitre l'etat du Job + const Batch::JobInfo jinfo = jobid.queryJob(); + cout << jinfo << endl; + + // On detruit l'objet BatchManager + delete &bm; + + @dots{} +@end example + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe BatchManagerCatalog, Classe FactBatchManager, Exemple, Classes utilisateur +@comment node-name, next, previous, up +@page +@subsubsection BatchManagerCatalog +@findex BatchManagerCatalog + +La classe @emph{BatchManagerCatalog} definit une interface d'acces au +catalogue de fabriques de BatchManager. @xref{Classe FactBatchManager}. + +Pourquoi utiliser une fabrique et ne pas instancier directement un objet +@emph{BatchManager} en fonction de sa classe ? C'est l'option qui avait ete +choisie dans la premiere version de la bibliotheque de classes +Batch. Cette facon de proceder est simple, aussi bien pour le +developpeur de la classe que pour l'utilisateur, mais elle se revele a +terme penalisante dans la souplesse d'utilisation des classes. Elle +permet aussi moins facilement de mettre en place une strategie de +singleton pour les objets @emph{BatchManager}, ce qui peut se reveler utile non +pas en termes de performance mais plutot en termes de genericite et +toujours de souplesse. + +En resume, l'utilisation de fabiques permet d'acceder a la genericite, +qui rappelons-le est l'objet de cette biliotheque, a la souplesse et a +la performance au prix d'une legere complication pour le developpeur +mais pas pour l'utilisateur. + +Le catalogue de fabriques est une @emph{map}, ou tableau associatif, +auquel on passe le nom d'une fabrique et qui retourne un pointeur sur +une instance de cette fabrique. + +Le catalogue est renseigne statiquement par les fabriques declarees +elles-memes statiquement dans la biliotheque. Il est donc precharge avec +les fabriques correspondant a chacune des API disponibles. Comme le +catalogue n'est pas declare constant, il est possible de rajouter ou de +supprimer des fabriques dans le catalogue dynamiquement. + +@itemize @bullet{} +@item Entete + +@example +class BatchManagerCatalog +@{ +public: + // Methode permettant de recuperer l'instance unique de catalogue + static BatchManagerCatalog& getInstance(); + + // Accesseurs + void addFactBatchManager(const char * type, Batch::FactBatchManager * pFBM); + Batch::FactBatchManager * operator() (const char * type); + + // Wrapping Python + virtual std::map * dict(); + virtual std::string __repr__() const; + +protected: + // Constructeur + BatchManagerCatalog(); + // Destructeur + virtual ~BatchManagerCatalog(); + + // Le catalogue proprement dit + std::map _catalog; + // Mutex permettant d'assurer des acces "thread-safe" au catalogue + pthread_mutex_t _mutex; + +private: + // On interdit la copie de l'instance unique du catalogue (singleton) + BatchManagerCatalog(const BatchManagerCatalog & orig); + BatchManagerCatalog& operator=(const BatchManagerCatalog & orig); + +@}; +@end example + +@item Exemple + +@example +@dots{} + +// On recupere l'instance du catalogue de gestionnaires de batch +Batch::BatchManagerCatalog cata = Batch::BatchManagerCatalog::getInstance(); + +@dots{} +@end example + +@item Methodes +@itemize @minus{} +@item +@b{static BatchManagerCatalog& getInstance()} + +Cette methode retourne l'instance unique du catalogue qui peut ensuite +etre utilisee pour ajouter ou recuperer des fabriques. + +@item +@b{void addFactBatchManager(const char * type, FactBatchManager * pFBM)} + +Cet accesseur enregistre dans le catalogue un pointeur sur un objet de type +@emph{FactBatchManager} sous le nom (le type) passe en argument. + +@item +@b{FactBatchManager * operator() (const char * type)} + +Cet accesseur retourne un pointeur sur un objet de type +@emph{FactBatchManager} en fonction du nom (le type) sous lequel il +s'est enregistre dans le catalogue. + +@item +@b{map * dict()} + +Cette methode utilisable depuis Python permet de recuperer un +dictionnaire decrivant le contenu du catalogue. + +@item +@b{string __repr__() const} + +Cette methode utilisable depuis Python retourne une description de +l'objet @emph{BatchManagerCatalog}. + +@item +@b{BatchManagerCatalog()} + +Le constructeur par defaut est declare "protected" et ne peut donc pas +etre utilise pour creer une nouvelle instance de @emph{BatchManagerCatalog}. +En effet, le catalogue est un singleton, ce qui signifie qu'une seule +instance du catalogue existe. Pour recuperer cette instance, il faut +utiliser la methode @emph{BatchManagerCatalog::getInstance()}. + +@item +@b{~BatchManagerCatalog()} + +De la meme maniere, le destructeur est declare "protected" et ne peut pas +etre utilise pour detruire l'instance de catalogue. Le singleton est detruit +automatiquement a la fin du programme. + +@end itemize + + +@end itemize + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe FactBatchManager, Classe BatchManager, Classe BatchManagerCatalog, Classes utilisateur +@comment node-name, next, previous, up +@page +@subsubsection FactBatchManager +@findex FactBatchManager + +La classe @emph{FactBatchManager} est abstraite. Elle definit une interface +qui doit etre implementee par des classes specialisees en fonction du +gestionnaire de batch et de son API de communication. @xref{Classes specifiques}. + +Les objets repondant a l'interface de @emph{FactBatchManager} sont +automatiquement inseres dans le catalogue des fabriques de +@emph{BatchManager} a la construction de l'objet. Il est ainsi possible +de definir statiquement des objets de ce type qui enrichiront le +catalogue des la compilation. @xref{Classe +BatchManagerCatalog}. @xref{Classe BatchManager}. + +Les objets de la classe @emph{FactBatchManager} ou de ses derivees sont +des functors et renvoient au moment de l'appel un pointeur sur un objet +gestionnaire de batch @emph{BatchManager} associe a un +serveur. L'allocation de l'objet est faite sur le tas et celui-ci doit +donc etre desalloue manuellement par l'utilisateur de la bibliotheque au +moment opportun. + +@itemize @bullet{} +@item Entete + +@example +class FactBatchManager +@{ +public: + // Constructeur + FactBatchManager(const string & type); + + // Destructeur + virtual ~FactBatchManager(); + + // Functor + virtual BatchManager * operator() (const char * hostname) const = 0; + + // Accesseur au type interne + string getType() const; + + // Wrapping Python + string __repr__() const; + +protected: + string type; // Le type interne + +private: + +@}; +@end example + +@item Exemple + +@example +@dots{} + +// On recupere l'instance du catalogue de gestionnaires de batch +Batch::BatchManagerCatalog cata = Batch::BatchManagerCatalog::getInstance(); + +// On cree une fabrique de BatchManager de type PBS +Batch::FactBatchManager & fbm = * cata("PBS"); + +@dots{} +@end example + +@item Methodes +@itemize @minus{} + +@item +@b{FactBatchManager(const string & type)} + +Le constructeur de la classe prend un type qui doit identifer de maniere +unique la fabrique au sein du catalogue de fabrique. Ce type sert de cle au +catalogue. @xref{Classe BatchManagerCatalog}. + +@item +@b{~FactBatchManager()} + +Le destructeur de la classe n'a pas d'action particuliere. + +@item +@b{BatchManager * operator() (const char * hostname) const} + +Cette methode est virtuelle pure. Elle doit etre surchargee dans les +classes derivees et doit retourner un pointeur sur un objet de type +@emph{BatchManager} correpondant au type de la classe et oeuvrant sur la +machine passee en argument. Le @emph{hostname} est soit alphabetique +soit numerique et doit etre soit un nom de machine valide soit une +adresse IP valide. Aucun controle n'est a priori realise et cet argument +est passe tel quel a l'API du gestionnaire de batch. + +Cet objet agit comme @emph{parent} vis-a-vis de l'objet +@emph{BatchManager} qu'il retourne. + +@item +@b{string getType() const} + +Cette methode renvoie le type interne de l'objet, c'est-a-dire la cle +sous lequel il est enregistre dans le catalogue. + +@item +@b{string __repr__() const} + +Cette methode utilisable depuis Python retourne une description de +l'objet @emph{FactBatchManager}. + +@end itemize + + +@end itemize + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe BatchManager, Classe Environnement, Classe FactBatchManager, Classes utilisateur +@comment node-name, next, previous, up +@page +@subsubsection BatchManager +@findex BatchManager + +La classe @emph{BatchManager} est abstraite. Elle definit une interface +qui doit etre implementee par des classes specialisees en fonction du +gestionnaire de batch et de son API de communication. @xref{Classes +specifiques}. + +Toute action a destination du gestionnaire de batch doit etre precedee +de l'instanciation d'un objet derivant de la classe @emph{BatchManager} +puisque c'est a travers cet objet que l'on aura acces a l'interface du +gestionnaire. + +Cette instanciation est realisee par une fabrique de gestionnaire de +batch, instance elle-meme derivee de la classe abstraite +FactBatchManager. @xref{Classe FactBatchManager}. + +@itemize @bullet{} +@item Entete + +@example +class BatchManager +@{ + public: + // Constructeur et destructeur + BatchManager(const FactBatchManager * parent, + const char * host="localhost") + throw(InvalidArgumentException); + virtual ~BatchManager(); + + // Recupere l'identifiant d'un job deja soumis au BatchManager + virtual const JobId getJobIdByReference(const string & ref); + + // Methodes pour le controle des jobs : virtuelles pures + // soumet un job au gestionnaire + virtual const JobId submitJob(const Job & job) = 0; + + // retire un job du gestionnaire + virtual void deleteJob(const JobId & jobid) = 0; + + // suspend un job en file d'attente + virtual void holdJob(const JobId & jobid) = 0; + + // relache un job suspendu + virtual void releaseJob(const JobId & jobid) = 0; + + // modifie un job en file d'attente + virtual void alterJob(const JobId & jobid, + const Parametre & param, + const Environnement & env) = 0; + virtual void alterJob(const JobId & jobid, + const Parametre & param) = 0; + virtual void alterJob(const JobId & jobid, + const Environnement & env) = 0; + + // renvoie l'etat du job + virtual JobInfo queryJob(const JobId & jobid) = 0; + + // wrapping Python + virtual string __repr__() const; + + protected: + string _hostname; // serveur ou tourne le BatchManager + const FactBatchManager * _parent; // fabrique qui a produit l'instance + + private: + +@}; +@end example + +@item Exemple + +@example +@dots{} + +// On recupere l'instance du catalogue de gestionnaires de batch +Batch::BatchManagerCatalog cata = Batch::BatchManagerCatalog::getInstance(); + +// On cree un BatchManager qui se connecte au veritable gestionnaire +// de batch +Batch::BatchManager & bm = (* cata("PBS"))("monserver.mondomaine.fr"); + +// Maintenant, on peut utiliser toutes les fonctionnalites du +// gestionnaire de batch a travers le variable myBM + +// On detruit l'objet BatchManager +delete &bm; + +@dots{} +@end example + +@item Methodes +@itemize @minus{} +@item +@b{BatchManager(const FactBatchManager * parent,$* +const char * host="localhost") throw(InvalidArgumentException)} + +Excepte un pointeur sur la fabrique qui a produit l'objet, @xref{Classe FactBatchManager}, + le constructeur accepte zero ou un argument de type +@emph{string} decrivant soit le nom de domaine completement qualifie +(FQDN, @i{fully qualified domain name}) du serveur de batch, soit son +adresse IP dans un format decimal "aaa.bbb.ccc.ddd". + +Une resolution du nom ou de l'adresse peut etre realisee en fonction des +capacites de la plate-forme pour s'assurer que le serveur est connu et +joignable. En cas d'echec, une exception InvalidArgumentException est +levee. @xref{Classe InvalidArgumentException}. A priori, aucune +verification n'est faite par defaut. + +Ceci fait, une connexion est etablie avec le gestionnaire de batch qui +est maintenue jusqu'a destruction de l'objet, si le gestionnaire le permet. + +@item +@b{~BatchManager()} + +Le destructeur supprime la connexion precedemment etablie par le +constructeur lorsque celle-ci a reussi. + +@item +@b{const JobId submitJob(const Job & job)} + +Cette methode soumet le job passe en argument au gestionnaire de +batch. Etant donne que le job ne peut pas etre envoye tel quel puisqu'il +a un format generique au sein de la bibliotheque de classes Batch, cette +methode est chargee de le convertir dans un format adapte au +gestionnaire de batch sous-jacent. + +Ce n'est que lorsque cette conversion est realisee que le job est soumis +au gestionnaire a travers son API. L'identifiant propose par le +gestionnaire est alors renvoye a l'appelant. Si la soumission echoue +pour une raison ou une autre, une exception APIInternalFailureException est +levee. @xref{Classe APIInternalFailureException}. + +@item +@b{void deleteJob(const JobId & jobid)} + +Cette methode retire le job dont l'identifiant est passe en argument de +la file d'attente du gestionnaire, ou bien l'arrete s'il est en cours +d'execution. Cette methode est inoperante sur des travaux deja termines, +auquel cas une exception APIInternalFailureException est +levee. @xref{Classe APIInternalFailureException}. + + +@item +@b{void holdJob(const JobId & jobid)} + +Cette methode suspend le job dont l'identifiant est passe en argument au +sein de la file d'attente du gestionnaire. Cette methode est inoperante +sur des travaux en cours d'execution ou deja termines, ainsi que sur des +travaux deja suspendus. +En cas de probleme, une exception APIInternalFailureException est +levee. @xref{Classe APIInternalFailureException}. + +@item +@b{void releaseJob(const JobId & jobid)} + +Cette methode relache un job precedemment suspendu en file +d'attente dont l'identifiant est passe en argument. Elle est inoperante +sur des travaux deja relaches, en cours d'execution ou termines. +En cas de probleme, une exception APIInternalFailureException est +levee. @xref{Classe APIInternalFailureException}. + + +@item +@b{void alterJob(const JobId & jobid, const Parametre & param, const Environnement & env)@* +void alterJob(const JobId & jobid, const Parametre & param)@* +void alterJob(const JobId & jobid, const Environnement & env)} + +Ces methodes permettent de modifier les parametres d'execution et +d'environnement d'un job dont l'identifiant est passe en +argument. @xref{Classe Parametre}. @xref{Classe Environnement}. Il +est important de noter que le job doit etre encore place en file +d'attente sinon la methode est inoperante. +En cas de probleme, une exception APIInternalFailureException est +levee. @xref{Classe APIInternalFailureException}. + +@item +@b{JobInfo queryJob(const JobId & jobid)} + +Cette methode permet de recuperer les informations concernant le job +dont l'identifiant est passe en argument dans un objet de classe +@emph{JobInfo}. @xref{Classe JobInfo}. On y retrouve les parametres +d'execution et d'environnement du job tels qu'ils ont ete passes au +gestionnaire au moment de la soumission, ainsi que des informations +concernant l'execution du job comme par exemple la machine d'execution, +le temps consomme, la memoire consommee, etc. + +Il n'est pas toujours possible d'interroger un job deja termine. +En cas de probleme, une exception APIInternalFailureException est +levee. @xref{Classe APIInternalFailureException}. + + +@item +@b{const JobId getJobIdByReference(const string & ref)} + +Cette methode permet de recuperer au sein de la classe un identifiant de +job a partir d'une chaine de caracteres obtenue par un biais +externe. Cet identifiant pourra etre utilise par la suite au sein de la +biliotheque de classes pour controler le job comme s'il avait ete cree +et soumis depuis la biliotheque-meme. + +@end itemize + + +@end itemize + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe Environnement, Classe Job, Classe BatchManager, Classes utilisateur +@comment node-name, next, previous, up +@page +@subsubsection Environnement +@findex Environnement + +La classe @emph{Environnement} permet de definir les variables +d'environnement necessaires a l'execution d'un job. Ces variables seront +creees automatiquement dans l'environnement du job lorsque celui-ci +debutera son execution sur la machine. + +Une variable d'environnement est traditionnellement composee d'un nom et +d'une valeur qui peut etre vide ou absente. L'ensemble des variables +d'environnement peut ainsi etre represente sous la forme d'une table +associative dans laquelle le nom de la variable correspond a la clef de la +table, et la valeur de la variable correspond a la valeur de la table +pour la clef donnee. + +Chaque objet de la classe @emph{Environnement} se comporte comme une +table associative telle que decrite auparavant. + +@itemize @bullet{} +@item Entete + +@example +typedef map < string, string > Environnement; +@end example + + +@item Exemple +@example +@dots{} + +Environnement env; +env["MYAPP_ROOTDIR"] = "/home/user/myapplication"; +env["MYAPP_LICENSEFILE"] = env["MYAPP_ROOTDIR"] + "/license.dat"; +env["CXX"] = "g++"; +env["CXXFLAGS"] = "-g -O2"; + +@dots{} +@end example + +@item Methodes + +Compte tenu de la definition actuelle de la classe @emph{Environnement} +en tant que map STL, elle beneficie de toutes les fonctionnalites +classiques des maps STL. + +@end itemize + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe Job, Classe JobId, Classe Environnement, Classes utilisateur +@comment node-name, next, previous, up +@page +@subsubsection Job +@findex Job + +La classe @emph{Job} represente la notion de travail, ou job, dans la +bibliotheque de classes Batch. Elle se comporte essentiellement comme +une collection de parametres et de variables necessaires a la +description des actions qui doivent etre realisees dans des conditions +precisees. + +Elle se repose sur deux autres classes qui distinguent la notion de +parametre d'execution et celle de variable d'environnement : les classes +@emph{Parametre} et @emph{Environnement}. @xref{Classe +Parametre}. @xref{Classe Environnement}. + +Son role est de preparer la soumission qui aura lieu et qui concretisera +l'incarnation du job dans le gestionnaire de batch. Tant que le job n'a +pas ete soumis, on ne peut pas vraiment considerer son existence et de +fait les interactions qu'on peut avoir avec l'objet sont tres limitees. + +@itemize @bullet{} +@item Entete + +@example +class Job +@{ + public: + // Constructeurs et destructeur + Job(); + Job(Parametre param); + Job(Environnement env); + Job(Parametre param, Environnement env); + virtual ~Job(); + + // Operateur pour l'affichage sur un stream + friend ostream & operator <<(ostream & os, const Job & job); + + // Accesseurs + Parametre getParametre() const; + void setParametre(const Parametre &); + + // Accesseurs + Environnement getEnvironnement() const; + void setEnvironnement(const Environnement &); + + // Methodes pour l'interfacage avec Python (SWIG) + string __repr__() const; + + protected: + Parametre _param; // table des parametres batch du job + Environnement _env; // table des variables d'environnement + + private: + +@}; +@end example + + +@item Exemple +@example +@dots{} + +@dots{} (ici on cree un BatchManager bm) +Parametre param; +Environnement env; + +@dots{} (ici on cree les parametres du job) + +Job job(param, env); +JobId jobid = bm.sumbitJob(job); + +@dots{} +@end example + +@item Methodes +@itemize @minus{} + +@item +@b{Job()$* +Job(Parametre param)$* +Job(Environnement env)$* +Job(Parametre param, Environnement env)} + +Le constructeur, en plus de creer l'objet, peut faire des verifications +sur la coherence des objets passes en argument s'il y en a. + +@item +@b{~Job()} + +Le destructeur libere simplement les espaces alloues. + +@item +@b{ostream & operator <<(ostream & os, const Job & job)} + +Cette methode permet a l'utilisateur d'afficher sur un stream le contenu +d'un objet de classe @emph{Job}. + +@item +@b{Parametre getParametre() const} + +Un accesseur pour recuperer l'objet Parametre passe en argument du +constructeur. + +@item +@b{void setParametre(const Parametre &)} + +Cette methode permet de positionner @i{a posteriori} l'objet +@emph{Parametre}. Des tests complementaires peuvent etre faits pour +verifier la coherence de l'objet. + +@item +@b{Environnement getEnvironnement() const} + +Un accesseur pour recuperer l'objet Environnement passe en argument du constructeur. + +@item +@b{void setEnvironnement(const Environnement &)} + +Cette methode permet de positionner @i{a posteriori} l'objet +@emph{Environnement}. Des tests complementaires peuvent etre faits pour +verifier la coherence de l'objet. + +@item +@b{string __repr__() const} + +Cette methode sert dans l'interfacage Python de l'objet et permet d'en +realiser l'affichage a travers l'interpreteur Python. + +@end itemize +@end itemize + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe JobId, Classe JobInfo, Classe Job, Classes utilisateur +@comment node-name, next, previous, up +@page +@subsubsection JobId +@findex JobId + +La classe @emph{JobId} represente l'incarnation d'un objet de classe +@emph{Job} une fois soumis au travers du gestionnaire de batch. A chaque +objet @emph{JobId} correspond une et une seule soumission d'un objet +@emph{Job}. Ainsi un meme objet @emph{Job} peut etre soumis plusieurs +fois de suite a un ou plusieurs gestionnaires de batch et produira +autant d'objets @emph{JobId}. + +L'objet @emph{JobId} assure le controle et la gestion du job au travers +du gestionnaire de batch. Chaque objet @emph{JobId} est associe a un +gestionnaire particulier aupres duquel il relaie les actions qu'on lui +soumet. + + +@itemize @bullet{} +@item Entete + +@example +class JobId +@{ + friend class BatchManager; + + public: + // Constructeur standard et destructeur + JobId(); + virtual ~JobId(); + + // Constructeur avec le pointeur sur le BatchManager associe + // et avec une reference + JobId(BatchManager *, string ref); + + // Operateur d'affectation entre objets + virtual JobId & operator =(const JobId &); + + // Constructeur par recopie + JobId(const JobId &); + + // Accesseur pour la reference interne + virtual string getReference() const; + + // Methodes pour le controle du job + // retire un job du gestionnaire + virtual void deleteJob() const; + + // suspend un job en file d'attente + virtual void holdJob() const; + + // relache un job suspendu + virtual void releaseJob() const; + + // modifie un job en file d'attente + virtual void alterJob(const Parametre & param, + const Environnement & env) const; + virtual void alterJob(const Parametre & param) const; + virtual void alterJob(const Environnement & env) const; + + // modifie un job en file d'attente + virtual void setParametre(const Parametre & param); + virtual void setEnvironnement(const Environnement & env); + + // renvoie l'etat du job + virtual Batch::JobInfo queryJob() const; + + // Methodes pour l'interfacage avec Python (SWIG) + string __str__() const; // SWIG : affichage en Python + string __repr__() const; // SWIG : affichage en Python + + protected: + BatchManager * _p_batchmanager; // pointeur sur le BatchManager + // qui controle le job + string _reference; // reference du job au sein du BatchManager + + private: + +@}; +@end example + + +@item Exemple +@example +@dots{} (ici on cree un BatchManager bm et un Job job) + +// On soumet le job et on recupere un identifiant +JobId jobid = bm.submitJob(job); + +// Ce qui permet d'interroger l'etat du job en cours +JobInfo jinfo = jobid.queryJob(); + +@dots{} +@end example + +@item Methodes + +@itemize @minus{} +@item +@b{JobId()@* +JobId(BatchManager *, string ref)} + +Le constructeur par defaut cree un @emph{JobId} qui devra etre complete +par la suite. Ceci n'est pas directement realisable par l'utilisateur +mais sert pour certaines classes amies de la classe @emph{JobId}. + +D'un point de vue utilisateur la construction d'un objet @emph{JobId} +necessite un pointeur sur un gestionnaire de batch existant et une +chaine de caractere representant une reference au sein de ce +gestionnaire de batch. + +Ces parametres sont en general issus de la +communication avec l'API du gestionnaire de batch et ne peuvent etre +aisement deduits. C'est pourquoi il est recommande de passer par une +classe d'implementation pour fabriquer un objet @emph{JobId}. + + +@item +@b{~JobId()} + +Le destructeur libere l'espace occupe par l'objet. + +@item +@b{JobId & operator =(const JobId &)} + +L'affectation d'un objet @emph{JobId} duplique les donnees internes de +l'objet passe en argument. Les deux objets sont totalement independants +a l'issue de l'affectation et designent chacun la meme instance du job +dans le meme gestionnaire de batch. Le controle du job peut etre realise +avec l'un ou l'autre des objets. + +@item +@b{JobId(const JobId &)} + +De meme que l'affectation le constructeur par recopie produit un objet +@emph{JobId} totalement independant de l'objet passe en argument et qui +designe le meme job dans le meme gestionnaire de batch. Le controle du +job peut etre realise avec l'un ou l'autre des objets. + +@item +@b{string getReference() const} + +Cet accesseur retourne la reference du job pour le gestionnaire de batch +qui a produit l'objet. + +@item +@b{void deleteJob() const} + +Cette methode relaie aupres au gestionnaire de batch qui a produit +l'objet la demande d'arret du job. + +@item +@b{void holdJob() const} + +Cette methode relaie aupres au gestionnaire de batch qui a produit +l'objet la demande de suspension du job. + +@item +@b{void releaseJob() const} + +Cette methode relaie aupres au gestionnaire de batch qui a produit +l'objet la demande de liberation du job. + +@item +@b{void alterJob(const Parametre & param, const Environnement & env) const@* +void alterJob(const Parametre & param) const@* +void alterJob(const Environnement & env) const} + +Ces methodes relaient aupres du gestionnaire de batch qui a produit +l'objet la demande de modification des parametres et/ou des variables +d'environnement du job. + +@item +@b{void setParametre(const Parametre & param)} + +Cette methode n'est utile que pour l'interfacage avec Python, car Python +ne sait pas gerer la surcharge de methode, et de fait leve des +exceptions lors d'appels a de telles methodes. + +Elle est equivalente a la methode @samp{void alterJob(const Parametre & param) const}. + + +@item +@b{void setEnvironnement(const Environnement & env)} + +Cette methode n'est utile que pour l'interfacage avec Python, car Python +ne sait pas gerer la surcharge de methode, et de fait leve des +exceptions lors d'appels a de telles methodes. + +Elle est equivalente a la methode @samp{void alterJob(const Environnement & env) const}. + +@item +@b{Batch::JobInfo queryJob() const} + +Cette methode relaie aupres du gestionnaire de batch qui a produit +l'objet la demande d'interrogation de l'etat du job. + +@item +@b{string __str__() const} + +Cette methode n'est utile que pour l'interfacage avec Python. Elle +permet d'afficher l'etat de l'objet @emph{JobId}. + +@item +@b{string __repr__() const} + +Cette methode n'est utile que pour l'interfacage avec Python. Elle +permet d'afficher l'etat de l'objet @emph{JobId}. + +@end itemize +@end itemize + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe JobInfo, Classe Parametre, Classe JobId, Classes utilisateur +@comment node-name, next, previous, up +@page +@subsubsection JobInfo +@findex JobInfo + +Un objet de classe @emph{JobInfo} represente l'ensemble des informations +disponibles sur un travail actif, c'est-a-dire soumis au gestionnaire de +batch, a un instant donne. + +Cet objet reprend des informations issues du job tel qu'il a ete soumis, +@xref{Classe Job}, mais aussi des informations produites par le +gestionnaire de batch a partir de la soumission et du transit du job en +son sein : nom de la queue dans laquelle le job est inscrit, duree +d'execution, date de soumission, etc. + +Ces informations sont disponibles aupres de l'utilisateur de la classe a +travers les objets @emph{Parametre} et @emph{Environnement} que l'objet +@emph{JobInfo} peut fournir. + +@itemize @bullet{} +@item Entete + +@example +class JobInfo +@{ + public: + // Constructeur standard et destructeur + JobInfo(); + virtual ~JobInfo(); + + // Constructeur par recopie + JobInfo(const JobInfo & jinfo); + + // Operateur pour l'affichage sur un stream + friend ostream & operator <<(ostream & os, const JobInfo & ji); + + // Accesseurs + virtual Parametre getParametre() const; + virtual Environnement getEnvironnement() const; + + // Methodes pour l'interfacage avec Python (SWIG) + string __str__() const; // SWIG : affichage en Python + string __repr__() const; // SWIG : affichage en Python + + protected: + Parametre _param; // parametres du job + Environnement _env; // variables d'environnement du job + + private: +@}; +@end example + + +@item Exemple +@example +@dots{} (ici on cree un BatchManager bm et un Job job) + +// On soumet le job et on recupere un identifiant +JobId jobid = bm.submitJob(job); + +// Ce qui permet d'interroger l'etat du job en cours +JobInfo jinfo = jobid.queryJob(); + +// On recupere l'objet Parametre interne modifie +// par le gestionnaire de batch +Parametre param = jinfo.getParametre(); + +// On recupere l'objet Environnement interne modifie +// par le gestionnaire de batch +Environnement env = jinfo.getEnvironnement(); + +@dots{} +@end example + +@item Methodes +@itemize @minus{} +@item +@b{JobInfo()} + +Ce constructeur cree un objet @emph{JobInfo} vide. + +@item +@b{~JobInfo()} + +Le destructeur libere l'espace memoire alloue par l'objet. + +@item +@b{JobInfo(const JobInfo & jinfo)} + +Le constructeur par recopie produit un objet identique a celui passe en +argument. Les deux objets sont totalement independants l'un de l'autre. + +@item +@b{ostream & operator <<(ostream & os, const JobInfo & ji)} + +Cet operateur permet de voir le contenu de l'objet sur un flot de sortie. + +@item +@b{Parametre getParametre() const} + +Cet accesseur retourne l'objet interne @emph{Parametre} modifie par le +gestionnaire de batch. En particulier on y retrouve toutes les clefs et +les valeurs correspondant aux informations produites dynamiquement par +le gestionnaire (duree d'execution, machine d'execution, etc.). +Il n'est pas garanti que les valeurs passees au moment de la soumission +soient inchangees car des modifications ont pu etre apportees a ces +valeurs pendant le traitement du job par le gestionnaire. + +@item +@b{Environnement getEnvironnement() const} + +Cet accesseur retourne l'objet interne @emph{Environnement} modifie par le +gestionnaire de batch. En particulier on y retrouve toutes les clefs et +les valeurs correspondant aux informations produites dynamiquement par +le gestionnaire (chemin d'acces, variables d'environnement specifiques a +la machine d'execution, etc.). +Il n'est pas garanti que les valeurs passees au moment de la soumission +soient inchangees car des modifications ont pu etre apportees a ces +valeurs pendant le traitement du job par le gestionnaire. + +@item +@b{string __str__() const} + +Cette methode n'est utile que pour l'interfacage avec Python. Elle +permet d'afficher l'etat de l'objet @emph{JobInfo}. + +@item +@b{string __repr__() const} + +Cette methode n'est utile que pour l'interfacage avec Python. Elle +permet d'afficher l'etat de l'objet @emph{JobInfo}. + +@end itemize + +@end itemize + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe Parametre, Classe Versatile, Classe JobInfo, Classes utilisateur +@comment node-name, next, previous, up +@page +@subsubsection Parametre +@findex Parametre + +Les objets de la classe @emph{Parametre} se comportent comme des maps +STL, dont ils ont les fonctionnalites, decrivant les parametres +d'execution du job. + +Contrairement aux variables d'environnement qui sont decrites par les +objets de la classe @emph{Environnement}, les parametres d'execution +servent a preciser les contraintes qui pesent sur le job, comme par +exemple la duree maximale d'execution autorisee, la quantite maximale de +memoire utilisable ou la queue de soumission, ou bien a renseigner le +job avec des informations specifiques a l'utilisateur, comme son +username, son adresse email, le code d'imputation du job, etc. + +En raison du caractere tres specifique et precis des informations qui +doivent etre fournies au gestionnaire de batch, une nomenclature est +proposee par la classe @emph{Parametre} qu'il est vivement conseille de +suivre. De plus tout a ete fait pour rendre cette ecriture naturelle et +facile, donc il ne devrait pas y avoir de probleme pour l'utiliser. + +Ainsi, a titre d'exemple, pour preciser le temps maximal autorise pour +un job, il faut creer une clef de nom @var{maxcputime} dans un objet de +classe @emph{Parametre} qui sera ensuite passe au job. Et pour preciser +le code d'imputation du job, il faut creer une clef de nom @var{account}. + +Mais cet exemple simple montre que la valeur associee a la clef +@var{maxcputime} est semantiquement une duree, et que la valeur associee a +la clef @var{account} est semantiquement un nom. On a donc un probleme de +type puisque dans la definition d'une map STL le type de la valeur doit +etre le meme, et ce meme si les valeurs doivent par la suite avoir des +types semantiques differents. C'est pourquoi on a definit une classe +@emph{Versatile} qui encapsule des types differents. @xref{Classe +Versatile}. + +Quoiqu'il en soit toute la mecanique est cachee et seul importe pour +l'utilisateur de savoir que les valeurs associees aux clefs sont typees +et que ces types sont definis dans l'enumeration @emph{DiscriminatorType}. +@xref{Classe Versatile}. + + +@itemize @bullet{} +@item Entete + +@example +class Parametre : public map< string, Versatile > +@{ + public: + // Constructeur standard + Parametre(); + + // Constructeur par recopie + Parametre(const Parametre & PM); + + // Operateur de recherche dans la map + Versatile & operator [] (const string &); + const Versatile & operator [] (const string &) const; + + // Operateur d'affectation + Parametre & operator =(const Parametre & PM); + + // Declarations statique des clefs de la map + static const string ACCOUNT; + static const string CHECKPOINT; + static const string CKPTINTERVAL; + static const string CREATIONTIME; + static const string EGROUP; + static const string ELIGIBLETIME; + static const string EUSER; + static const string EXECUTABLE; + static const string EXECUTIONHOST; + static const string HOLD; + static const string ID; + static const string INFILE; + static const string MAIL; + static const string MAXCPUTIME; + static const string MAXDISKSIZE; + static const string MAXRAMSIZE; + static const string MAXWALLTIME; + static const string MODIFICATIONTIME; + static const string NAME; + static const string OUTFILE; + static const string PID; + static const string QUEUE; + static const string QUEUEDTIME; + static const string SERVER; + static const string STARTDATE; + static const string STATE; + static const string TEXT; + static const string TMPDIR; + static const string USEDCPUTIME; + static const string USEDDISKSIZE; + static const string USEDRAMSIZE; + static const string USEDWALLTIME; + static const string USER; + + protected: + // map interne servant a controler le type + // de la valeur associee a chaque clef + map< string, TypeParam > TypeMap; + + private: + +@}; +@end example + + +@item Exemple +@example +@dots{} + +Parametre param; + +param[EXECUTABLE] = "/home/user/mon_application/executable"; +param[NAME] = "MonJob"; +param[ACCOUNT] = "MonProjet"; // code d'imputation/facturation +param[MAXCPUTIME] = 360L; // 6min +param[MAXWALLTIME] = 480L; // 8min +param[INFILE] = Couple("/tmp/infich1", rempath + "/infich1"); +param[OUTFILE] = Couple("/tmp/outfich1", rempath + "/outfich1"); +param[OUTFILE] += Couple("stderr", path + "/STDERR"); +param[OUTFILE] += Couple("stdout", path + "/STDOUT"); +param[MAIL] = "user@@domaine.fr"; +param[USER] = "user"; + +@dots{} +@end example + +@item Methodes +@itemize @minus{} + +@item +@b{Parametre()} + +Le constructeur par defaut initialise l'objet @emph{Parametre} et cree +la table des types internes. Par contre l'objet ne contient aucune valeur. + +@item +@b{Parametre(const Parametre & PM)} + +Le constructeur par recopie cree un objet @emph{Parametre} a l'image de +celui qui lui est passe en argument. La table des types internes est +dupliquee ainsi que tous les objets correspondant a chacune des clefs. + +@item +@b{Versatile & operator [] (const string &)} + +Cet operateur permet de recuperer la valeur designee par la clef passee +en argument. Cette valeur est de classe @emph{Versatile} qui encapsule +tous les types de base utilisables dans la bibliotheque en tant que +parametre. @xref{Classe Versatile}. + + +@item +@b{const Versatile & operator [] (const string &) const} + +A l'image de l'operateur precedent, cet operateur permet de recuperer la +valeur designee par la clef passee en argument mais uniquement pour des +objets constants. + +@item +@b{Parametre & operator =(const Parametre & PM)} + +L'operateur d'affectation remplace l'ensemble du contenu de l'objet +@emph{Parametre} par le contenu de l'objet passe en argument. Les +valeurs sont dupliquees par rapport a l'objet @var{pm}. + +@end itemize + +@item Description des clefs + +Selon les gestionnaires de batch utilises, certaines clefs sont actives +ou inactives. Une definition superflue ne pose pas de probleme et se +trouve ignoree au moment de la soumission. Par contre l'absence d'un +clef peut empecher la soumission d'aboutir et lever une exception. + +@itemize @minus{} +@item ACCOUNT : type STRING + +Le code de facturation sur lequel le job doit s'imputer. + +@item CHECKPOINT : type LONG + +Une valeur non nulle indique au gestionnaire de batch que le job est +@dfn{checkpointable}, c'est-a-dire interruptible pour une reprise +ulterieure. + +@item CKPTINTERVAL : type LONG + +En liaison avec la clef @var{CHECKPOINT}, la clef @var{CKPTINTERVAL} +indique l'intervalle en secondes entre deux interruptions du code +(@dfn{checkpoint}). + +@item CREATIONTIME : type LONG + +La date a laquelle le job a ete cree (soumis) dans le gestionnaire de batch. + +@item EGROUP : type STRING + +Le groupe effectif au sens Unix du terme dans lequel le job s'execute. + +@item ELIGIBLETIME : type LONG + +La date a laquelle le job a pu disposer des ressources necessaires a son +execution. + +@item EUSER : type STRING + +L'utilisateur effectif au sens Unix du terme pour lequel le job s'execute. + +@item EXECUTABLE : type STRING + +Le chemin d'acces absolu a l'executable sur la machine qui soumet le job. + +@item EXECUTIONHOST : type STRING + +Le nom de la machine qui execute le job. + +@item HOLD : type LONG + +Une valeur non nulle indique au gestionnaire de batch que le job doit +etre place dans l'etat suspendu. Une valeur nulle libere le job. + +@item ID : type STRING + +L'identifiant unique du job pour le gestionnaire de batch. + +@item INFILE : type liste de COUPLE + +La clef @var{infile} liste les fichiers qui seront envoyes au job avant +son execution. Chaque fichier peut avoir un nom different sur la machine +cliente --- qui soumet le job --- et sur le serveur. C'est pourquoi +chaque fichier a envoyer est represente par un couple dont le nom @var{local} +est le chemin absolu du fichier sur la machine cliente et le nom +@var{remote} est le chemin absolu du fichier sur le +serveur. @xref{Classe Couple}. + +Si le nom @var{remote} vaut @samp{stdin}, alors le contenu du fichier +designe par le nom @var{local} est envoye sur l'entree standard du job +au moment de son execution. + +@item MAIL : type STRING + +L'adresse email de l'utilisateur ou lui seront envoyes les eventuels +messages d'information et d'alerte du gestionnaire de batch. + +@item MAXCPUTIME : type LONG + +Le temps de calcul (@i{CPU time}) en secondes que ne devra pas depasser le job. + +@item MAXDISKSIZE : type LONG + +L'espace disque en octets que ne devra pas depasser le job. + +@item MAXRAMSIZE : type LONG + +La quantite de memoire vive en octets que ne devra pas depasser le job. + +@item MAXWALLTIME : type LONG + +Le temps reel (@i{elapsed time}) en secondes que ne devra pas depasser le job. + +@item MODIFICATIONTIME : type LONG + +La date a laquelle le job a ete modifie pour la derniere fois dans le +gestionnaire de batch. Cette date correspond le plus souvent a la +derniere operation realisee par le gestionnaire dans la gestion du job : +routage au sein des files, suspension ou reprise, etc. + +@item NAME : type STRING + +Le nom du job tel qu'il apparait a l'utilisateur dans son dialogue avec +le gestionnaire de batch. Ce nom n'a pas besoin d'etre unique et ne +remplace pas l'identifiant (ID). Il n'est la que pour informer +l'utilisateur de la nature de son job. + +@item OUTFILE : type liste de COUPLE + +La clef @var{outfile} liste les fichiers qui sont produits par le job et +qui seront recuperes sur la machine locale de l'utilisateur apres +son execution. Chaque fichier peut avoir un nom different sur la machine +cliente --- qui soumet le job --- et sur le serveur. C'est pourquoi +chaque fichier a recuperer est represente par un couple dont le nom @var{local} +est le chemin absolu du fichier sur la machine cliente et le nom +@var{remote} est le chemin absolu du fichier sur le +serveur. @xref{Classe Couple}. + +Si le nom @var{local} vaut @samp{stdout}, alors le contenu du fichier +designe par le nom @var{local} contient la sortie standard du job +au moment de son execution. + +Si le nom @var{local} vaut @samp{stderr}, alors le contenu du fichier +designe par le nom @var{local} contient la sortie d'erreur du job +au moment de son execution. + +@item PID : type LONG + +La valeur du PID (@i{process identifier}) du job sur la machine sur +lqsuelle il s'execute. + +@item QUEUE : type STRING + +Le nom de la queue, aussi appelee classe ou file suivant les +terminologies, qui accueille le job. + +@item QUEUEDTIME : type LONG + +La date depuis laquelle le job a ete place en queue dans le gestionnaire +de batch. + +@item SERVER : type STRING + +Le nom complet du serveur qui recoit les soumissions de job. + +@item STARTDATE : type LONG + +La date a partir de laquelle l'utilisateur desire que le job soit +execute. L'execution ne demarrera qu'au dela de cette date et a +condition que toutes les conditions de ressources soient remplies. + +@item STATE : type STRING + +L'etat actuel du job. + +ATTENTION : Ces valeurs ne sont pas encore normalisees. + +@item TEXT : type STRING + +Un texte d'information que le gestionnaire peut emettre a destination de +l'utilisateur lorsque l'ensemble des parametres n'est pas suffisant pour +traduire l'etat reel du job. Par exemple, ce message peut informer +l'utilisateur de la raison qui maintient un job dans un etat suspendu ou +qui l'empeche de s'executer. + +@item TMPDIR : type STRING + +Un chemin d'acces absolu a un repertoire qui sera cree au demarrage du +job et qui isolera le job des autres travaux en cours d'execution sur la +meme machine. + +@item USEDCPUTIME : type LONG + +Le temps de calcul (@i{CPU time}) en secondes reellement consomme par le job. + +@item USEDDISKSIZE : type LONG + +L'espace disque en octets reellement consomme par le job. + +@item USEDRAMSIZE : type LONG + +L'espace disque en octets reellement consommee par le job. + +@item USEDWALLTIME : type LONG + +Le temps reel (@i{elapsed time}) en secondes reellement consomme par le job. + +@item USER : type STRING + +Le nom de l'utilisateur (@i{username}) sous lequel le job devra tourner +sur la machine d'execution. Ce parametre est utile lorsque l'utilisateur +possede des comptes differents sur les machines sur lequel il soumet et calcule. + +@end itemize + + +@end itemize + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe Versatile, Exceptions, Classe Parametre, Classes utilisateur +@comment node-name, next, previous, up +@page +@subsubsection Versatile +@findex Versatile + +Cette classe est normalement invisible en tant que telle a l'utilsateur +de la bibliotheque de classes Batch. Mais il est tout de meme utile de +la presenter car son action est visible, notamment dans son interaction +fine avec la classe @emph{Parametre}. @xref{Classe Parametre}. + +Comme il a ete precise dans la descrption de la classe @emph{Parametre}, +la classe @emph{Versatile} a ete concue pour encapsuler les valeurs de +la map @emph{Parametre} qui peuvent etre de types effectifs differents. + +Ces types, decrits par l'enumeration @emph{DiscriminatorType}, sont +actuellement au nombre de trois : @var{long}, @var{string} et +@var{couple}. Ces types correpondent au types de base du langage C++ ou +de la biliotheque de classes Batch. @xref{Types de base}. + +Le type special @var{undefined} ne sert que pour l'objet +@emph{Versatile} juste cree mais non encore affecte d'une valeur et donc +d'un type. La premiere affection d'une valeur a un objet +@emph{Versatile} non encore affecte lui donne automatiquement le type de +la valeur. + +Les objets de classe @emph{Versatile} peuvent se comporter soit comme +des variables scalaires, c'est-a-dire ne contenant qu'une valeur unique, +soit comme des listes, auquel cas elles utilisent l'interface des +@emph{list} de la STL. Toutefois afin de faciliter l'ecriture pour +l'utilisateur basique de la classe @emph{Versatile} --- et de la classe +@emph{Parametre} ---, des operateurs de concatenation @samp{+=} et +@samp{,} ont ete ajoutes. + + +@itemize @bullet{} +@item Entete + +@example +// Les types autorises +enum DiscriminatorType @{ UNDEFINED, LONG, STRING, COUPLE @}; + +typedef struct @{ + DiscriminatorType type; // le type de l'element interne + int maxelem; // le nombre d'elements autorises +@} TypeParam; + +class Versatile : public list< GenericType * > +@{ + public: + // Constructeur standard et destructeur + Versatile(); + virtual ~Versatile(); + + // Constructeur par recopie + Versatile(const Versatile & V); + + // Constructeur depuis le type de "base" + Versatile(long l); + Versatile(const string & s); + Versatile(const Couple & c); + + // Operateur d'affectation et de concatenation + // a partir d'un type de "base" + Versatile & operator = (const long l) + throw(TypeMismatchException); + Versatile & operator = (const string & ch) + throw(TypeMismatchException); + Versatile & operator +=(const string & ch) + throw(TypeMismatchException,ListIsFullException); + Versatile & operator , (const string & ch) + throw(TypeMismatchException,ListIsFullException); + Versatile & operator = (const Couple & cp) + throw(TypeMismatchException); + Versatile & operator +=(const Couple & cp) + throw(TypeMismatchException,ListIsFullException); + Versatile & operator , (const Couple & cp) + throw(TypeMismatchException,ListIsFullException); + + // Operateur d'affectation entre objets + Versatile & operator = (const Versatile & V) + throw(TypeMismatchException); + + // Conversion de type vers un type de "base" + operator long() const throw(TypeMismatchException); + operator string() const throw(TypeMismatchException); + operator Couple() const throw(TypeMismatchException); + string str() const throw(TypeMismatchException); + + // Operateur pour l'affichage sur un stream + friend ostream & operator << (ostream & os, const Versatile & ); + + // Positionnement et recuperation du type de l'element interne + void setType(DiscriminatorType) throw(TypeMismatchException); + DiscriminatorType getType() const; + + // Positionnement et recuperation du nombre d'elements internes + void setMaxSize(int i); + int getMaxSize() const; + + // Positionnement et recuperation du nom de l'objet + string getName() const; + void setName(const string & name); + + protected: + // Efface tous les elements internes de l'objet + virtual void eraseAll(); + + DiscriminatorType _discriminator; // type de l'element interne + int _maxsize; // nombre max d'elements internes + string _name; // nom de l'objet (sert pour les exceptions) + + private: + +@}; +@end example + + +@item Exemple +@example +@dots{} + +// On cree un objet Versatile non encore affecte (scalaire) +Versatile Vlong; + +// L'affectation d'un long lui donne le type LONG +Vlong = 1024L * 1024L * 1024L; +cout << "Versatile long (must be 1073741824) : " << Vlong << endl; + +// On cree un objet Versatile non encore affecte (scalaire) +Versatile Vstring; + +// L'affectation d'une string (const char * promu en string) +// lui donne le type STRING +Vstring = "UneChaine"; +cout << "Versatile string (must be UneChaine) : " << Vstring << endl; + +try + @{ + // L'affectation d'un autre type leve une exception. + // Il n'y a pas de retypage dynamique. + Vlong = ""; + cout << "ERR : No TypeMismatchException catched for Versatile long" + << endl; + @} +catch (TypeMismatchException & ex) + @{ + cout << "OK : TypeMismatchException catched for Versatile long" + << endl; + @} + +// Reaffectation avec le meme type +Vlong = 1024L * 1024L; +cout << "Versatile long (must be 1048576) : " << Vlong << endl; + +// On cree un objet Versatile non encore affecte (scalaire) ... +Versatile Vcat1; + +// ... que l'on transforme en liste (non limitee) +Vcat1.setMaxSize(0); + +// On affecte la premiere valeur ... +Vcat1 = "A"; + +// ... puis les suivantes par concatenation +Vcat1 += "B"; +Vcat1 += "C"; +Vcat1 += "D"; +Vcat1 += "E"; +cout << "Versatile string concatenation (must be A B C D E) : " + << Vcat1 << endl; + +// Idem que pour Vcat1, mais avec une limite a 5 elements dans la liste +Versatile Vcat2; +Vcat2.setMaxSize(5); +Vcat2 = "a", "b", "c", "d", "e"; +cout << "Versatile string concatenation (must be a b c d e) : " + << Vcat2 << endl; + +// On tronque les 2 derniers elements de la liste (il en reste 3) +Vcat2.setMaxSize(3); +cout << "Versatile string concatenation (must be a b c) : " + << Vcat2 << endl; + + +Versatile Vcopy2(Vcat2); +cout << "Versatile copy (must be a b c) : " << Vcopy2 << endl; + +Versatile Vaffect; +Vaffect = Vcat1; +cout << "Versatile affect (must be A B C D E) : " << Vaffect << endl; +Vaffect = Vcat2; +cout << "Versatile affect (must be a b c) : " << Vaffect << endl; + +try + @{ + // Retypage dynamique interdit + Vaffect = Vlong; + cout << "ERR : No TypeMismatchException catched for Versatile" + << endl; + @} +catch (TypeMismatchException & ex) + @{ + cout << "OK : TypeMismatchException catched for Versatile string" + << endl; + @} + +try + @{ + // Concatenation au dela de la limite interdit + Vcat2 += "En trop"; + cout << "ERR : No ListIsFullException catched for Versatile string" + << endl; + @} +catch (ListIsFullException & ex) + @{ + cout << "OK : ListIsFullException catched for Versatile string" + << endl; + @} + +// Les objets Versatile se comportent (presque) comme des objets +// standards du langage +long L = Vlong; +cout << "Long value of Versatile long (must be 1048576) : " + << L << endl; + +string S = Vstring; +cout << "String value of Versatile (must be EncoreUneAutreChaine):" + << S << endl; + +@dots{} +@end example + +@item Methodes +@itemize @minus{} +@item +@b{Versatile()} + +Le constructeur par defaut fabrique un objet scalaire de type +@var{undefined} et de nom @samp{undefined}. + +@item +@b{~Versatile()} + +Le destructeur efface tout le contenu de l'objet si celui-ci avait ete affecte. + +@item +@b{Versatile(const Versatile & V)} + +Le constructeur par recopie duplique l'objet passe en argument ainsi que +les valeurs qu'il contient. Le nouvel objet est totalement independant +de son geniteur. + +@item +@b{Versatile(long l)@* +Versatile(const string & s)@* +Versatile(const Couple & c)} + +Ces constructeurs fabriquent des objets scalaires @emph{Versatile} a partir des +types de base passes en argument. Chaque objet acquerera definitivement +le type correspondant au type de base : @var{long} pour @samp{long}, +@var{string} pour @samp{string} et @var{couple} pour @samp{Couple}. + +@item +@b{Versatile & operator = (const long l) throw(TypeMismatchException)@* +Versatile & operator = (const string & ch) throw(TypeMismatchException)@* +Versatile & operator = (const Couple & cp) throw(TypeMismatchException)} + +Ces operateurs affectent ou reaffectent la valeur passee en argument a +l'objet. Le type de la valeur doit correspondre au type de l'objet si +celui-ci a deja ete affecte, sinon une exception @emph{TypeMismatchException} est +levee. @xref{Classe TypeMismatchException}. + +L'ancienne valeur de l'objet est perdue. + +@item +@b{Versatile & operator += (const string & ch) + throw(TypeMismatchException, ListIsFullException)@* +Versatile & operator , (const string & ch) + throw(TypeMismatchException, ListIsFullException)@* +Versatile & operator += (const Couple & cp) + throw(TypeMismatchException, ListIsFullException)@* +Versatile & operator , (const Couple & cp) + throw(TypeMismatchException, ListIsFullException)} + +Ces operateurs concatenent la valeur passee en argument a l'objet. Le +type de la valeur doit correspondre au type interne de l'objet si +celui-ci a deja ete affecte, sinon une exception @emph{TypeMismatchException} est +levee. @xref{Classe TypeMismatchException}. + +Si la taille maximale de la liste est depasse, une exception @emph{ListIsFullException} est +levee. @xref{Classe ListIsFullException}. + +@item +@b{Versatile & operator = (const Versatile & V) throw(TypeMismatchException)} + +L'operateur d'affectation duplique l'objet passe en argument dans +l'objet. Toutes les valeurs internes sont dupliquees de maniere a avoir +une independance totale entre les deux objets a l'issue de +l'affectation. + +Il est a noter qu'il est possible d'affecter a un objet un objet +possedant un type different, auquel cas l'objet courant change de type +pour acquerir celui de l'objet passe en argument. C'est le seul cas de +changement de type autorise pour un objet. + +@item +@b{operator long() const throw(TypeMismatchException)@* +operator string() const throw(TypeMismatchException)@* +operator Couple() const throw(TypeMismatchException)@* +string str() const throw(TypeMismatchException)} + +Ces operateur de conversion dans les types de base permettent de +recuperer la valeur interne de l'objet. Lorsque le type interne est +incompatible avec la conversion une exception @emph{TypeMismatchException} est +levee. @xref{Classe TypeMismatchException}. + +@item +@b{ostream & operator << (ostream & os, const Versatile & )} + +Cet operateur permet de voir le contenu de l'objet sur un flot de sortie. + +@item +@b{void setType(DiscriminatorType) throw(TypeMismatchException)} + +Cette methode change le type interne de l'objet en celui passe en +argument. Ceci n'est possible que pour un objet non encore affecte. Si +le nouveau type est different du type actuel une exception @emph{TypeMismatchException} est +levee. @xref{Classe TypeMismatchException}. + +@item +@b{DiscriminatorType getType() const} + +Cet accesseur renvoie le type interne de l'objet. + +@item +@b{void setMaxSize(int i)} + +Cette methode permet de changer le nombre d'elements que l'objet est +capable de stocker. Par defaut ce nombre est 1 a la construction de +l'objet, signifiant qu'il ne peut contenir qu'une seule valeur a la fois +(scalaire). + +Si ce nombre est superieur a 1 alors il represente une +limite qui ne pourra etre depassee par l'objet sans lever d'exception +@emph{ListIsFullException}. @xref{Classe ListIsFullException}. + +Si ce nombre vaut 0 (zero) alors il n'y a aucune limite superieure au +nombre d'element dans l'objet. + +@item +@b{int getMaxSize() const} + +Cet accesseur renvoie la taille maximale admise par l'objet. + +@item +@b{void setName(const string & name)} + +Cette methode permet de positionner le nom de l'objet. Par defaut ce nom +vaut @samp{undefined} a la construction de l'objet. + +Il est interessant de positionner le nom a une valeur significative +comme par exemple le nom de la variable contenant l'objet car lorsqu'une +exception est levee ce nom apparait en clair et aide au debugging. + +@item +@b{string getName() const} + +Cet accesseur renvoie le nom interne de l'objet. + +@end itemize + +@end itemize + + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Exceptions, Classe APIInternalFailureException, Classe Versatile, Classes generiques +@comment node-name, next, previous, up +@page +@subsection Exceptions +@cindex exceptions + +La bibliotheque de classes Batch definit un certain nombre d'exceptions +qui sont levees par les classes lors d'evenements qui traduisent un +comportement anormal de la bibliotheque. + +@menu +* Classe APIInternalFailureException:: Erreur d'utilisation de l'API. +* Classe ConnexionFailureException:: Probleme de connexion de l'API. +* Classe GenericException:: Classe-mere de toutes les exceptions. +* Classe InvalidArgumentException:: Parametre errone d'une methode. +* Classe InvalidKeyException:: Clef erronee d'une map. +* Classe ListIsFullException:: Debordement de taille d'une liste. +* Classe NotYetImplementedException:: Methodes non encore implementee. +* Classe RunTimeException:: Erreur d'execution imprevue. +* Classe TypeMismatchException:: Probleme de conversion de type. +@end menu + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe APIInternalFailureException, Classe ConnexionFailureException, Exceptions, Exceptions +@comment node-name, next, previous, up +@page +@subsubsection APIInternalFailureException +@findex APIInternalFailureException + +Cette exception est levee par les classes d'implementation de la +bibliotheque lorsqu'une erreur est detectee au moment de la +communication avec l'API du gestionnaire de batch. En general l'erreur +renvoyee par l'API est incluse dans le message de l'exception. + +Cette exception herite de la classe @emph{GenericException} qui definit +uniquement un constructeur et deux membres publics constants : @emph{type} et +@emph{message}. @xref{Classe GenericException}. + +@itemize @bullet{} +@item Entete + +@example +class APIInternalFailureException : public GenericException +@{ + public: + // Constructeur + APIInternalFailureException(string msg = "undefined"); +@}; +@end example + + +@item Methodes +@itemize @minus{} +@item +@b{APIInternalFailureException(string msg = "undefined")} + +Ce contructeur prend la chaine @emph{msg} comme message d'erreur a +renvoyer au gestionnaire d'exception. Cette valeur est stockee dans le +membre public constant @emph{message}. + +Le membre public constant @emph{type} est initialise avec le nom de la +classe, soit @emph{APIInternalFailureException}. + +@end itemize + +@end itemize + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe ConnexionFailureException, Classe GenericException, Classe APIInternalFailureException, Exceptions +@comment node-name, next, previous, up +@page +@subsubsection ConnexionFailureException +@findex ConnexionFailureException + +Cette exception est levee par les classes d'implementation de la +bibliotheque lorsqu'une erreur est detectee au moment de la +connexion au gestionnaire de batch. En general l'erreur +renvoyee par l'API de connexion est incluse dans le message de l'exception. + +Cette exception herite de la classe @emph{GenericException} qui definit +uniquement un constructeur et deux membres publics constants : @emph{type} et +@emph{message}. @xref{Classe GenericException}. + +@itemize @bullet{} +@item Entete + +@example +class ConnexionFailureException : public GenericException +@{ + public: + // Constructeur + ConnexionFailureException(string msg = "undefined"); +@}; +@end example + + +@item Methodes +@itemize @minus{} +@item +@b{ConnexionFailureException(string msg = "undefined")} + +Ce contructeur prend la chaine @emph{msg} comme message d'erreur a +renvoyer au gestionnaire d'exception. Cette valeur est stockee dans le +membre public constant @emph{message}. + +Le membre public constant @emph{type} est initialise avec le nom de la +classe, soit @emph{ConnexionFailureException}. + +@end itemize + +@end itemize + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe GenericException, Classe InvalidArgumentException, Classe ConnexionFailureException, Exceptions +@comment node-name, next, previous, up +@page +@subsubsection GenericException +@findex GenericException + +Cette classe est generique comme son nom l'indique et definit une +interface commune pour toutes les exceptions de la +bibliotheque. + +Cette exception definit uniquement un constructeur et deux membres +publics constants : @emph{type} et @emph{message}. @xref{Classe +GenericException}. + + +@itemize @bullet{} +@item Entete + +@example +class GenericException +@{ + public: + const string type; // la nature de l'exception + const string message; // la raison de l'exception + + // Constructeur + GenericException(const string tp = "GenericException", + const string msg = "undefined"); +@}; +@end example + + +@item Methodes +@itemize @minus{} +@item +@b{GenericException(const string tp = "GenericException", const string msg = "undefined")} + +Ce contructeur prend la chaine @emph{msg} comme message d'erreur a +renvoyer au gestionnaire d'exception. Cette valeur est stockee dans le +membre public constant @emph{message}. + +Le membre public constant @emph{type} est initialise avec le parametre +@emph{tp} qui contient generalement le nom de la classe. + +@end itemize + +@end itemize + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe InvalidArgumentException, Classe InvalidKeyException, Classe GenericException, Exceptions +@comment node-name, next, previous, up +@page +@subsubsection InvalidArgumentException +@findex InvalidArgumentException + +Cette exception est levee par les classes de la bibliotheque lorsqu'un +parametre erronne est passe en argument a une methode. En general +le nom de l'arguement erronne est inclus dans le message de +l'exception. + +Cette exception herite de la classe @emph{GenericException} qui definit +uniquement un constructeur et deux membres publics constants : @emph{type} et +@emph{message}. @xref{Classe GenericException}. + +@itemize @bullet{} +@item Entete + +@example +class InvalidArgumentException : public GenericException +@{ + public: + // Constructeur + InvalidArgumentException(string msg = "undefined"); +@}; +@end example + + +@item Methodes +@itemize @minus{} +@item +@b{InvalidArgumentException(string msg = "undefined")} + +Ce contructeur prend la chaine @emph{msg} comme message d'erreur a +renvoyer au gestionnaire d'exception. Cette valeur est stockee dans le +membre public constant @emph{message}. + +Le membre public constant @emph{type} est initialise avec le nom de la +classe, soit @emph{InvalidArgumentException}. + +@end itemize + +@end itemize + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe InvalidKeyException, Classe ListIsFullException, Classe InvalidArgumentException, Exceptions +@comment node-name, next, previous, up +@page +@subsubsection InvalidKeyException +@findex InvalidKeyException + + +Cette exception est levee par les methodes de la classe @emph{Parametre} +lorsqu'une clef erronnee est utilisee. En general le nom de la clef +erronnee est inclus dans le message de l'exception. + +Cette exception herite de la classe @emph{GenericException} qui definit +uniquement un constructeur et deux membres publics constants : @emph{type} et +@emph{message}. @xref{Classe GenericException}. + +@itemize @bullet{} +@item Entete + +@example +class InvalidKeyException : public GenericException +@{ + public: + // Constructeur + InvalidKeyException(string msg = "undefined"); +@}; +@end example + + +@item Methodes +@itemize @minus{} +@item +@b{InvalidKeyException(string msg = "undefined")} + +Ce contructeur prend la chaine @emph{msg} comme message d'erreur a +renvoyer au gestionnaire d'exception. Cette valeur est stockee dans le +membre public constant @emph{message}. + +Le membre public constant @emph{type} est initialise avec le nom de la +classe, soit @emph{InvalidKeyException}. + +@end itemize + +@end itemize + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe ListIsFullException, Classe NotYetImplementedException, Classe InvalidKeyException, Exceptions +@comment node-name, next, previous, up +@page +@subsubsection ListIsFullException +@findex ListIsFullException + +Cette exception est levee par les methodes de la classe @emph{Versatile} +lorsque la taille maximale de la liste interne est depasse. En general +le nom de l'objet en erreur est inclus dans le message de l'exception. + +Cette exception herite de la classe @emph{GenericException} qui definit +uniquement un constructeur et deux membres publics constants : @emph{type} et +@emph{message}. @xref{Classe GenericException}. + +@itemize @bullet{} +@item Entete + +@example +class ListIsFullException : public GenericException +@{ + public: + // Constructeur + ListIsFullException(string msg = "undefined"); +@}; +@end example + + +@item Methodes +@itemize @minus{} +@item +@b{ListIsFullException(string msg = "undefined")} + +Ce contructeur prend la chaine @emph{msg} comme message d'erreur a +renvoyer au gestionnaire d'exception. Cette valeur est stockee dans le +membre public constant @emph{message}. + +Le membre public constant @emph{type} est initialise avec le nom de la +classe, soit @emph{ListIsFullException}. + +@end itemize + +@end itemize + + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe NotYetImplementedException, Classe RunTimeException, Classe ListIsFullException, Exceptions +@comment node-name, next, previous, up +@page +@subsubsection NotYetImplementedException +@findex NotYetImplementedException + +Cette exception est levee par les classes de la bibliotheque lorsqu'une +methode declaree mais non encore implementee est utilisee. En general +le nom de l'objet en erreur est inclus dans le message de l'exception. + +Cette exception herite de la classe @emph{GenericException} qui definit +uniquement un constructeur et deux membres publics constants : @emph{type} et +@emph{message}. @xref{Classe GenericException}. + +@itemize @bullet{} +@item Entete + +@example +class NotYetImplementedException : public GenericException +@{ + public: + // Constructeur + NotYetImplementedException(string msg = "undefined"); +@}; +@end example + + +@item Methodes +@itemize @minus{} +@item +@b{NotYetImplementedException(string msg = "undefined")} + +Ce contructeur prend la chaine @emph{msg} comme message d'erreur a +renvoyer au gestionnaire d'exception. Cette valeur est stockee dans le +membre public constant @emph{message}. + +Le membre public constant @emph{type} est initialise avec le nom de la +classe, soit @emph{NotYetImplementedException}. + +@end itemize + +@end itemize + + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe RunTimeException, Classe TypeMismatchException, Classe NotYetImplementedException, Exceptions +@comment node-name, next, previous, up +@page +@subsubsection RunTimeException +@findex RunTimeException + +Cette exception est levee par les classes de la bibliotheque lorsqu'une +erreur inconnue et imprevue apparait. Cette exception est le +comportement par defaut que doit gerer le gestionnaire d'exception en ce +qui concerne les classes de la bibliotheque. En general le nom de +l'objet en erreur est inclus dans le message de l'exception. + +Cette exception herite de la classe @emph{GenericException} qui definit +uniquement un constructeur et deux membres publics constants : @emph{type} et +@emph{message}. @xref{Classe GenericException}. + +@itemize @bullet{} +@item Entete + +@example +class RunTimeException : public GenericException +@{ + public: + // Constructeur + RunTimeException(string msg = "undefined"); +@}; +@end example + + +@item Methodes +@itemize @minus{} +@item +@b{RunTimeException(string msg = "undefined")} + +Ce contructeur prend la chaine @emph{msg} comme message d'erreur a +renvoyer au gestionnaire d'exception. Cette valeur est stockee dans le +membre public constant @emph{message}. + +Le membre public constant @emph{type} est initialise avec le nom de la +classe, soit @emph{RunTimeException}. + +@end itemize + +@end itemize + + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe TypeMismatchException, Classes specifiques, Classe RunTimeException, Exceptions +@comment node-name, next, previous, up +@page +@subsubsection TypeMismatchException +@findex TypeMismatchException + +Cette exception est levee par les methodes de la classe @emph{Versatile} +lorsque qu'une erreur de type est rencontree dans un objet. Ce genre +d'erreur survient lorsqu'on essaie d'affecter une valeur d'un type +different du type interne de l'objet @emph{Versatile} a ce meme objet, +ou bien lorsqu'on ajoute une valeur d'un type different a une liste. En +general le nom de l'objet en erreur est inclus dans le message de +l'exception. + +Cette exception herite de la classe @emph{GenericException} qui definit +uniquement un constructeur et deux membres publics constants : @emph{type} et +@emph{message}. @xref{Classe GenericException}. + +@itemize @bullet{} +@item Entete + +@example +class TypeMismatchException : public GenericException +@{ + public: + // Constructeur + TypeMismatchException(string msg = "undefined"); +@}; +@end example + + +@item Methodes +@itemize @minus{} +@item +@b{TypeMismatchException(string msg = "undefined")} + +Ce contructeur prend la chaine @emph{msg} comme message d'erreur a +renvoyer au gestionnaire d'exception. Cette valeur est stockee dans le +membre public constant @emph{message}. + +Le membre public constant @emph{type} est initialise avec le nom de la +classe, soit @emph{TypeMismatchException}. + +@end itemize + +@end itemize + + + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classes specifiques, Classes PBS, Classe TypeMismatchException, Classes +@comment node-name, next, previous, up +@page +@section Classes specifiques +@cindex classes specifiques + +Afin de pouvoir se connecter aux gestionnaires de batch reels a travers +leurs API, les classes generiques ont ete derivees pour offrir une +implementation correspondant a l'interface qu'elles definissent. + +Pour traduire a la fois le fait que les nouvelles classes derivent d'une +classe generique et qu'elles sont une implementation d'une API +particuliere, on adopte la convention de nom suivante : la classe se +nomme comme sa classe generique mais est suffixee par le nom de l'API du +gestionnaire de batch, les deux termes etant separes par un caractere +@kbd{_} (souligne). + +Actuellement, seul le gestionnaire de batch OpenPBS, @xref{Prerequis}, est +supporte. Mais ce catalogue devrait s'enrichir par la suite. + +Les classes de la bibliotheque sont egalement accessibles a travers un +interpreteur Python, ce qui a necessite la creation de certaines classes +d'interface avec l'interpreteur. + +@menu +* Classes PBS:: Classes d'implementation pour OpenPBS +* Classes Python:: Classes d'interfacage avec Python. +@end menu + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classes PBS, Classe FactBatchManager_PBS, Classes specifiques, Classes specifiques +@comment node-name, next, previous, up +@page +@subsection Classes PBS +@cindex classes PBS + +Actuellement seules les classes @emph{BatchManager}, @emph{JobInfo} et +@emph{Job} ont besoin d'etre derivees pour implementer la communication +et l'interfacage avec l'API du gestionnaire de batch OpenPBS. + + +@menu +* Classe FactBatchManager_PBS:: Description de la classe FactBatchManager_PBS. +* Classe BatchManager_PBS:: Description de la classe BatchManager_PBS. +* Classe JobInfo_PBS:: Description de la classe JobInfo_PBS. +* Classe Job_PBS:: Description de la classe Job_PBS. +@end menu + + +@node Classe FactBatchManager_PBS, Classe BatchManager_PBS, Classes PBS, Classes PBS +@comment node-name, next, previous, up +@subsubsection FactBatchManager_PBS +@cindex FactBatchManager_PBS + +Cette classe derive de la classe generique @emph{FactBatchManager}, +@xref{Classe FactBatchManager}. + +Les objets de la classe @emph{BatchManager_PBS} realisent l'interface de +la bibliotheque avec l'API du gestionnaire de batch OpenPBS. + +@itemize @bullet{} +@item Entete + +@example +class FactBatchManager_PBS : public FactBatchManager +@{ +public: + // Constructeur et destructeur + FactBatchManager_PBS(); + virtual ~FactBatchManager_PBS(); + + virtual BatchManager_PBS * operator() (const char * hostname) const; + +protected: + +private: + +@}; +@end example + +@item Exemple + +@example +@dots{} + +// On recupere l'instance du catalogue de gestionnaires de batch +Batch::BatchManagerCatalog cata = Batch::BatchManagerCatalog::getInstance(); + +// On cree une fabrique de BatchManager de type PBS +Batch::FactBatchManager & fbm = * cata("PBS"); + +@dots{} +@end example + +@item Methodes +@itemize @minus{} +@item +@b{FactBatchManager_PBS()} + +Ce constructeur instancie un objet de la classe +@emph{FactBatchManager_PBS} et l'enregistre automatiquement aupres du +catalogue de fabrique. @xref{Classe BatchManagerCatalog}. + +Le type est positionne a la valeur PBS. + +@item +@b{~FactBatchManager_PBS()} + +Le destructeur ne fait rien de particulier. + +@item +@b{BatchManager_PBS * operator() (const char * hostname) const} + +Cet operateur renvoie un objet nouvellement cree de type +@emph{BatchManager_PBS} derivant de @emph{BatchManager} et oeuvrant sur +la machine @emph{hostname}. La destruction de l'objet est a la charge de +l'appelant. + +@end itemize + +@end itemize + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classe BatchManager_PBS, Classe JobInfo_PBS, Classe FactBatchManager_PBS, Classes PBS +@comment node-name, next, previous, up +@page +@subsubsection BatchManager_PBS +@cindex BatchManager_PBS + +Cette classe derive de la classe generique @emph{BatchManager}, +@xref{Classe BatchManager}. + +Les objets de la classe @emph{BatchManager_PBS} realisent l'interface de +la bibliotheque avec l'API du gestionnaire de batch OpenPBS. + +@itemize @bullet{} +@item Entete + +@example +class BatchManager_PBS : public BatchManager +@{ + public: + // Constructeur et destructeur + BatchManager_PBS(FactBatchManager * parent, + const char * host) throw(InvalidArgumentException); + virtual ~BatchManager_PBS(); + + // Recupere le nom du serveur par defaut + static string getDefaultServer(); + + // Recupere le l'identifiant d'un job deja soumis au BatchManager + virtual const JobId getJobIdByReference(const string & ref); + + // Methodes pour le controle des jobs : virtuelles pures + // soumet un job au gestionnaire + virtual const JobId submitJob(const Job & job); + + // retire un job du gestionnaire + virtual void deleteJob(const JobId & jobid); + + // suspend un job en file d'attente + virtual void holdJob(const JobId & jobid); + + // relache un job suspendu + virtual void releaseJob(const JobId & jobid); + + // modifie un job en file d'attente + virtual void alterJob(const JobId & jobid, + const Parametre & param, + const Environnement & env); + virtual void alterJob(const JobId & jobid, + const Parametre & param); + virtual void alterJob(const JobId & jobid, + const Environnement & env); + + // renvoie l'etat du job + virtual JobInfo queryJob(const JobId & jobid); + + // modifie un job en file d'attente + virtual void setParametre(const JobId & jobid, + const Parametre & param); + virtual void setEnvironnement(const JobId & jobid, + const Environnement & env); + + protected: + string _hostname; // serveur ou tourne le BatchManager + + private: + +@}; +@end example + +@item Exemple + +@example +@dots{} + +// On recupere l'instance du catalogue de gestionnaires de batch +Batch::BatchManagerCatalog cata = Batch::BatchManagerCatalog::getInstance(); + +// On cree une fabrique de BatchManager de type PBS +Batch::BatchManager & myBM = (* cata("PBS"))("serveur.domaine.fr") + +// Maintenant, on peut utiliser toutes les fonctionnalites du +// gestionnaire de batch a travers le variable myBM + +@dots{} +@end example + +@item Methodes +@itemize @minus{} +@item +@b{BatchManager_PBS(FactBatchManager * parent, +const char * host) throw(InvalidArgumentException)} + +Excepte un pointeur sur la fabrique qui a produit l'objet, le +constructeur accepte zero ou un argument de type @emph{string} decrivant +soit le nom de domaine completement qualifie (FQDN, @i{fully qualified +domain name}) du serveur de batch, soit son adresse IP dans un format +decimal "aaa.bbb.ccc.ddd". + +Si aucun parametre n'est passe au constructeur, celui-ci prend le +serveur par defaut tel que renvoye par la methode @emph{getDefaultServer}. + +Une resolution du nom ou de l'adresse peut etre realisee en fonction des +capacites de la plate-forme pour s'assurer que le serveur est connu et +joignable. En cas d'echec, une exception InvalidArgumentException est +levee. @xref{Classe InvalidArgumentException}. + +Ceci fait, une connexion est etablie avec le gestionnaire de batch qui +est maintenue jusqu'a destruction de l'objet. + +@item +@b{~BatchManager()} + +Le destructeur supprime la connexion precedemment etablie par le +constructeur lorsque celle-ci a reussi. + +@item +@b{const JobId submitJob(const Job & job)} + +Cette methode soumet le job passe en argument au gestionnaire de +batch. Etant donne que le job ne peut pas etre envoye tel quel puisqu'il +a un format generique au sein de la bibliotheque de classes Batch, cette +methode est chargee de le convertir dans un format adapte au +gestionnaire de batch sous-jacent. + +La methode opere ici une conversion du job de la classe @emph{Job} en @emph{Job_PBS}. + +Ce n'est que lorsque cette conversion est realisee que le job est soumis +au gestionnaire a travers son API. L'identifiant propose par le +gestionnaire est alors renvoye a l'appelant. Si la soumission echoue +pour une raison ou une autre, une exception APIInternalFailureException est +levee. @xref{Classe APIInternalFailureException}. + +@item +@b{void deleteJob(const JobId & jobid)} + +Cette methode retire le job dont l'identifiant est passe en argument de +la file d'attente du gestionnaire, ou bien l'arrete en cours +d'execution. Cette methode est inoperante sur des travaux deja termines, +auquel cas une exception APIInternalFailureException est +levee. @xref{Classe APIInternalFailureException}. + + +@item +@b{void holdJob(const JobId & jobid)} + +Cette methode suspend le job dont l'identifiant est passe en argument au +sein de la file d'attente du gestionnaire. Cette methode est inoperante +sur des travaux en cours d'execution ou deja termines, ainsi que sur des +travaux deja suspendus. +En cas de probleme, une exception APIInternalFailureException est +levee. @xref{Classe APIInternalFailureException}. + +@item +@b{void releaseJob(const JobId & jobid)} + +Cette methode relache un job precedemment suspendu en file +d'attente dont l'identifiant est passe en argument. Elle est inoperante +sur des travaux deja reclaches, en cours d'execution ou termines. +En cas de probleme, une exception APIInternalFailureException est +levee. @xref{Classe APIInternalFailureException}. + + +@item +@b{void alterJob(const JobId & jobid, const Parametre & param, const Environnement & env)@* +void alterJob(const JobId & jobid, const Parametre & param)@* +void alterJob(const JobId & jobid, const Environnement & env)} + +Ces methodes permettent de modifier les parametres d'execution et +d'environnement d'un job dont l'identifiant est passe en +argument. @xref{Classe Parametre}. @xref{Classe Environnement}. Il +est important de noter que le job doit etre encore place en file +d'attente sinon la methode est inoperante. +En cas de probleme, une exception APIInternalFailureException est +levee. @xref{Classe APIInternalFailureException}. + +@item +@b{JobInfo queryJob(const JobId & jobid)} + +Cette methode permet de recuperer les informations concernant le job +dont l'identifiant est passe en argument dans un objet de classe +@emph{JobInfo}. @xref{Classe JobInfo}. On y retrouve les parametres +d'execution et d'environnement du job tels qu'ils ont ete passes au +gestionnaire au moment de la soumission, ainsi que des informations +concernant l'execution du job comme par exemple la machine d'execution, +le temps consomme, la memoire consommee, etc. + +Il n'est pas toujours possible d'interroger un job deja termine. +En cas de probleme, une exception APIInternalFailureException est +levee. @xref{Classe APIInternalFailureException}. + + +@item +@b{const JobId getJobIdByReference(const string & ref)} + +Cette methode permet de recuperer au sein de la classe un identifiant de +job a partir d'une chaine de caracteres obtenue par un biais +externe. Cet identifiant pourra etre utilise par la suite au sein de la +biliotheque de classes pour controler le job comme s'il avait ete cree +et soumis depuis la biliotheque-meme. + +@item +@b{void setParametre(const JobId & jobid, const Parametre & param)} + +Cette methode n'est utile que pour l'interfacage avec Python, car Python +ne sait pas gerer la surcharge de methode, et de fait leve des +exceptions lors d'appels a de telles methodes. + +Elle est equivalente a la methode @samp{void alterJob(const JobId & jobid, const Parametre & param)}. + +@item +@b{void setEnvironnement(const JobId & jobid, const Environnement & env)} + +Cette methode n'est utile que pour l'interfacage avec Python, car Python +ne sait pas gerer la surcharge de methode, et de fait leve des +exceptions lors d'appels a de telles methodes. + +Elle est equivalente a la methode @samp{void alterJob(const JobId & jobid, const Environnement & env)}. + +@end itemize + + +@end itemize + +@c ---------------------- +@c ---------------------- +@c ---------------------- + + +@node Classe JobInfo_PBS, Classe Job_PBS, Classe BatchManager_PBS, Classes PBS +@comment node-name, next, previous, up +@page +@subsubsection JobInfo_PBS +@cindex JobInfo_PBS + +Un objet de classe @emph{JobInfo} represente l'ensemble des informations +disponibles sur un travail actif, c'est-a-dire soumis au gestionnaire de +batch, a un instant donne. + +Cet objet reprend des informations issues du job tel qu'il a ete soumis, +@xref{Classe Job}, mais aussi des informations produites par le +gestionnaire de batch a partir de la soumission et du transit du job en +son sein : nom de la queue dans laquelle le job est inscrit, duree +d'execution, date de soumission, etc. + +Ces informations sont disponibles aupres de l'utilisateur de la classe a +travers les objets @emph{Parametre} et @emph{Environnement} que l'objet +@emph{JobInfo} peut fournir. + +@itemize @bullet{} +@item Entete + +@example +class JobInfo_PBS : public JobInfo +@{ + public: + // Constructeur standard et destructeur + JobInfo_PBS(); + JobInfo_PBS(struct batch_status * stat_list, + bool tobedeleted = false); + virtual ~JobInfo_PBS(); + + // Constructeur par recopie + JobInfo_PBS(const JobInfo_PBS & jinfo); + + // Methodes pour l'interfacage avec Python (SWIG) + string __str__() const; // SWIG : affichage en Python + string __repr__() const; // SWIG : affichage en Python + + protected: + Parametre _param; // parametres du job + Environnement _env; // variables d'environnement du job + + private: +@}; +@end example + + +@item Exemple +@example +@dots{} (ici on cree un BatchManager bm et un Job job) + +// On soumet le job et on recupere un identifiant +JobId jobid = bm.submitJob(job); + +// Ce qui permet d'interroger l'etat du job en cours +// Nota : l'objet retourne est un JobInfo_PBS +JobInfo jinfo = jobid.queryJob(); + +@dots{} +@end example + +@item Methodes +@itemize @minus{} +@item +@b{JobInfo_PBS()} + +Ce constructeur cree un objet @emph{JobInfo_PBS} vide. + +@item +@b{~JobInfo_PBS()} + +Le destructeur libere l'espace memoire alloue pour l'objet si la +desollacation n'a pas eu deja lieu dans le constructeur. + +@item +@b{JobInfo_PBS(const JobInfo_PBS & jinfo)} + +Le constructeur par recopie produit un objet identique a celui passe en +argument. Les deux objets sont totalement independants l'un de l'autre. + +@item +@b{JobInfo_PBS(struct batch_status * stat_list, bool tobedeleted = false)} + +Ce constructeur recupere une liste chainee du type interne OpenPBS +@emph{struct batch_status *}, la parcoure et l'analyse pour en extraire +les informations utilisables par la bibliotheque de classes et les +stocker dans deux objets internes @emph{Parametre} et +@emph{Environnement}. + +Si le parametre @emph{tobedeleted} vaut @emph{true} alors la liste +chainee @emph{stat_list} sera desallouee a la fin du constructeur. Sinon +elle sera desalloue dans le destructeur au plus tard. + +@item +@b{string __str__() const} + +Cette methode n'est utile que pour l'interfacage avec Python. Elle +permet d'afficher l'etat de l'objet @emph{JobInfo}. + +@item +@b{string __repr__() const} + +Cette methode n'est utile que pour l'interfacage avec Python. Elle +permet d'afficher l'etat de l'objet @emph{JobInfo}. + +@end itemize + +@end itemize + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + + +@node Classe Job_PBS, Classes Python, Classe JobInfo_PBS, Classes PBS +@comment node-name, next, previous, up +@page +@subsubsection Job_PBS +@cindex Job_PBS + +Un objet de classe @emph{Job} possede une structure generique +potentiellement utilisable par tout gestionnaire de batch mais pas en +l'etat. Une conversion dans un format lisible par le gestionnaire doit +etre realisee. + +Ceci se fait en produisant a partir des donnees generiques de la classe +@emph{Job} des structures de donnees specifiques qui peuvent etre +directement passees a l'API du gestionnaire. + +La classe @emph{Job_PBS} se distingue donc de la classe @emph{Job} par son +constructeur et par des accesseurs specifiques qui produisent des +donnees lisibles par OpenPBS. + +Etant donnee la specificite de cette classe, elle ne devrait concerner +que les developpeurs de la bibliotheque de classes Batch. + +@itemize @bullet{} +@item Entete + +@example +class Job_PBS +@{ + public: + // Constructeurs 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 d'attributs + operateur + struct attrl * _p_attrl; // liste d'attributs + char * _script; // chemin d'acces au script du job + char * _destination; // queue dans laquelle le job est soumis + + private: + +@}; +@end example + + +@item Exemple +@example +@dots{} + +Parametre param; +Environnement env; + +@dots{} (ici on cree les parametres du job) + +Job job(param, env); + +// On fabrique un job specifique a OpenPBS a partir du job generique +// Ceci ne concerne en general pas l'utilisateur de la bibliotheque +Job_PBS jobpbs(job); + +@dots{} +@end example + +@item Methodes +@itemize @minus{} + +@item +@b{Job_PBS(const Job & job)} + +Le constructeur convertit les objets internes @emph{Parametre} et +@emph{Environnement} de l'objet passe en argument en un ensemble de +quatre structures C @emph{AttributesOP}, @emph{Attributes}, +@emph{Script} et @emph{Destination} directement utilisable par l'API de +OpenPBS. + +@item +@b{~Job_PBS()} + +Le destructeur libere simplement les espaces alloues pour les structures +@emph{AttributesOP}, @emph{Attributes}, @emph{Script} et +@emph{Destination}. + +@item +@b{struct attropl * getAttributesOP()} + +Cet accesseur retourne un pointeur sur la structure interne +@emph{AttributesOP} de l'objet. Cette structure n'est pas protogee +contre les modifications accidentelles de l'utilisateur. Par consequent +il est recommande d'eviter d'y apporter toute alteration sous peine de +dysfonctionnement. + +Pour la definition de la structure @emph{AttributesOP}, voir la +documentation OpenPBS. + +@item +@b{struct attrl * getAttributes()} + +Cet accesseur retourne un pointeur sur la structure interne +@emph{Attributes} de l'objet. Cette structure n'est pas protogee +contre les modifications accidentelles de l'utilisateur. Par consequent +il est recommande d'eviter d'y apporter toute alteration sous peine de +dysfonctionnement. + +Pour la definition de la structure @emph{Attributes}, voir la +documentation OpenPBS. + +@item +@b{char * getScript()} + +Cet accesseur retourne un parametre @emph{Script} qui est une chaine de +caracteres C contenant le chemin absolu (sur la machine d'execution) +du script a soumettre au gestionnaire de batch. + +Cette chaine n'est pas protegee contre les modifications accidentelles +de l'utilisateur. Il est donc recommande de ne pas y apporter de modification. + +@item +@b{char * getDestination()} + +Cet accesseur retourne un parametre @emph{Destination} qui est une chaine de +caracteres C contenant le nom de la queue, ou classe ou file selon les terminologies, +du gestionnaire de batch dans laquelle le job doit etre soumis. + +Cette chaine n'est pas protegee contre les modifications accidentelles +de l'utilisateur. Il est donc recommande de ne pas y apporter de modification. + + +@end itemize +@end itemize + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Classes Python, Classe PyVersatile, Classe Job_PBS, Classes specifiques +@comment node-name, next, previous, up +@page +@subsection Classes Python +@cindex classes Python + +L'integration de la bibliotheque de classes Batch dans l'interpreteur +Python a beaucoup progresse depuis la precedente version et se trouve +etre quasiment iso-fonctionelle avec le C++. + +Actuellement, l'interface avec Python s'appuie a la fois sur les +fonctionnalites de l'utilitaire SWIG, et sur la definition d'une classe +specifique qui permet de voir en Python la classe @emph{Versatile}. + +Certaines classes ont de plus des methodes specifiques pour le wrapping +Python qui simplifient grandement le developpement des classes +d'interface au detriment, il est vrai, d'une bonne independance entre +les langages. Ce choix n'est pas definitif et pourra etre revu si +l'occasion s'en presente. + +Quoi qu'il en soit toutes les classes de haut niveau sont interfacees en +Python sous le meme nom et proposent les memes methodes (sauf celles +surchargees en C++ qui sot parfois renommees pour lever +l'ambiguite). Pour ne pas refaire un expose detaille et fastidieux des +fonctionnalites Python de la bibliotheque de classes, il est propose de +retrouver les noms et la syntaxe de ces classe dans la partie +Utilisation de ce document. @xref{Utilisation}. + +@menu +* Classe PyVersatile:: Description de la classe PyVersatile. +@end menu + +@c ---------------------- +@c ---------------------- +@c ---------------------- + + +@node Classe PyVersatile, Utilisation, Classes Python, Classes Python +@comment node-name, next, previous, up +@page +@subsubsection PyVersatile +@cindex PyVersatile + + +La classe @emph{PyVersatile} derive de la classe @emph{Versatile} et +offre la possibilite de convertir un tel objet en objet Python et +@i{vice versa}. + + +@itemize @bullet{} +@item Entete + +@example +class PyVersatile : public Versatile +@{ + public: + // Constructeur a partir d'un objet Versatile + PyVersatile(const Versatile &); + + // Constructeur a partir d'un PyObject + PyVersatile(const PyObject *) throw(TypeMismatchException, + ListIsFullException, + InvalidArgumentException); + + // Conversion de type vers un PyObject + operator PyObject *() const; + + // Operateur d'affectation a partir d'un objet Versatile + PyVersatile & operator =(const Versatile &); + + protected: + + private: + +@}; +@end example + + +@item Exemple +@example +@dots{} + +// On cree un objet Versatile contenant +// une liste de chaine de caracteres +Versatile V; +V = "a", "b", "c"; + +// On convertit cet objet Versatile en PyVersatile +PyVersatile PyV(V); + +// De la on produit un objet Python +// qui est une liste de chaine de caracteres +PyObject * PyO = PyV; + +@dots{} +@end example + +@item Methodes +@itemize @minus{} + +@item +@b{PyVersatile(const Versatile &)} + +Ce constructeur convertit un objet @emph{Versatile} en objet @emph{PyVersatile}. + +@item +@b{PyVersatile(const PyObject *) throw(TypeMismatchException, ListIsFullException, InvalidArgumentException)} + +Ce constructeur convertit un objet Python passe en argument en un objet +@emph{PyVersatile}. + +Seuls certains objets Python peuvent etre convertis : les @emph{string} +et les @emph{long}, ainsi que les listes homogenes de ces types, ce qui +est coherent avec la nature de l'objet @emph{Versatile}. Si tel n'est +pas le cas, une exception Python est renvoyee a l'interpreteur. + + +@item +@b{operator PyObject *() const} + +Cet operateur convertit l'objet en objet Python. Selon le cas, l'objet +retourne est soit un scalaire soit une liste. L'objet retourne est +alloue dynamiquement et doit donc etre pris en charge par l'interpreteur. + +@item +@b{PyVersatile & operator =(const Versatile &)} + +L'affectation d'un objet @emph{Versatile} passe en argument est +similaire a l'affectation entre objets @emph{Versatile}. Les structures +de donnees internes initiales de l'objet sont effacees et remplacees par +une copie des donnees internes de l'objet passe en argument. Les deux +objets restent independants l'un de l'autre a l'issue de l'affectation. + +@end itemize +@end itemize + + + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Utilisation, Connexion, Classe PyVersatile, Top +@comment node-name, next, previous, up +@page +@chapter Utilisation +@cindex utilisation + +Ce chapitre presente les differentes actions qu'il est possible de +realiser avec les classes de la bilbiotheque. + +On presente un cas hypothetique ou un utilisateur voudrait soumettre et +controler un job depuis un code C++. Les sections suivantes decrivent +les operations a faire ainsi que leur action sur le travail soumis. + +@menu +* Connexion:: Creation d'un gestionnaire de batch. +* Creation:: Declaration d'un job (travail). +* Soumission:: Demande d'execution du job. +* Interrogation:: Recuperation des informations sur le job. +* Destruction:: Arret du job en cours. +* Suspension:: Suspension du job en file d'attente. +* Reprise:: Liberation du job en file d'attente. +* Modification:: Modification d'un job en file d'attente. +@end menu + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Connexion, Creation, Utilisation, Utilisation +@comment node-name, next, previous, up +@section Connexion +@cindex connexion +@cindex deconnexion + +La premiere etape avant toute utilisation pratique des classes de la +bibliotheque consiste a se connecter a un gestionnaire de batch. + +Ce concept de connexion est purement interne a la bibliotheque car il +est tout a fait possible d'imaginer le controle de jobs a travers l'API +d'un gestionnaire sans jamais etablir ni maintenir une quelconque +connexion avec celui-ci. D'autres par contre reclament l'etablissement +d'une connexion. + +Quoiqu'il en soit ceci n'est pas genant et l'etablissement et le +maintien de la connexion avec le gestionnaire de batch se fait par la +creation d'un objet de classe @emph{BatchManager} ou d'une classe +derivee. + +En pratique, la classe @emph{BatchManager} se comporte comme une +interface et seules les classes d'implementation derivee doivent etre +instanciees. + +Si l'on prend le cas d'un serveur @samp{serveur.domaine.fr} supportant +un gestionnaire de batch OpenPBS, on peut s'y connecter de la maniere +suivante : + +@itemize @bullet{} +@item Exemple C++ : + +@example +BatchManagerCatalog cata = BatchManagerCatalog::getInstance(); +BatchManager_PBS & bm = * (* cata('PBS'))("serveur.domaine.fr"); +@end example + +@item Exemple Python: + +@example +cata = BatchManagerCatalog.getInstance() +bm = cata('PBS')('serveur.domaine.fr') +@end example + +@end itemize + +Tant que l'objet @emph{bm} sera present --- tant que son destructeur +n'aura pas ete appele --- la connexion sera maintenue. La deconnexion +aura lieu a la destruction de l'objet. + +@xref{Classe BatchManager}. +@xref{Classe BatchManager_PBS}. + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Creation, Soumission, Connexion, Utilisation +@comment node-name, next, previous, up +@section Creation +@cindex creation + +La creation du job est l'etape qui precede toute soumission. Elle +necessite de decrire d'un maniere ou d'un autre ce que l'on va demander +a la machine d'executer. + +Pour cela on passe par deux objets intermediaires qui sont l'objet +@emph{Parametre} et l'objet @emph{Environnement}. + +Le minimum a preciser est en general le chemin absolu d'acces a +l'executable, quoique ceci depende fortement de la configuration du +gestionnaire auquel on se connecte. Celui-ci peut reclamer des +parametres supplementaires. + +Pour connaitre l'ensemble des parametres disponibles : @xref{Classe +Parametre}. + +On supposera dans cet exemple que l'application en question sait +reconnaitre une variable d'environnement @var{myapp_loglevel} qui prend +une valeur numerique correspondant au niveau d'information affiche en +sortie. + +Cette application imaginaire utilise egalement trois fichiers : + +@itemize @bullet{} +@item +un fichier d'entree nomme @file{Cas1.data} sur la machine locale qu'il +faudra renommer @file{fort.9} pour que l'application puisse le lire +(notre application imaginaire est ecrite en FORTRAN et attend un fichier +d'entree sur son descripteur 9); + +@item +un fichier de sortie standard que l'on voudra recuperer sous le nom +@file{Cas1.out}; + +@item +un fichier d'erreur standard que l'on voudra recuperer sous le nom +@file{Cas1.err}. + +@end itemize + +Le job est ensuite cree simplement a l'aide des deux objets precedents. + +@itemize @bullet{} +@item Exemple C++ : + +@example +Parametre param; +param[EXECUTABLE] = "/home/user/my_app/bin/exec_app.sh"; +param[INFILE] = Couple("/home/user/my_app/data/Cas1.data","fort.9"); +param[OUTFILE] = Couple("/home/user/my_app/data/Cas1.out", "stdout"), + Couple("/home/user/my_app/data/Cas1.err", "stderr"); + +Environnement env; +env["MYAPP_LOGLEVEL"] = "3"; + +Job job(param, env); +@end example + +@item Exemple Python: + +@example +param = @{@} +param["EXECUTABLE"] = "/home/user/my_app/bin/exec_app.sh" +param["INFILE"] = [ ("/home/user/my_app/data/Cas1.data","fort.9") ] +param["OUTFILE"] = [ ("/home/user/my_app/data/Cas1.out", "stdout"), + ("/home/user/my_app/data/Cas1.err", "stderr") ] + +env = @{@} +env["MYAPP_LOGLEVEL"] = "3" + +job = Job() +job.setParametre(param) +job.setEnvironnement(env) +@end example + +@end itemize + + +@xref{Classe Parametre}. +@xref{Classe Environnement}. +@xref{Classe Job}. + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Soumission, Interrogation, Creation, Utilisation +@comment node-name, next, previous, up +@section Soumission +@cindex soumission +@findex submitJob + +Une fois le job cree, il est alors tres simple de le soumettre au +gestionnaire de batch en passant par l'intermediaire de l'objet +@emph{BatchManager} cree precedemment. + +Cette soumission produira un objet @emph{JobId} qui servira a controler +le job par la suite. + +Cependant des exceptions peuvent etre levees au moment de la soumission +et il convient de fournir un gestionnaire d'exception pour gerer +proprement ces incidents. + +@itemize @bullet{} +@item Exemple C++ : + +@example +try @{ + const JobId jobid = bm.submitJob(job); + +@} catch (GenericException & ex) @{ + @dots{} +@} +@end example + +@item Exemple Python: + +@example +try : + jobid = bm.submitJob(job) +except : + @dots{} +@end example + +@end itemize + + +@xref{Classe Job}. +@xref{Classe JobId}. +@xref{Exceptions}. + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Interrogation, Destruction, Soumission, Utilisation +@comment node-name, next, previous, up +@section Interrogation +@cindex interrogation +@findex queryJob + +La fourniture d'un objet @emph{JobId} permet d'avoir tout controle sur +le job en cours. En particulier il est possible de l'interroger : +ceci generera un objet @emph{JobInfo} qui donnera l'ensemble des +informations disponibles sur l'etat du job aupres du gestionnaire de +batch. + +Ces informations sont disponibles a travers deux objets internes de +classes @emph{Parametre} et @emph{Environnement}, les memes que pour la +classe @emph{Job}, mais modifies et completes avec les donnees les plus +a jour du gestionnaire de batch. + +@itemize @bullet{} +@item Exemple C++ : + +@example +try @{ + const JobInfo jinfo = jobid.queryJob(); + + Parametre newparam = jinfo.getParametre(); + Environnement newenv = jinfo.getEnvironnement(); + +@} catch (GenericException & ex) @{ + @dots{} +@} +@end example + +@item Exemple Python: + +@example +try : + jobinfo = jobid.queryJob() + + newparam = jinfo.getParametre() + newenv = jinfo.getEnvironnement() +except : + @dots{} +@end example + +@end itemize + + +@xref{Classe JobId}. +@xref{Classe JobInfo}. +@xref{Exceptions}. + + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Destruction, Suspension, Interrogation, Utilisation +@comment node-name, next, previous, up +@section Destruction +@cindex destruction +@cindex suppression +@findex deleteJob + + +Il est possible de detruire un job que celui-ci soit encore en file +d'attente ou bien que son execution ait deja commence, auquel cas elle +serait immediatement interrompue. + + +@itemize @bullet{} +@item Exemple C++ : + +@example +try @{ + jobid.deleteJob(); + +@} catch (GenericException & ex) @{ + @dots{} +@} +@end example + +@item Exemple Python: + +@example +try : + jobid.deleteJob() + +except : + @dots{} +@end example + +@end itemize + + +@xref{Classe JobId}. +@xref{Exceptions}. + + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Suspension, Reprise, Destruction, Utilisation +@comment node-name, next, previous, up +@section Suspension +@cindex suspension +@findex holdJob + +La suspension consiste a figer en file d'attente un job qui n'aurait pas +encore commence son execution. Il n'est pas possible de suspendre un job +qui s'execute. + +Il y a deux manieres de suspendre un job en file d'attente : +@itemize @bullet{} +@item en utilisant la methode @samp{holdJob}; +@item en modifiant les parametres du job a l'aide de la methode @samp{alterJob}. +@end itemize + +Exemple 1 : + +@itemize @bullet{} +@item Exemple C++ : + +@example +try @{ + jobid.holdJob(); + +@} catch (GenericException & ex) @{ + @dots{} +@} +@end example + +@item Exemple Python: + +@example +try : + jobid.holdJob() + +except : + @dots{} +@end example + +@end itemize + +Exemple 2 : + +@itemize @bullet{} +@item Exemple C++ : + +@example +try @{ + Parametre altparam; + altparam[HOLD] = 1; + jobid.alterJob(altparam); + +@} catch (GenericException & ex) @{ + @dots{} +@} +@end example + +@item Exemple Python: + +@example +// Compte tenu de la surcharge d'operateur, cet exemple peut ne pas +// fonctionner encore +try : + altparam = @{@} + altparam["HOLD"] = 1 + jobid.alterJob(altparam) + +except : + @dots{} +@end example + +@end itemize + + + +@xref{Classe JobId}. +@xref{Exceptions}. +@xref{Reprise}. + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Reprise, Modification, Suspension, Utilisation +@comment node-name, next, previous, up +@section Reprise +@cindex reprise +@findex releaseJob + +La reprise est l'operation inverse de la suspension en ceci qu'elle +libere un job precedemment suspendu en file d'attente. Le job continuera +alors son cheminement normal au sein du gestionnaire de batch. + +Il y a deux manieres de suspendre un job en file d'attente : +@itemize @bullet{} +@item en utilisant la methode @samp{releaseJob}; +@item en modifiant les parametres du job a l'aide de la methode @samp{alterJob}. +@end itemize + +Exemple 1 : + +@itemize @bullet{} +@item Exemple C++ : + +@example +try @{ + jobid.releaseJob(); + +@} catch (GenericException & ex) @{ + @dots{} +@} +@end example + +@item Exemple Python: + +@example +try : + jobid.releaseJob() + +except : + @dots{} +@end example + +@end itemize + +Exemple 2 : + +@itemize @bullet{} +@item Exemple C++ : + +@example +try @{ + Parametre altparam; + altparam[HOLD] = 0; + jobid.alterJob(altparam); + +@} catch (GenericException & ex) @{ + @dots{} +@} +@end example + +@item Exemple Python: + +@example +// Compte tenu de la surcharge d'operateur, cet exemple peut ne pas +// fonctionner encore +try : + altparam = @{@} + altparam["HOLD"] = 0 + jobid.alterJob(altparam) + +except : + @dots{} +@end example + +@end itemize + + +@xref{Classe JobId}. +@xref{Exceptions}. +@xref{Suspension}. + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Modification, Installation de la bibliotheque, Reprise, Utilisation +@comment node-name, next, previous, up +@section Modification +@cindex modification +@findex alterJob + +Il est possible de modifier tout ou partie des parametres et des +variables d'un job a condition que celui-ci soit encore en file +d'attente. Un job dont l'execution a deja debute devient inalterable, +sauf a l'arreter definitvement. + +La modification se fait en declarant un objet @emph{Parametre} et/ou un +objet @emph{Environnement} contenant l'ensemble des alterations a +apporter a la description du job. Ces alterations peuvent porter sur des +parametres ou des variables deja definies ou non. + +En reprenant le cas du job imaginaire utilise jusqu'ici, on peut +souhaiter changer le script qui tient lieu d'executable car le precedent +etait incomplet, modifier le niveau d'affichage de la log et ajouter une +variable nommee @var{myapp_debug} qui indique au code de passer en mode +debug. Ceci pourrait se faire de la maniere suivante : + +@itemize @bullet{} +@item Exemple C++ : + +@example +try @{ + Parametre altparam; + altparam[EXECUTABLE] = "/home/user/my_app/bin/exec_app.sh"; + + Environnement altenv; + altenv["MYAPP_LOGLEVEL"] = "4"; + altenv["MYAPP_DEBUG"] = "1"; + jobid.alterJob(altparam, altenv); + +@} catch (GenericException & ex) @{ + @dots{} +@} +@end example + +@item Exemple Python: + +@example +// Compte tenu de la surcharge d'operateur, cet exemple peut ne pas +// fonctionner encore +try : + altparam = @{@} + altparam["EXECUTABLE"] = "/home/user/my_app/bin/exec_app.sh" + + altenv = @{@} + altenv["MYAPP_LOGLEVEL"] = "4"; + altenv["MYAPP_DEBUG"] = "1"; + + jobid.alterJob(altparam, altenv) + +except : + @dots{} +@end example + +@end itemize + + +@xref{Classe JobId}. +@xref{Exceptions}. + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Installation de la bibliotheque, Prerequis, Modification, Top +@comment node-name, next, previous, up +@chapter Installation +@cindex installation + +Cette section montre comment installer l'ensemble de la bibliotheque de +classes Batch sur une machine Unix. + +@menu +* Prerequis:: +* Installation rapide:: +* Configuration:: +* Compilation:: +* Compilation de la documentation:: +* Tests:: +* Installation:: +@end menu + + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Prerequis, Installation rapide, Installation de la bibliotheque, Installation de la bibliotheque +@comment node-name, next, previous, up +@section Prerequis +@cindex prerequis + +@unnumberedsubsubsec CMake +@cindex CMake + +La bibliotheque de classes Batch utilise CMake pour la configuration et +la generation des Makefiles (voir le site officiel +@uref{http://www.cmake.org/}). La version minimum requise est la 2.4. + +@unnumberedsubsec GCC/G++ + +A l'heure actuelle, la bibliotheque de classes Batch est developpee en +C++ et necessite de fait un compilateur pour ce langage. GCC/G++ +version 2.95.3 ou une version ulterieure est un choix judicieux. + +@unnumberedsubsec Gestionnaires de batch + +Comme la bibliotheque utilise les fonctionnalites de certains +gestionnaires de batch, il est indispensable de pouvoir acceder aux +bibliotheques et aux fichiers d'entete de ces produits, ou du moins des +produits dont on se servira par la suite, ceci pour pouvoir communiquer +a travers l'API qu'ils ont developpe. + +Le cas le plus simple est d'avoir le produit directement installe sur la +machine sur laquelle sera compilee la bibliotheque de classes Batch. + +@unnumberedsubsubsec OpenPBS +@cindex OpenPBS +@cindex PBS + +A ce jour, seul le gestionnaire de batch PBS (OpenPBS et PBS Pro) est +supporte (voir le site officiel @uref{http://www.openpbs.org}). Il doit +avoir une version au moins egale a 2.3.16. + +@unnumberedsubsubsec LSF +@cindex LSF + +Il est prevu d'avoir un support de LSF dans les mois qui viennent. + +@unnumberedsubsubsec LoadLeveler +@cindex LoadLeveler + +Il est prevu d'avoir un support de LoadLeveler mais dans un futur plus +lointain en fonction de la disponibilite du produit mais surtout d'une +machine sur lequel il serait installe. + +@unnumberedsubsubsec Sun Grid Engine + +Ce choix-la est beaucoup plus hypothetique, et risque bien de ne jamais +etre mene a bien. + +@unnumberedsubsubsec Rsh/Ssh + +Il est prevu de simuler le fonctionnement d'un gestionnaire de batch a +l'aide de commandes Unix Rsh et Ssh dans la mesure de leurs capacites +lorsque qu'il n'est pas possible d'avoir un gestionnaire de batch sur +certaines machines ou de s'y connecter (par exemple lorsqu'on traverse +un coupe-feu). + +@unnumberedsubsec Python +@cindex Python + +Les classes de haut-niveau de la bibliotheque de classes Batch disposent +d'une interface en Python qui leur permet d'etre utilisables dans ce +langage. L'usage de cette fonctionnalite necessite d'avoir a disposition +une version de Python (voir le site officiel +@uref{http://www.python.org}) au moins egale a 2.2. + +@unnumberedsubsec SWIG +@cindex SWIG + +De plus l'interfacage avec Python est automatise a l'aide de +l'utilitaire SWIG (voir le site officiel @uref{http://www.swig.org}) qui +transcrit les definitions des classes C++ en classes Python. Il faut +pour cela disposer de la version 1.3.17 ou ulterieure. + + + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Installation rapide, Configuration, Prerequis, Installation de la bibliotheque +@comment node-name, next, previous, up +@section Installation rapide +@cindex installation rapide + +Il faut commencer par decompresser le fichier @file{.tar.gz} ou +@file{.tgz} et descendre dans le repertoire qu'il a cree : + +@example +$ tar -xzvf libBatch-@value{VERSION}.tar.gz +$ cd libBatch-@value{VERSION} +@end example + +Pour ceux qui sont vraiment presses, le minimum requis est : + +@example +$ cmake +$ make +$ make install +@end example + +Pour ceux qui ont le temps de lire la suite, les sections suivantes +decrivent plus en detail ces etapes et les differents tests que l'on +peut mener. + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Configuration, Compilation, Installation rapide, Installation de la bibliotheque +@comment node-name, next, previous, up +@section Configuration +@cindex configuration + +La phase de configuration, tres classique dans le domaine des logiciels +libres, est basee sur CMake (voir @uref{http://www.cmake.org/}). + +La configuration est faite en appelant @file{cmake} avec en parametre +le repertoire racine de la bibliotheque de classes +Batch. Ce programme analyse l'ensemble des elements du systeme sur +lequel se deroulera la compilation pour determiner les parametres +optimaux et la presence de tous les produits necessaires a la +compilation. + +On n'oubliera pas de se referer a la documentation de @file{cmake} +notamment pour determiner l'emplacement definitif de l'installation. Le +fichier @file{INSTALL} situe a la racine de la bibliotheque de classes +Batch pourra egalement donner des indications d'utilisation. + +C'est aussi au cours de cette phase de configuration qu'il est +indispensable de preciser avec quelles options la bibliotheque doit etre +generee. En particulier il est necessaire d'indiquer avec quel(s) +gestionnaire(s) de batch doit se faire la compilation de maniere a avoir +acces a l'API. L'utilitaire @file{ccmake}, qui prend en parametre +le repertoire racine de la bibliotheque de classes Batch, permet de +preciser cette configuration. + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Compilation, Compilation de la documentation, Configuration, Installation de la bibliotheque +@comment node-name, next, previous, up +@section Compilation +@cindex compilation + +La compilation proprement dite n'appelle pas de remarque particuliere : + +@example +$ make +@end example + +On n'oubliera pas d'utiliser les fonctionnalites de chaque @file{make}, +comme par exemple la compilation parallele pour reduire les temps de +compilation (voir @inforef{Top, ,make}). + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Compilation de la documentation, Tests, Compilation, Installation de la bibliotheque +@comment node-name, next, previous, up +@section Compilation de la documentation +@cindex compilation de la documentation + +Normalement la documentation est automatiquement compilee lors de la +compilation de la bibliotheque, mais uniquement sous forme HTML. +Il est egalement possible d'obtenir un fichier @file{.info} ou un fichier +@file{.dvi} qui permettra de generer d'autres formats comme le +PostScript (fichier @file{.ps}) ou le PDF (fichier @file{.pdf}). +Cependant les cibles permettant de generer ces autres formats n'ont pas +ete creees a l'heure actuelle. + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Tests, Installation, Compilation de la documentation, Installation de la bibliotheque +@comment node-name, next, previous, up +@section Tests +@cindex tests + +@unnumberedsubsec Tests de pre-installation + +La bibliotheque de classes Batch dispose d'un ensemble de tests +permettant de verifier le fonctionnement des differents systemes de +batch. Les tests sont executes de la maniere suivante : + +@example +$ make test +@end example + +A la fin des tests, un compte rendu est fait qui avertit l'utilisateur +des tests reussis et des echecs rencontres. Chaque test peut etre rejoue +individuellement grace a l'utilitaire @file{ctest} et en precisant le +nom du test. Par exemple : + +@example +$ ctest -R Local_SSH +@end example + +@unnumberedsubsec Tests de post-installation + +Aucun test de post-installation n'est actuellement possible sur la +bibliotheque de classes Batch. + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Installation, Divers, Tests, Installation de la bibliotheque +@comment node-name, next, previous, up +@section Installation +@cindex installation + +L'installation est la mise a disposition definitive dans le systeme de +la bibliotheque de classes Batch. C'est la derniere etape de la +procedure apres la configuration et la compilation. + +On l'execute de la maniere suivante : + +@example +$ make install +@end example + +La bibliotheque, les fichiers d'entete, la documentation et eventuellement +le module Python sont installes dans le repertoire definitif. + + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Divers, Index, Installation, Top +@comment node-name, next, previous, up +@chapter Divers +@cindex divers + + + + + +@c ---------------------- +@c ---------------------- +@c ---------------------- + +@node Index, Top , Divers, Top +@comment node-name, next, previous, up +@unnumbered Index + +@heading Index des concepts +@printindex cp + +@heading Index des fonctions et des methodes +@printindex fn + +@bye + diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 0000000..5a5e3ab --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,32 @@ +# Copyright (C) 2007-2008 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 +# + +SET (TEXI_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Batch.texi) + +ADD_CUSTOM_TARGET(doc ALL + ${MAKEINFO_EXECUTABLE} --html ${TEXI_FILE} + DEPENDS ${TEXI_FILE} + ) + +FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Batch) + +INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Batch DESTINATION share/doc) diff --git a/doc/version.texi b/doc/version.texi new file mode 100644 index 0000000..95f3bec --- /dev/null +++ b/doc/version.texi @@ -0,0 +1,4 @@ +@set UPDATED 23 March 2009 +@set UPDATED-MONTH March 2009 +@set EDITION 1.0.0 +@set VERSION 1.0.0 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..b91a7e8 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,87 @@ +# Copyright (C) 2007-2008 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 +# + +# These macros are used to create the lists of source files and header files in global variables. +# If we move to cmake 2.6, this can be done more cleanly with the PARENT_SCOPE option. +MACRO(APPEND_TO_GLOBAL_VAR VAR) + SET(${VAR} ${${VAR}} ${ARGN} CACHE INTERNAL "") +ENDMACRO(APPEND_TO_GLOBAL_VAR) + +MACRO(APPEND_CLASSES_TO_SRC_FILES) + FOREACH(CLASS ${ARGV}) + APPEND_TO_GLOBAL_VAR(SRC_FILES_BUILD ${CLASS}.cxx) + ENDFOREACH(CLASS ${ARGV}) +ENDMACRO(APPEND_CLASSES_TO_SRC_FILES) + +MACRO(APPEND_CLASSES_TO_HDR_FILES) + FOREACH(CLASS ${ARGV}) + APPEND_TO_GLOBAL_VAR(HDR_FILES_BUILD ${CLASS}.hxx) + ENDFOREACH(CLASS ${ARGV}) +ENDMACRO(APPEND_CLASSES_TO_HDR_FILES) + + + +add_subdirectory (Core) + +IF (BUILD_LOCAL_SUBMISSION) + add_subdirectory (Local) +ENDIF (BUILD_LOCAL_SUBMISSION) + +add_subdirectory (LSF) +add_subdirectory (PBS) +add_subdirectory (SGE) + +# Make a copy of the built value and clear the built value for the next run of cmake +SET(SRC_FILES ${SRC_FILES_BUILD} CACHE INTERNAL "") +SET(SRC_FILES_BUILD CACHE INTERNAL "") + +SET(HDR_FILES ${HDR_FILES_BUILD} CACHE INTERNAL "") +SET(HDR_FILES_BUILD CACHE INTERNAL "") + + + +add_library (Batch SHARED ${SRC_FILES}) + +include_directories(${CMAKE_BINARY_DIR}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Core) + +target_link_libraries(Batch ${CMAKE_THREAD_LIBS_INIT}) + +# If necessary, activate all warnings (useful for debugging and code cleaning) +# add_definitions(-Wall -Werror -ansi -pedantic) + +IF (BUILD_LSF_INTERFACE AND LSF_FOUND) + include_directories(${LSF_INCLUDE_DIR}) + target_link_libraries(Batch ${LSF_LIBRARY} ${LSF_BAT_LIBRARY}) +ENDIF (BUILD_LSF_INTERFACE AND LSF_FOUND) + +IF (BUILD_PBS_INTERFACE AND PBS_FOUND) + include_directories(${PBS_INCLUDE_DIR}) + target_link_libraries(Batch ${PBS_LIBRARY}) +ENDIF (BUILD_PBS_INTERFACE AND PBS_FOUND) + +INSTALL(TARGETS Batch DESTINATION lib) +INSTALL(FILES ${HDR_FILES} DESTINATION include/Batch) + +IF (BUILD_PYTHON_WRAPPING AND PYTHON_INCLUDE_PATH AND PYTHON_LIBRARIES AND SWIG_FOUND) + add_subdirectory (Python) +ENDIF (BUILD_PYTHON_WRAPPING AND PYTHON_INCLUDE_PATH AND PYTHON_LIBRARIES AND SWIG_FOUND) diff --git a/src/Core/Batch_APIInternalFailureException.cxx b/src/Core/Batch_APIInternalFailureException.cxx new file mode 100644 index 0000000..b75e3bd --- /dev/null +++ b/src/Core/Batch_APIInternalFailureException.cxx @@ -0,0 +1,37 @@ +// Copyright (C) 2007-2008 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 +// +/* + * APIInternalFailureException.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Thu Nov 20 15:15:42 2003 + * Projet : Salome 2 + * + */ + +#include "Batch_APIInternalFailureException.hxx" +using namespace std; + +namespace Batch { + +} diff --git a/src/Core/Batch_APIInternalFailureException.hxx b/src/Core/Batch_APIInternalFailureException.hxx new file mode 100644 index 0000000..a270a6a --- /dev/null +++ b/src/Core/Batch_APIInternalFailureException.hxx @@ -0,0 +1,51 @@ +// Copyright (C) 2007-2008 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 +// +/* + * APIInternalFailureException.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Thu Nov 20 15:15:41 2003 + * Projet : Salome 2 + * + */ + +#ifndef _APIINTERNALFAILUREEXCEPTION_H_ +#define _APIINTERNALFAILUREEXCEPTION_H_ + +#include "Batch_Defines.hxx" + +#include "Batch_GenericException.hxx" +#include "Batch_GenericException.hxx" + +namespace Batch { + + class BATCH_EXPORT APIInternalFailureException : public GenericException + { + public: + // Constructeur + APIInternalFailureException(std::string ch = "undefined") : GenericException("APIInternalFailureException", ch) {} + }; + +} + +#endif diff --git a/src/Core/Batch_BatchManager.cxx b/src/Core/Batch_BatchManager.cxx new file mode 100644 index 0000000..d4744af --- /dev/null +++ b/src/Core/Batch_BatchManager.cxx @@ -0,0 +1,149 @@ +// Copyright (C) 2007-2008 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.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#include +#include +#include +#ifdef WIN32 +# include +#else +# include +#endif + +//#include "MEDMEM_STRING.hxx" +#include "Batch_Job.hxx" +#include "Batch_JobId.hxx" +#include "Batch_JobInfo.hxx" +#include "Batch_InvalidArgumentException.hxx" +#include "Batch_FactBatchManager.hxx" +#include "Batch_BatchManager.hxx" +using namespace std; + +namespace Batch { + + // Constructeur +// BatchManager::BatchManager(string host) throw(InvalidArgumentException) : _hostname(host), jobid_map() +// { +// // On verifie que le hostname est correct +// if (!gethostbyname(_hostname.c_str())) { // hostname unknown from network +// string msg = "hostname \""; +// msg += _hostname; +// msg += "\" unknown from the network"; +// throw InvalidArgumentException(msg.c_str()); +// } +// } + BatchManager::BatchManager(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException) : _hostname(host), jobid_map(), _parent(parent) + { + // On verifie que le hostname est correct + if (!gethostbyname(_hostname.c_str())) { // hostname unknown from network + string msg = "hostname \""; + msg += _hostname; + msg += "\" unknown from the network"; + throw InvalidArgumentException(msg.c_str()); + } + } + + // Destructeur + BatchManager::~BatchManager() + { + // Nothing to do + } + + string BatchManager::__repr__() const + { + ostringstream oss; + oss << "getType() : "unknown (no factory)") << "' connected to server '" << _hostname << "'>"; + return oss.str(); + } + + // Recupere le l'identifiant d'un job deja soumis au BatchManager +// const JobId BatchManager::getJobIdByReference(const string & ref) +// { +// return JobId(this, ref); +// } + const JobId BatchManager::getJobIdByReference(const char * ref) + { + return JobId(this, ref); + } + +// // Methode pour le controle des jobs : soumet un job au gestionnaire +// const JobId BatchManager::submitJob(const Job & job) +// { +// static int idx = 0; +// //MEDMEM::STRING sst; +// ostringstream sst; +// sst << "Jobid_" << idx++; +// JobId id(this, sst.str()); +// return id; +// } + +// // Methode pour le controle des jobs : retire un job du gestionnaire +// void BatchManager::deleteJob(const JobId & jobid) +// { +// // Nothing to do +// } + +// // Methode pour le controle des jobs : suspend un job en file d'attente +// void BatchManager::holdJob(const JobId & jobid) +// { +// // Nothing to do +// } + +// // Methode pour le controle des jobs : relache un job suspendu +// void BatchManager::releaseJob(const JobId & jobid) +// { +// // Nothing to do +// } + +// // Methode pour le controle des jobs : modifie un job en file d'attente +// void BatchManager::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env) +// { +// // Nothing to do +// } + +// // Methode pour le controle des jobs : modifie un job en file d'attente +// void BatchManager::alterJob(const JobId & jobid, const Parametre & param) +// { +// // Nothing to do +// } + +// // Methode pour le controle des jobs : modifie un job en file d'attente +// void BatchManager::alterJob(const JobId & jobid, const Environnement & env) +// { +// // Nothing to do +// } + +// // Methode pour le controle des jobs : renvoie l'etat du job +// JobInfo BatchManager::queryJob(const JobId & jobid) +// { +// return JobInfo(); +// } + +} diff --git a/src/Core/Batch_BatchManager.hxx b/src/Core/Batch_BatchManager.hxx new file mode 100644 index 0000000..bda2961 --- /dev/null +++ b/src/Core/Batch_BatchManager.hxx @@ -0,0 +1,85 @@ +// Copyright (C) 2007-2008 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.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#ifndef _BATCHMANAGER_H_ +#define _BATCHMANAGER_H_ + +#include "Batch_Defines.hxx" + +#include +#include +#include "Batch_Job.hxx" +#include "Batch_JobId.hxx" +#include "Batch_JobInfo.hxx" +#include "Batch_InvalidArgumentException.hxx" + +namespace Batch { + + class Job; + class JobId; + class JobInfo; + class FactBatchManager; + + class BATCH_EXPORT BatchManager + { + public: + // Constructeur et destructeur + //BatchManager(std::string host="localhost") throw(InvalidArgumentException); // connexion a la machine host + BatchManager(const Batch::FactBatchManager * parent, const char * host="localhost") throw(InvalidArgumentException); // connexion a la machine host + virtual ~BatchManager(); + virtual std::string __repr__() const; + + // Recupere le l'identifiant d'un job deja soumis au BatchManager + //virtual const JobId getJobIdByReference(const std::string & ref); + virtual const Batch::JobId getJobIdByReference(const char * ref); + + // Methodes pour le controle des jobs : virtuelles pures + virtual const Batch::JobId submitJob(const Batch::Job & job) = 0; // soumet un job au gestionnaire + virtual void deleteJob(const Batch::JobId & jobid) = 0; // retire un job du gestionnaire + virtual void holdJob(const Batch::JobId & jobid) = 0; // suspend un job en file d'attente + virtual void releaseJob(const Batch::JobId & jobid) = 0; // relache un job suspendu + virtual void alterJob(const Batch::JobId & jobid, const Batch::Parametre & param, const Batch::Environnement & env) = 0; // modifie un job en file d'attente + virtual void alterJob(const Batch::JobId & jobid, const Batch::Parametre & param) = 0; // modifie un job en file d'attente + virtual void alterJob(const Batch::JobId & jobid, const Batch::Environnement & env) = 0; // modifie un job en file d'attente + virtual Batch::JobInfo queryJob(const Batch::JobId & jobid) = 0; // renvoie l'etat du job + + protected: + std::string _hostname; // serveur ou tourne le BatchManager + // std::map< const std::string, const Batch::JobId * > jobid_map; // table des jobs deja soumis + std::map< std::string, const Batch::JobId * > jobid_map; // table des jobs deja soumis + const Batch::FactBatchManager * _parent; + + private: + + }; + +} + +#endif diff --git a/src/Core/Batch_BatchManagerCatalog.cxx b/src/Core/Batch_BatchManagerCatalog.cxx new file mode 100644 index 0000000..957285c --- /dev/null +++ b/src/Core/Batch_BatchManagerCatalog.cxx @@ -0,0 +1,99 @@ +// Copyright (C) 2007-2008 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 +// +/* + * BatchManagerCatalog.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2004 + * Projet : SALOME 2 + * Modified by Renaud Barate, April 2009 + * + */ + +#include +#include +#include +#include "Batch_BatchManagerCatalog.hxx" +#include "Batch_FactBatchManager.hxx" +using namespace std; + +namespace Batch { + + // Constructeur + BatchManagerCatalog::BatchManagerCatalog() + { + pthread_mutex_init(&_mutex, NULL); + } + + // Destructeur + BatchManagerCatalog::~BatchManagerCatalog() + { + pthread_mutex_destroy(&_mutex); + } + + /** + * Returns the catalog singleton. + * We use the construct-on-first-use idiom here because otherwise there could be a problem with + * the initialization order between the factory singletons and this catalog. Note that since the + * destructors do not depend on the other objects, the order is not important for destruction. + */ + BatchManagerCatalog& BatchManagerCatalog::getInstance () { + static BatchManagerCatalog instance; + return instance; + } + + void BatchManagerCatalog::addFactBatchManager(const char * type, FactBatchManager * pFBM) + { + if (pFBM) { // *** section critique *** + pthread_mutex_lock(&_mutex); + _catalog[type] = pFBM; + pthread_mutex_unlock(&_mutex); + } + } + + // Functor + FactBatchManager * BatchManagerCatalog::operator() (const char * type) + { + pthread_mutex_lock(&_mutex); + FactBatchManager * result = _catalog[type]; + pthread_mutex_unlock(&_mutex); + return result; + } + + std::map * BatchManagerCatalog::dict() + { + return &_catalog; + } + + string BatchManagerCatalog::__repr__() const + { + ostringstream oss; + oss << "::const_iterator it = _catalog.begin(); it != _catalog.end(); it++, sep=", ") { + oss << sep << "'" << (*it).first << "' : '" << (*it).second->__repr__() << "'"; + } + oss << "}>"; + return oss.str(); + } + +} diff --git a/src/Core/Batch_BatchManagerCatalog.hxx b/src/Core/Batch_BatchManagerCatalog.hxx new file mode 100644 index 0000000..f171419 --- /dev/null +++ b/src/Core/Batch_BatchManagerCatalog.hxx @@ -0,0 +1,75 @@ +// Copyright (C) 2007-2008 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 +// +/* + * BatchManagerCatalog.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2004 + * Projet : SALOME 2 + * Modified by Renaud Barate, April 2009 + * + */ + +#ifndef _CATALOG_H_ +#define _CATALOG_H_ + +#include "Batch_Defines.hxx" + +#include +#include +#include + +namespace Batch { + + class FactBatchManager; + + class BATCH_EXPORT BatchManagerCatalog + { + public: + static BatchManagerCatalog& getInstance(); + + void addFactBatchManager(const char * type, Batch::FactBatchManager * pFBM); + Batch::FactBatchManager * operator() (const char * type); + + virtual std::map * dict(); + virtual std::string __repr__() const; + + protected: + // Constructeur + BatchManagerCatalog(); + // Destructeur + virtual ~BatchManagerCatalog(); + + std::map _catalog; + pthread_mutex_t _mutex; + + private: + + // Forbid the use of copy constructor and assignment operator + BatchManagerCatalog(const BatchManagerCatalog & orig) {} + BatchManagerCatalog& operator=(const BatchManagerCatalog & orig) {} + + }; + +} + +#endif diff --git a/src/Core/Batch_BatchManager_eClient.cxx b/src/Core/Batch_BatchManager_eClient.cxx new file mode 100644 index 0000000..1bbabf8 --- /dev/null +++ b/src/Core/Batch_BatchManager_eClient.cxx @@ -0,0 +1,254 @@ +// Copyright (C) 2007-2008 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_eLSF.cxx : emulation of LSF client +* +* Auteur : Bernard SECHER - CEA DEN +* Mail : mailto:bernard.secher@cea.fr +* Date : Thu Apr 24 10:17:22 2008 +* Projet : PAL Salome +* +*/ + +#include "Batch_BatchManager_eClient.hxx" +#include "Batch_RunTimeException.hxx" +#include "Batch_NotYetImplementedException.hxx" + +#include +#include +#include +#include +#include +#include + +using namespace std; + + +namespace Batch { + + BatchManager_eClient::BatchManager_eClient(const Batch::FactBatchManager * parent, const char* host, + const char* protocol, const char* mpiImpl) + : BatchManager(parent, host), _protocol(protocol), _username("") + { + // instanciation of mpi implementation needed to launch executable in batch script + _mpiImpl = FactoryMpiImpl(mpiImpl); + } + + // Destructeur + BatchManager_eClient::~BatchManager_eClient() + { + // Nothing to do + delete _mpiImpl; + } + + void BatchManager_eClient::exportInputFiles(const Job& job) + { + int status; + Parametre params = job.getParametre(); + Versatile V = params[INFILE]; + Versatile::iterator Vit; + string command; + string copy_command; + _username = string(params[USER]); + + // Test protocol + if( _protocol == "rsh" ) + copy_command = "rcp "; + else if( _protocol == "ssh" ) + copy_command = "scp "; + else + throw EmulationException("Unknown protocol : only rsh and ssh are known !"); + + // First step : creating batch tmp files directory + command = _protocol; + command += " "; + if(_username != ""){ + command += _username; + command += "@"; + } + command += _hostname; + command += " \"mkdir -p "; + command += string(params[TMPDIR]); + command += "\"" ; + cerr << command.c_str() << endl; + status = system(command.c_str()); + if(status) { + std::ostringstream oss; + oss << status; + std::string ex_mess("Error of connection on remote host ! status = "); + ex_mess += oss.str(); + throw EmulationException(ex_mess.c_str()); + } + + // Second step : copy fileToExecute into + // batch tmp files directory + string executeFile = params[EXECUTABLE]; + if( executeFile.size() > 0 ){ + command = copy_command; + command += string(params[EXECUTABLE]); + command += " "; + if(_username != ""){ + command += _username; + command += "@"; + } + command += _hostname; + command += ":"; + command += string(params[TMPDIR]); + cerr << command.c_str() << endl; + status = system(command.c_str()); + if(status) { + std::ostringstream oss; + oss << status; + std::string ex_mess("Error of connection on remote host ! status = "); + ex_mess += oss.str(); + throw EmulationException(ex_mess.c_str()); + } + } + + // Third step : copy filesToExportList into + // batch tmp files directory + for(Vit=V.begin(); Vit!=V.end(); Vit++) { + CoupleType cpt = *static_cast< CoupleType * >(*Vit); + Couple inputFile = cpt; + command = copy_command; + command += inputFile.getLocal(); + command += " "; + if(_username != ""){ + command += _username; + command += "@"; + } + command += _hostname; + command += ":"; + command += inputFile.getRemote(); + cerr << command.c_str() << endl; + status = system(command.c_str()); + if(status) { + std::ostringstream oss; + oss << status; + std::string ex_mess("Error of connection on remote host ! status = "); + ex_mess += oss.str(); + throw EmulationException(ex_mess.c_str()); + } + } + + } + + void BatchManager_eClient::importOutputFiles( const Job & job, const string directory ) throw(EmulationException) + { + string command; + int status; + + Parametre params = job.getParametre(); + Versatile V = params[OUTFILE]; + Versatile::iterator Vit; + + for(Vit=V.begin(); Vit!=V.end(); Vit++) { + CoupleType cpt = *static_cast< CoupleType * >(*Vit); + Couple outputFile = cpt; + if( _protocol == "rsh" ) + command = "rcp "; + else if( _protocol == "ssh" ) + command = "scp "; + else + throw EmulationException("Unknown protocol"); + + if (_username != ""){ + command += _username; + command += "@"; + } + command += _hostname; + command += ":"; + command += outputFile.getRemote(); + command += " "; + command += directory; + cerr << command.c_str() << endl; + status = system(command.c_str()); + if(status) + { + // Try to get what we can (logs files) + // throw BatchException("Error of connection on remote host"); + std::string mess("Copy command failed ! status is :"); + ostringstream status_str; + status_str << status; + mess += status_str.str(); + cerr << mess << endl; + } + } + + } + + MpiImpl *BatchManager_eClient::FactoryMpiImpl(string mpiImpl) throw(EmulationException) + { + if(mpiImpl == "lam") + return new MpiImpl_LAM(); + else if(mpiImpl == "mpich1") + return new MpiImpl_MPICH1(); + else if(mpiImpl == "mpich2") + return new MpiImpl_MPICH2(); + else if(mpiImpl == "openmpi") + return new MpiImpl_OPENMPI(); + else if(mpiImpl == "slurm") + return new MpiImpl_SLURM(); + else if(mpiImpl == "prun") + return new MpiImpl_PRUN(); + else if(mpiImpl == "nompi") + throw EmulationException("you must specify an mpi implementation for batch manager"); + else{ + ostringstream oss; + oss << mpiImpl << " : not yet implemented"; + throw EmulationException(oss.str().c_str()); + } + } + + /** + * This method creates a temporary file and opens an output stream to write into this file. + * The file is created with the pattern "/tmp/batch_XXXXXX" where the X's are replaced by random + * characters. The caller is responsible for closing and deleting the file when it is no more used. + * \param outputStream an output stream that will be opened for writing in the temporary file. If + * the stream is already open, it will be closed first. + * \return the name of the created file. + */ + string BatchManager_eClient::createAndOpenTemporaryFile(ofstream & outputStream) const + { + string fileName; +#ifdef WIN32 + throw NotYetImplementedException("Temporary file creation in Batch library has not been ported to Windows yet"); +#else + char * tmpFileName = strdup("/tmp/batch_XXXXXX"); + int fd = mkstemp(tmpFileName); + if (fd == -1) + { + throw RunTimeException("Can't create temporary file"); + } + + if (outputStream.is_open()) + outputStream.close(); + outputStream.open(tmpFileName); + close(fd); // Close the file descriptor so that the file is not opened twice + + fileName = tmpFileName; + delete[] tmpFileName; +#endif + return fileName; + } + +} diff --git a/src/Core/Batch_BatchManager_eClient.hxx b/src/Core/Batch_BatchManager_eClient.hxx new file mode 100644 index 0000000..938e8ec --- /dev/null +++ b/src/Core/Batch_BatchManager_eClient.hxx @@ -0,0 +1,70 @@ +// Copyright (C) 2007-2008 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_eLSF.hxx : emulation of client + * + * Auteur : Bernard SECHER - CEA DEN + * Mail : mailto:bernard.secher@cea.fr + * Date : Thu Apr 24 10:17:22 2008 + * Projet : PAL Salome + * + */ + +#ifndef _BATCHMANAGER_eClient_H_ +#define _BATCHMANAGER_eClient_H_ + +#include "Batch_Defines.hxx" +#include "Batch_MpiImpl.hxx" +#include "Batch_BatchManager.hxx" +#include "Batch_EmulationException.hxx" + +#include + +namespace Batch { + + class Job; + + class BATCH_EXPORT BatchManager_eClient : public BatchManager + { + public: + // Constructeur et destructeur + BatchManager_eClient(const Batch::FactBatchManager * parent, const char* host="localhost", + const char* protocol="ssh", const char* mpiImpl="mpich1"); + virtual ~BatchManager_eClient(); + void importOutputFiles( const Job & job, const std::string directory ) throw(EmulationException); + + protected: + std::string _protocol; // protocol to access _hostname + std::string _username; // username to access _hostname + MpiImpl *_mpiImpl; // Mpi implementation to launch executable in batch script + + std::string createAndOpenTemporaryFile(std::ofstream & outputStream) const; + MpiImpl* FactoryMpiImpl(std::string mpiImpl) throw(EmulationException); + void exportInputFiles(const Job & job); + + private: + + }; + +} + +#endif diff --git a/src/Core/Batch_BoolType.cxx b/src/Core/Batch_BoolType.cxx new file mode 100644 index 0000000..138b4ae --- /dev/null +++ b/src/Core/Batch_BoolType.cxx @@ -0,0 +1,66 @@ +// Copyright (C) 2007-2008 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 +// +/* + * BoolType.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#include +#include +#include "Batch_BoolType.hxx" +using namespace std; + +namespace Batch { + + // Conversion en chaine + string BoolType::affiche() const + { + return _data ? string("true") : string("false"); + } + + // Operateur d'affectation + BoolType & BoolType::operator =(bool b) + { + _data = b; + return *this; + } + + // Conversion en bool + BoolType::operator bool() const + { + return this->_data; + } + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + GenericType * BoolType::clone() const + { + BoolType * pB = new BoolType(this->_data); + assert(pB != 0); + return pB; + } + +} diff --git a/src/Core/Batch_BoolType.hxx b/src/Core/Batch_BoolType.hxx new file mode 100644 index 0000000..99e87ad --- /dev/null +++ b/src/Core/Batch_BoolType.hxx @@ -0,0 +1,69 @@ +// Copyright (C) 2007-2008 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 +// +/* + * BoolType.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#ifndef _BOOLTYPE_H_ +#define _BOOLTYPE_H_ + +#include "Batch_Defines.hxx" + +#include +#include "Batch_GenericType.hxx" + +namespace Batch { + + class BATCH_EXPORT BoolType : public GenericType + { + public: + // Constructeur + BoolType(const bool b=false) : _data(b) {} + + // Conversion en chaine + virtual std::string affiche() const; + + // Operateur d'affectation + virtual BoolType & operator =(bool); + + // Conversion en bool + virtual operator bool() const; + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + virtual GenericType * clone() const; + + protected: + bool _data; + + private: + + }; + +} + +#endif diff --git a/src/Core/Batch_CharType.cxx b/src/Core/Batch_CharType.cxx new file mode 100644 index 0000000..d1649c3 --- /dev/null +++ b/src/Core/Batch_CharType.cxx @@ -0,0 +1,66 @@ +// Copyright (C) 2007-2008 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 +// +/* + * CharType.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#include +#include +#include "Batch_CharType.hxx" +using namespace std; + +namespace Batch { + + // Conversion en chaine + string CharType::affiche() const + { + return string(1, _data); + } + + // Operateur d'affectation + CharType & CharType::operator =(char c) + { + _data = c; + return *this; + } + + // Conversion en char + CharType::operator char() const + { + return this->_data; + } + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + GenericType * CharType::clone() const + { + CharType * pC = new CharType(this->_data); + assert(pC != 0); + return pC; + } + +} diff --git a/src/Core/Batch_CharType.hxx b/src/Core/Batch_CharType.hxx new file mode 100644 index 0000000..2a6afca --- /dev/null +++ b/src/Core/Batch_CharType.hxx @@ -0,0 +1,70 @@ +// Copyright (C) 2007-2008 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 +// +/* + * CharType.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#ifndef _CHARTYPE_H_ +#define _CHARTYPE_H_ + +#include "Batch_Defines.hxx" + +#include +#include "Batch_GenericType.hxx" + +namespace Batch { + + class BATCH_EXPORT CharType : public GenericType + { + public: + // Constructeur + CharType(const char c=0) : _data(c) {} + + // Conversion en chaine + virtual std::string affiche() const; + + // Operateur d'affectation + virtual CharType & operator =(char); + + // Conversion en char + virtual operator char() const; + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + virtual GenericType * clone() const; + + protected: + char _data; + + private: + + }; + +} + +#endif + diff --git a/src/Core/Batch_ConnexionFailureException.cxx b/src/Core/Batch_ConnexionFailureException.cxx new file mode 100644 index 0000000..e1294f8 --- /dev/null +++ b/src/Core/Batch_ConnexionFailureException.cxx @@ -0,0 +1,37 @@ +// Copyright (C) 2007-2008 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 +// +/* + * ConnexionFailureException.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Thu Nov 13 11:24:31 2003 + * Projet : Salome 2 + * + */ + +#include "Batch_ConnexionFailureException.hxx" +using namespace std; + +namespace Batch { + +} diff --git a/src/Core/Batch_ConnexionFailureException.hxx b/src/Core/Batch_ConnexionFailureException.hxx new file mode 100644 index 0000000..178fecd --- /dev/null +++ b/src/Core/Batch_ConnexionFailureException.hxx @@ -0,0 +1,53 @@ +// Copyright (C) 2007-2008 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 +// +/* + * ConnexionFailureException.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Thu Nov 13 11:24:31 2003 + * Projet : Salome 2 + * + */ + +#ifndef _CONNEXIONFAILUREEXCEPTION_H_ +#define _CONNEXIONFAILUREEXCEPTION_H_ + +#include "Batch_Defines.hxx" + + +#include "Batch_GenericException.hxx" + +namespace Batch { + + class BATCH_EXPORT ConnexionFailureException : public GenericException + { + public: + // Constructeur + ConnexionFailureException(std::string ch = "undefined") : GenericException("ConnexionFailureException", ch) {} + + }; + +} + +#endif + diff --git a/src/Core/Batch_Couple.cxx b/src/Core/Batch_Couple.cxx new file mode 100644 index 0000000..d70367b --- /dev/null +++ b/src/Core/Batch_Couple.cxx @@ -0,0 +1,63 @@ +// Copyright (C) 2007-2008 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 +// +/* + * Couple.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Tue Dec 9 15:00:35 2003 + * Projet : Salome 2 + * + */ + +#include "Batch_Couple.hxx" +using namespace std; + +namespace Batch { + + // Operateur d'affectation + Couple & Couple::operator =(const Couple & C) + { + _local = C._local; + _remote = C._remote; + return *this; + } + + // Conversion en chaine + string Couple::str() const + { + string res; + res = "Couple(local : "; + res += _local; + res += ", remote : "; + res += _remote; + res += ")"; + return res; + } + + // Operateur pour l'affichage sur un stream + ostream & operator << (ostream & os, const Couple & cp) + { + return os << cp.str(); + } + +} diff --git a/src/Core/Batch_Couple.hxx b/src/Core/Batch_Couple.hxx new file mode 100644 index 0000000..a6ce2d9 --- /dev/null +++ b/src/Core/Batch_Couple.hxx @@ -0,0 +1,76 @@ +// Copyright (C) 2007-2008 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 +// +/* + * Couple.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Tue Dec 9 15:00:35 2003 + * Projet : Salome 2 + * + */ + +#ifndef _COUPLE_H_ +#define _COUPLE_H_ + +#include "Batch_Defines.hxx" + +#include + +namespace Batch { + + class BATCH_EXPORT Couple + { + public: + // Constructeur standard + Couple(const std::string & local="", const std::string & remote="") : _local(local), _remote(remote) {} + + // Constructeur par recopie + Couple(const Couple & C) : _local(C._local), _remote(C._remote) {} + + // Destructeur + virtual ~Couple() {} + + // Operateur pour l'affichage sur un stream + friend std::ostream & operator << (std::ostream & os, const Couple & cp); + + // Operateur d'affectation + virtual Couple & operator =(const Couple &); + + // Conversion en chaine + virtual std::string str() const; + + // Accesseurs + virtual std::string getLocal() const { return _local; } + virtual std::string getRemote() const { return _remote; } + + protected: + std::string _local; // chemin d'acces au fichier local + std::string _remote; // chemin d'acees au fichier distant + + private: + + }; + +} + +#endif diff --git a/src/Core/Batch_CoupleType.cxx b/src/Core/Batch_CoupleType.cxx new file mode 100644 index 0000000..2b6bfea --- /dev/null +++ b/src/Core/Batch_CoupleType.cxx @@ -0,0 +1,73 @@ +// Copyright (C) 2007-2008 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 +// +/* + * CoupleType.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Tue Dec 9 14:51:53 2003 + * Projet : Salome 2 + * + */ + +#include +#include "Batch_CoupleType.hxx" +using namespace std; + +namespace Batch { + + // Conversion en chaine + string CoupleType::affiche() const + { + return _data.str(); + } + + // Operateur d'affectation + CoupleType & CoupleType::operator =(const Couple & C) + { + _data = C; + return *this; + } + + // Conversion en char + CoupleType::operator Couple() const + { + return _data; + } + + // Conversion en chaine + CoupleType::operator string() const + { + return _data.str(); + } + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + GenericType * CoupleType::clone() const + { + CoupleType * pC = new CoupleType(this->_data); + assert(pC != 0); + return pC; + } + +} + diff --git a/src/Core/Batch_CoupleType.hxx b/src/Core/Batch_CoupleType.hxx new file mode 100644 index 0000000..ca2e7e9 --- /dev/null +++ b/src/Core/Batch_CoupleType.hxx @@ -0,0 +1,72 @@ +// Copyright (C) 2007-2008 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 +// +/* + * CoupleType.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Tue Dec 9 14:51:53 2003 + * Projet : Salome 2 + * + */ + +#ifndef _COUPLETYPE_H_ +#define _COUPLETYPE_H_ + +#include "Batch_Defines.hxx" + +#include +#include "Batch_GenericType.hxx" +#include "Batch_Couple.hxx" + +namespace Batch { + + class BATCH_EXPORT CoupleType : public GenericType + { + public: + // Constructeur + CoupleType(const Couple & C) : _data(C) {} + + // Conversion en chaine + virtual std::string affiche() const; + virtual operator std::string() const; + + // Operateur d'affectation + virtual CoupleType & operator =(const Couple & C); + + // Conversion en char + virtual operator Couple() const; + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + virtual GenericType * clone() const; + + protected: + Couple _data; + + private: + + }; + +} + +#endif diff --git a/src/Core/Batch_Date.cxx b/src/Core/Batch_Date.cxx new file mode 100644 index 0000000..2b1959b --- /dev/null +++ b/src/Core/Batch_Date.cxx @@ -0,0 +1,195 @@ +// Copyright (C) 2007-2008 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 +// +/* + * Date.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Wed Nov 26 14:11:42 2003 + * Projet : Salome 2 + * + */ + +#include +#include +#include "Batch_Date.hxx" +using namespace std; + +namespace Batch { + + Date::Date(const long l) + { + time_t l_t = l; + struct tm * p_tm = localtime(&l_t); + _day = p_tm->tm_mday; + _month = p_tm->tm_mon + 1; + _year = p_tm->tm_year + 1900; + _hour = p_tm->tm_hour; + _min = p_tm->tm_min; + _sec = p_tm->tm_sec; + } + + Date::Date(const string s) + { + if ((s == "now") || (s == "Now") || (s == "NOW")) { + long l = time(0); + time_t l_t = l; + struct tm * p_tm = localtime(&l_t); + _day = p_tm->tm_mday; + _month = p_tm->tm_mon + 1; + _year = p_tm->tm_year + 1900; + _hour = p_tm->tm_hour; + _min = p_tm->tm_min; + _sec = p_tm->tm_sec; + + } else { +// char c; +// istringstream ist(s); +// ist >> _day >> c +// >> _month >> c +// >> _year >> c +// >> _hour >> c +// >> _min >> c +// >> _sec; + sscanf(s.c_str(), "%d/%d/%d-%d:%d:%d", &_day, &_month, &_year, &_hour, &_min, &_sec); + } + } + + Date & Date::operator =(long l) + { + time_t l_t = l; + struct tm * p_tm = localtime(&l_t); + _day = p_tm->tm_mday; + _month = p_tm->tm_mon + 1; + _year = p_tm->tm_year + 1900; + _hour = p_tm->tm_hour; + _min = p_tm->tm_min; + _sec = p_tm->tm_sec; + + return *this; + } + + Date & Date::operator +(long l) + { + *this = epoch() + l; + return *this; + } + + Date & Date::operator -(long l) + { + *this = epoch() - l; + return *this; + } + + Date & Date::operator +=(long l) + { + *this = epoch() + l; + return *this; + } + + Date & Date::operator -=(long l) + { + *this = epoch() - l; + return *this; + } + + Date & Date::operator =(const string & s) + { + if ((s == "now") || (s == "Now") || (s == "NOW")) { + long l = time(0); + time_t l_t = l; + struct tm * p_tm = localtime(&l_t); + _day = p_tm->tm_mday; + _month = p_tm->tm_mon + 1; + _year = p_tm->tm_year + 1900; + _hour = p_tm->tm_hour; + _min = p_tm->tm_min; + _sec = p_tm->tm_sec; + + } else { +// char c; +// istringstream ist(s); +// ist >> _day >> c +// >> _month >> c +// >> _year >> c +// >> _hour >> c +// >> _min >> c +// >> _sec; + sscanf(s.c_str(), "%d/%d/%d-%d:%d:%d", &_day, &_month, &_year, &_hour, &_min, &_sec); + } + + return *this; + } + + string Date::str() const + { + char buf[64]; + string datestr; + + // _day to char * + sprintf(buf, "%02d", _day); + datestr += buf; + datestr += "/"; + + // _month to char * + sprintf(buf, "%02d", _month); + datestr += buf; + datestr += "/"; + + // _year to char * + sprintf(buf, "%04d", _year); + datestr += buf; + datestr += "-"; + + // _hour to char * + sprintf(buf, "%02d", _hour); + datestr += buf; + datestr += ":"; + + // _min to char * + sprintf(buf, "%02d", _min); + datestr += buf; + datestr += ":"; + + // _sec to char * + sprintf(buf, "%02d", _sec); + datestr += buf; + + return datestr; + } + + long Date::epoch() const + { + struct tm T; + T.tm_mday = _day; + T.tm_mon = _month - 1; + T.tm_year = _year - 1900; + T.tm_hour = _hour; + T.tm_min = _min; + T.tm_sec = _sec; + return mktime(&T); + } + +} + + +// COMMENTS diff --git a/src/Core/Batch_Date.hxx b/src/Core/Batch_Date.hxx new file mode 100644 index 0000000..a5b2456 --- /dev/null +++ b/src/Core/Batch_Date.hxx @@ -0,0 +1,68 @@ +// Copyright (C) 2007-2008 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 +// +/* + * Date.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Wed Nov 26 14:11:42 2003 + * Projet : Salome 2 + * + */ + +#ifndef _DATE_H_ +#define _DATE_H_ + +#include "Batch_Defines.hxx" + +#include + +namespace Batch { + + class BATCH_EXPORT Date + { + public: + Date(const long l=0); + Date(const std::string s); + virtual ~Date() {} + virtual Date & operator =(long l); + virtual Date & operator +(long l); + virtual Date & operator -(long l); + virtual Date & operator +=(long l); + virtual Date & operator -=(long l); + virtual Date & operator =(const std::string & s); + virtual std::string str() const; + virtual long epoch() const; + + protected: + int _day, _month, _year; + int _hour, _min, _sec; + + private: + + }; + +} + +#endif + +// COMMENTS diff --git a/src/Core/Batch_DateType.cxx b/src/Core/Batch_DateType.cxx new file mode 100644 index 0000000..43d78d9 --- /dev/null +++ b/src/Core/Batch_DateType.cxx @@ -0,0 +1,74 @@ +// Copyright (C) 2007-2008 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 +// +/* + * DateType.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Wed Nov 26 11:15:34 2003 + * Projet : Salome 2 + * + */ +extern "C" { +#include +} +#include +#include "Batch_DateType.hxx" +using namespace std; + +namespace Batch { + + // Conversion en chaine + string DateType::affiche() const + { + return _data.str(); + } + + // Operateur d'affectation + DateType & DateType::operator =(const Date & d) + { + _data = d; + return *this; + } + + // Conversion en Date + DateType::operator Date() const + { + return _data; + } + + // Conversion en long + DateType::operator long() const + { + return _data.epoch(); + } + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + GenericType * DateType::clone() const + { + DateType * pD = new DateType(this->_data); + assert(pD != 0); + return pD; + } + +} diff --git a/src/Core/Batch_DateType.hxx b/src/Core/Batch_DateType.hxx new file mode 100644 index 0000000..bed2846 --- /dev/null +++ b/src/Core/Batch_DateType.hxx @@ -0,0 +1,74 @@ +// Copyright (C) 2007-2008 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 +// +/* + * DateType.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Wed Nov 26 11:15:34 2003 + * Projet : Salome 2 + * + */ + +#ifndef _DATETYPE_H_ +#define _DATETYPE_H_ + +#include "Batch_Defines.hxx" + +#include +#include "Batch_GenericType.hxx" +#include "Batch_Date.hxx" + +namespace Batch { + + class BATCH_EXPORT DateType : public GenericType + { + public: + // Constructeur + DateType(const Date & d) : _data(d) {}; + + // Conversion en chaine + virtual std::string affiche() const; + + // Operateur d'affectation + virtual DateType & operator =(const Date &); + + // Conversion en Date + virtual operator Date() const; + + // Conversion en long + virtual operator long() const; + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + virtual GenericType * clone() const; + + protected: + Date _data; + + private: + }; + +} + +#endif + diff --git a/src/Core/Batch_Defines.hxx b/src/Core/Batch_Defines.hxx new file mode 100644 index 0000000..84548ad --- /dev/null +++ b/src/Core/Batch_Defines.hxx @@ -0,0 +1,42 @@ +// Copyright (C) 2007-2008 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 +// +// File : Batch_Defines.hxx +// Author : Alexander A. BORODIN +// Module : SALOME +// +#ifndef _BATCH_Defines_HXX_ +#define _BATCH_Defines_HXX_ + +#ifdef WIN32 +# if defined BATCH_EXPORTS || defined SalomeBatch_EXPORTS +# define BATCH_EXPORT __declspec( dllexport ) +# else +# define BATCH_EXPORT __declspec( dllimport ) +# endif +# define RM "rm" +# define RCP "rpc" +# define RSH "rsh" +#else +# define BATCH_EXPORT +#endif + +#endif diff --git a/src/Core/Batch_EmulationException.cxx b/src/Core/Batch_EmulationException.cxx new file mode 100644 index 0000000..3842a5a --- /dev/null +++ b/src/Core/Batch_EmulationException.cxx @@ -0,0 +1,35 @@ +// Copyright (C) 2007-2008 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 +// +/* + * EmulationException.cxx : + * + * Author : Renaud BARATE - EDF R&D + * Date : April 2009 + * + */ + +#include "Batch_EmulationException.hxx" +using namespace std; + +namespace Batch { + +} diff --git a/src/Core/Batch_EmulationException.hxx b/src/Core/Batch_EmulationException.hxx new file mode 100644 index 0000000..fa5171d --- /dev/null +++ b/src/Core/Batch_EmulationException.hxx @@ -0,0 +1,48 @@ +// Copyright (C) 2007-2008 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 +// +/* + * EmulationException.hxx : + * + * Author : Renaud BARATE - EDF R&D + * Date : April 2009 + * + */ + +#ifndef _EMULATIONEXCEPTION_H_ +#define _EMULATIONEXCEPTION_H_ + +#include "Batch_Defines.hxx" +#include "Batch_GenericException.hxx" + +namespace Batch { + + class BATCH_EXPORT EmulationException : public GenericException + { + public: + // Constructor + EmulationException(const std::string & ch = "undefined") + : GenericException("EmulationException", ch) {} + }; + +} + +#endif diff --git a/src/Core/Batch_Environnement.cxx b/src/Core/Batch_Environnement.cxx new file mode 100644 index 0000000..f74b030 --- /dev/null +++ b/src/Core/Batch_Environnement.cxx @@ -0,0 +1,38 @@ +// Copyright (C) 2007-2008 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 +// +/* + * Environnement.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Thu Oct 16 11:37:47 2003 + * Projet : Salome 2 + * + */ + +#include "Batch_Environnement.hxx" +using namespace std; + +namespace Batch { + + +} diff --git a/src/Core/Batch_Environnement.hxx b/src/Core/Batch_Environnement.hxx new file mode 100644 index 0000000..354be1b --- /dev/null +++ b/src/Core/Batch_Environnement.hxx @@ -0,0 +1,48 @@ +// Copyright (C) 2007-2008 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 +// +/* + * Environnement.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Thu Oct 16 11:37:47 2003 + * Projet : Salome 2 + * + */ + +#ifndef _ENVIRONNEMENT_H_ +#define _ENVIRONNEMENT_H_ + +#include "Batch_Defines.hxx" + + +#include +#include + +namespace Batch { + + typedef std::map < std::string, std::string > Environnement; + +} + +#endif + diff --git a/src/Core/Batch_FactBatchManager.cxx b/src/Core/Batch_FactBatchManager.cxx new file mode 100644 index 0000000..b4b32ce --- /dev/null +++ b/src/Core/Batch_FactBatchManager.cxx @@ -0,0 +1,68 @@ +// Copyright (C) 2007-2008 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.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2004 + * Projet : SALOME 2 + * + */ + +#include +#include +#include +#include "Batch_BatchManagerCatalog.hxx" +#include "Batch_FactBatchManager.hxx" +using namespace std; + +namespace Batch { + + // Constructeur + FactBatchManager::FactBatchManager(const string & _t) : type(_t) + { + BatchManagerCatalog::getInstance().addFactBatchManager(type.c_str(), this); + ostringstream msg; + msg << "FactBatchManager of type '" << type << "' inserted into catalog"; + cerr << msg.str().c_str() << endl; + } + + // Destructeur + FactBatchManager::~FactBatchManager() + { + // Nothing to do + } + + // Accesseur + string FactBatchManager::getType() const + { + return type; + } + + string FactBatchManager::__repr__() const + { + ostringstream oss; + oss << ""; + return oss.str(); + } + +} diff --git a/src/Core/Batch_FactBatchManager.hxx b/src/Core/Batch_FactBatchManager.hxx new file mode 100644 index 0000000..6b73b01 --- /dev/null +++ b/src/Core/Batch_FactBatchManager.hxx @@ -0,0 +1,63 @@ +// Copyright (C) 2007-2008 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.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2004 + * Projet : SALOME 2 + * + */ + +#ifndef _FACTBATCHMANAGER_H_ +#define _FACTBATCHMANAGER_H_ + +#include "Batch_Defines.hxx" + +#include +#include + +namespace Batch { + + class BatchManager; + + class BATCH_EXPORT FactBatchManager + { + public: + // Constructeur et destructeur + FactBatchManager(const std::string & type); + virtual ~FactBatchManager(); + + virtual Batch::BatchManager * operator() (const char * hostname) const = 0; + std::string getType() const; + std::string __repr__() const; + + protected: + std::string type; + + private: + + }; + +} + +#endif diff --git a/src/Core/Batch_FactBatchManager_eClient.cxx b/src/Core/Batch_FactBatchManager_eClient.cxx new file mode 100644 index 0000000..528bed8 --- /dev/null +++ b/src/Core/Batch_FactBatchManager_eClient.cxx @@ -0,0 +1,50 @@ +// Copyright (C) 2007-2008 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_eClient.cxx : emulation of client + * + * Auteur : Bernard SECHER - CEA DEN + * Mail : mailto:bernard.secher@cea.fr + * Date : Thu Apr 24 10:17:22 2008 + * Projet : PAL Salome + * + */ + +#include +#include +#include "Batch_FactBatchManager_eClient.hxx" +using namespace std; + +namespace Batch { + + // Constructeur + FactBatchManager_eClient::FactBatchManager_eClient(const string & _t) : FactBatchManager(_t) + { + } + + // Destructeur + FactBatchManager_eClient::~FactBatchManager_eClient() + { + // Nothing to do + } + +} diff --git a/src/Core/Batch_FactBatchManager_eClient.hxx b/src/Core/Batch_FactBatchManager_eClient.hxx new file mode 100644 index 0000000..82192d7 --- /dev/null +++ b/src/Core/Batch_FactBatchManager_eClient.hxx @@ -0,0 +1,60 @@ +// Copyright (C) 2007-2008 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_eClient.hxx : emulation of client + * + * Auteur : Bernard SECHER - CEA DEN + * Mail : mailto:bernard.secher@cea.fr + * Date : Thu Apr 24 10:17:22 2008 + * Projet : PAL Salome + * + */ + +#ifndef _FACTBATCHMANAGER_eClient_H_ +#define _FACTBATCHMANAGER_eClient_H_ + +#include +#include +#include "Batch_FactBatchManager.hxx" + +namespace Batch { + + class BatchManager_eClient; + + class FactBatchManager_eClient : public FactBatchManager + { + public: + // Constructeur et destructeur + FactBatchManager_eClient(const std::string & type); + virtual ~FactBatchManager_eClient(); + + virtual Batch::BatchManager_eClient * operator() (const char * hostname,const char * protocol, const char * mpi) const = 0; + + protected: + + private: + + }; + +} + +#endif diff --git a/src/Core/Batch_GenericException.cxx b/src/Core/Batch_GenericException.cxx new file mode 100644 index 0000000..4303e1c --- /dev/null +++ b/src/Core/Batch_GenericException.cxx @@ -0,0 +1,37 @@ +// Copyright (C) 2007-2008 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 +// +/* + * GenericException.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Wed Nov 26 10:15:57 2003 + * Projet : Salome 2 + * + */ + +#include "Batch_GenericException.hxx" +using namespace std; + +namespace Batch { + +} diff --git a/src/Core/Batch_GenericException.hxx b/src/Core/Batch_GenericException.hxx new file mode 100644 index 0000000..7961c5c --- /dev/null +++ b/src/Core/Batch_GenericException.hxx @@ -0,0 +1,55 @@ +// Copyright (C) 2007-2008 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 +// +/* + * GenericException.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Wed Nov 26 10:15:56 2003 + * Projet : Salome 2 + * + */ + +#ifndef _GENERICEXCEPTION_H_ +#define _GENERICEXCEPTION_H_ + +#include "Batch_Defines.hxx" + + +#include + +namespace Batch { + + class BATCH_EXPORT GenericException + { + public: + const std::string type; // la nature de l'exception + const std::string message; // la raison de l'exception + + // Constructeur + GenericException(const std::string & tp = "GenericException", + const std::string & ch = "undefined") : type(tp), message(ch) {} + }; + +} + +#endif diff --git a/src/Core/Batch_GenericType.cxx b/src/Core/Batch_GenericType.cxx new file mode 100644 index 0000000..95a5a16 --- /dev/null +++ b/src/Core/Batch_GenericType.cxx @@ -0,0 +1,65 @@ +// Copyright (C) 2007-2008 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 +// +/* + * GenericType.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + + +#include +#include +#include +#include "Batch_GenericType.hxx" +using namespace std; + +namespace Batch { + + // nombre total d'objet GenericType et al. + int GenericType::_nb = 0; + + // Operateur pour l'affichage sur un stream + ostream & operator << (ostream & os, const GenericType & obj) + { + return os << obj.affiche(); + } + + // Conversion en chaine + string GenericType::affiche() const + { + return string("(GenericType : si ce message apparait, vous devez avoir un probleme)"); + } + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + GenericType * GenericType::clone() const + { + GenericType * pG = new GenericType; + assert(pG != 0); + return pG; + } + +} + diff --git a/src/Core/Batch_GenericType.hxx b/src/Core/Batch_GenericType.hxx new file mode 100644 index 0000000..613d1f5 --- /dev/null +++ b/src/Core/Batch_GenericType.hxx @@ -0,0 +1,72 @@ +// Copyright (C) 2007-2008 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 +// +/* + * GenericType.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#ifndef _GENERICTYPE_H_ +#define _GENERICTYPE_H_ + +#include "Batch_Defines.hxx" + + +#include +#include + +namespace Batch { + + class BATCH_EXPORT GenericType + { + public: + // Constructeur et destructeur + GenericType() { _nb++; } + virtual ~GenericType() { _nb--; } + + // Operateur pour l'affichage sur un stream + friend std::ostream & operator << (std::ostream & os, const GenericType & obj); + + // Conversion en chaine + virtual std::string affiche() const; + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + virtual GenericType * clone() const; + + // Retourne le nombre d'objets GenericType et al. + static int getNb() { return _nb; } + + protected: + + private: + static int _nb; // nombre total d'objets GenericType et al. + + }; + +} + +#endif + diff --git a/src/Core/Batch_IntType.cxx b/src/Core/Batch_IntType.cxx new file mode 100644 index 0000000..aa704ef --- /dev/null +++ b/src/Core/Batch_IntType.cxx @@ -0,0 +1,72 @@ +// Copyright (C) 2007-2008 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 +// +/* + * IntType.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#include +#include +#include +//#include "MEDMEM_STRING.hxx" +#include "Batch_IntType.hxx" +using namespace std; + + +namespace Batch { + + // Conversion en chaine + string IntType::affiche() const + { + //MEDMEM::STRING sst; + ostringstream sst; + sst << _data; + return sst.str(); + } + + // Operateur d'affectation + IntType & IntType::operator =(int i) + { + _data = i; + return *this; + } + + // Conversion en int + IntType::operator int() const + { + return this->_data; + } + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + GenericType * IntType::clone() const + { + IntType * pI = new IntType(this->_data); + assert(pI != 0); + return pI; + } + +} diff --git a/src/Core/Batch_IntType.hxx b/src/Core/Batch_IntType.hxx new file mode 100644 index 0000000..79db3b7 --- /dev/null +++ b/src/Core/Batch_IntType.hxx @@ -0,0 +1,69 @@ +// Copyright (C) 2007-2008 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 +// +/* + * IntType.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#ifndef _INTTYPE_H_ +#define _INTTYPE_H_ + +#include "Batch_Defines.hxx" + +#include +#include "Batch_GenericType.hxx" + +namespace Batch { + + class BATCH_EXPORT IntType : public GenericType + { + public: + // Constructeur + IntType(const int i=0) : _data(i) {} + + // Conversion en chaine + virtual std::string affiche() const; + + // Operateur d'affectation + virtual IntType & operator =(int); + + // Conversion en int + virtual operator int() const; + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + virtual GenericType * clone() const; + + protected: + int _data; + + private: + + }; + +} + +#endif diff --git a/src/Core/Batch_InvalidArgumentException.cxx b/src/Core/Batch_InvalidArgumentException.cxx new file mode 100644 index 0000000..b57b834 --- /dev/null +++ b/src/Core/Batch_InvalidArgumentException.cxx @@ -0,0 +1,37 @@ +// Copyright (C) 2007-2008 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 +// +/* + * InvalidArgumentException.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Thu Oct 16 16:18:00 2003 + * Projet : Salome 2 + * + */ + +#include "Batch_InvalidArgumentException.hxx" +using namespace std; + +namespace Batch { + +} diff --git a/src/Core/Batch_InvalidArgumentException.hxx b/src/Core/Batch_InvalidArgumentException.hxx new file mode 100644 index 0000000..ae6e903 --- /dev/null +++ b/src/Core/Batch_InvalidArgumentException.hxx @@ -0,0 +1,53 @@ +// Copyright (C) 2007-2008 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 +// +/* + * InvalidArgumentException.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Thu Oct 16 16:18:00 2003 + * Projet : Salome 2 + * + */ + +#ifndef _INVALIDARGUMENTEXCEPTION_H_ +#define _INVALIDARGUMENTEXCEPTION_H_ + + +#include "Batch_Defines.hxx" + +#include "Batch_GenericException.hxx" + +namespace Batch { + + class BATCH_EXPORT InvalidArgumentException : public GenericException + { + public: + // Constructeur + InvalidArgumentException(const std::string & ch = "undefined") + : GenericException("InvalidArgumentException", ch) {} + }; + +} + +#endif + diff --git a/src/Core/Batch_InvalidKeyException.cxx b/src/Core/Batch_InvalidKeyException.cxx new file mode 100644 index 0000000..2daaabf --- /dev/null +++ b/src/Core/Batch_InvalidKeyException.cxx @@ -0,0 +1,38 @@ +// Copyright (C) 2007-2008 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 +// +/* + * InvalidKeyException.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Wed Oct 15 10:39:51 2003 + * Projet : Salome 2 + * + */ + +#include "Batch_InvalidKeyException.hxx" +using namespace std; + +namespace Batch { + +} + diff --git a/src/Core/Batch_InvalidKeyException.hxx b/src/Core/Batch_InvalidKeyException.hxx new file mode 100644 index 0000000..628c4cd --- /dev/null +++ b/src/Core/Batch_InvalidKeyException.hxx @@ -0,0 +1,57 @@ +// Copyright (C) 2007-2008 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 +// +/* + * InvalidKeyException.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Wed Oct 15 10:39:51 2003 + * Projet : Salome 2 + * + */ + +#ifndef _INVALIDKEYEXCEPTION_H_ +#define _INVALIDKEYEXCEPTION_H_ + +#include "Batch_Defines.hxx" + + +#include "Batch_GenericException.hxx" + +namespace Batch { + + class BATCH_EXPORT InvalidKeyException : public GenericException + { + public: + // Constructeur + InvalidKeyException(std::string ch = "undefined") : GenericException("InvalidKeyException", ch) {} + + protected: + + private: + + }; + +} + +#endif + diff --git a/src/Core/Batch_Job.cxx b/src/Core/Batch_Job.cxx new file mode 100644 index 0000000..2760372 --- /dev/null +++ b/src/Core/Batch_Job.cxx @@ -0,0 +1,117 @@ +// Copyright (C) 2007-2008 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.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#include "Batch_Job.hxx" +#include "Batch_Parametre.hxx" +#include +//#include "MEDMEM_STRING.hxx" +using namespace std; + +namespace Batch { + + // Constructeur + Job::Job() : _param(), _env() + { + // Nothing to do + } + + + // Constructeur + Job::Job(Parametre param) : _param(param), _env() + { + // Nothing to do + } + + + // Constructeur + Job::Job(Environnement env) : _param(), _env(env) + { + // Nothing to do + } + + + // Constructeur + Job::Job(Parametre param, Environnement env) : _param(param), _env(env) + { + // Nothing to do + } + + // Operateur pour l'affichage sur un stream + ostream & operator <<(ostream & os, const Job & job) + { + return os << job.__str__(); + } + + // Accesseur + Batch::Parametre Job::getParametre() const + { + return _param; + } + + // Accesseur + void Job::setParametre(const Batch::Parametre & param) + { + _param = param; + } + + // Accesseur + Environnement Job::getEnvironnement() const + { + return _env; + } + + // Accesseur + void Job::setEnvironnement(const Environnement & env) + { + _env = env; + } + + + // Methode pour l'interfacage avec Python (SWIG) : affichage en Python + string Job::__str__() const { + //MEDMEM::STRING str; + ostringstream str; + str << ""; + return str.str(); + } + + +} diff --git a/src/Core/Batch_Job.hxx b/src/Core/Batch_Job.hxx new file mode 100644 index 0000000..264fb8e --- /dev/null +++ b/src/Core/Batch_Job.hxx @@ -0,0 +1,78 @@ +// Copyright (C) 2007-2008 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.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#ifndef _JOB_H_ +#define _JOB_H_ + +#include "Batch_Defines.hxx" + + +#include "Batch_Parametre.hxx" +#include "Batch_Environnement.hxx" + +namespace Batch { + + class BATCH_EXPORT Job + { + public: + // Constructeurs et destructeur + Job(); + Job(Batch::Parametre param); + Job(Batch::Environnement env); + Job(Batch::Parametre param, Batch::Environnement env); + virtual ~Job() {} + + // Operateur pour l'affichage sur un stream + friend std::ostream & operator <<(std::ostream & os, const Job & job); + + // Accesseurs + Batch::Parametre getParametre() const; + void setParametre(const Batch::Parametre &); + + // Accesseurs + Batch::Environnement getEnvironnement() const; + void setEnvironnement(const Batch::Environnement &); + + // Methodes pour l'interfacage avec Python (SWIG) + // TODO : supprimer ces methodes et transferer leur definitions dans SWIG + std::string __str__() const; // SWIG : affichage en Python + std::string __repr__() const { return __str__(); }; // SWIG : affichage en Python + + protected: + Batch::Parametre _param; // table des parametres batch du job + Batch::Environnement _env; // table des variables d'environnement + + private: + + }; + +} + +#endif diff --git a/src/Core/Batch_JobId.cxx b/src/Core/Batch_JobId.cxx new file mode 100644 index 0000000..c465ada --- /dev/null +++ b/src/Core/Batch_JobId.cxx @@ -0,0 +1,137 @@ +// Copyright (C) 2007-2008 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 +// +/* + * JobId.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#include "Batch_JobId.hxx" +#include "Batch_BatchManager.hxx" +#include +#include +//#include "MEDMEM_STRING.hxx" +using namespace std; + +namespace Batch { + + // Constructeur standard + JobId::JobId() : _p_batchmanager(), _reference("undefined") + { + // Nothing to do + } + + // Constructeur avec le pointeur sur le BatchManager associe et avec une reference + JobId::JobId(BatchManager * _p_bm, string ref) : _p_batchmanager(_p_bm), _reference(ref) + { + // Nothing to do + } + + // Destructeur + JobId::~JobId() + { + // Nothing to do + } + + // Operateur d'affectation entre objets + JobId & JobId::operator =(const JobId & jobid) + { + _p_batchmanager = jobid._p_batchmanager; + _reference = jobid._reference; + + return *this; + } + + // Constructeur par recopie + JobId::JobId(const JobId & jobid) : _p_batchmanager(jobid._p_batchmanager), _reference(jobid._reference) + { + // Nothing to do + } + + // Accesseur pour la reference interne + string JobId::getReference() const + { + return _reference; + } + + // Methode pour le controle du job : retire le job du gestionnaire + void JobId::deleteJob() const + { + assert(_p_batchmanager != 0); + _p_batchmanager->deleteJob(*this); + } + + // Methode pour le controle du job : suspend le job en file d'attente + void JobId::holdJob() const + { + assert(_p_batchmanager != 0); + _p_batchmanager->holdJob(*this); + } + + // Methode pour le controle du job : relache le job suspendu + void JobId::releaseJob() const + { + assert(_p_batchmanager != 0); + _p_batchmanager->releaseJob(*this); + } + + // Methode pour le controle du job : modifie le job en file d'attente + void JobId::alterJob(const Parametre & param, const Environnement & env) const + { + assert(_p_batchmanager != 0); + _p_batchmanager->alterJob(*this, param, env); + } + + // Methode pour le controle du job : modifie le job en file d'attente + void JobId::alterJob(const Parametre & param) const + { + assert(_p_batchmanager != 0); + _p_batchmanager->alterJob(*this, param); + } + + // Methode pour le controle du job : modifie le job en file d'attente + void JobId::alterJob(const Environnement & env) const + { + assert(_p_batchmanager != 0); + _p_batchmanager->alterJob(*this, env); + } + + // Methode pour le controle du job : renvoie l'etat du job + JobInfo JobId::queryJob() const + { + assert(_p_batchmanager != 0); + return _p_batchmanager->queryJob(*this); + } + + + // Methode pour l'interfacage avec Python (SWIG) : affichage en Python + string JobId::__str__() const { + //MEDMEM::STRING str; + ostringstream str; + str << ""; + return str.str(); + } + +} diff --git a/src/Core/Batch_JobId.hxx b/src/Core/Batch_JobId.hxx new file mode 100644 index 0000000..efd2632 --- /dev/null +++ b/src/Core/Batch_JobId.hxx @@ -0,0 +1,91 @@ +// Copyright (C) 2007-2008 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 +// +/* + * JobId.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#ifndef _JOBID_H_ +#define _JOBID_H_ + + +#include "Batch_Defines.hxx" + +#include "Batch_JobInfo.hxx" +#include "Batch_BatchManager.hxx" + +namespace Batch { + + class BatchManager; + + class BATCH_EXPORT JobId + { + friend class BatchManager; + + public: + // Constructeur standard et destructeur + JobId(); + virtual ~JobId(); + + // Constructeur avec le pointeur sur le BatchManager associe et avec une reference + JobId(Batch::BatchManager *, std::string ref); + + // Operateur d'affectation entre objets + virtual JobId & operator =(const Batch::JobId &); + + // Constructeur par recopie + JobId(const Batch::JobId &); + + // Accesseur pour la reference interne + virtual std::string getReference() const; + + // Methodes pour le controle du job + virtual void deleteJob() const; // retire un job du gestionnaire + virtual void holdJob() const; // suspend un job en file d'attente + virtual void releaseJob() const; // relache un job suspendu + virtual void alterJob(const Batch::Parametre & param, const Batch::Environnement & env) const; // modifie un job en file d'attente + virtual void alterJob(const Batch::Parametre & param) const; // modifie un job en file d'attente + virtual void alterJob(const Batch::Environnement & env) const; // modifie un job en file d'attente + virtual void setParametre(const Batch::Parametre & param) { return alterJob(param); } // modifie un job en file d'attente + virtual void setEnvironnement(const Batch::Environnement & env) { return alterJob(env); } // modifie un job en file d'attente + virtual Batch::JobInfo queryJob() const; // renvoie l'etat du job + + // Methodes pour l'interfacage avec Python (SWIG) + // 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: + Batch::BatchManager * _p_batchmanager; // pointeur sur le BatchManager qui controle le job + std::string _reference; // reference du job au sein du BatchManager + + private: + + }; + +} + +#endif diff --git a/src/Core/Batch_JobInfo.cxx b/src/Core/Batch_JobInfo.cxx new file mode 100644 index 0000000..63c8502 --- /dev/null +++ b/src/Core/Batch_JobInfo.cxx @@ -0,0 +1,96 @@ +// Copyright (C) 2007-2008 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.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Thu Nov 6 10:05:30 2003 + * Projet : Salome 2 + * + */ + +#include +#include +#include +//#include "MEDMEM_STRING.hxx" +#include "Batch_JobInfo.hxx" + +using namespace std; + +namespace Batch { + + // Destructeur + JobInfo::~JobInfo() + { + // Nothing to do + } + + + // Operateur pour l'affichage sur un stream + ostream & operator <<(ostream & os, const JobInfo & ji) + { + return os << ji.__str__(); + } + + + // Methodes pour l'interfacage avec Python (SWIG) : affichage en Python + string JobInfo::__str__() const + { + //MEDMEM::STRING sst; + ostringstream sst; + sst << ""; + + return sst.str(); + } + + // Accesseur + Parametre JobInfo::getParametre() const + { + return _param; + } + + // Accesseur + Environnement JobInfo::getEnvironnement() const + { + return _env; + } + + +} diff --git a/src/Core/Batch_JobInfo.hxx b/src/Core/Batch_JobInfo.hxx new file mode 100644 index 0000000..f4b54f1 --- /dev/null +++ b/src/Core/Batch_JobInfo.hxx @@ -0,0 +1,79 @@ +// Copyright (C) 2007-2008 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.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Thu Nov 6 10:05:30 2003 + * Projet : Salome 2 + * + */ + +#ifndef _JOBINFO_H_ +#define _JOBINFO_H_ + +#include "Batch_Defines.hxx" + +#include +#include +#include "Batch_Parametre.hxx" +#include "Batch_Environnement.hxx" + +namespace Batch { + + class BATCH_EXPORT JobInfo + { + public: + // Constructeur standard et destructeur + JobInfo() : _param(), _env() {}; + virtual ~JobInfo(); + + // Constructeur par recopie + JobInfo(const JobInfo & jinfo) : _param(jinfo._param), _env(jinfo._env) {}; + + // Operateur pour l'affichage sur un stream + friend std::ostream & operator <<(std::ostream & os, const JobInfo & ji); + + // Accesseurs + // _CS_gbo Ajout explicite du namespace pour les besoins de swig (mauvaise gestion + // des namespace par swig. + virtual Batch::Parametre getParametre() const; + virtual Batch::Environnement getEnvironnement() const; + + // Methodes pour l'interfacage avec Python (SWIG) + // TODO : supprimer ces methodes et transferer leur definitions dans SWIG + std::string __str__() const; // SWIG : affichage en Python + std::string __repr__() const { return __str__(); }; // SWIG : affichage en Python + + protected: + Parametre _param; // parametres du job + Environnement _env; // variables d'environnement du job + JobInfo(const Parametre & param, const Environnement & env) : _param(param), _env(env) {}; + + private: + + }; + +} + +#endif diff --git a/src/Core/Batch_ListIsFullException.cxx b/src/Core/Batch_ListIsFullException.cxx new file mode 100644 index 0000000..1da8c0e --- /dev/null +++ b/src/Core/Batch_ListIsFullException.cxx @@ -0,0 +1,37 @@ +// Copyright (C) 2007-2008 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 +// +/* + * ListIsFullException.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#include "Batch_ListIsFullException.hxx" +using namespace std; + + +namespace Batch { + +} diff --git a/src/Core/Batch_ListIsFullException.hxx b/src/Core/Batch_ListIsFullException.hxx new file mode 100644 index 0000000..bfb7ff8 --- /dev/null +++ b/src/Core/Batch_ListIsFullException.hxx @@ -0,0 +1,50 @@ +// Copyright (C) 2007-2008 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 +// +/* + * ListIsFullException.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#ifndef _LISTISFULLEXCEPTION_H_ +#define _LISTISFULLEXCEPTION_H_ + +#include "Batch_Defines.hxx" + +#include "Batch_GenericException.hxx" + +namespace Batch { + + class BATCH_EXPORT ListIsFullException : public GenericException + { + public: + // Constructeur + ListIsFullException(std::string ch = "undefined") : GenericException("ListIsFullException", ch) {} + }; + +} + +#endif + diff --git a/src/Core/Batch_LongType.cxx b/src/Core/Batch_LongType.cxx new file mode 100644 index 0000000..867c2bc --- /dev/null +++ b/src/Core/Batch_LongType.cxx @@ -0,0 +1,71 @@ +// Copyright (C) 2007-2008 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 +// +/* + * LongType.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#include +#include +#include +//#include "MEDMEM_STRING.hxx" +#include "Batch_LongType.hxx" +using namespace std; + +namespace Batch { + + // Conversion en chaine + string LongType::affiche() const + { + //MEDMEM::STRING sst; + ostringstream sst; + sst << _data; + return sst.str(); + } + + // Operateur d'affectation + LongType & LongType::operator =(long l) + { + _data = l; + return *this; + } + + // Conversion en long + LongType::operator long() const + { + return this->_data; + } + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + GenericType * LongType::clone() const + { + LongType * pL = new LongType(this->_data); + assert(pL != 0); + return pL; + } + +} diff --git a/src/Core/Batch_LongType.hxx b/src/Core/Batch_LongType.hxx new file mode 100644 index 0000000..448035b --- /dev/null +++ b/src/Core/Batch_LongType.hxx @@ -0,0 +1,69 @@ +// Copyright (C) 2007-2008 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 +// +/* + * LongType.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#ifndef _LONGTYPE_H_ +#define _LONGTYPE_H_ + +#include "Batch_Defines.hxx" + +#include +#include "Batch_GenericType.hxx" + +namespace Batch { + + class BATCH_EXPORT LongType : public GenericType + { + public: + // Constructeur + LongType(const long l=0L) : _data(l) {} + + // Conversion en chaine + virtual std::string affiche() const; + + // Operateur d'affectation + virtual LongType & operator =(long); + + // Conversion en long + virtual operator long() const; + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + virtual GenericType * clone() const; + + protected: + long _data; + + private: + + }; + +} + +#endif diff --git a/src/Core/Batch_MapKey.cxx b/src/Core/Batch_MapKey.cxx new file mode 100644 index 0000000..0a4d401 --- /dev/null +++ b/src/Core/Batch_MapKey.cxx @@ -0,0 +1,42 @@ +// Copyright (C) 2007-2008 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 +// +/* + * MapKey.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Tue Oct 14 14:00:30 2003 + * Projet : Salome 2 + * + */ + +#include +#include "Batch_MapKey.hxx" +using namespace std; + +namespace Batch { + + +} + + +// COMMENTS diff --git a/src/Core/Batch_MapKey.hxx b/src/Core/Batch_MapKey.hxx new file mode 100644 index 0000000..c4a7afe --- /dev/null +++ b/src/Core/Batch_MapKey.hxx @@ -0,0 +1,69 @@ +// Copyright (C) 2007-2008 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 +// +/* + * MapKey.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Tue Oct 14 14:00:29 2003 + * Projet : Salome 2 + * + */ + +#ifndef _MAPKEY_H_ +#define _MAPKEY_H_ + +#include "Batch_Defines.hxx" + + +#include + +namespace Batch { + + // une classe privee pour les differents types + // ces types ne peuvent pas etre redefinis + class BATCH_EXPORT MapKey : public std::string + { + private: + friend class Parametre; // seule la classe Parametre peut creer des MapKey + MapKey() : std::string() {} + MapKey(const MapKey & mk, size_type pos, size_type npos) : std::string(mk, pos, npos) {} + MapKey(const char * s, size_type n) : std::string(s, n) {} + MapKey(const char * s) : std::string(s) {} + MapKey(size_type n, char c) : std::string(n, c) {} +#ifdef __STL_MEMBER_TEMPLATES + template + MapKey(InputIterator __begin, InputIterator __end) : std::string(__begin, __end) {} +#else + MapKey(const_iterator __begin, const_iterator __end) : std::string(__begin, __end) {} +#endif + + public: + MapKey(const MapKey & mk) : std::string(mk) {} + + }; + +} + +#endif + +// COMMENTS diff --git a/src/Core/Batch_MpiImpl.cxx b/src/Core/Batch_MpiImpl.cxx new file mode 100644 index 0000000..6a1d706 --- /dev/null +++ b/src/Core/Batch_MpiImpl.cxx @@ -0,0 +1,277 @@ +// Copyright (C) 2007-2008 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 +// + +#include +#include +#include +#include "Batch_MpiImpl.hxx" + +using namespace std; + +// Constructor +MpiImpl::MpiImpl() +{ +} + +// Destructor +MpiImpl::~MpiImpl() +{ +} + +// lam implementation +// Constructor +MpiImpl_LAM::MpiImpl_LAM() : MpiImpl() +{ +} + +// Destructor +MpiImpl_LAM::~MpiImpl_LAM() +{ +} + +string MpiImpl_LAM::size() +{ + return "${LAMWORLD}"; +} + +string MpiImpl_LAM::rank() +{ + return "${LAMRANK}"; +} + +string MpiImpl_LAM::boot(const string machinefile, const unsigned int nbnodes) +{ + ostringstream oss; + oss << "lamboot " << machinefile << endl; + return oss.str(); +} + +string MpiImpl_LAM::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute) +{ + ostringstream oss; + oss << "mpirun -np " << nbproc << " " << fileNameToExecute << endl; + return oss.str(); +} + +string MpiImpl_LAM::halt() +{ + ostringstream oss; + oss << "lamhalt" << endl; + return oss.str(); +} + +// mpich1 implementation +// Constructor +MpiImpl_MPICH1::MpiImpl_MPICH1() : MpiImpl() +{ +} + +// Destructor +MpiImpl_MPICH1::~MpiImpl_MPICH1() +{ +} + +string MpiImpl_MPICH1::size() +{ + return "${MPIRUN_NPROCS}"; +} + +string MpiImpl_MPICH1::rank() +{ + return "${MPIRUN_RANK}"; +} + +string MpiImpl_MPICH1::boot(const string machinefile, const unsigned int nbnodes) +{ + return ""; +} + +string MpiImpl_MPICH1::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute) +{ + ostringstream oss; + oss << "mpirun -machinefile " << machinefile << " -np " << nbproc << " " << fileNameToExecute << endl; + return oss.str(); +} + +string MpiImpl_MPICH1::halt() +{ + return ""; +} + +// mpich2 implementation +// Constructor +MpiImpl_MPICH2::MpiImpl_MPICH2() : MpiImpl() +{ +} + +// Destructor +MpiImpl_MPICH2::~MpiImpl_MPICH2() +{ +} + +string MpiImpl_MPICH2::size() +{ + return "${PMI_SIZE}"; +} + +string MpiImpl_MPICH2::rank() +{ + return "${PMI_RANK}"; +} + +string MpiImpl_MPICH2::boot(const string machinefile, const unsigned int nbnodes) +{ + ostringstream oss; + oss << "mpdboot" << " -n " << nbnodes; + if (machinefile!="") + oss << " -f " << machinefile; + oss << endl; + return oss.str(); +} + +string MpiImpl_MPICH2::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute) +{ + ostringstream oss; + oss << "mpirun -np " << nbproc << " " << fileNameToExecute << endl; + return oss.str(); +} + +string MpiImpl_MPICH2::halt() +{ + ostringstream oss; + oss << "mpdallexit" << endl; + return oss.str(); +} + +// openmpi implementation +// Constructor +MpiImpl_OPENMPI::MpiImpl_OPENMPI() : MpiImpl() +{ +} + +// Destructor +MpiImpl_OPENMPI::~MpiImpl_OPENMPI() +{ +} + +string MpiImpl_OPENMPI::size() +{ + return "${OMPI_MCA_ns_nds_num_procs}"; +} + +string MpiImpl_OPENMPI::rank() +{ + return "${OMPI_MCA_ns_nds_vpid}"; +} + +string MpiImpl_OPENMPI::boot(const string machinefile, const unsigned int nbnodes) +{ + return ""; +} + +string MpiImpl_OPENMPI::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute) +{ + ostringstream oss; + oss << "mpirun -hostfile " << machinefile << " -np " << nbproc << " " << fileNameToExecute << endl; + return oss.str(); +} + +string MpiImpl_OPENMPI::halt() +{ + return ""; +} + +// slurm implementation +// Constructor +MpiImpl_SLURM::MpiImpl_SLURM() : MpiImpl() +{ +} + +// Destructor +MpiImpl_SLURM::~MpiImpl_SLURM() +{ +} + +string MpiImpl_SLURM::size() +{ + return "${SLURM_NPROCS}"; +} + +string MpiImpl_SLURM::rank() +{ + return "${SLURM_PROCID}"; +} + +string MpiImpl_SLURM::boot(const string machinefile, const unsigned int nbnodes) +{ + return ""; +} + +string MpiImpl_SLURM::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute) +{ + ostringstream oss; + oss << "srun " << fileNameToExecute << endl; + return oss.str(); +} + +string MpiImpl_SLURM::halt() +{ + return ""; +} + +// prun implementation +// Constructor +MpiImpl_PRUN::MpiImpl_PRUN() : MpiImpl() +{ +} + +// Destructor +MpiImpl_PRUN::~MpiImpl_PRUN() +{ +} + +string MpiImpl_PRUN::size() +{ + return "${RMS_NPROCS}"; +} + +string MpiImpl_PRUN::rank() +{ + return "${RMS_RANK}"; +} + +string MpiImpl_PRUN::boot(const string machinefile, const unsigned int nbnodes) +{ + return ""; +} + +string MpiImpl_PRUN::run(const string machinefile, const unsigned int nbproc, const string fileNameToExecute) +{ + ostringstream oss; + oss << "prun -n " << nbproc << " " << "-p mpi " << fileNameToExecute << endl; + return oss.str(); +} + +string MpiImpl_PRUN::halt() +{ + return ""; +} diff --git a/src/Core/Batch_MpiImpl.hxx b/src/Core/Batch_MpiImpl.hxx new file mode 100644 index 0000000..4639e6e --- /dev/null +++ b/src/Core/Batch_MpiImpl.hxx @@ -0,0 +1,170 @@ +// Copyright (C) 2007-2008 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 +// + +#ifndef _BL_MPIIMPL_H_ +#define _BL_MPIIMPL_H_ + +#include "Batch_Defines.hxx" +#include + +class BATCH_EXPORT MpiImplException +{ +public: + const std::string msg; + + MpiImplException(const std::string m) : msg(m) {} +}; + +class BATCH_EXPORT MpiImpl +{ +public: + // Constructeur et destructeur + MpiImpl(); // constrcuctor + virtual ~MpiImpl(); //Destructor + + virtual std::string size() = 0; // get number of process of current job + virtual std::string rank() = 0; // get process number of current job + virtual std::string boot(const std::string machinefile, const unsigned int nbnodes) = 0; // get boot command + virtual std::string run(const std::string machinefile, const unsigned int nbproc, const std::string fileNameToExecute) = 0; // get run command + virtual std::string halt() = 0; // get stop command + +protected: + +private: + +}; + +class BATCH_EXPORT MpiImpl_LAM : public MpiImpl +{ +public: + // Constructeur et destructeur + MpiImpl_LAM(); // constructor + virtual ~MpiImpl_LAM(); //Destructor + + std::string size(); // get number of process of current job + std::string rank(); // get process number of current job + std::string boot( const std::string machinefile, const unsigned int nbnodes); // get boot command + std::string run( const std::string machinefile, const unsigned int nbproc, const std::string fileNameToExecute); // get run command + std::string halt(); // get stop command + +protected: + +private: + +}; + +class BATCH_EXPORT MpiImpl_MPICH1 : public MpiImpl +{ +public: + // Constructeur et destructeur + MpiImpl_MPICH1(); // constructor + virtual ~MpiImpl_MPICH1(); //Destructor + + std::string size(); // get number of process of current job + std::string rank(); // get process number of current job + std::string boot( const std::string machinefile, const unsigned int nbnodes); // get boot command + std::string run( const std::string machinefile, const unsigned int nbproc, const std::string fileNameToExecute); // get run command + std::string halt(); // get stop command + +protected: + +private: + +}; + +class BATCH_EXPORT MpiImpl_MPICH2 : public MpiImpl +{ +public: + // Constructeur et destructeur + MpiImpl_MPICH2(); // constructor + virtual ~MpiImpl_MPICH2(); //Destructor + + std::string size(); // get number of process of current job + std::string rank(); // get process number of current job + std::string boot( const std::string machinefile, const unsigned int nbnodes); // get boot command + std::string run( const std::string machinefile, const unsigned int nbproc, const std::string fileNameToExecute); // get run command + std::string halt(); // get stop command + +protected: + +private: + +}; + +class BATCH_EXPORT MpiImpl_OPENMPI : public MpiImpl +{ +public: + // Constructeur et destructeur + MpiImpl_OPENMPI(); // constructor + virtual ~MpiImpl_OPENMPI(); //Destructor + + std::string size(); // get number of process of current job + std::string rank(); // get process number of current job + std::string boot( const std::string machinefile, const unsigned int nbnodes); // get boot command + std::string run( const std::string machinefile, const unsigned int nbproc, const std::string fileNameToExecute); // get run command + std::string halt(); // get stop command + +protected: + +private: + +}; + +class BATCH_EXPORT MpiImpl_SLURM : public MpiImpl +{ +public: + // Constructeur et destructeur + MpiImpl_SLURM(); // constructor + virtual ~MpiImpl_SLURM(); //Destructor + + std::string size(); // get number of process of current job + std::string rank(); // get process number of current job + std::string boot( const std::string machinefile, const unsigned int nbnodes); // get boot command + std::string run( const std::string machinefile, const unsigned int nbproc, const std::string fileNameToExecute); // get run command + std::string halt(); // get stop command + +protected: + +private: + +}; + +class BATCH_EXPORT MpiImpl_PRUN : public MpiImpl +{ +public: + // Constructeur et destructeur + MpiImpl_PRUN(); // constructor + virtual ~MpiImpl_PRUN(); //Destructor + + std::string size(); // get number of process of current job + std::string rank(); // get process number of current job + std::string boot( const std::string machinefile, const unsigned int nbnodes); // get boot command + std::string run( const std::string machinefile, const unsigned int nbproc, const std::string fileNameToExecute); // get run command + std::string halt(); // get stop command + +protected: + +private: + +}; + +#endif diff --git a/src/Core/Batch_NotYetImplementedException.cxx b/src/Core/Batch_NotYetImplementedException.cxx new file mode 100644 index 0000000..b9ef409 --- /dev/null +++ b/src/Core/Batch_NotYetImplementedException.cxx @@ -0,0 +1,37 @@ +// Copyright (C) 2007-2008 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 +// +/* + * NotYetImplementedException.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Tue Nov 25 11:35:07 2003 + * Projet : Salome 2 + * + */ + +#include "Batch_NotYetImplementedException.hxx" + +namespace Batch { + +} + diff --git a/src/Core/Batch_NotYetImplementedException.hxx b/src/Core/Batch_NotYetImplementedException.hxx new file mode 100644 index 0000000..2f3b8b4 --- /dev/null +++ b/src/Core/Batch_NotYetImplementedException.hxx @@ -0,0 +1,52 @@ +// Copyright (C) 2007-2008 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 +// +/* + * NotYetImplementedException.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Tue Nov 25 11:35:07 2003 + * Projet : Salome 2 + * + */ + +#ifndef _NOTYETIMPLEMENTEDEXCEPTION_H_ +#define _NOTYETIMPLEMENTEDEXCEPTION_H_ + +#include "Batch_Defines.hxx" +#include "Batch_GenericException.hxx" + +#include + +namespace Batch { + + class BATCH_EXPORT NotYetImplementedException : public GenericException + { + public: + // Constructeur + NotYetImplementedException(std::string ch = "undefined") : GenericException("NotYetImplementedException", ch) {} + }; + +} + +#endif + diff --git a/src/Core/Batch_Parametre.cxx b/src/Core/Batch_Parametre.cxx new file mode 100644 index 0000000..c8e13e6 --- /dev/null +++ b/src/Core/Batch_Parametre.cxx @@ -0,0 +1,295 @@ +// Copyright (C) 2007-2008 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 +// +/* + * Parametre.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#include "Batch_Versatile.hxx" +#include "Batch_InvalidKeyException.hxx" +#include "Batch_Parametre.hxx" + +using namespace std; + +// Definition des membres constants statiques +// Definition des noms globaux pour les clefs en tant que references +// TODO : supprimer les declarations statiques des clefs de la map +def_static_MapKey(ACCOUNT) +def_static_MapKey(ARGUMENTS) +def_static_MapKey(CHECKPOINT) +def_static_MapKey(CKPTINTERVAL) +def_static_MapKey(CREATIONTIME) +def_static_MapKey(EGROUP) +def_static_MapKey(ELIGIBLETIME) +def_static_MapKey(ENDTIME) +def_static_MapKey(EUSER) +def_static_MapKey(EXECUTABLE) +def_static_MapKey(EXECUTIONHOST) +def_static_MapKey(EXITCODE) +def_static_MapKey(HOLD) +def_static_MapKey(ID) +def_static_MapKey(INFILE) +def_static_MapKey(MAIL) +def_static_MapKey(MAXCPUTIME) +def_static_MapKey(MAXDISKSIZE) +def_static_MapKey(MAXRAMSIZE) +def_static_MapKey(MAXWALLTIME) +def_static_MapKey(MODIFICATIONTIME) +def_static_MapKey(NAME) +def_static_MapKey(NBPROC) +def_static_MapKey(OUTFILE) +def_static_MapKey(PID) +def_static_MapKey(QUEUE) +def_static_MapKey(QUEUEDTIME) +def_static_MapKey(SERVER) +def_static_MapKey(STARTTIME) +def_static_MapKey(STATE) +def_static_MapKey(TEXT) +def_static_MapKey(TMPDIR) +def_static_MapKey(USEDCPUTIME) +def_static_MapKey(USEDDISKSIZE) +def_static_MapKey(USEDRAMSIZE) +def_static_MapKey(USEDWALLTIME) +def_static_MapKey(USER) +def_static_MapKey(WORKDIR) +def_static_MapKey(HOMEDIR) + +namespace Batch { + + // Constructeur standard + // La map interne TypeMap possede les memes clefs que la map principale, mais les + // valeurs associees contiennent le type des clefs de la map principale ainsi que + // le nombre de valeurs autorisees dans l'objet Versatile (0=nombre quelconque, + // sinon valeur precisee) + Parametre::Parametre() : map< string, Versatile >() + { + TypeMap[ACCOUNT].type = STRING; + TypeMap[ACCOUNT].maxelem = 1; + + TypeMap[ARGUMENTS].type = STRING; + TypeMap[ARGUMENTS].maxelem = 0; + + TypeMap[CHECKPOINT].type = LONG; + TypeMap[CHECKPOINT].maxelem = 1; + + TypeMap[CKPTINTERVAL].type = LONG; + TypeMap[CKPTINTERVAL].maxelem = 1; + + TypeMap[CREATIONTIME].type = LONG; + TypeMap[CREATIONTIME].maxelem = 1; + + TypeMap[EGROUP].type = STRING; + TypeMap[EGROUP].maxelem = 1; + + TypeMap[ELIGIBLETIME].type = LONG; + TypeMap[ELIGIBLETIME].maxelem = 1; + + TypeMap[ENDTIME].type = LONG; + TypeMap[ENDTIME].maxelem = 1; + + TypeMap[EUSER].type = STRING; + TypeMap[EUSER].maxelem = 1; + + TypeMap[EXECUTABLE].type = STRING; + TypeMap[EXECUTABLE].maxelem = 1; + + TypeMap[EXECUTIONHOST].type = STRING; + TypeMap[EXECUTIONHOST].maxelem = 0; + + TypeMap[EXITCODE].type = LONG; + TypeMap[EXITCODE].maxelem = 1; + + TypeMap[HOLD].type = LONG; + TypeMap[HOLD].maxelem = 1; + + TypeMap[ID].type = STRING; + TypeMap[ID].maxelem = 1; + + TypeMap[INFILE].type = COUPLE; + TypeMap[INFILE].maxelem = 0; + + TypeMap[MAIL].type = STRING; + TypeMap[MAIL].maxelem = 1; + + TypeMap[MAXCPUTIME].type = LONG; + TypeMap[MAXCPUTIME].maxelem = 1; + + TypeMap[MAXDISKSIZE].type = LONG; + TypeMap[MAXDISKSIZE].maxelem = 1; + + TypeMap[MAXRAMSIZE].type = LONG; + TypeMap[MAXRAMSIZE].maxelem = 1; + + TypeMap[MAXWALLTIME].type = LONG; + TypeMap[MAXWALLTIME].maxelem = 1; + + TypeMap[MODIFICATIONTIME].type = LONG; + TypeMap[MODIFICATIONTIME].maxelem = 1; + + TypeMap[NAME].type = STRING; + TypeMap[NAME].maxelem = 1; + + TypeMap[NBPROC].type = LONG; + TypeMap[NBPROC].maxelem = 1; + + TypeMap[OUTFILE].type = COUPLE; + TypeMap[OUTFILE].maxelem = 0; + + TypeMap[PID].type = LONG; + TypeMap[PID].maxelem = 1; + + TypeMap[QUEUE].type = STRING; + TypeMap[QUEUE].maxelem = 1; + + TypeMap[QUEUEDTIME].type = LONG; + TypeMap[QUEUEDTIME].maxelem = 1; + + TypeMap[SERVER].type = STRING; + TypeMap[SERVER].maxelem = 1; + + TypeMap[STARTTIME].type = LONG; + TypeMap[STARTTIME].maxelem = 1; + + TypeMap[STATE].type = STRING; + TypeMap[STATE].maxelem = 1; + + TypeMap[TEXT].type = STRING; + TypeMap[TEXT].maxelem = 1; + + TypeMap[TMPDIR].type = STRING; + TypeMap[TMPDIR].maxelem = 1; + + TypeMap[USEDCPUTIME].type = LONG; + TypeMap[USEDCPUTIME].maxelem = 1; + + TypeMap[USEDDISKSIZE].type = LONG; + TypeMap[USEDDISKSIZE].maxelem = 1; + + TypeMap[USEDRAMSIZE].type = LONG; + TypeMap[USEDRAMSIZE].maxelem = 1; + + TypeMap[USEDWALLTIME].type = LONG; + TypeMap[USEDWALLTIME].maxelem = 1; + + TypeMap[USER].type = STRING; + TypeMap[USER].maxelem = 1; + + TypeMap[WORKDIR].type = STRING; + TypeMap[WORKDIR].maxelem = 1; + + TypeMap[HOMEDIR].type = STRING; + TypeMap[HOMEDIR].maxelem = 1; + } + + // Operateur de recherche dans la map + // Cet operateur agit sur les objets NON CONSTANTS, il autorise la modification de + // la valeur associ�e � la clef car il retourne une reference non constante + Versatile & Parametre::operator [] (const string & mk) + { + // On controle que la clef est valide + if (TypeMap.find(mk) == TypeMap.end()) throw InvalidKeyException(mk.c_str()); + + // On recherche la valeur associee... + Versatile & V = map< string, Versatile >::operator [] (mk); + + // ... et on l'initialise systematiquement + // ATTENTION : si un probleme de type survient (ie, on stocke une valeur d'un type + // different de celui inscrit dans TypeMap) une exception TypeMismatchException est + // levee + V.setName(mk); + V.setType(TypeMap[mk].type); + V.setMaxSize(TypeMap[mk].maxelem); + + return V; + } + + // Operateur de recherche dans la map + // Cet operateur agit sur les objets CONSTANTS + const Versatile & Parametre::operator [] (const string & mk) const + { + // On controle que la clef est valide + if (TypeMap.find(mk) == TypeMap.end()) throw InvalidKeyException(mk.c_str()); + + // On recherche la valeur associee + Parametre::const_iterator it = find(mk); + if (it == end()) throw InvalidKeyException(mk.c_str()); + const Versatile & V = (*it).second; + + return V; + } + + // Operateur d'affectation + Parametre & Parametre::operator =(const Parametre & PM) + { + // On ne reaffecte pas l'objet a lui-meme, sinon aie, aie, aie + if (this == &PM) return *this; + + // On efface toute la map + erase(begin(), end()); + + // On recopie la map interne + // Meme si cela ne sert a rien pour le moment car les maps internes sont identiques, + // il n'est pas exclu que dans un avenir proche elles puissent etre differentes + (*this).TypeMap = PM.TypeMap; + + // On recree la structure interne de la map avec les valeurs de celle passee en argument + Parametre::const_iterator it; + for(it=PM.begin(); it!=PM.end(); it++) + insert(make_pair( (*it).first , + Versatile( (*it).second) + ) ); + + return *this; + } + + // Constructeur par recopie + Parametre::Parametre(const Parametre & PM) + { + // inutile car l'objet est vierge : il vient d'etre cree + // On efface toute la map + // erase(begin(), end()); + + // On recopie la map interne + (*this).TypeMap = PM.TypeMap; + + // On cree la structure interne de la map avec les valeurs de celle passee en argument + Parametre::const_iterator it; + for(it=PM.begin(); + it!=PM.end(); + it++) + insert( + make_pair( + (*it).first , + Versatile( (*it).second) + ) ); + } + + // map< string, TypeParam > Parametre::getTypeMap() const + // { + // return TypeMap; + // } + +} diff --git a/src/Core/Batch_Parametre.hxx b/src/Core/Batch_Parametre.hxx new file mode 100644 index 0000000..17401ca --- /dev/null +++ b/src/Core/Batch_Parametre.hxx @@ -0,0 +1,159 @@ +// Copyright (C) 2007-2008 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 +// +/* + * Parametre.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#ifndef _PARAMETRE_H_ +#define _PARAMETRE_H_ + +#include "Batch_Defines.hxx" + +#include +#include +#include "Batch_InvalidKeyException.hxx" +#include "Batch_Versatile.hxx" + +// Ces macros permettent de simplifier l'ajout de nouvelles +// clefs dans la map Parametre +// TODO : remplacer ce mecanisme statique par la lecture +// TODO : d'une descrption dans un fichier exterieur (genre XML) + +#define def_extern_MapKey(mk) extern BATCH_EXPORT const std::string & mk; +#define def_static_MapKey(mk) const std::string Batch::Parametre::mk(#mk); \ + const std::string & mk = Batch::Parametre::mk; + +namespace Batch { + + class BATCH_EXPORT Parametre : public std::map< std::string, Versatile > + { + public: + // Constructeur standard + Parametre(); + + // Constructeur par recopie + Parametre(const Parametre & PM); + + // Operateur de recherche dans la map + Versatile & operator [] (const std::string &); + const Versatile & operator [] (const std::string &) const; + + // Operateur d'affectation + Parametre & operator =(const Parametre & PM); + + // Declarations statique des clefs de la map + // TODO : supprimer les declarations statiques des clefs de la map + static const std::string ACCOUNT; + static const std::string ARGUMENTS; + static const std::string CHECKPOINT; + static const std::string CKPTINTERVAL; + static const std::string CREATIONTIME; + static const std::string EGROUP; + static const std::string ELIGIBLETIME; + static const std::string ENDTIME; + static const std::string EUSER; + static const std::string EXECUTABLE; + static const std::string EXECUTIONHOST; + static const std::string EXITCODE; + static const std::string HOLD; + static const std::string ID; + static const std::string INFILE; + static const std::string MAIL; + static const std::string MAXCPUTIME; + static const std::string MAXDISKSIZE; + static const std::string MAXRAMSIZE; + static const std::string MAXWALLTIME; + static const std::string MODIFICATIONTIME; + static const std::string NAME; + static const std::string NBPROC; + static const std::string OUTFILE; + static const std::string PID; + static const std::string QUEUE; + static const std::string QUEUEDTIME; + static const std::string SERVER; + static const std::string STARTTIME; + static const std::string STATE; + static const std::string TEXT; + static const std::string TMPDIR; + static const std::string USEDCPUTIME; + static const std::string USEDDISKSIZE; + static const std::string USEDRAMSIZE; + static const std::string USEDWALLTIME; + static const std::string USER; + static const std::string WORKDIR; + static const std::string HOMEDIR; + + protected: + std::map< std::string, TypeParam > TypeMap; // map interne servant a controler le type de la valeur associee a chaque clef + + private: + + }; + +} + +def_extern_MapKey(ACCOUNT) +def_extern_MapKey(ARGUMENTS) +def_extern_MapKey(CHECKPOINT) +def_extern_MapKey(CKPTINTERVAL) +def_extern_MapKey(CREATIONTIME) +def_extern_MapKey(EGROUP) +def_extern_MapKey(ELIGIBLETIME) +def_extern_MapKey(ENDTIME) +def_extern_MapKey(EUSER) +def_extern_MapKey(EXECUTABLE) +def_extern_MapKey(EXECUTIONHOST) +def_extern_MapKey(EXITCODE) +def_extern_MapKey(HOLD) +def_extern_MapKey(ID) +def_extern_MapKey(INFILE) +def_extern_MapKey(MAIL) +def_extern_MapKey(MAXCPUTIME) +def_extern_MapKey(MAXDISKSIZE) +def_extern_MapKey(MAXRAMSIZE) +def_extern_MapKey(MAXWALLTIME) +def_extern_MapKey(MODIFICATIONTIME) +def_extern_MapKey(NAME) +def_extern_MapKey(NBPROC) +def_extern_MapKey(OUTFILE) +def_extern_MapKey(PID) +def_extern_MapKey(QUEUE) +def_extern_MapKey(QUEUEDTIME) +def_extern_MapKey(SERVER) +def_extern_MapKey(STARTTIME) +def_extern_MapKey(STATE) +def_extern_MapKey(TEXT) +def_extern_MapKey(TMPDIR) +def_extern_MapKey(USEDCPUTIME) +def_extern_MapKey(USEDDISKSIZE) +def_extern_MapKey(USEDRAMSIZE) +def_extern_MapKey(USEDWALLTIME) +def_extern_MapKey(USER) +def_extern_MapKey(WORKDIR) +def_extern_MapKey(HOMEDIR) + +#endif diff --git a/src/Core/Batch_RunTimeException.cxx b/src/Core/Batch_RunTimeException.cxx new file mode 100644 index 0000000..3db54fd --- /dev/null +++ b/src/Core/Batch_RunTimeException.cxx @@ -0,0 +1,37 @@ +// Copyright (C) 2007-2008 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 +// +/* + * RunTimeException.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Tue Nov 25 14:04:13 2003 + * Projet : Salome 2 + * + */ + +#include "Batch_RunTimeException.hxx" +using namespace std; + +namespace Batch { + +} diff --git a/src/Core/Batch_RunTimeException.hxx b/src/Core/Batch_RunTimeException.hxx new file mode 100644 index 0000000..bdb3148 --- /dev/null +++ b/src/Core/Batch_RunTimeException.hxx @@ -0,0 +1,51 @@ +// Copyright (C) 2007-2008 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 +// +/* + * RunTimeException.hxx : + * + * Auteur : %author% - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Tue Nov 25 14:04:13 2003 + * Projet : Salome 2 + * + */ + +#ifndef _RUNTIMEEXCEPTION_H_ +#define _RUNTIMEEXCEPTION_H_ + +#include "Batch_Defines.hxx" + + +#include "Batch_GenericException.hxx" + +namespace Batch { + + class BATCH_EXPORT RunTimeException : public GenericException + { + public: + // Constructeur + RunTimeException(std::string ch = "undefined") : GenericException("RunTimeException", ch) {} + }; + +} + +#endif diff --git a/src/Core/Batch_StringType.cxx b/src/Core/Batch_StringType.cxx new file mode 100644 index 0000000..33c7c5f --- /dev/null +++ b/src/Core/Batch_StringType.cxx @@ -0,0 +1,66 @@ +// Copyright (C) 2007-2008 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 +// +/* + * StringType.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#include +#include +#include "Batch_StringType.hxx" +using namespace std; + +namespace Batch { + + // Conversion en chaine + string StringType::affiche() const + { + return _data; + } + + // Operateur d'affectation + StringType & StringType::operator =(string s) + { + _data = s; + return *this; + } + + // Conversion en chaine + StringType::operator string() const + { + return this->_data; + } + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + GenericType * StringType::clone() const + { + StringType * pS = new StringType(this->_data); + assert(pS != 0); + return pS; + } + +} diff --git a/src/Core/Batch_StringType.hxx b/src/Core/Batch_StringType.hxx new file mode 100644 index 0000000..fb5a80e --- /dev/null +++ b/src/Core/Batch_StringType.hxx @@ -0,0 +1,67 @@ +// Copyright (C) 2007-2008 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 +// +/* + * StringType.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#ifndef _STRINGTYPE_H_ +#define _STRINGTYPE_H_ + +#include "Batch_Defines.hxx" + +#include +#include "Batch_GenericType.hxx" + +namespace Batch { + + class BATCH_EXPORT StringType : public GenericType + { + public: + // Constructeur + StringType(const std::string & s="") : _data(s) {} + + // Conversion en chaine + virtual std::string affiche() const; + virtual operator std::string() const; + + // Operateur d'affectation + virtual StringType & operator =(std::string); + + // Clone duplique l'objet et en fabrique un nouveau a l'aide de new + // qu'il faudra detruire ensuite manuellement + virtual GenericType * clone() const; + + protected: + std::string _data; + + private: + + }; + +} + +#endif diff --git a/src/Core/Batch_TypeMismatchException.cxx b/src/Core/Batch_TypeMismatchException.cxx new file mode 100644 index 0000000..96b30be --- /dev/null +++ b/src/Core/Batch_TypeMismatchException.cxx @@ -0,0 +1,36 @@ +// Copyright (C) 2007-2008 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 +// +/* + * TypeMismatchException.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#include "Batch_TypeMismatchException.hxx" +using namespace std; + +namespace Batch { + +} diff --git a/src/Core/Batch_TypeMismatchException.hxx b/src/Core/Batch_TypeMismatchException.hxx new file mode 100644 index 0000000..10912f6 --- /dev/null +++ b/src/Core/Batch_TypeMismatchException.hxx @@ -0,0 +1,51 @@ +// Copyright (C) 2007-2008 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 +// +/* + * TypeMismatchException.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#ifndef _TYPEMISMATCHEXCEPTION_H_ +#define _TYPEMISMATCHEXCEPTION_H_ + +#include "Batch_Defines.hxx" + + +#include "Batch_GenericException.hxx" + +namespace Batch { + + class BATCH_EXPORT TypeMismatchException : public GenericException + { + public: + // Constructeur + TypeMismatchException(std::string ch = "undefined") : GenericException("TypeMismatchException", ch) {} + }; + +} + +#endif + diff --git a/src/Core/Batch_Versatile.cxx b/src/Core/Batch_Versatile.cxx new file mode 100644 index 0000000..0074600 --- /dev/null +++ b/src/Core/Batch_Versatile.cxx @@ -0,0 +1,323 @@ +// Copyright (C) 2007-2008 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 +// +/* + * Versatile.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#include +#include +#include +#include +#include +//#include "MEDMEM_STRING.hxx" +#include "Batch_GenericType.hxx" +#include "Batch_IntType.hxx" +#include "Batch_BoolType.hxx" +#include "Batch_CharType.hxx" +#include "Batch_LongType.hxx" +#include "Batch_StringType.hxx" +#include "Batch_Versatile.hxx" +#include "Batch_TypeMismatchException.hxx" +#include "Batch_ListIsFullException.hxx" +using namespace std; + +namespace Batch { + + // Constructeur par recopie + Versatile::Versatile(const Versatile & V) : _discriminator(V._discriminator), _maxsize(V._maxsize), _name(V._name) // , _str_value(0) + { + Versatile::const_iterator it; + + // On prend un a un les elements de l'objet passe en argument qu'on duplique + for(it=V.begin(); it!=V.end(); it++) + push_back( (*it)->clone() ); // Attention, la methode clone fait un new implicite + } + + // Destructeur + Versatile::~Versatile() + { + eraseAll(); + } + + // Operateur d'affectation entre objets + Versatile & Versatile::operator = (const Versatile & Vrhs) throw(TypeMismatchException) + { + // ATTENTION : le forçage de type leve une exception TypeMismatchException entre cas de conflit + setType(Vrhs._discriminator); + setMaxSize(Vrhs._maxsize); + _name = Vrhs._name; + + // On efface les donnees precedentes + eraseAll(); + + // On copie les donnees de Vrhs + Versatile::const_iterator it; + + for(it=Vrhs.begin(); it!=Vrhs.end(); it++) + push_back( (*it)->clone() ); // Attention, la methode clone fait un new implicite + + return *this; + } + + // Operateur d'affectation a partir d'un long + Versatile & Versatile::operator = (const long l) throw(TypeMismatchException) + { + // ATTENTION : le forçage de type leve une exception TypeMismatchException entre cas de conflit + setType(LONG); + + // On efface les donnees precedentes + eraseAll(); + + // On ajoute un element interne de type long a l'objet + LongType * pL = new LongType(l); + assert(pL != 0); + push_back(pL); + return *this; + } + + // Operateur d'affectation a partir d'une string + Versatile & Versatile::operator = (const string & ch) throw(TypeMismatchException) + { + // ATTENTION : le forçage de type leve une exception TypeMismatchException entre cas de conflit + setType(STRING); + + // On efface les donnees precedentes + eraseAll(); + + // On ajoute un element interne de type string a l'objet + StringType * pS = new StringType(ch); + assert(pS != 0); + push_back(pS); + + return *this; + } + + // Operateur de concatenation a partir d'une string + Versatile & Versatile::operator +=(const string & ch) throw(TypeMismatchException,ListIsFullException) + { + // ATTENTION : le forçage de type leve une exception TypeMismatchException entre cas de conflit + setType(STRING); + + // Si la taille maximale est atteinte, on leve une exception ListIsFullException + if (_maxsize == 0) push_back(new StringType(ch)); + else if ((_maxsize > 0) && (size() < _maxsize)) push_back(new StringType(ch)); + else { + //MEDMEM::STRING msg; + ostringstream msg; + msg << "Taille maximum : " << _maxsize; + throw(ListIsFullException(msg.str())); + } + return *this; + } + + // Operateur de concatenation a partir d'une string + Versatile & Versatile::operator , (const string & ch) throw(TypeMismatchException,ListIsFullException) + { + *this += ch; + return *this; + } + + // Operateur d'affectation a partir d'un Couple + Versatile & Versatile::operator = (const Couple & cp) throw(TypeMismatchException) + { + // ATTENTION : le forçage de type leve une exception TypeMismatchException entre cas de conflit + setType(COUPLE); + + // On efface les donnees precedentes + eraseAll(); + + // On ajoute un element interne de type Couple a l'objet + CoupleType * pC = new CoupleType(cp); + assert(pC != 0); + push_back(pC); + + return *this; + } + + // Operateur de concatenation a partir d'un Couple + Versatile & Versatile::operator +=(const Couple & cp) throw(TypeMismatchException,ListIsFullException) + { + // ATTENTION : le forçage de type leve une exception TypeMismatchException entre cas de conflit + setType(COUPLE); + + // Si la taille maximale est atteinte, on leve une exception ListIsFullException + if (_maxsize == 0) push_back(new CoupleType(cp)); + else if ((_maxsize > 0) && (size() < _maxsize)) push_back(new CoupleType(cp)); + else { + //MEDMEM::STRING msg; + ostringstream msg; + msg << "Taille maximum : " << _maxsize; + throw(ListIsFullException(msg.str())); + } + return *this; + } + + // Operateur de concatenation a partir d'un Couple + Versatile & Versatile::operator , (const Couple & cp) throw(TypeMismatchException,ListIsFullException) + { + *this += cp; + return *this; + } + + ostream & operator << (ostream & os, const Versatile & V) + { + Versatile::const_iterator it; + const char * sep = ""; + + for(it=V.begin(); it!=V.end(); it++, sep=" ") { + string s = (*it)->affiche(); + os << sep << s; + } + return os; + } + + // Positionnement du type de l'element interne + void Versatile::setType(DiscriminatorType t) throw(TypeMismatchException) + { + // Si le type est deja defini et ne correspond pas au type en argument + // une exception TypeMismatchException est levee + if ( (_discriminator == UNDEFINED) || (_discriminator == t) ) + _discriminator = t; + else { + //MEDMEM::STRING sst; + ostringstream sst; + sst << "Trying to change type of Versatile object \"" + << _name << "\""; + throw(TypeMismatchException(sst.str())); + } + } + + // Positionnement du nombre d'elements internes + void Versatile::setMaxSize(int i) + { + _maxsize = i; + if (i <= 0) return; + // Si la nouvelle taille est inferieure au nombre d'elements deja + // presents, les elements en surplus sont effaces (troncature) + if (size() > _maxsize) + { + int reste = size() - _maxsize; + Versatile::iterator it; + for(it=end(); (it!=begin()) && reste; it--, reste--) + { + delete back(); + pop_back(); + } + } + } + + + // Conversion de type vers un long + Versatile::operator long() const throw(TypeMismatchException) + { + // Si le type ne correspond pas ou si la liste contient plus d'un element, + // la conversion est impossible et une exception TypeMismatchException + // est levee + if ( (_maxsize != 1) || (_discriminator != LONG) || (size() == 0) ) { + //MEDMEM::STRING sst; + ostringstream sst; + sst << "Cannot cast Versatile object \"" + << _name << "\" to long"; + throw(TypeMismatchException(sst.str())); + } + return *( static_cast(this->front()) ); + } + + // Conversion de type vers un Couple + Versatile::operator Couple() const throw(TypeMismatchException) + { + // Si le type ne correspond pas ou si la liste contient plus d'un element, + // la conversion est impossible et une exception TypeMismatchException + // est levee + if ( (_maxsize != 1) || (_discriminator != COUPLE) || (size() == 0) ) { + //MEDMEM::STRING sst; + ostringstream sst; + sst << "Cannot cast Versatile object \"" + << _name << "\" to Couple"; + throw(TypeMismatchException(sst.str())); + } + return *( static_cast(this->front()) ); + } + + // Conversion de type vers une string + string Versatile::str() const throw(TypeMismatchException) + { + // Si le type ne correspond pas, la conversion est impossible et + // une exception TypeMismatchException est levee + if ( (_discriminator != STRING) || (size() == 0) ) { + //MEDMEM::STRING sst; + ostringstream sst; + sst << "Cannot cast Versatile object \"" + << _name << "\" to string"; + throw(TypeMismatchException(sst.str())); + } + + // La chaine renvoyee est la concatenation des chaines internes + string s; + Versatile::const_iterator it; + const char * sep = ""; + for(it=begin(); it!=end(); it++, s+=sep, sep=" ") + s += *( static_cast(*it)); + + return s; + } + + // Conversion de type vers une string + Versatile::operator string () const throw(TypeMismatchException) + { + return str(); + } + + // Efface tous les elements internes de l'objet + void Versatile::eraseAll() + { + while(!empty()) + { + delete back(); + pop_back(); + } + } + + + // Recuperation du type de l'element interne + DiscriminatorType Versatile::getType() const + { + return _discriminator; + } + + // Recuperation du nom de l'objet + string Versatile::getName() const + { + return _name; + } + + // Positionnement du nom de l'objet + void Versatile::setName(const string & name) + { + _name = name; + } +} diff --git a/src/Core/Batch_Versatile.hxx b/src/Core/Batch_Versatile.hxx new file mode 100644 index 0000000..ec42d18 --- /dev/null +++ b/src/Core/Batch_Versatile.hxx @@ -0,0 +1,122 @@ +// Copyright (C) 2007-2008 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 +// +/* + * Versatile.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#ifndef _VERSATILE_H_ +#define _VERSATILE_H_ + +#include "Batch_Defines.hxx" + +#include +#include +#include +#include "Batch_GenericType.hxx" +#include "Batch_IntType.hxx" +#include "Batch_BoolType.hxx" +#include "Batch_CharType.hxx" +#include "Batch_LongType.hxx" +#include "Batch_StringType.hxx" +#include "Batch_CoupleType.hxx" +#include "Batch_TypeMismatchException.hxx" +#include "Batch_ListIsFullException.hxx" + +namespace Batch { + + // Les types autorises + // enum DiscriminatorType { UNDEFINED, BOOL, CHAR, INT, LONG, STRING}; + enum DiscriminatorType { UNDEFINED, LONG, STRING, COUPLE }; + + typedef struct { + DiscriminatorType type; // le type de l'element interne + int maxelem; // le nombre d'elements autorises + } TypeParam; + + class BATCH_EXPORT Versatile : public std::list< GenericType * > + { + public: + // Constructeur standard et destructeur + Versatile() : _discriminator(UNDEFINED), _maxsize(1), _name("undefined") {} + virtual ~Versatile(); + + // Constructeur par recopie + Versatile(const Versatile & V); + + // Constructeur depuis le type de "base" + Versatile(long l) : _discriminator(LONG), _maxsize(1), _name("long") { push_back(new LongType(l)); } + Versatile(const std::string & s) : _discriminator(STRING), _maxsize(1), _name("string") { push_back(new StringType(s)); } + Versatile(const Couple & c) : _discriminator(COUPLE), _maxsize(1), _name("couple") { push_back(new CoupleType(c)); } + + // Operateur d'affectation et de concatenation a partir d'un type de "base" + Versatile & operator = (const long l) throw(TypeMismatchException); + Versatile & operator = (const std::string & ch) throw(TypeMismatchException); + Versatile & operator +=(const std::string & ch) throw(TypeMismatchException,ListIsFullException); + Versatile & operator , (const std::string & ch) throw(TypeMismatchException,ListIsFullException); + Versatile & operator = (const Couple & cp) throw(TypeMismatchException); + Versatile & operator +=(const Couple & cp) throw(TypeMismatchException,ListIsFullException); + Versatile & operator , (const Couple & cp) throw(TypeMismatchException,ListIsFullException); + + // Operateur d'affectation entre objets + Versatile & operator = (const Versatile & V) throw(TypeMismatchException); + + // Conversion de type vers un type de "base" + operator long() const throw(TypeMismatchException); + operator std::string() const throw(TypeMismatchException); + operator Couple() const throw(TypeMismatchException); + std::string str() const throw(TypeMismatchException); + + // Operateur pour l'affichage sur un stream + friend std::ostream & operator << (std::ostream & os, const Versatile & ); + + // Positionnement et recuperation du type de l'element interne + void setType(DiscriminatorType) throw(TypeMismatchException); + DiscriminatorType getType() const; + + // Positionnement et recuperation du nombre d'elements internes + void setMaxSize(int i); + int getMaxSize() const { return _maxsize; } + + // Positionnement et recuperation du nom de l'objet + std::string getName() const; + void setName(const std::string & name); + + protected: + // Efface tous les elements internes de l'objet + virtual void eraseAll(); + + DiscriminatorType _discriminator; // type de l'element interne + size_type _maxsize; // nombre max d'elements internes + std::string _name; // nom de l'objet (sert pour les exceptions) + + private: + + }; + +} + +#endif diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt new file mode 100644 index 0000000..23007a6 --- /dev/null +++ b/src/Core/CMakeLists.txt @@ -0,0 +1,60 @@ +# Copyright (C) 2007-2008 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 +# + +SET(CLASS_LIST Core/Batch_APIInternalFailureException + Core/Batch_BatchManager_eClient + Core/Batch_BatchManager + Core/Batch_BatchManagerCatalog + Core/Batch_BoolType + Core/Batch_CharType + Core/Batch_ConnexionFailureException + Core/Batch_Couple + Core/Batch_CoupleType + Core/Batch_Date + Core/Batch_DateType + Core/Batch_EmulationException + Core/Batch_Environnement + Core/Batch_FactBatchManager_eClient + Core/Batch_FactBatchManager + Core/Batch_GenericException + Core/Batch_GenericType + Core/Batch_IntType + Core/Batch_InvalidArgumentException + Core/Batch_InvalidKeyException + Core/Batch_Job + Core/Batch_JobId + Core/Batch_JobInfo + Core/Batch_ListIsFullException + Core/Batch_LongType + Core/Batch_MapKey + Core/Batch_MpiImpl + Core/Batch_NotYetImplementedException + Core/Batch_Parametre + Core/Batch_RunTimeException + Core/Batch_StringType + Core/Batch_TypeMismatchException + Core/Batch_Versatile + ) + +APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST}) +APPEND_CLASSES_TO_HDR_FILES(${CLASS_LIST}) +APPEND_CLASSES_TO_HDR_FILES(Core/Batch_Defines) diff --git a/src/LSF/Batch_BatchManager_LSF.cxx b/src/LSF/Batch_BatchManager_LSF.cxx new file mode 100644 index 0000000..ae8afad --- /dev/null +++ b/src/LSF/Batch_BatchManager_LSF.cxx @@ -0,0 +1,194 @@ +// Copyright (C) 2007-2008 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; + } + + // 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 new file mode 100644 index 0000000..283be2f --- /dev/null +++ b/src/LSF/Batch_BatchManager_LSF.hxx @@ -0,0 +1,97 @@ +// Copyright (C) 2007-2008 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 + + + 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_BatchManager_eLSF.cxx b/src/LSF/Batch_BatchManager_eLSF.cxx new file mode 100644 index 0000000..e48690c --- /dev/null +++ b/src/LSF/Batch_BatchManager_eLSF.cxx @@ -0,0 +1,362 @@ +// Copyright (C) 2007-2008 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_eLSF.cxx : emulation of LSF client + * + * Auteur : Bernard SECHER - CEA DEN + * Mail : mailto:bernard.secher@cea.fr + * Date : Thu Apr 24 10:17:22 2008 + * Projet : PAL Salome + * + */ + +#include +#include +#include +#include +#include +#include + +#include "Batch_BatchManager_eLSF.hxx" +#ifdef WIN32 +# include +# include +#else +# include +#endif + +using namespace std; + +namespace Batch { + + BatchManager_eLSF::BatchManager_eLSF(const FactBatchManager * parent, const char * host, const char * protocol, const char * mpiImpl) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager_eClient(parent,host,protocol,mpiImpl) + { + // Nothing to do + } + + // Destructeur + BatchManager_eLSF::~BatchManager_eLSF() + { + // Nothing to do + } + + // Methode pour le controle des jobs : soumet un job au gestionnaire + const JobId BatchManager_eLSF::submitJob(const Job & job) + { + int status; + Parametre params = job.getParametre(); + const std::string dirForTmpFiles = params[TMPDIR]; + const string fileToExecute = params[EXECUTABLE]; + std::string fileNameToExecute; + if( fileToExecute.size() > 0 ){ + string::size_type p1 = fileToExecute.find_last_of("/"); + string::size_type p2 = fileToExecute.find_last_of("."); + fileNameToExecute = fileToExecute.substr(p1+1,p2-p1-1); + } + else + fileNameToExecute = "command"; + + // export input files on cluster + exportInputFiles(job); + + // build batch script for job + buildBatchScript(job); + + // define name of log file + string logFile="/tmp/logs/"; + logFile += getenv("USER"); + logFile += "/batchSalome_"; + srand ( time(NULL) ); + int ir = rand(); + ostringstream oss; + oss << ir; + logFile += oss.str(); + logFile += ".log"; + + string command; + + // define command to submit batch + command = _protocol; + command += " "; + + if(_username != ""){ + command += _username; + command += "@"; + } + + command += _hostname; + command += " \"cd " ; + command += dirForTmpFiles ; + command += "; bsub < " ; + command += fileNameToExecute ; + command += "_Batch.sh\" > "; + command += logFile; + cerr << command.c_str() << endl; + status = system(command.c_str()); + if(status) + throw EmulationException("Error of connection on remote host"); + + // read id of submitted job in log file + char line[128]; + FILE *fp = fopen(logFile.c_str(),"r"); + fgets( line, 128, fp); + fclose(fp); + + string sline(line); + int p10 = sline.find("<"); + int p20 = sline.find(">"); + string strjob = sline.substr(p10+1,p20-p10-1); + + JobId id(this, strjob); + return id; + } + + // Methode pour le controle des jobs : retire un job du gestionnaire + void BatchManager_eLSF::deleteJob(const JobId & jobid) + { + int status; + int ref; + istringstream iss(jobid.getReference()); + iss >> ref; + + // define command to submit batch + string command; + command = _protocol; + command += " "; + + if (_username != ""){ + command += _username; + command += "@"; + } + + command += _hostname; + command += " \"bkill " ; + command += iss.str(); + command += "\""; + cerr << command.c_str() << endl; + status = system(command.c_str()); + if(status) + throw EmulationException("Error of connection on remote host"); + + cerr << "jobId = " << ref << "killed" << endl; + } + + // Methode pour le controle des jobs : suspend un job en file d'attente + void BatchManager_eLSF::holdJob(const JobId & jobid) + { + throw EmulationException("Not yet implemented"); + } + + // Methode pour le controle des jobs : relache un job suspendu + void BatchManager_eLSF::releaseJob(const JobId & jobid) + { + throw EmulationException("Not yet implemented"); + } + + + // Methode pour le controle des jobs : modifie un job en file d'attente + void BatchManager_eLSF::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env) + { + throw EmulationException("Not yet implemented"); + } + + // Methode pour le controle des jobs : modifie un job en file d'attente + void BatchManager_eLSF::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_eLSF::alterJob(const JobId & jobid, const Environnement & env) + { + alterJob(jobid, Parametre(), env); + } + + // Methode pour le controle des jobs : renvoie l'etat du job + JobInfo BatchManager_eLSF::queryJob(const JobId & jobid) + { + int id; + istringstream iss(jobid.getReference()); + iss >> id; + + // define name of log file + string logFile="/tmp/logs/"; + logFile += getenv("USER"); + logFile += "/batchSalome_"; + + srand ( time(NULL) ); + int ir = rand(); + ostringstream oss; + oss << ir; + logFile += oss.str(); + logFile += ".log"; + + string command; + int status; + + // define command to submit batch + command = _protocol; + command += " "; + + if (_username != ""){ + command += _username; + command += "@"; + } + + command += _hostname; + command += " \"bjobs " ; + command += iss.str(); + command += "\" > "; + command += logFile; + cerr << command.c_str() << endl; + status = system(command.c_str()); + if(status) + throw EmulationException("Error of connection on remote host"); + + JobInfo_eLSF ji = JobInfo_eLSF(id,logFile); + return ji; + } + + + + // Methode pour le controle des jobs : teste si un job est present en machine + bool BatchManager_eLSF::isRunning(const JobId & jobid) + { + throw EmulationException("Not yet implemented"); + } + + void BatchManager_eLSF::buildBatchScript(const Job & job) + { +#ifndef WIN32 //TODO: need for porting on Windows + int status; + Parametre params = job.getParametre(); + Environnement env = job.getEnvironnement(); + const int nbproc = params[NBPROC]; + const long edt = params[MAXWALLTIME]; + const long mem = params[MAXRAMSIZE]; + const string workDir = params[WORKDIR]; + const std::string dirForTmpFiles = params[TMPDIR]; + const string fileToExecute = params[EXECUTABLE]; + 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); + char* basec=strdup(fileToExecute.c_str()); + fileNameToExecute = "~/" + dirForTmpFiles + "/" + string(basename(basec)); + free(basec); + + int idx = dirForTmpFiles.find("Batch/"); + filelogtemp = dirForTmpFiles.substr(idx+6, dirForTmpFiles.length()); + } + else{ + rootNameToExecute = "command"; + } + + ofstream tempOutputFile; + std::string TmpFileName = createAndOpenTemporaryFile(tempOutputFile); + + tempOutputFile << "#! /bin/sh -f" << endl ; + if (queue != "") + tempOutputFile << "#BSUB -q " << queue << endl; + if( edt > 0 ) + tempOutputFile << "#BSUB -W " << getWallTime(edt) << endl ; + if( mem > 0 ) + tempOutputFile << "#BSUB -M " << mem*1024 << endl ; + tempOutputFile << "#BSUB -n " << nbproc << endl ; + if( fileToExecute.size() > 0 ){ + tempOutputFile << "#BSUB -o " << home << "/" << dirForTmpFiles << "/output.log." << filelogtemp << endl ; + tempOutputFile << "#BSUB -e " << home << "/" << dirForTmpFiles << "/error.log." << filelogtemp << endl ; + } + else{ + tempOutputFile << "#BSUB -o " << dirForTmpFiles << "/" << env["LOGFILE"] << ".output.log" << endl ; + tempOutputFile << "#BSUB -e " << dirForTmpFiles << "/" << env["LOGFILE"] << ".error.log" << endl ; + } + if( workDir.size() > 0 ) + tempOutputFile << "cd " << workDir << endl ; + if( fileToExecute.size() > 0 ){ + tempOutputFile << _mpiImpl->boot("",nbproc); + tempOutputFile << _mpiImpl->run("",nbproc,fileNameToExecute); + tempOutputFile << _mpiImpl->halt(); + } + else{ + tempOutputFile << "source " << env["SOURCEFILE"] << endl ; + tempOutputFile << env["COMMAND"]; + } + + tempOutputFile.flush(); + tempOutputFile.close(); +#ifdef WIN32 + _chmod( +#else + chmod( +#endif + TmpFileName.c_str(), 0x1ED); + cerr << TmpFileName.c_str() << endl; + + string command; + if( _protocol == "rsh" ) + command = "rcp "; + else if( _protocol == "ssh" ) + command = "scp "; + else + throw EmulationException("Unknown protocol"); + command += TmpFileName; + command += " "; + if(_username != ""){ + command += _username; + command += "@"; + } + command += _hostname; + command += ":"; + command += dirForTmpFiles ; + command += "/" ; + command += rootNameToExecute ; + command += "_Batch.sh" ; + cerr << command.c_str() << endl; + status = system(command.c_str()); + if(status) + throw EmulationException("Error of connection on remote host"); + + remove(TmpFileName.c_str()); +#endif + + } + + std::string BatchManager_eLSF::getWallTime(const long edt) + { + long h, m; + h = edt / 60; + m = edt - h*60; + ostringstream oss; + if( m >= 10 ) + oss << h << ":" << m; + else + oss << h << ":0" << m; + return oss.str(); + } + +} diff --git a/src/LSF/Batch_BatchManager_eLSF.hxx b/src/LSF/Batch_BatchManager_eLSF.hxx new file mode 100644 index 0000000..d09db3d --- /dev/null +++ b/src/LSF/Batch_BatchManager_eLSF.hxx @@ -0,0 +1,96 @@ +// Copyright (C) 2007-2008 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_eLSF.hxx : emulation of LSF client + * + * Auteur : Bernard SECHER - CEA DEN + * Mail : mailto:bernard.secher@cea.fr + * Date : Thu Apr 24 10:17:22 2008 + * Projet : PAL Salome + * + */ + +#ifndef _BATCHMANAGER_eLSF_H_ +#define _BATCHMANAGER_eLSF_H_ + +#include "Batch_Defines.hxx" + +#include "Batch_JobId.hxx" +#include "Batch_JobInfo.hxx" +#include "Batch_JobInfo_eLSF.hxx" +#include "Batch_InvalidArgumentException.hxx" +#include "Batch_ConnexionFailureException.hxx" +#include "Batch_APIInternalFailureException.hxx" +#include "Batch_NotYetImplementedException.hxx" +#include "Batch_BatchManager.hxx" +#include "Batch_BatchManager_eClient.hxx" + +namespace Batch { + + class Job; + class JobId; + class JobInfo; + class FactBatchManager; + + class BATCH_EXPORT BatchManager_eLSF : public BatchManager_eClient + { + public: + // Constructeur et destructeur + BatchManager_eLSF(const FactBatchManager * parent, const char * host="localhost", const char * protocol="ssh", const char * mpiImpl="nompi") throw(InvalidArgumentException,ConnexionFailureException); // connexion a la machine host + virtual ~BatchManager_eLSF(); + + // Recupere le nom du serveur par defaut + // static string BatchManager_LSF::getDefaultServer(); + + // Methodes pour le controle des jobs + virtual const JobId submitJob(const Job & job); // soumet un job au gestionnaire + virtual void deleteJob(const JobId & jobid); // retire un job du gestionnaire + virtual void holdJob(const JobId & jobid); // suspend un job en file d'attente + virtual void releaseJob(const JobId & jobid); // relache un job suspendu + virtual void alterJob(const JobId & jobid, const Parametre & param, const Environnement & env); // modifie un job en file d'attente + virtual void alterJob(const JobId & jobid, const Parametre & param); // modifie un job en file d'attente + virtual void alterJob(const JobId & jobid, const Environnement & env); // modifie un job en file d'attente + virtual JobInfo queryJob(const JobId & jobid); // renvoie l'etat du job + virtual bool isRunning(const JobId & jobid); // teste si un job est present en machine + + virtual void setParametre(const JobId & jobid, const Parametre & param) { return alterJob(jobid, param); } // modifie un job en file d'attente + virtual void setEnvironnement(const JobId & jobid, const Environnement & env) { return alterJob(jobid, env); } // modifie un job en file d'attente + + + protected: + void buildBatchScript(const Job & job); + std::string getWallTime(const long edt); + + private: + +#ifdef SWIG + public: + // Recupere le l'identifiant d'un job deja soumis au BatchManager + //virtual const JobId getJobIdByReference(const string & ref) { return BatchManager::getJobIdByReference(ref); } + virtual const JobId getJobIdByReference(const char * ref) { return BatchManager::getJobIdByReference(ref); } +#endif + + }; + +} + +#endif diff --git a/src/LSF/Batch_FactBatchManager_LSF.cxx b/src/LSF/Batch_FactBatchManager_LSF.cxx new file mode 100644 index 0000000..6149947 --- /dev/null +++ b/src/LSF/Batch_FactBatchManager_LSF.cxx @@ -0,0 +1,60 @@ +// Copyright (C) 2007-2008 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 new file mode 100644 index 0000000..59ef2ad --- /dev/null +++ b/src/LSF/Batch_FactBatchManager_LSF.hxx @@ -0,0 +1,57 @@ +// Copyright (C) 2007-2008 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_FactBatchManager_eLSF.cxx b/src/LSF/Batch_FactBatchManager_eLSF.cxx new file mode 100644 index 0000000..e46b355 --- /dev/null +++ b/src/LSF/Batch_FactBatchManager_eLSF.cxx @@ -0,0 +1,63 @@ +// Copyright (C) 2007-2008 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_eLSF.cxx : + * + * Auteur : Bernard SECHER - CEA DEN + * Date : Avril 2008 + * Projet : PAL Salome + * + */ + +#include +#include "Batch_BatchManager_eLSF.hxx" +#include "Batch_FactBatchManager_eLSF.hxx" +//#include "utilities.h" + +namespace Batch { + + // Constructeur + FactBatchManager_eLSF::FactBatchManager_eLSF() : FactBatchManager_eClient("eLSF") + { + // Nothing to do + } + + // Destructeur + FactBatchManager_eLSF::~FactBatchManager_eLSF() + { + // Nothing to do + } + + // Functor + BatchManager * FactBatchManager_eLSF::operator() (const char * hostname) const + { + // MESSAGE("Building new BatchManager_LSF on host '" << hostname << "'"); + return new BatchManager_eLSF(this, hostname); + } + + BatchManager_eClient * FactBatchManager_eLSF::operator() (const char * hostname, const char * protocol, const char * mpiImpl) const + { + // MESSAGE("Building new BatchManager_LSF on host '" << hostname << "'"); + return new BatchManager_eLSF(this, hostname, protocol, mpiImpl); + } + +} diff --git a/src/LSF/Batch_FactBatchManager_eLSF.hxx b/src/LSF/Batch_FactBatchManager_eLSF.hxx new file mode 100644 index 0000000..d2dec68 --- /dev/null +++ b/src/LSF/Batch_FactBatchManager_eLSF.hxx @@ -0,0 +1,63 @@ +// Copyright (C) 2007-2008 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_eLSF.hxx : + * + * Auteur : Bernard SECHER : CEA DEN + * Date : Avril 2008 + * Projet : PAL Salome + * + */ + +#ifndef _FACTBATCHMANAGER_eLSF_H_ +#define _FACTBATCHMANAGER_eLSF_H_ + +#include "Batch_Defines.hxx" + +#include +#include +#include "Batch_BatchManager_eClient.hxx" +#include "Batch_FactBatchManager_eClient.hxx" + +namespace Batch { + + class BatchManager_eLSF; + + class BATCH_EXPORT FactBatchManager_eLSF : public FactBatchManager_eClient + { + public: + // Constructeur et destructeur + FactBatchManager_eLSF(); + virtual ~FactBatchManager_eLSF(); + + virtual BatchManager * operator() (const char * hostname) const; + virtual BatchManager_eClient * operator() (const char * hostname, const char * protocol, const char * mpiImpl) const; + + protected: + + private: + + }; + +} + +#endif diff --git a/src/LSF/Batch_JobInfo_LSF.cxx b/src/LSF/Batch_JobInfo_LSF.cxx new file mode 100644 index 0000000..b964aba --- /dev/null +++ b/src/LSF/Batch_JobInfo_LSF.cxx @@ -0,0 +1,204 @@ +// Copyright (C) 2007-2008 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_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;"; + + _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_JobInfo_eLSF.cxx b/src/LSF/Batch_JobInfo_eLSF.cxx new file mode 100644 index 0000000..6f6f063 --- /dev/null +++ b/src/LSF/Batch_JobInfo_eLSF.cxx @@ -0,0 +1,107 @@ +// Copyright (C) 2007-2008 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_eLSF.cxx : emulation of LSF client + * + * Auteur : Bernard SECHER - CEA DEN + * Mail : mailto:bernard.secher@cea.fr + * Date : Thu Apr 24 10:17:22 2008 + * Projet : PAL Salome + * + */ + +#include +#include +#include +#include +#include "Batch_Parametre.hxx" +#include "Batch_Environnement.hxx" +#include "Batch_RunTimeException.hxx" +#include "Batch_APIInternalFailureException.hxx" +#include "Batch_JobInfo_eLSF.hxx" + +using namespace std; + +namespace Batch { + + + + // Constructeurs + JobInfo_eLSF::JobInfo_eLSF(int id, string logFile) : JobInfo() + { + // On remplit les membres _param et _env + ostringstream oss; + oss << id; + _param[ID] = oss.str(); + + // read status of job in log file + char line[128]; + ifstream fp(logFile.c_str(),ios::in); + fp.getline(line,80,'\n'); + + string sjobid, username, status; + fp >> sjobid; + fp >> username; + fp >> status; + + _param[STATE] = status; + + if( status.find("RUN") != string::npos) + _running = true; + + } + + // Teste si un job est present en machine + bool JobInfo_eLSF::isRunning() const + { + return _running; + } + + + // Destructeur + JobInfo_eLSF::~JobInfo_eLSF() + { + // Nothing to do + } + + // Convertit une date HH:MM:SS en secondes + long JobInfo_eLSF::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_eLSF::__str__() const + { + ostringstream sst; + sst << " + +namespace Batch { + + class JobInfo_eLSF : public JobInfo + { + public: + // Constructeurs et destructeur + JobInfo_eLSF() : _running(false) {}; + JobInfo_eLSF(int id,std::string logFile); + virtual ~JobInfo_eLSF(); + + // Constructeur par recopie + JobInfo_eLSF(const JobInfo_eLSF & 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 new file mode 100644 index 0000000..760e7b7 --- /dev/null +++ b/src/LSF/Batch_Job_LSF.cxx @@ -0,0 +1,264 @@ +// Copyright (C) 2007-2008 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_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 new file mode 100644 index 0000000..8db0766 --- /dev/null +++ b/src/LSF/Batch_Job_LSF.hxx @@ -0,0 +1,65 @@ +// Copyright (C) 2007-2008 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 new file mode 100644 index 0000000..484bf16 --- /dev/null +++ b/src/LSF/CMakeLists.txt @@ -0,0 +1,38 @@ +# Copyright (C) 2007-2008 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 +# + +SET(CLASS_LIST LSF/Batch_BatchManager_eLSF + LSF/Batch_FactBatchManager_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}) +APPEND_CLASSES_TO_HDR_FILES(${CLASS_LIST}) diff --git a/src/Local/Batch_BatchManager_Local.cxx b/src/Local/Batch_BatchManager_Local.cxx new file mode 100644 index 0000000..3b726d6 --- /dev/null +++ b/src/Local/Batch_BatchManager_Local.cxx @@ -0,0 +1,825 @@ +// Copyright (C) 2007-2008 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_Local.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 +* +*/ + +#include +#include +#include +#include +#include + +#include +#ifdef WIN32 +# include +#else +# include +# include +#endif +#include +#include +#include +#include +#include +#include "Batch_IOMutex.hxx" +#include "Batch_BatchManager_Local.hxx" + +using namespace std; + +namespace Batch { + + + // Constructeur + BatchManager_Local::BatchManager_Local(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager(parent, host), _connect(0), _threads_mutex(), _threads(), _thread_id_id_association_mutex(), _thread_id_id_association_cond() +#ifndef WIN32 //TODO: porting of following functionality + ,_thread_id_id_association() +#endif + { + pthread_mutex_init(&_threads_mutex, NULL); + pthread_mutex_init(&_thread_id_id_association_mutex, NULL); + pthread_cond_init(&_thread_id_id_association_cond, NULL); + } + + // Destructeur + BatchManager_Local::~BatchManager_Local() + { + pthread_mutex_destroy(&_threads_mutex); + pthread_mutex_destroy(&_thread_id_id_association_mutex); + pthread_cond_destroy(&_thread_id_id_association_cond); + } + + // Methode pour le controle des jobs : soumet un job au gestionnaire + const JobId BatchManager_Local::submitJob(const Job & job) + { + Job_Local jobLocal = job; + + pthread_t thread_id = submit(jobLocal); + + ostringstream oss; + oss << getIdByThread_id(thread_id); + + JobId id(this, oss.str()); + + return id; + } + + // Methode pour le controle des jobs : retire un job du gestionnaire + void BatchManager_Local::deleteJob(const JobId & jobid) + { + Id id; + + istringstream iss(jobid.getReference()); + iss >> id; + + // On retrouve le thread_id du thread + pthread_t thread_id; + + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_threads_mutex); + if (_threads.find(id) != _threads.end()) + thread_id = _threads[id].thread_id; + pthread_mutex_unlock(&_threads_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + + cancel(thread_id); + } + + // Methode pour le controle des jobs : suspend un job en file d'attente + void BatchManager_Local::holdJob(const JobId & jobid) + { + Id id; + istringstream iss(jobid.getReference()); + iss >> id; + + UNDER_LOCK( cout << "BatchManager is sending HOLD command to the thread " << id << endl ); + + // On introduit une commande dans la queue du thread + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_threads_mutex); + if (_threads.find(id) != _threads.end()) + _threads[id].command_queue.push(HOLD); + pthread_mutex_unlock(&_threads_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + } + + // Methode pour le controle des jobs : relache un job suspendu + void BatchManager_Local::releaseJob(const JobId & jobid) + { + Id id; + istringstream iss(jobid.getReference()); + iss >> id; + + UNDER_LOCK( cout << "BatchManager is sending RELEASE command to the thread " << id << endl ); + + // On introduit une commande dans la queue du thread + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_threads_mutex); + if (_threads.find(id) != _threads.end()) + _threads[id].command_queue.push(RELEASE); + pthread_mutex_unlock(&_threads_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + } + + + // Methode pour le controle des jobs : modifie un job en file d'attente + void BatchManager_Local::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env) + { + } + + // Methode pour le controle des jobs : modifie un job en file d'attente + void BatchManager_Local::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_Local::alterJob(const JobId & jobid, const Environnement & env) + { + alterJob(jobid, Parametre(), env); + } + + + + // Methode pour le controle des jobs : renvoie l'etat du job + JobInfo BatchManager_Local::queryJob(const JobId & jobid) + { + Id id; + istringstream iss(jobid.getReference()); + iss >> id; + + Parametre param; + Environnement env; + + //UNDER_LOCK( cout << "JobInfo BatchManager_Local::queryJob(const JobId & jobid) : AVANT section critique" << endl ); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_threads_mutex); + param = _threads[id].param; + env = _threads[id].env; + pthread_mutex_unlock(&_threads_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + //UNDER_LOCK( cout << "JobInfo BatchManager_Local::queryJob(const JobId & jobid) : APRES section critique" << endl ); + + JobInfo_Local ji(param, env); + return ji; + } + + + + // Methode pour le controle des jobs : teste si un job est present en machine + bool BatchManager_Local::isRunning(const JobId & jobid) + { + Id id; + istringstream iss(jobid.getReference()); + iss >> id; + + Status status; + + //UNDER_LOCK( cout << "JobInfo BatchManager_Local::queryJob(const JobId & jobid) : AVANT section critique" << endl ); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_threads_mutex); + status = _threads[id].status; + pthread_mutex_unlock(&_threads_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + //UNDER_LOCK( cout << "JobInfo BatchManager_Local::queryJob(const JobId & jobid) : APRES section critique" << endl ); + + return (status == RUNNING); + } + + + // Methode d'execution d'un job + pthread_t BatchManager_Local::submit(const Job_Local & job) + { + // L'id du thread a creer + pthread_t thread_id = +#ifdef WIN32 + {0,0}; +#else + 0; +#endif + + // Les attributs du thread a sa creation + pthread_attr_t thread_attr; + pthread_attr_init(&thread_attr); + pthread_attr_setdetachstate(&thread_attr, PTHREAD_CREATE_DETACHED); + + ThreadAdapter * p_ta = new ThreadAdapter(*this, job); + + // Creation du thread qui va executer la commande systeme qu'on lui passe + int rc = pthread_create(&thread_id, + &thread_attr, + &ThreadAdapter::run, + static_cast(p_ta)); + if (rc) { + } + + // Liberation des zones memoire maintenant inutiles occupees par les attributs du thread + pthread_attr_destroy(&thread_attr); + + return thread_id; + } + + + // Methode de destruction d'un job + void BatchManager_Local::cancel(pthread_t thread_id) + { + pthread_cancel(thread_id); + } + + + // Fabrique un identifiant unique pour les threads puisque le thread_id n'est pas unique + // au cours du temps (il peut etre reutilise lorsqu'un thread se termine) + // ATTENTION : cette methode est uniquement protegee par la section critique de l'association + // Thread_id / Id (_thread_id_id_association_mutex) + BatchManager_Local::Id BatchManager_Local::nextId() + { + static Id id = 0; + Id nextId = id++; + //UNDER_LOCK( cout << "BatchManager_Local::Id BatchManager_Local::nextId() : Id = " << nextId << endl ); + return nextId; + } + + + // Retourne l'Id enregistre dans l'association Thread_id / Id et le detruit immediatement + BatchManager_Local::Id BatchManager_Local::getIdByThread_id(pthread_t thread_id) + { + Id id = -1; + + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_thread_id_id_association_mutex); +#ifndef WIN32 //TODO: porting of following functionality + while (_thread_id_id_association.find(thread_id) == _thread_id_id_association.end()) + pthread_cond_wait(&_thread_id_id_association_cond, &_thread_id_id_association_mutex); + + id = _thread_id_id_association[thread_id]; + _thread_id_id_association.erase(thread_id); +#endif + + pthread_mutex_unlock(&_thread_id_id_association_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + + //UNDER_LOCK( cout << "BatchManager_Local::Id BatchManager_Local::getIdByThread_id(pthread_t thread_id) : Id = " << id << " - thread_id = " << thread_id << endl ); + return id; + } + + + // Associe un Thread_id a un Id nouvellement cree + BatchManager_Local::Id BatchManager_Local::registerThread_id(pthread_t thread_id) + { + Id id = -1; + + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_thread_id_id_association_mutex); +#ifndef WIN32 //TODO: porting of following functionality + if (_thread_id_id_association.find(thread_id) == _thread_id_id_association.end()) { + id = _thread_id_id_association[thread_id] = nextId(); + pthread_cond_signal(&_thread_id_id_association_cond); + + } else { + UNDER_LOCK( cerr << "ERROR : Pthread Inconstency. Two threads own the same thread_id." << endl ); + } +#endif + pthread_mutex_unlock(&_thread_id_id_association_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + + //UNDER_LOCK( cout << "BatchManager_Local::Id BatchManager_Local::registerThread_id(pthread_t thread_id) : Id = " << id << " - thread_id = " << thread_id << endl ); + return id; + } + + + // Constructeur de la classe ThreadAdapter + BatchManager_Local::ThreadAdapter::ThreadAdapter(BatchManager_Local & bm, const Job_Local & job) : + _bm(bm), _job(job) + { + // Nothing to do + } + + + + // Methode d'execution du thread + void * BatchManager_Local::ThreadAdapter::run(void * arg) + { +#ifndef WIN32 //TODO: porting of following functionality + // On bloque tous les signaux pour ce thread + sigset_t setmask; + sigfillset(&setmask); + pthread_sigmask(SIG_BLOCK, &setmask, NULL); + + // On autorise la terminaison differee du thread + // (ces valeurs sont les valeurs par defaut mais on les force par precaution) + pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); + pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL); + + // On enregistre la fonction de suppression du fils en cas d'arret du thread + // Cette fontion sera automatiquement appelee lorsqu'une demande d'annulation + // sera prise en compte par pthread_testcancel() + pid_t child; + pthread_cleanup_push(BatchManager_Local::kill_child_on_exit, static_cast (&child)); + pthread_cleanup_push(BatchManager_Local::delete_on_exit, arg); + + ThreadAdapter * p_ta = static_cast(arg); + + + + + // Le code retour cumule (ORed) de tous les appels + // Nul en cas de reussite de l'ensemble des operations + int rc = 0; + + // Cette table contient la liste des fichiers a detruire a la fin du processus + std::vector files_to_delete; + + + + // On copie les fichiers d'entree pour le fils + const Parametre param = p_ta->_job.getParametre(); + Parametre::const_iterator it; + + // On initialise la variable workdir a la valeur du Current Working Directory + char * cwd = +#ifdef WIN32 + _getcwd(NULL, 0); +#else + new char [PATH_MAX]; + getcwd(cwd, PATH_MAX); +#endif + string workdir = cwd; + delete [] cwd; + + if ( (it = param.find(WORKDIR)) != param.end() ) { + workdir = static_cast( (*it).second ); + } + + string executionhost = string(param[EXECUTIONHOST]); + + if ( (it = param.find(INFILE)) != param.end() ) { + 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(); + + string copy_cmd = p_ta->getBatchManager().copy_command("", local, executionhost, workdir + "/" + remote); + UNDER_LOCK( cout << "Copying : " << copy_cmd << endl ); + + if (system(copy_cmd.c_str()) ) { + // Echec de la copie + rc |= 1; + } else { + // On enregistre le fichier comme etant a detruire + files_to_delete.push_back(workdir + "/" + remote); + } + + } + } + + + + +#ifdef WIN32 + //TODO + //Using CreateThread instead fork() POSIX function +#else + // On forke/exec un nouveau process pour pouvoir controler le fils + // (plus finement qu'avec un appel system) + // int rc = system(commande.c_str()); + child = fork(); + if (child < 0) { // erreur + UNDER_LOCK( cerr << "Fork impossible (rc=" << child << ")" << endl ); + + } else if (child > 0) { // pere + p_ta->pere(child); + + } else { // fils + p_ta->fils(); + } +#endif + + + + // On copie les fichiers de sortie du fils + if ( (it = param.find(OUTFILE)) != param.end() ) { + 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(); + + string copy_cmd = p_ta->getBatchManager().copy_command(executionhost, workdir + "/" + remote, "", local); + UNDER_LOCK( cout << "Copying : " << copy_cmd << endl ); + + if (system(copy_cmd.c_str()) ) { + // Echec de la copie + rc |= 1; + } else { + // On enregistre le fichier comme etant a detruire + files_to_delete.push_back(workdir + "/" + remote); + } + + } + } + + // On efface les fichiers d'entree et de sortie du fils si les copies precedentes ont reussi + // ou si la creation du fils n'a pu avoir lieu + if ( (rc == 0) || (child < 0) ) { + std::vector::const_iterator it; + for(it=files_to_delete.begin(); it!=files_to_delete.end(); it++) { + string remove_cmd = p_ta->getBatchManager().remove_command(executionhost, *it); + UNDER_LOCK( cout << "Removing : " << remove_cmd << endl ); + system(remove_cmd.c_str()); + } + } + + + + // On retire la fonction de nettoyage de la memoire + pthread_cleanup_pop(0); + + // On retire la fonction de suppression du fils + pthread_cleanup_pop(0); + + + + // On invoque la fonction de nettoyage de la memoire + delete_on_exit(arg); + + UNDER_LOCK( cout << "Father is leaving" << endl ); + pthread_exit(NULL); +#endif + return NULL; + } + + + + + void BatchManager_Local::ThreadAdapter::pere(pid_t child) + { +#ifndef WIN32 //TODO: porting of following functionality + time_t child_starttime = time(NULL); + + // On enregistre le fils dans la table des threads + pthread_t thread_id = pthread_self(); + Id id = _bm.registerThread_id(thread_id); + + Parametre param = _job.getParametre(); + Environnement env = _job.getEnvironnement(); + + ostringstream thread_id_sst; + thread_id_sst << id; + param[ID] = thread_id_sst.str(); + param[STATE] = "Running"; + param[PID] = child; + + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_bm._threads_mutex); + _bm._threads[id].thread_id = thread_id; + _bm._threads[id].pid = child; + _bm._threads[id].status = RUNNING; + _bm._threads[id].param = param; + _bm._threads[id].env = env; + _bm._threads[id].command_queue.push(NOP); + pthread_mutex_unlock(&_bm._threads_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + + + + + + // on boucle en attendant que le fils ait termine + while (1) { + int child_rc = 0; + pid_t child_wait_rc = waitpid(child, &child_rc, WNOHANG /* | WUNTRACED */); + if (child_wait_rc > 0) { + if (WIFSTOPPED(child_rc)) { + // NOTA : pour rentrer dans cette section, il faut que le flag WUNTRACED + // soit positionne dans l'appel a waitpid ci-dessus. Ce flag est couramment + // desactive car s'il est possible de detecter l'arret d'un process, il est + // plus difficile de detecter sa reprise. + + // Le fils est simplement stoppe + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_bm._threads_mutex); + _bm._threads[id].status = STOPPED; + _bm._threads[id].param[STATE] = "Stopped"; + pthread_mutex_unlock(&_bm._threads_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + UNDER_LOCK( cout << "Father sees his child is STOPPED : " << child_wait_rc << endl ); + + } + else { + // Le fils est termine, on sort de la boucle et du if englobant + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_bm._threads_mutex); + _bm._threads[id].status = DONE; + _bm._threads[id].param[STATE] = "Done"; + pthread_mutex_unlock(&_bm._threads_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + UNDER_LOCK( cout << "Father sees his child is DONE : " << child_wait_rc << " (child_rc=" << (WIFEXITED(child_rc) ? WEXITSTATUS(child_rc) : -1) << ")" << endl ); + break; + } + } + else if (child_wait_rc == -1) { + // Le fils a disparu ... + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_bm._threads_mutex); + _bm._threads[id].status = DEAD; + _bm._threads[id].param[STATE] = "Dead"; + pthread_mutex_unlock(&_bm._threads_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + UNDER_LOCK( cout << "Father sees his child is DEAD : " << child_wait_rc << " (Reason : " << strerror(errno) << ")" << endl ); + break; + } + + + + // On teste si le thread doit etre detruit + pthread_testcancel(); + + + + // On regarde si le fils n'a pas depasse son temps (wallclock time) + time_t child_currenttime = time(NULL); + time_t child_elapsedtime = child_currenttime - child_starttime; + if (param.find(MAXWALLTIME) != param.end()) { + int maxwalltime = param[MAXWALLTIME]; + // cout << "child_starttime = " << child_starttime << endl + // << "child_currenttime = " << child_currenttime << endl + // << "child_elapsedtime = " << child_elapsedtime << endl + // << "maxwalltime = " << maxwalltime << endl + // << "int(maxwalltime * 1.1) = " << int(maxwalltime * 1.1) << endl; + if (child_elapsedtime > int(maxwalltime * 1.1) ) { // On se donne 10% de marge avant le KILL + UNDER_LOCK( cout << "Father is sending KILL command to the thread " << id << endl ); + // On introduit une commande dans la queue du thread + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_bm._threads_mutex); + if (_bm._threads.find(id) != _bm._threads.end()) + _bm._threads[id].command_queue.push(KILL); + pthread_mutex_unlock(&_bm._threads_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + + + } else if (child_elapsedtime > maxwalltime ) { + UNDER_LOCK( cout << "Father is sending TERM command to the thread " << id << endl ); + // On introduit une commande dans la queue du thread + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_bm._threads_mutex); + if (_bm._threads.find(id) != _bm._threads.end()) + _bm._threads[id].command_queue.push(TERM); + pthread_mutex_unlock(&_bm._threads_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + } + } + + + + // On regarde s'il y a quelque chose a faire dans la queue de commande + // @@@ --------> SECTION CRITIQUE <-------- @@@ + pthread_mutex_lock(&_bm._threads_mutex); + if (_bm._threads.find(id) != _bm._threads.end()) { + while (_bm._threads[id].command_queue.size() > 0) { + Commande cmd = _bm._threads[id].command_queue.front(); + _bm._threads[id].command_queue.pop(); + + switch (cmd) { + case NOP: + UNDER_LOCK( cout << "Father does nothing to his child" << endl ); + break; + + case HOLD: + UNDER_LOCK( cout << "Father is sending SIGSTOP signal to his child" << endl ); + kill(child, SIGSTOP); + break; + + case RELEASE: + UNDER_LOCK( cout << "Father is sending SIGCONT signal to his child" << endl ); + kill(child, SIGCONT); + break; + + case TERM: + UNDER_LOCK( cout << "Father is sending SIGTERM signal to his child" << endl ); + kill(child, SIGTERM); + break; + + case KILL: + UNDER_LOCK( cout << "Father is sending SIGKILL signal to his child" << endl ); + kill(child, SIGKILL); + break; + + case ALTER: + break; + + default: + break; + } + } + + } + pthread_mutex_unlock(&_bm._threads_mutex); + // @@@ --------> SECTION CRITIQUE <-------- @@@ + + // On fait une petite pause pour ne pas surcharger inutilement le processeur + sleep(1); + + } +#endif + + + } + + + + + void BatchManager_Local::ThreadAdapter::fils() + { +#ifndef WIN32 //TODO: porting of following functionality + Parametre param = _job.getParametre(); + Parametre::iterator it; + + try { + + // On se place dans le repertoire de travail + if ( (it = param.find(WORKDIR)) != param.end() ) { + string workdir = static_cast( (*it).second ); + chdir(workdir.c_str()); + } + + + + + // EXECUTABLE is MANDATORY, if missing, we exit with failure notification + char * execpath = NULL; + if (param.find(EXECUTABLE) != param.end()) { + string executable = _bm.exec_command(param); + execpath = new char [executable.size() + 1]; + strncpy(execpath, executable.c_str(), executable.size() + 1); + } else exit(1); + + string debug_command = execpath; + + string name = (param.find(NAME) != param.end()) ? param[NAME] : param[EXECUTABLE]; + + char ** argv = NULL; + if (param.find(ARGUMENTS) != param.end()) { + Versatile V = param[ARGUMENTS]; + + argv = new char * [V.size() + 2]; // 1 pour name et 1 pour le NULL terminal + + argv[0] = new char [name.size() + 1]; + strncpy(argv[0], name.c_str(), name.size() + 1); + + debug_command += string(" # ") + argv[0]; + + int i = 1; + for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++, i++) { + StringType argt = * static_cast(*it); + string arg = argt; + argv[i] = new char [arg.size() + 1]; + strncpy(argv[i], arg.c_str(), arg.size() + 1); + debug_command += string(" # ") + argv[i]; + } + + // assert (i == V.size() + 1) + argv[i] = NULL; + } + + + UNDER_LOCK( cout << "*** debug_command = " << debug_command << endl ); + + + + Environnement env = _job.getEnvironnement(); + + + char ** envp = NULL; + if(env.size() > 0) { + envp = new char * [env.size() + 1]; // 1 pour le NULL terminal + int i = 0; + for(Environnement::const_iterator it=env.begin(); it!=env.end(); it++, i++) { + const string & key = (*it).first; + const string & value = (*it).second; + ostringstream oss; + oss << key << "=" << value; + envp[i] = new char [oss.str().size() + 1]; + strncpy(envp[i], oss.str().c_str(), oss.str().size() + 1); + } + + // assert (i == env.size()) + envp[i] = NULL; + } + + + + + // On positionne les limites systeme imposees au fils + if (param.find(MAXCPUTIME) != param.end()) { + int maxcputime = param[MAXCPUTIME]; + struct rlimit limit; + limit.rlim_cur = maxcputime; + limit.rlim_max = int(maxcputime * 1.1); + setrlimit(RLIMIT_CPU, &limit); + } + + if (param.find(MAXDISKSIZE) != param.end()) { + int maxdisksize = param[MAXDISKSIZE]; + struct rlimit limit; + limit.rlim_cur = maxdisksize * 1024; + limit.rlim_max = int(maxdisksize * 1.1) * 1024; + setrlimit(RLIMIT_FSIZE, &limit); + } + + if (param.find(MAXRAMSIZE) != param.end()) { + int maxramsize = param[MAXRAMSIZE]; + struct rlimit limit; + limit.rlim_cur = maxramsize * 1024; + limit.rlim_max = int(maxramsize * 1.1) * 1024; + setrlimit(RLIMIT_AS, &limit); + } + + + + // On cree une session pour le fils de facon a ce qu'il ne soit pas + // detruit lorsque le shell se termine (le shell ouvre une session et + // tue tous les process appartenant a la session en quittant) + setsid(); + + + // On ferme les descripteurs de fichiers standards + //close(STDIN_FILENO); + //close(STDOUT_FILENO); + //close(STDERR_FILENO); + + + // On execute la commande du fils + execve(execpath, argv, envp); + + // No need to deallocate since nothing happens after a successful exec + + // Normalement on ne devrait jamais arriver ici + ofstream file_err("error.log"); + UNDER_LOCK( file_err << "Echec de l'appel a execve" << endl ); + + } catch (GenericException & e) { + + std::cerr << "Caught exception : " << e.type << " : " << e.message << std::endl; + } + + exit(99); +#endif + } + + + + + void BatchManager_Local::kill_child_on_exit(void * p_pid) + { +#ifndef WIN32 + //TODO: porting of following functionality + pid_t child = * static_cast(p_pid); + + // On tue le fils + kill(child, SIGTERM); + + // Nota : on pourrait aussi faire a la suite un kill(child, SIGKILL) + // mais cette option n'est pas implementee pour le moment, car il est + // preferable de laisser le process fils se terminer normalement et seul. +#endif + } + + void BatchManager_Local::delete_on_exit(void * arg) + { + ThreadAdapter * p_ta = static_cast(arg); + delete p_ta; + } + +} diff --git a/src/Local/Batch_BatchManager_Local.hxx b/src/Local/Batch_BatchManager_Local.hxx new file mode 100644 index 0000000..33f9dfa --- /dev/null +++ b/src/Local/Batch_BatchManager_Local.hxx @@ -0,0 +1,174 @@ +// Copyright (C) 2007-2008 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_Local.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_LOCAL_H_ +#define _BATCHMANAGER_LOCAL_H_ + +#include "Batch_Defines.hxx" + +#include +#include +#include +#include +#include "Batch_Job.hxx" +#include "Batch_JobId.hxx" +#include "Batch_JobInfo.hxx" +#include "Batch_JobInfo_Local.hxx" +#include "Batch_Job_Local.hxx" +#include "Batch_InvalidArgumentException.hxx" +#include "Batch_ConnexionFailureException.hxx" +#include "Batch_APIInternalFailureException.hxx" +#include "Batch_NotYetImplementedException.hxx" +#include "Batch_BatchManager.hxx" + +namespace Batch { + + class FactBatchManager; + + class BATCH_EXPORT BatchManager_Local : public BatchManager + { + private: + friend class ThreadAdapter; + class ThreadAdapter{ + public: + ThreadAdapter(BatchManager_Local & bm, const Job_Local & job); + static void * run(void * arg); + BatchManager_Local & getBatchManager() const { return _bm; }; + + protected: + BatchManager_Local & _bm; + const Job_Local _job; + + private: + void pere(pid_t child); + void fils(); + + }; + + typedef int Id; + + enum Commande { + NOP = 0, + HOLD, + RELEASE, + TERM, + KILL, + ALTER + }; + + enum Status { + UNKNOWN = 0, + RUNNING, + STOPPED, + DONE, + DEAD + }; + + struct Child { + pthread_t thread_id; + std::queue > command_queue; + pid_t pid; + int exit_code; + Status status; + Parametre param; + Environnement env; + }; + + + + public: + // Constructeur et destructeur + BatchManager_Local(const FactBatchManager * parent, const char * host="localhost") throw(InvalidArgumentException,ConnexionFailureException); // connexion a la machine host + virtual ~BatchManager_Local(); + + // Recupere le nom du serveur par defaut + // static string BatchManager_Local::getDefaultServer(); + + // Methodes pour le controle des jobs + virtual const JobId submitJob(const Job & job); // soumet un job au gestionnaire + virtual void deleteJob(const JobId & jobid); // retire un job du gestionnaire + virtual void holdJob(const JobId & jobid); // suspend un job en file d'attente + virtual void releaseJob(const JobId & jobid); // relache un job suspendu + virtual void alterJob(const JobId & jobid, const Parametre & param, const Environnement & env); // modifie un job en file d'attente + virtual void alterJob(const JobId & jobid, const Parametre & param); // modifie un job en file d'attente + virtual void alterJob(const JobId & jobid, const Environnement & env); // modifie un job en file d'attente + virtual JobInfo queryJob(const JobId & jobid); // renvoie l'etat du job + virtual bool isRunning(const JobId & jobid); // teste si un job est present en machine + + virtual void setParametre(const JobId & jobid, const Parametre & param) { return alterJob(jobid, param); } // modifie un job en file d'attente + virtual void setEnvironnement(const JobId & jobid, const Environnement & env) { return alterJob(jobid, env); } // modifie un job en file d'attente + + + protected: + int _connect; // Local connect id + pthread_mutex_t _threads_mutex; + std::map _threads; + + // Methode abstraite qui renvoie la commande de copie du fichier source en destination + virtual std::string copy_command( const std::string & host_source, + const std::string & source, + const std::string & host_destination, + const std::string & destination) const = 0; + + // Methode abstraite qui renvoie la commande a executer + virtual std::string exec_command(Parametre & param) const = 0; + + // Methode abstraite qui renvoie la commande d'effacement du fichier + virtual std::string remove_command( const std::string & host_destination, + const std::string & destination) const = 0; + + private: + virtual pthread_t submit(const Job_Local & job); + virtual void cancel(pthread_t thread_id); + static void kill_child_on_exit(void * p_pid); + static void delete_on_exit(void * arg); + Id nextId(); // Retourne un identifiant unique pour un thread (clef de la map) + Id getIdByThread_id(pthread_t thread_id); + Id registerThread_id(pthread_t thread_id); + pthread_mutex_t _thread_id_id_association_mutex; + pthread_cond_t _thread_id_id_association_cond; +#ifndef WIN32 //TODO: porting of following functionality + //reason: pthread_t on win32 is a struct of pointer and int members + std::map _thread_id_id_association; +#endif + +#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/Local/Batch_BatchManager_Local_RSH.cxx b/src/Local/Batch_BatchManager_Local_RSH.cxx new file mode 100644 index 0000000..56c6e45 --- /dev/null +++ b/src/Local/Batch_BatchManager_Local_RSH.cxx @@ -0,0 +1,150 @@ +// Copyright (C) 2007-2008 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_Local_RSH.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 + * + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include +#ifndef WIN32 +#include +#include +#endif +#include +#include +#include +#include +#include +#include "Batch_IOMutex.hxx" +#include "Batch_BatchManager_Local_RSH.hxx" + +#include "Batch_config.h" + +#ifndef RM +#error "RM undefined. You must set RM to a valid path to a rm-like command." +#endif + +#ifndef RCP +#error "RCP undefined. You must set RCP to a valid path to a rcp-like command." +#endif + +#ifndef RSH +#error "RSH undefined. You must set RSH to a valid path to a rsh-like command." +#endif + +using namespace std; + +namespace Batch { + + + // Constructeur + BatchManager_Local_RSH::BatchManager_Local_RSH(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager_Local(parent, host) + { + } + + // Destructeur + BatchManager_Local_RSH::~BatchManager_Local_RSH() + { + } + + + // Methode abstraite qui renvoie la commande de copie du fichier source en destination + string BatchManager_Local_RSH::copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const + { + ostringstream fullsource; + if (host_source.size() != 0) { + fullsource << host_source << ":"; + } + fullsource << source; + + ostringstream fulldestination; + if (host_destination.size() != 0) { + fulldestination << host_destination << ":"; + } + fulldestination << destination; + + ostringstream copy_cmd; + copy_cmd << RCP << " " << fullsource.str() << " " << fulldestination.str(); + return copy_cmd.str(); + } + + // Methode abstraite qui renvoie la commande a executer + string BatchManager_Local_RSH::exec_command(Parametre & param) const + { + ostringstream exec_sub_cmd; + exec_sub_cmd << "cd " << param[WORKDIR] << ";"; + exec_sub_cmd << param[EXECUTABLE]; + + if (param.find(ARGUMENTS) != param.end()) { + Versatile V = param[ARGUMENTS]; + for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++) { + StringType argt = * static_cast(*it); + string arg = argt; + exec_sub_cmd << " " << arg; + } + } + + + Versatile new_arguments; + new_arguments.setMaxSize(0); + new_arguments = string(param[EXECUTIONHOST]); + + + if (param.find(USER) != param.end()) { + new_arguments += "-l"; + new_arguments += string(param[USER]); + } + + new_arguments += exec_sub_cmd.str(); + + param[ARGUMENTS] = new_arguments; + + // Sous Linux on est oblige de modifier ces deux parametres pour faire fonctionner la commande rsh + param[EXECUTABLE] = RSH; + param.erase(NAME); + + return RSH; + } + + // Methode qui renvoie la commande d'effacement du fichier + string BatchManager_Local_RSH::remove_command(const string & host_destination, const string & destination) const + { + string host = (host_destination.size()) ? host_destination : "localhost:"; + + ostringstream remove_cmd; + remove_cmd << RSH << " " << host << " \"" << RM << " " << destination << "\""; + return remove_cmd.str(); + } +} diff --git a/src/Local/Batch_BatchManager_Local_RSH.hxx b/src/Local/Batch_BatchManager_Local_RSH.hxx new file mode 100644 index 0000000..c5c6604 --- /dev/null +++ b/src/Local/Batch_BatchManager_Local_RSH.hxx @@ -0,0 +1,82 @@ +// Copyright (C) 2007-2008 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_Local_RSH.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_LOCAL_RSH_H_ +#define _BATCHMANAGER_LOCAL_RSH_H_ + +#include "Batch_Defines.hxx" + +#include +#include +#include +#include +#include +#include "Batch_Job.hxx" +#include "Batch_JobId.hxx" +#include "Batch_JobInfo.hxx" +#include "Batch_JobInfo_Local.hxx" +#include "Batch_Job_Local.hxx" +#include "Batch_InvalidArgumentException.hxx" +#include "Batch_ConnexionFailureException.hxx" +#include "Batch_APIInternalFailureException.hxx" +#include "Batch_NotYetImplementedException.hxx" +#include "Batch_BatchManager_Local.hxx" + +namespace Batch { + + class FactBatchManager; + + class BATCH_EXPORT BatchManager_Local_RSH : public BatchManager_Local + { + public: + // Constructeur et destructeur + BatchManager_Local_RSH(const FactBatchManager * parent, const char * host="localhost") throw(InvalidArgumentException,ConnexionFailureException); // connexion a la machine host + virtual ~BatchManager_Local_RSH(); + + protected: + // Methode abstraite qui renvoie la commande de copie du fichier source en destination + virtual std::string copy_command( const std::string & host_source, + const std::string & source, + const std::string & host_destination, + const std::string & destination) const; + + // Methode abstraite qui renvoie la commande a executer + virtual std::string exec_command(Parametre & param) const; + + // Methode qui renvoie la commande d'effacement du fichier + virtual std::string remove_command( const std::string & host_destination, + const std::string & destination) const; + + }; + +} + +#endif diff --git a/src/Local/Batch_BatchManager_Local_SH.cxx b/src/Local/Batch_BatchManager_Local_SH.cxx new file mode 100644 index 0000000..c71847b --- /dev/null +++ b/src/Local/Batch_BatchManager_Local_SH.cxx @@ -0,0 +1,120 @@ +// Copyright (C) 2007-2008 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_Local_SH.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 + * + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include +#ifndef WIN32 +#include +#include +#endif +#include +#include +#include +#include +#include +#include "Batch_IOMutex.hxx" +#include "Batch_BatchManager_Local_SH.hxx" + +#include "Batch_config.h" + +#ifndef RM +#error "RM undefined. You must set RM to a valid path to a rm-like command." +#endif + +#ifndef CP +#error "CP undefined. You must set CP to a valid path to a cp-like command." +#endif + +#ifndef SH +#error "SH undefined. You must set SH to a valid path to a sh-like command." +#endif + +using namespace std; + +namespace Batch { + + + // Constructeur + BatchManager_Local_SH::BatchManager_Local_SH(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager_Local(parent, host) + { + } + + // Destructeur + BatchManager_Local_SH::~BatchManager_Local_SH() + { + } + + + // Methode qui renvoie la commande de copie du fichier source en destination + string BatchManager_Local_SH::copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const + { + ostringstream copy_cmd; + copy_cmd << CP << " " << source << " " << destination; + return copy_cmd.str(); + } + + // Methode qui renvoie la commande a executer + string BatchManager_Local_SH::exec_command(Parametre & param) const + { + ostringstream exec_sub_cmd; + exec_sub_cmd << param[EXECUTABLE]; + + if (param.find(ARGUMENTS) != param.end()) { + Versatile V = param[ARGUMENTS]; + for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++) { + StringType argt = * static_cast(*it); + string arg = argt; + exec_sub_cmd << " " << arg; + } + } + + param[ARGUMENTS] = "-c"; + param[ARGUMENTS] += exec_sub_cmd.str(); + + return SH; + } + + // Methode qui renvoie la commande d'effacement du fichier + string BatchManager_Local_SH::remove_command(const string & host_destination, const string & destination) const + { + ostringstream remove_cmd; + remove_cmd << RM << " " << destination; + return remove_cmd.str(); + } + +} diff --git a/src/Local/Batch_BatchManager_Local_SH.hxx b/src/Local/Batch_BatchManager_Local_SH.hxx new file mode 100644 index 0000000..23b5909 --- /dev/null +++ b/src/Local/Batch_BatchManager_Local_SH.hxx @@ -0,0 +1,82 @@ +// Copyright (C) 2007-2008 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_Local_SH.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_LOCAL_SH_H_ +#define _BATCHMANAGER_LOCAL_SH_H_ + +#include "Batch_Defines.hxx" + +#include +#include +#include +#include +#include +#include "Batch_Job.hxx" +#include "Batch_JobId.hxx" +#include "Batch_JobInfo.hxx" +#include "Batch_JobInfo_Local.hxx" +#include "Batch_Job_Local.hxx" +#include "Batch_InvalidArgumentException.hxx" +#include "Batch_ConnexionFailureException.hxx" +#include "Batch_APIInternalFailureException.hxx" +#include "Batch_NotYetImplementedException.hxx" +#include "Batch_BatchManager_Local.hxx" + +namespace Batch { + + class FactBatchManager; + + class BATCH_EXPORT BatchManager_Local_SH : public BatchManager_Local + { + public: + // Constructeur et destructeur + BatchManager_Local_SH(const FactBatchManager * parent, const char * host="localhost") throw(InvalidArgumentException,ConnexionFailureException); // connexion a la machine host + virtual ~BatchManager_Local_SH(); + + protected: + // Methode qui renvoie la commande de copie du fichier source en destination + virtual std::string copy_command( const std::string & host_source, + const std::string & source, + const std::string & host_destination, + const std::string & destination) const; + + // Methode qui renvoie la commande a executer + virtual std::string exec_command(Parametre & param) const; + + // Methode qui renvoie la commande d'effacement du fichier + virtual std::string remove_command( const std::string & host_destination, + const std::string & destination) const; + + }; + +} + +#endif diff --git a/src/Local/Batch_BatchManager_Local_SSH.cxx b/src/Local/Batch_BatchManager_Local_SSH.cxx new file mode 100644 index 0000000..70b0d9e --- /dev/null +++ b/src/Local/Batch_BatchManager_Local_SSH.cxx @@ -0,0 +1,153 @@ +// Copyright (C) 2007-2008 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_Local_SSH.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 + * + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include +#ifndef WIN32 +#include +#include +#endif +#include + +#include +#include +#include +#include +#include "Batch_IOMutex.hxx" +#include "Batch_BatchManager_Local_SSH.hxx" + +#include "Batch_config.h" + +#ifndef RM +#error "RM undefined. You must set RM to a valid path to a rm-like command." +#endif + +#ifndef SCP +#error "SCP undefined. You must set SCP to a valid path to a scp-like command." +#endif + +#ifndef SSH +#error "SSH undefined. You must set SSH to a valid path to a ssh-like command." +#endif + +using namespace std; + +namespace Batch { + + + // Constructeur + BatchManager_Local_SSH::BatchManager_Local_SSH(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager_Local(parent, host) + { + } + + // Destructeur + BatchManager_Local_SSH::~BatchManager_Local_SSH() + { + } + + + // Methode abstraite qui renvoie la commande de copie du fichier source en destination + string BatchManager_Local_SSH::copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const + { + ostringstream fullsource; + if (host_source.size() != 0) { + fullsource << host_source << ":"; + } + fullsource << source; + + ostringstream fulldestination; + if (host_destination.size() != 0) { + fulldestination << host_destination << ":"; + } + fulldestination << destination; + + ostringstream copy_cmd; + // Option -p is used to keep the same permissions for the destination file (particularly useful to keep scripts + // executable when copying them) + copy_cmd << SCP << " -p " << fullsource.str() << " " << fulldestination.str(); + return copy_cmd.str(); + } + + // Methode abstraite qui renvoie la commande a executer + string BatchManager_Local_SSH::exec_command(Parametre & param) const + { + ostringstream exec_sub_cmd; + exec_sub_cmd << "cd " << param[WORKDIR] << ";"; + exec_sub_cmd << param[EXECUTABLE]; + + if (param.find(ARGUMENTS) != param.end()) { + Versatile V = param[ARGUMENTS]; + for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++) { + StringType argt = * static_cast(*it); + string arg = argt; + exec_sub_cmd << " " << arg; + } + } + + + Versatile new_arguments; + new_arguments.setMaxSize(0); + new_arguments = string(param[EXECUTIONHOST]); + + + if (param.find(USER) != param.end()) { + new_arguments += "-l"; + new_arguments += string(param[USER]); + } + + new_arguments += exec_sub_cmd.str(); + + param[ARGUMENTS] = new_arguments; + + // Sous Linux on est oblige de modifier ces deux parametres pour faire fonctionner la commande rsh + param[EXECUTABLE] = SSH; + param.erase(NAME); + + return SSH; + } + + // Methode qui renvoie la commande d'effacement du fichier + string BatchManager_Local_SSH::remove_command(const string & host_destination, const string & destination) const + { + string host = (host_destination.size()) ? host_destination : "localhost:"; + + ostringstream remove_cmd; + remove_cmd << SSH << " " << host << " \"" << RM << " " << destination << "\""; + return remove_cmd.str(); + } +} diff --git a/src/Local/Batch_BatchManager_Local_SSH.hxx b/src/Local/Batch_BatchManager_Local_SSH.hxx new file mode 100644 index 0000000..12772fb --- /dev/null +++ b/src/Local/Batch_BatchManager_Local_SSH.hxx @@ -0,0 +1,82 @@ +// Copyright (C) 2007-2008 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_Local_SSH.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_LOCAL_SSH_H_ +#define _BATCHMANAGER_LOCAL_SSH_H_ + +#include "Batch_Defines.hxx" + +#include +#include +#include +#include +#include +#include "Batch_Job.hxx" +#include "Batch_JobId.hxx" +#include "Batch_JobInfo.hxx" +#include "Batch_JobInfo_Local.hxx" +#include "Batch_Job_Local.hxx" +#include "Batch_InvalidArgumentException.hxx" +#include "Batch_ConnexionFailureException.hxx" +#include "Batch_APIInternalFailureException.hxx" +#include "Batch_NotYetImplementedException.hxx" +#include "Batch_BatchManager_Local.hxx" + +namespace Batch { + + class FactBatchManager; + + class BATCH_EXPORT BatchManager_Local_SSH : public BatchManager_Local + { + public: + // Constructeur et destructeur + BatchManager_Local_SSH(const FactBatchManager * parent, const char * host="localhost") throw(InvalidArgumentException,ConnexionFailureException); // connexion a la machine host + virtual ~BatchManager_Local_SSH(); + + protected: + // Methode abstraite qui renvoie la commande de copie du fichier source en destination + virtual std::string copy_command( const std::string & host_source, + const std::string & source, + const std::string & host_destination, + const std::string & destination) const; + + // Methode abstraite qui renvoie la commande a executer + virtual std::string exec_command(Parametre & param) const; + + // Methode qui renvoie la commande d'effacement du fichier + virtual std::string remove_command( const std::string & host_destination, + const std::string & destination) const; + + }; + +} + +#endif diff --git a/src/Local/Batch_FactBatchManager_Local.cxx b/src/Local/Batch_FactBatchManager_Local.cxx new file mode 100644 index 0000000..46fb130 --- /dev/null +++ b/src/Local/Batch_FactBatchManager_Local.cxx @@ -0,0 +1,60 @@ +// Copyright (C) 2007-2008 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_Local.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2004 + * Projet : SALOME 2 + * + */ + +#include +#include "Batch_BatchManager_Local.hxx" +#include "Batch_FactBatchManager_Local.hxx" +//#include "utilities.h" + +namespace Batch { + +// static FactBatchManager_Local sFBM_Local; + + // Constructeur + FactBatchManager_Local::FactBatchManager_Local() : FactBatchManager("Local") + { + // Nothing to do + } + + // Destructeur + FactBatchManager_Local::~FactBatchManager_Local() + { + // Nothing to do + } + + // Functor +// BatchManager * FactBatchManager_Local::operator() (const char * hostname) const +// { +// // MESSAGE("Building new BatchManager_Local on host '" << hostname << "'"); +// return new BatchManager_Local(this, hostname); +// } + + +} diff --git a/src/Local/Batch_FactBatchManager_Local.hxx b/src/Local/Batch_FactBatchManager_Local.hxx new file mode 100644 index 0000000..4b2f0d4 --- /dev/null +++ b/src/Local/Batch_FactBatchManager_Local.hxx @@ -0,0 +1,57 @@ +// Copyright (C) 2007-2008 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_Local.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2004 + * Projet : SALOME 2 + * + */ + +#ifndef _FACTBATCHMANAGER_LOCAL_H_ +#define _FACTBATCHMANAGER_LOCAL_H_ + +#include "Batch_FactBatchManager.hxx" + +namespace Batch { + + class BatchManager_Local; + + class FactBatchManager_Local : public FactBatchManager + { + public: + // Constructeur et destructeur + FactBatchManager_Local(); + virtual ~FactBatchManager_Local(); + + virtual BatchManager * operator() (const char * hostname) const = 0; + + protected: + + private: + + }; + +} + +#endif diff --git a/src/Local/Batch_FactBatchManager_Local_RSH.cxx b/src/Local/Batch_FactBatchManager_Local_RSH.cxx new file mode 100644 index 0000000..cd15bad --- /dev/null +++ b/src/Local/Batch_FactBatchManager_Local_RSH.cxx @@ -0,0 +1,60 @@ +// Copyright (C) 2007-2008 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_Local_RSH.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2004 + * Projet : SALOME 2 + * + */ + +#include +#include "Batch_BatchManager_Local_RSH.hxx" +#include "Batch_FactBatchManager_Local_RSH.hxx" +//#include "utilities.h" + +namespace Batch { + + static FactBatchManager_Local_RSH sFBM_Local_RSH; + + // Constructeur + FactBatchManager_Local_RSH::FactBatchManager_Local_RSH() : FactBatchManager("RSH") + { + // Nothing to do + } + + // Destructeur + FactBatchManager_Local_RSH::~FactBatchManager_Local_RSH() + { + // Nothing to do + } + + // Functor + BatchManager * FactBatchManager_Local_RSH::operator() (const char * hostname) const + { + // MESSAGE("Building new BatchManager_Local_RSH on host '" << hostname << "'"); + return new BatchManager_Local_RSH(this, hostname); + } + + +} diff --git a/src/Local/Batch_FactBatchManager_Local_RSH.hxx b/src/Local/Batch_FactBatchManager_Local_RSH.hxx new file mode 100644 index 0000000..8b11c5d --- /dev/null +++ b/src/Local/Batch_FactBatchManager_Local_RSH.hxx @@ -0,0 +1,57 @@ +// Copyright (C) 2007-2008 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_Local_RSH.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2004 + * Projet : SALOME 2 + * + */ + +#ifndef _FACTBATCHMANAGER_LOCAL_RSH_H_ +#define _FACTBATCHMANAGER_LOCAL_RSH_H_ + +#include "Batch_FactBatchManager.hxx" + +namespace Batch { + + class BatchManager_Local_RSH; + + class FactBatchManager_Local_RSH : public FactBatchManager + { + public: + // Constructeur et destructeur + FactBatchManager_Local_RSH(); + virtual ~FactBatchManager_Local_RSH(); + + virtual BatchManager * operator() (const char * hostname) const; + + protected: + + private: + + }; + +} + +#endif diff --git a/src/Local/Batch_FactBatchManager_Local_SH.cxx b/src/Local/Batch_FactBatchManager_Local_SH.cxx new file mode 100644 index 0000000..a317e3c --- /dev/null +++ b/src/Local/Batch_FactBatchManager_Local_SH.cxx @@ -0,0 +1,60 @@ +// Copyright (C) 2007-2008 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_Local_SH.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2004 + * Projet : SALOME 2 + * + */ + +#include +#include "Batch_BatchManager_Local_SH.hxx" +#include "Batch_FactBatchManager_Local_SH.hxx" +//#include "utilities.h" + +namespace Batch { + + static FactBatchManager_Local_SH sFBM_Local_SH; + + // Constructeur + FactBatchManager_Local_SH::FactBatchManager_Local_SH() : FactBatchManager("SH") + { + // Nothing to do + } + + // Destructeur + FactBatchManager_Local_SH::~FactBatchManager_Local_SH() + { + // Nothing to do + } + + // Functor + BatchManager * FactBatchManager_Local_SH::operator() (const char * hostname) const + { + // MESSAGE("Building new BatchManager_Local_SH on host '" << hostname << "'"); + return new BatchManager_Local_SH(this, hostname); + } + + +} diff --git a/src/Local/Batch_FactBatchManager_Local_SH.hxx b/src/Local/Batch_FactBatchManager_Local_SH.hxx new file mode 100644 index 0000000..499eafe --- /dev/null +++ b/src/Local/Batch_FactBatchManager_Local_SH.hxx @@ -0,0 +1,57 @@ +// Copyright (C) 2007-2008 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_Local_SH.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2004 + * Projet : SALOME 2 + * + */ + +#ifndef _FACTBATCHMANAGER_LOCAL_SH_H_ +#define _FACTBATCHMANAGER_LOCAL_SH_H_ + +#include "Batch_FactBatchManager.hxx" + +namespace Batch { + + class BatchManager_Local_SH; + + class FactBatchManager_Local_SH : public FactBatchManager + { + public: + // Constructeur et destructeur + FactBatchManager_Local_SH(); + virtual ~FactBatchManager_Local_SH(); + + virtual BatchManager * operator() (const char * hostname) const; + + protected: + + private: + + }; + +} + +#endif diff --git a/src/Local/Batch_FactBatchManager_Local_SSH.cxx b/src/Local/Batch_FactBatchManager_Local_SSH.cxx new file mode 100644 index 0000000..d962374 --- /dev/null +++ b/src/Local/Batch_FactBatchManager_Local_SSH.cxx @@ -0,0 +1,60 @@ +// Copyright (C) 2007-2008 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_Local_SSH.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2004 + * Projet : SALOME 2 + * + */ + +#include +#include "Batch_BatchManager_Local_SSH.hxx" +#include "Batch_FactBatchManager_Local_SSH.hxx" +//#include "utilities.h" + +namespace Batch { + + static FactBatchManager_Local_SSH sFBM_Local_SSH; + + // Constructeur + FactBatchManager_Local_SSH::FactBatchManager_Local_SSH() : FactBatchManager("SSH") + { + // Nothing to do + } + + // Destructeur + FactBatchManager_Local_SSH::~FactBatchManager_Local_SSH() + { + // Nothing to do + } + + // Functor + BatchManager * FactBatchManager_Local_SSH::operator() (const char * hostname) const + { + // MESSAGE("Building new BatchManager_Local_SSH on host '" << hostname << "'"); + return new BatchManager_Local_SSH(this, hostname); + } + + +} diff --git a/src/Local/Batch_FactBatchManager_Local_SSH.hxx b/src/Local/Batch_FactBatchManager_Local_SSH.hxx new file mode 100644 index 0000000..7f64f0e --- /dev/null +++ b/src/Local/Batch_FactBatchManager_Local_SSH.hxx @@ -0,0 +1,57 @@ +// Copyright (C) 2007-2008 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_Local_SSH.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2004 + * Projet : SALOME 2 + * + */ + +#ifndef _FACTBATCHMANAGER_LOCAL_SSH_H_ +#define _FACTBATCHMANAGER_LOCAL_SSH_H_ + +#include "Batch_FactBatchManager.hxx" + +namespace Batch { + + class BatchManager_Local_SSH; + + class FactBatchManager_Local_SSH : public FactBatchManager + { + public: + // Constructeur et destructeur + FactBatchManager_Local_SSH(); + virtual ~FactBatchManager_Local_SSH(); + + virtual BatchManager * operator() (const char * hostname) const; + + protected: + + private: + + }; + +} + +#endif diff --git a/src/Local/Batch_IOMutex.cxx b/src/Local/Batch_IOMutex.cxx new file mode 100644 index 0000000..06a9f7e --- /dev/null +++ b/src/Local/Batch_IOMutex.cxx @@ -0,0 +1,38 @@ +// Copyright (C) 2007-2008 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 +// +/* + * IOMutex.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 "Batch_IOMutex.hxx" + +namespace Batch { + + pthread_mutex_t IOMutex = PTHREAD_MUTEX_INITIALIZER; + +} diff --git a/src/Local/Batch_IOMutex.hxx b/src/Local/Batch_IOMutex.hxx new file mode 100644 index 0000000..a047b38 --- /dev/null +++ b/src/Local/Batch_IOMutex.hxx @@ -0,0 +1,47 @@ +// Copyright (C) 2007-2008 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 +// +/* + * IOMutex.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 _IOMUTEX_H_ +#define _IOMUTEX_H_ + +#include + +#define LOCK_IO { pthread_mutex_lock(&Batch::IOMutex) ; } +#define UNLOCK_IO { pthread_mutex_unlock(&Batch::IOMutex) ; } +#define UNDER_LOCK(statement) { LOCK_IO ; { statement ; } ; UNLOCK_IO ; } + +namespace Batch { + + extern pthread_mutex_t IOMutex; + +} + +#endif diff --git a/src/Local/Batch_JobInfo_Local.cxx b/src/Local/Batch_JobInfo_Local.cxx new file mode 100644 index 0000000..da7a32c --- /dev/null +++ b/src/Local/Batch_JobInfo_Local.cxx @@ -0,0 +1,54 @@ +// Copyright (C) 2007-2008 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_Local.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 "Batch_Parametre.hxx" +#include "Batch_Environnement.hxx" +#include "Batch_JobInfo_Local.hxx" + +namespace Batch { + + // Constructeurs + JobInfo_Local::JobInfo_Local(const Parametre & param, const Environnement & env) : + JobInfo(param, env) + { + // Nothing to do + } + + + // Destructeur + JobInfo_Local::~JobInfo_Local() + { + // Nothing to do + } + + +} diff --git a/src/Local/Batch_JobInfo_Local.hxx b/src/Local/Batch_JobInfo_Local.hxx new file mode 100644 index 0000000..ed325b4 --- /dev/null +++ b/src/Local/Batch_JobInfo_Local.hxx @@ -0,0 +1,60 @@ +// Copyright (C) 2007-2008 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_Local.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Fri Nov 21 09:42:05 2003 + * Projet : Salome 2 + * + */ + +#ifndef _JOBINFO_LOCAL_H_ +#define _JOBINFO_LOCAL_H_ + +#include +#include "Batch_JobInfo.hxx" + +namespace Batch { + + class JobInfo_Local : public JobInfo + { + public: + // Constructeurs et destructeur + JobInfo_Local() {}; + JobInfo_Local(const Parametre & param, const Environnement & env); + virtual ~JobInfo_Local(); + + // Constructeur par recopie + JobInfo_Local(const JobInfo_Local & jinfo) : JobInfo(jinfo) {}; + + + protected: + + private: + + }; + +} + +#endif diff --git a/src/Local/Batch_Job_Local.cxx b/src/Local/Batch_Job_Local.cxx new file mode 100644 index 0000000..d93354b --- /dev/null +++ b/src/Local/Batch_Job_Local.cxx @@ -0,0 +1,106 @@ +// Copyright (C) 2007-2008 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_Local.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 +#ifndef WIN32 +#include +#endif +#include "Batch_Job_Local.hxx" + +using namespace std; + +namespace Batch { + + // Constructeur + Job_Local::Job_Local(const Job & job) : + _command(), _param(job.getParametre()), _env(job.getEnvironnement()) + { + // On positionne le nom du EXECUTIONHOST a "localhost" s'il n'est pas precise + if ( _param.find(EXECUTIONHOST) == _param.end() ) { + _param[EXECUTIONHOST] = "localhost"; + } + + // On convertit les objets Parametre et Environnement en liste chainee d'attributs + operateur + addEnvironnement( _env ); + addParametre ( _param ); + + } + + + // Destructeur + Job_Local::~Job_Local() + { + } + + + void Job_Local::addParametre(const Parametre & P) + { + // En dernier, on ajoute le chemin complet de la commande + _command += P[EXECUTABLE].str(); + } + + + void Job_Local::addEnvironnement(const Environnement & E) + { + for(Environnement::const_iterator it=E.begin(); it != E.end(); it++) { + string variable = (*it).first; + string value = (*it).second; + + // On remplace toutes les occurences de single-quote par backslash-single-quote + for(size_t pos=0; pos < value.size(); pos++) { + pos = value.find("'", pos); + if ( pos > value.size() ) break; + value.replace(pos, 1, "\'"); + } + _command += variable + "='" + value + "' "; + } + } + + string Job_Local::getCommand(void) const { + return _command; + } + + + // Retourne l'objet Parametre + Parametre Job_Local::getParametre() const + { + return _param; + } + + // Retourne l'objet Environnement + Environnement Job_Local::getEnvironnement() const + { + return _env; + } + + +} diff --git a/src/Local/Batch_Job_Local.hxx b/src/Local/Batch_Job_Local.hxx new file mode 100644 index 0000000..30e8ffd --- /dev/null +++ b/src/Local/Batch_Job_Local.hxx @@ -0,0 +1,71 @@ +// Copyright (C) 2007-2008 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_Local.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_LOCAL_H_ +#define _JOB_LOCAL_H_ + +#include "Batch_Parametre.hxx" +#include "Batch_Environnement.hxx" +#include "Batch_Job.hxx" + +namespace Batch { + + class Job_Local + { + public: + // Constructeur et destructeur + Job_Local(const Job & job); + virtual ~Job_Local(); + + // Retourne la commande _command + virtual std::string getCommand(void) const; + + // Retourne l'objet Parametre + virtual Parametre getParametre() const; + + // Retourne l'objet Environnement + virtual Environnement getEnvironnement() const; + + + protected: + std::string _command; + Parametre _param; + Environnement _env; + + private: + void addParametre(const Parametre & P); + void addEnvironnement(const Environnement & E); + + }; + +} + +#endif diff --git a/src/Local/CMakeLists.txt b/src/Local/CMakeLists.txt new file mode 100644 index 0000000..0fbe4a2 --- /dev/null +++ b/src/Local/CMakeLists.txt @@ -0,0 +1,39 @@ +# Copyright (C) 2007-2008 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 +# + +SET(CLASS_LIST Local/Batch_BatchManager_Local_RSH + Local/Batch_BatchManager_Local_SH + Local/Batch_BatchManager_Local_SSH + Local/Batch_BatchManager_Local + Local/Batch_FactBatchManager_Local_RSH + Local/Batch_FactBatchManager_Local_SH + Local/Batch_FactBatchManager_Local_SSH + Local/Batch_FactBatchManager_Local + Local/Batch_IOMutex + Local/Batch_Job_Local + Local/Batch_JobInfo_Local + ) + +APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST}) +APPEND_CLASSES_TO_HDR_FILES(${CLASS_LIST}) + +add_subdirectory(Test) diff --git a/src/Local/Test/CMakeLists.txt b/src/Local/Test/CMakeLists.txt new file mode 100644 index 0000000..cc95e45 --- /dev/null +++ b/src/Local/Test/CMakeLists.txt @@ -0,0 +1,59 @@ +# Copyright (C) 2007-2008 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 +# + +# Declare the configuration variables for the test scripts +SET (TEST_LOCAL_RSH_EXECUTION_HOST "localhost" CACHE STRING + "Execution host for RSH Batch test (only necessary for test target)") +SET (TEST_LOCAL_RSH_WORK_DIR "/tmp" CACHE STRING + "Work directory for RSH Batch test (only necessary for test target)") + +SET (TEST_LOCAL_SSH_EXECUTION_HOST "localhost" CACHE STRING + "Execution host for SSH Batch test (only necessary for test target)") +SET (TEST_LOCAL_SSH_WORK_DIR "/tmp" CACHE STRING + "Work directory for SSH Batch test (only necessary for test target)") + +# Configure the config file for all the test scripts +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Test_Local_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/Test_Local_config.h) + +# Just copy the test scripts to the binary dir +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/seta.sh ${CMAKE_CURRENT_BINARY_DIR}/seta.sh COPYONLY) +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/setb.sh ${CMAKE_CURRENT_BINARY_DIR}/setb.sh COPYONLY) +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test-script.sh ${CMAKE_CURRENT_BINARY_DIR}/test-script.sh COPYONLY) + +# set the include directories +include_directories(${CMAKE_SOURCE_DIR}/src/Core) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +# Build the test programs +add_executable(Test_Local_SH Test_Local_SH.cxx) +target_link_libraries(Test_Local_SH Batch) + +add_executable(Test_Local_RSH Test_Local_RSH.cxx) +target_link_libraries(Test_Local_RSH Batch) + +add_executable(Test_Local_SSH Test_Local_SSH.cxx) +target_link_libraries(Test_Local_SSH Batch) + +# Add the tests themselves +ADD_TEST(Local_SH Test_Local_SH) +ADD_TEST(Local_RSH Test_Local_RSH) +ADD_TEST(Local_SSH Test_Local_SSH) diff --git a/src/Local/Test/Test_Local_RSH.cxx b/src/Local/Test/Test_Local_RSH.cxx new file mode 100644 index 0000000..24c926b --- /dev/null +++ b/src/Local/Test/Test_Local_RSH.cxx @@ -0,0 +1,108 @@ +// Copyright (C) 2007-2008 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_Local_RSH.cxx : + * + * Author : Renaud BARATE - EDF R&D + * Date : April 2009 + * + */ + +#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 local batch submission based on RSH. Passwordless RSH authentication" << endl; + cout << "must be used for this test to pass (this can be configured with the .rhosts file)." << endl; + cout << "*******************************************************************************************" << endl; + + // eventually remove any previous result + remove("result.txt"); + + // Define the job... + Job job; + // ... and its parameters ... + Parametre p; + p["EXECUTABLE"] = "./copied-test-script.sh"; + p["NAME"] = "Test_Local_RSH"; + p["WORKDIR"] = TEST_LOCAL_RSH_WORK_DIR; + p["INFILE"] = Couple("seta.sh", "copied-seta.sh"); + p["INFILE"] += Couple("setb.sh", "copied-setb.sh"); + p["INFILE"] += Couple("test-script.sh", "copied-test-script.sh"); + p["OUTFILE"] = Couple("result.txt", "orig-result.txt"); + p["EXECUTIONHOST"] = TEST_LOCAL_RSH_EXECUTION_HOST; + job.setParametre(p); + // ... and its environment + Environnement e; + job.setEnvironnement(e); + cout << job << endl; + + // Get the catalog + BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); + + // Create a BatchManager of type Local_RSH on localhost + FactBatchManager * fbm = c("RSH"); + BatchManager * bm = (*fbm)("localhost"); + + // Submit the job to the BatchManager + JobId jobid = bm->submitJob(job); + cout << jobid.__repr__() << endl; + + // Wait for the end of the job + string state = "Unknown"; + while (state != "Done") { + usleep(10000); + JobInfo jinfo = jobid.queryJob(); + state = jinfo.getParametre()["STATE"].str(); + } + + cout << "Job " << jobid.__repr__() << " is done" << endl; + + // wait for 5 more seconds for the copy of output files and the cleanup + // (there's no cleaner way to do that yet) + sleep(5); + + // test the result file + string exp = "c = 12"; + string res; + ifstream f("result.txt"); + getline(f, res); + f.close(); + + cout << "result found : " << res << ", expected : " << exp << endl; + + if (res == exp) + return 0; + else + return 1; +} diff --git a/src/Local/Test/Test_Local_SH.cxx b/src/Local/Test/Test_Local_SH.cxx new file mode 100644 index 0000000..d11ea60 --- /dev/null +++ b/src/Local/Test/Test_Local_SH.cxx @@ -0,0 +1,107 @@ +// Copyright (C) 2007-2008 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_Local_SH.cxx : + * + * Author : Renaud BARATE - EDF R&D + * Date : April 2009 + * + */ + +#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 local batch submission based on SH. No specific configuration is" << endl; + cout << "needed for this test." << endl; + cout << "*******************************************************************************************" << endl; + + // eventually remove any previous result + remove("result.txt"); + + // Define the job... + Job job; + // ... and its parameters ... + Parametre p; + p["EXECUTABLE"] = "./copied-test-script.sh"; + p["NAME"] = "Test_Local_SH"; + p["WORKDIR"] = "/tmp"; + p["INFILE"] = Couple("seta.sh", "copied-seta.sh"); + p["INFILE"] += Couple("setb.sh", "copied-setb.sh"); + p["INFILE"] += Couple("test-script.sh", "copied-test-script.sh"); + p["OUTFILE"] = Couple("result.txt", "orig-result.txt"); + job.setParametre(p); + // ... and its environment + Environnement e; + job.setEnvironnement(e); + cout << job << endl; + + // Get the catalog + BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); + + // Create a BatchManager of type Local_SH on localhost + FactBatchManager * fbm = c("SH"); + BatchManager * bm = (*fbm)("localhost"); + + // Submit the job to the BatchManager + JobId jobid = bm->submitJob(job); + cout << jobid.__repr__() << endl; + + // Wait for the end of the job + string state = "Unknown"; + while (state != "Done") { + usleep(10000); + JobInfo jinfo = jobid.queryJob(); + state = jinfo.getParametre()["STATE"].str(); + } + + cout << "Job " << jobid.__repr__() << " is done" << endl; + + // wait for 2 more seconds for the copy of output files and the cleanup + // (there's no cleaner way to do that yet) + sleep(2); + + // test the result file + string exp = "c = 12"; + string res; + ifstream f("result.txt"); + getline(f, res); + f.close(); + + cout << "result found : " << res << ", expected : " << exp << endl; + + if (res == exp) + return 0; + else + return 1; +} diff --git a/src/Local/Test/Test_Local_SSH.cxx b/src/Local/Test/Test_Local_SSH.cxx new file mode 100644 index 0000000..f946b43 --- /dev/null +++ b/src/Local/Test/Test_Local_SSH.cxx @@ -0,0 +1,109 @@ +// Copyright (C) 2007-2008 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_Local_SSH.cxx : + * + * Author : Renaud BARATE - EDF R&D + * Date : April 2009 + * + */ + +#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 local batch submission based on SSH. Passwordless SSH authentication" << endl; + cout << "must be used for this test to pass (this can be configured with ssh-agent for instance)." << endl; + cout << "*******************************************************************************************" << endl; + + // eventually remove any previous result + remove("result.txt"); + + // Define the job... + Job job; + // ... and its parameters ... + Parametre p; + p["EXECUTABLE"] = "./copied-test-script.sh"; + p["NAME"] = "Test_Local_SSH"; + p["WORKDIR"] = TEST_LOCAL_SSH_WORK_DIR; + p["INFILE"] = Couple("seta.sh", "copied-seta.sh"); + p["INFILE"] += Couple("setb.sh", "copied-setb.sh"); + p["INFILE"] += Couple("test-script.sh", "copied-test-script.sh"); + p["OUTFILE"] = Couple("result.txt", "orig-result.txt"); + p["EXECUTIONHOST"] = TEST_LOCAL_SSH_EXECUTION_HOST; + job.setParametre(p); + // ... and its environment (SSH_AUTH_SOCK env var is important for ssh agent authentication) + Environnement e; + e["SSH_AUTH_SOCK"] = getenv("SSH_AUTH_SOCK"); + job.setEnvironnement(e); + cout << job << endl; + + // Get the catalog + BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); + + // Create a BatchManager of type Local_SSH on localhost + FactBatchManager * fbm = c("SSH"); + BatchManager * bm = (*fbm)("localhost"); + + // Submit the job to the BatchManager + JobId jobid = bm->submitJob(job); + cout << jobid.__repr__() << endl; + + // Wait for the end of the job + string state = "Unknown"; + while (state != "Done") { + usleep(10000); + JobInfo jinfo = jobid.queryJob(); + state = jinfo.getParametre()["STATE"].str(); + } + + cout << "Job " << jobid.__repr__() << " is done" << endl; + + // wait for 5 more seconds for the copy of output files and the cleanup + // (there's no cleaner way to do that yet) + sleep(5); + + // test the result file + string exp = "c = 12"; + string res; + ifstream f("result.txt"); + getline(f, res); + f.close(); + + cout << "result found : " << res << ", expected : " << exp << endl; + + if (res == exp) + return 0; + else + return 1; +} diff --git a/src/Local/Test/Test_Local_config.h.in b/src/Local/Test/Test_Local_config.h.in new file mode 100644 index 0000000..c8eefa6 --- /dev/null +++ b/src/Local/Test/Test_Local_config.h.in @@ -0,0 +1,27 @@ +// Copyright (C) 2007-2008 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 +// + +#define TEST_LOCAL_RSH_EXECUTION_HOST "${TEST_LOCAL_RSH_EXECUTION_HOST}" +#define TEST_LOCAL_RSH_WORK_DIR "${TEST_LOCAL_RSH_WORK_DIR}" + +#define TEST_LOCAL_SSH_EXECUTION_HOST "${TEST_LOCAL_SSH_EXECUTION_HOST}" +#define TEST_LOCAL_SSH_WORK_DIR "${TEST_LOCAL_SSH_WORK_DIR}" diff --git a/src/Local/Test/seta.sh b/src/Local/Test/seta.sh new file mode 100644 index 0000000..42d1e38 --- /dev/null +++ b/src/Local/Test/seta.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +a=4 diff --git a/src/Local/Test/setb.sh b/src/Local/Test/setb.sh new file mode 100644 index 0000000..8969060 --- /dev/null +++ b/src/Local/Test/setb.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +b=3 diff --git a/src/Local/Test/test-script.sh b/src/Local/Test/test-script.sh new file mode 100755 index 0000000..afd53de --- /dev/null +++ b/src/Local/Test/test-script.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +source copied-seta.sh +source copied-setb.sh + +c=`expr $a "*" $b` + +echo "c = $c" > orig-result.txt diff --git a/src/PBS/Batch_BatchManager_PBS.cxx b/src/PBS/Batch_BatchManager_PBS.cxx new file mode 100644 index 0000000..dd2b1b8 --- /dev/null +++ b/src/PBS/Batch_BatchManager_PBS.cxx @@ -0,0 +1,216 @@ +// Copyright (C) 2007-2008 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 "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 + char * errmsg = pbs_geterrmsg(_connect); + string msg = "PBS Server on host \""; + msg += _hostname; + msg += "\" : "; + msg += errmsg ? errmsg : "Reason unknown"; + throw ConnexionFailureException(msg.c_str()); + } + } + + // Destructeur + BatchManager_PBS::~BatchManager_PBS() + { + // On se deconnecte du serveur PBS + int rc = pbs_disconnect(_connect); + if (rc < 0) { // si erreur + string msg = "PBS Server on host \""; + msg += _hostname; + msg += "\" : "; + msg += pbs_geterrmsg(_connect); + throw ConnexionFailureException(msg.c_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 + char * msg = pbs_geterrmsg(_connect); + if (!msg) msg = "unknown"; + throw APIInternalFailureException(string("PBS submit error. Reason : ") + msg); + } + + JobId id(this, string(ref)); + free(ref); + return id; + } + + // 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 + char * msg = pbs_geterrmsg(_connect); + if (!msg) msg = "unknown"; + throw APIInternalFailureException(string("PBS deljob error. Reason : ") + msg); + } + } + + // 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, USER_HOLD, 0); + if (rc) { // si erreur + char * msg = pbs_geterrmsg(_connect); + if (!msg) msg = "unknown"; + throw APIInternalFailureException(string("PBS holdjob error. Reason : ") + msg); + } + } + + // 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, USER_HOLD, 0); + if (rc) { // si erreur + char * msg = pbs_geterrmsg(_connect); + if (!msg) msg = "unknown"; + throw APIInternalFailureException(string("PBS rlsjob error. Reason : ") + msg); + } + } + + + // 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 + char * msg = pbs_geterrmsg(_connect); + if (!msg) msg = "unknown"; + throw APIInternalFailureException(string("PBS alterjob error. Reason : ") + msg); + } + + } + + // 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 new file mode 100644 index 0000000..ee6ac82 --- /dev/null +++ b/src/PBS/Batch_BatchManager_PBS.hxx @@ -0,0 +1,98 @@ +// Copyright (C) 2007-2008 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 + + + protected: + 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_BatchManager_ePBS.cxx b/src/PBS/Batch_BatchManager_ePBS.cxx new file mode 100644 index 0000000..261c9b8 --- /dev/null +++ b/src/PBS/Batch_BatchManager_ePBS.cxx @@ -0,0 +1,345 @@ +// Copyright (C) 2007-2008 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_ePBS.cxx : emulation of PBS client + * + * Auteur : Bernard SECHER - CEA DEN + * Mail : mailto:bernard.secher@cea.fr + * Date : Thu Apr 24 10:17:22 2008 + * Projet : PAL Salome + * + */ + +#include +#include +#include +#include +#include +#include + +#include "Batch_BatchManager_ePBS.hxx" +#ifdef WIN32 +# include +# include +#else +# include +#endif + +using namespace std; + +namespace Batch { + + BatchManager_ePBS::BatchManager_ePBS(const FactBatchManager * parent, const char * host, + const char * protocol, const char * mpiImpl) + : BatchManager_eClient(parent, host, protocol, mpiImpl) + { + // Nothing to do + } + + // Destructeur + BatchManager_ePBS::~BatchManager_ePBS() + { + // Nothing to do + } + + // Methode pour le controle des jobs : soumet un job au gestionnaire + const JobId BatchManager_ePBS::submitJob(const Job & job) + { + int status; + Parametre params = job.getParametre(); + const std::string dirForTmpFiles = params[TMPDIR]; + const string fileToExecute = params[EXECUTABLE]; + string::size_type p1 = fileToExecute.find_last_of("/"); + string::size_type p2 = fileToExecute.find_last_of("."); + std::string fileNameToExecute = fileToExecute.substr(p1+1,p2-p1-1); + + // export input files on cluster + exportInputFiles(job); + + // build batch script for job + buildBatchScript(job); + + // create log dir (local) and define name of log file + string logDir = "/tmp/logs/"; + mkdir(logDir.c_str(), S_IRWXU); + logDir += getenv("USER"); + mkdir(logDir.c_str(), S_IRWXU); + string logFile = logDir + "/batchSalome_"; + srand ( time(NULL) ); + int ir = rand(); + ostringstream oss; + oss << ir; + logFile += oss.str(); + logFile += ".log"; + + string command; + + // define command to submit batch + command = _protocol; + command += " "; + + if(_username != ""){ + command += _username; + command += "@"; + } + + command += _hostname; + command += " \"cd " ; + command += dirForTmpFiles ; + command += "; qsub " ; + command += fileNameToExecute ; + command += "_Batch.sh\" > "; + command += logFile; + cerr << command.c_str() << endl; + status = system(command.c_str()); + if(status) + throw EmulationException("Error of connection on remote host"); + + // read id of submitted job in log file + char line[128]; + FILE *fp = fopen(logFile.c_str(),"r"); + fgets( line, 128, fp); + fclose(fp); + + string sline(line); + size_t pos = sline.find("."); + string strjob; + if(pos == string::npos) + strjob = sline; + else + strjob = sline.substr(0,pos); + + JobId id(this, strjob); + return id; + } + + // Methode pour le controle des jobs : retire un job du gestionnaire + void BatchManager_ePBS::deleteJob(const JobId & jobid) + { + int status; + int ref; + istringstream iss(jobid.getReference()); + iss >> ref; + + // define command to submit batch + string command; + command = _protocol; + command += " "; + + if (_username != ""){ + command += _username; + command += "@"; + } + + command += _hostname; + command += " \"qdel " ; + command += iss.str(); + command += "\""; + cerr << command.c_str() << endl; + status = system(command.c_str()); + if(status) + throw EmulationException("Error of connection on remote host"); + + cerr << "jobId = " << ref << "killed" << endl; + } + + // Methode pour le controle des jobs : suspend un job en file d'attente + void BatchManager_ePBS::holdJob(const JobId & jobid) + { + throw EmulationException("Not yet implemented"); + } + + // Methode pour le controle des jobs : relache un job suspendu + void BatchManager_ePBS::releaseJob(const JobId & jobid) + { + throw EmulationException("Not yet implemented"); + } + + + // Methode pour le controle des jobs : modifie un job en file d'attente + void BatchManager_ePBS::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env) + { + throw EmulationException("Not yet implemented"); + } + + // Methode pour le controle des jobs : modifie un job en file d'attente + void BatchManager_ePBS::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_ePBS::alterJob(const JobId & jobid, const Environnement & env) + { + alterJob(jobid, Parametre(), env); + } + + // Methode pour le controle des jobs : renvoie l'etat du job + JobInfo BatchManager_ePBS::queryJob(const JobId & jobid) + { + int id; + istringstream iss(jobid.getReference()); + iss >> id; + + // define name of log file + string logFile="/tmp/logs/"; + logFile += getenv("USER"); + logFile += "/batchSalome_"; + + ostringstream oss; + oss << this << "_" << id; + logFile += oss.str(); + logFile += ".log"; + + string command; + int status; + + // define command to submit batch + command = _protocol; + command += " "; + + if (_username != ""){ + command += _username; + command += "@"; + } + + command += _hostname; + command += " \"qstat -f " ; + command += iss.str(); + command += "\" > "; + command += logFile; + cerr << command.c_str() << endl; + status = system(command.c_str()); + if(status && status != 153 && status != 256*153) + throw EmulationException("Error of connection on remote host"); + + JobInfo_ePBS ji = JobInfo_ePBS(id,logFile); + return ji; + } + + // Methode pour le controle des jobs : teste si un job est present en machine + bool BatchManager_ePBS::isRunning(const JobId & jobid) + { + throw EmulationException("Not yet implemented"); + } + + void BatchManager_ePBS::buildBatchScript(const Job & job) + { +#ifndef WIN32 //TODO: need for porting on Windows + int status; + Parametre params = job.getParametre(); + Environnement env = job.getEnvironnement(); + const long nbproc = params[NBPROC]; + const long edt = params[MAXWALLTIME]; + const long mem = params[MAXRAMSIZE]; + const 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); + char* basec=strdup(fileToExecute.c_str()); + fileNameToExecute = "~/" + dirForTmpFiles + "/" + string(basename(basec)); + free(basec); + + int idx = dirForTmpFiles.find("Batch/"); + filelogtemp = dirForTmpFiles.substr(idx+6, dirForTmpFiles.length()); + } + else{ + rootNameToExecute = "command"; + } + + ofstream tempOutputFile; + std::string TmpFileName = createAndOpenTemporaryFile(tempOutputFile); + + tempOutputFile << "#! /bin/sh -f" << endl; + if (queue != "") + tempOutputFile << "#BSUB -q " << queue << endl; + if( edt > 0 ) + tempOutputFile << "#PBS -l walltime=" << edt*60 << endl ; + if( mem > 0 ) + tempOutputFile << "#PBS -l mem=" << mem << "mb" << endl ; + if( fileToExecute.size() > 0 ){ + tempOutputFile << "#PBS -o " << home << "/" << dirForTmpFiles << "/output.log." << filelogtemp << endl ; + tempOutputFile << "#PBS -e " << home << "/" << dirForTmpFiles << "/error.log." << filelogtemp << endl ; + } + else{ + tempOutputFile << "#PBS -o " << dirForTmpFiles << "/" << env["LOGFILE"] << ".output.log" << endl ; + tempOutputFile << "#PBS -e " << dirForTmpFiles << "/" << env["LOGFILE"] << ".error.log" << endl ; + } + if( workDir.size() > 0 ) + tempOutputFile << "cd " << workDir << endl ; + if( fileToExecute.size() > 0 ){ + tempOutputFile << _mpiImpl->boot("${PBS_NODEFILE}",nbproc); + tempOutputFile << _mpiImpl->run("${PBS_NODEFILE}",nbproc,fileNameToExecute); + tempOutputFile << _mpiImpl->halt(); + } + else{ + tempOutputFile << "source " << env["SOURCEFILE"] << endl ; + tempOutputFile << env["COMMAND"]; + } + + tempOutputFile.flush(); + tempOutputFile.close(); +#ifdef WIN32 + _chmod( +#else + chmod( +#endif + TmpFileName.c_str(), 0x1ED); + cerr << TmpFileName.c_str() << endl; + + string command; + if( _protocol == "rsh" ) + command = "rcp "; + else if( _protocol == "ssh" ) + command = "scp "; + else + throw EmulationException("Unknown protocol"); + command += TmpFileName; + command += " "; + if(_username != ""){ + command += _username; + command += "@"; + } + command += _hostname; + command += ":"; + command += dirForTmpFiles ; + command += "/" ; + command += rootNameToExecute ; + command += "_Batch.sh" ; + cerr << command.c_str() << endl; + status = system(command.c_str()); + if(status) + throw EmulationException("Error of connection on remote host"); + + remove(TmpFileName.c_str()); +#endif + } + +} diff --git a/src/PBS/Batch_BatchManager_ePBS.hxx b/src/PBS/Batch_BatchManager_ePBS.hxx new file mode 100644 index 0000000..094b796 --- /dev/null +++ b/src/PBS/Batch_BatchManager_ePBS.hxx @@ -0,0 +1,96 @@ +// Copyright (C) 2007-2008 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_ePBS.hxx : emulation of PBS client + * + * Auteur : Bernard SECHER - CEA DEN + * Mail : mailto:bernard.secher@cea.fr + * Date : Thu Apr 24 10:17:22 2008 + * Projet : PAL Salome + * + */ + +#ifndef _BATCHMANAGER_eLSF_H_ +#define _BATCHMANAGER_eLSF_H_ + +#include "Batch_Defines.hxx" + +#include "Batch_JobId.hxx" +#include "Batch_JobInfo.hxx" +#include "Batch_JobInfo_ePBS.hxx" +#include "Batch_InvalidArgumentException.hxx" +#include "Batch_ConnexionFailureException.hxx" +#include "Batch_APIInternalFailureException.hxx" +#include "Batch_NotYetImplementedException.hxx" +#include "Batch_BatchManager.hxx" +#include "Batch_BatchManager_eClient.hxx" + +namespace Batch { + + class Job; + class JobId; + class JobInfo; + class FactBatchManager; + + class BATCH_EXPORT BatchManager_ePBS : public BatchManager_eClient + { + public: + // Constructeur et destructeur + BatchManager_ePBS(const FactBatchManager * parent, const char * host="localhost", + const char * protocol="ssh", const char * mpiImpl="nompi"); // connexion a la machine host + virtual ~BatchManager_ePBS(); + + // Recupere le nom du serveur par defaut + // static string BatchManager_LSF::getDefaultServer(); + + // Methodes pour le controle des jobs + virtual const JobId submitJob(const Job & job); // soumet un job au gestionnaire + virtual void deleteJob(const JobId & jobid); // retire un job du gestionnaire + virtual void holdJob(const JobId & jobid); // suspend un job en file d'attente + virtual void releaseJob(const JobId & jobid); // relache un job suspendu + virtual void alterJob(const JobId & jobid, const Parametre & param, const Environnement & env); // modifie un job en file d'attente + virtual void alterJob(const JobId & jobid, const Parametre & param); // modifie un job en file d'attente + virtual void alterJob(const JobId & jobid, const Environnement & env); // modifie un job en file d'attente + virtual JobInfo queryJob(const JobId & jobid); // renvoie l'etat du job + virtual bool isRunning(const JobId & jobid); // teste si un job est present en machine + + virtual void setParametre(const JobId & jobid, const Parametre & param) { return alterJob(jobid, param); } // modifie un job en file d'attente + virtual void setEnvironnement(const JobId & jobid, const Environnement & env) { return alterJob(jobid, env); } // modifie un job en file d'attente + + + protected: + void buildBatchScript(const Job & job); + + 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/PBS/Batch_FactBatchManager_PBS.cxx b/src/PBS/Batch_FactBatchManager_PBS.cxx new file mode 100644 index 0000000..43c79e2 --- /dev/null +++ b/src/PBS/Batch_FactBatchManager_PBS.cxx @@ -0,0 +1,58 @@ +// Copyright (C) 2007-2008 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 new file mode 100644 index 0000000..cc43b6e --- /dev/null +++ b/src/PBS/Batch_FactBatchManager_PBS.hxx @@ -0,0 +1,57 @@ +// Copyright (C) 2007-2008 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_FactBatchManager_ePBS.cxx b/src/PBS/Batch_FactBatchManager_ePBS.cxx new file mode 100644 index 0000000..f7516ec --- /dev/null +++ b/src/PBS/Batch_FactBatchManager_ePBS.cxx @@ -0,0 +1,66 @@ +// Copyright (C) 2007-2008 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_ePBS.cxx : + * + * Auteur : Bernard SECHER - CEA DEN + * Date : Avril 2008 + * Projet : PAL Salome + * + */ + +#include +#include "Batch_BatchManager_ePBS.hxx" +#include "Batch_FactBatchManager_ePBS.hxx" +//#include "utilities.h" + +namespace Batch { + + static FactBatchManager_ePBS sFBM_ePBS; + + // Constructeur + FactBatchManager_ePBS::FactBatchManager_ePBS() : FactBatchManager_eClient("ePBS") + { + // Nothing to do + } + + // Destructeur + FactBatchManager_ePBS::~FactBatchManager_ePBS() + { + // Nothing to do + } + + // Functor + BatchManager * FactBatchManager_ePBS::operator() (const char * hostname) const + { + // MESSAGE("Building new BatchManager_PBS on host '" << hostname << "'"); + return new BatchManager_ePBS(this, hostname); + } + + BatchManager_eClient * FactBatchManager_ePBS::operator() (const char * hostname, const char * protocol, const char * mpiImpl) const + { + // MESSAGE("Building new BatchManager_PBS on host '" << hostname << "'"); + return new BatchManager_ePBS(this, hostname, protocol, mpiImpl); + } + + +} diff --git a/src/PBS/Batch_FactBatchManager_ePBS.hxx b/src/PBS/Batch_FactBatchManager_ePBS.hxx new file mode 100644 index 0000000..027e9ed --- /dev/null +++ b/src/PBS/Batch_FactBatchManager_ePBS.hxx @@ -0,0 +1,63 @@ +// Copyright (C) 2007-2008 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_ePBS.hxx : + * + * Auteur : Bernard SECHER : CEA DEN + * Date : Avril 2008 + * Projet : PAL Salome + * + */ + +#ifndef _FACTBATCHMANAGER_ePBS_H_ +#define _FACTBATCHMANAGER_ePBS_H_ + +#include "Batch_Defines.hxx" + +#include +#include +#include "Batch_BatchManager_eClient.hxx" +#include "Batch_FactBatchManager_eClient.hxx" + +namespace Batch { + + class BatchManager_ePBS; + + class BATCH_EXPORT FactBatchManager_ePBS : public FactBatchManager_eClient + { + public: + // Constructeur et destructeur + FactBatchManager_ePBS(); + virtual ~FactBatchManager_ePBS(); + + virtual BatchManager * operator() (const char * hostname) const; + virtual BatchManager_eClient * operator() (const char * hostname, const char * protocol, const char * mpiImpl) const; + + protected: + + private: + + }; + +} + +#endif diff --git a/src/PBS/Batch_JobInfo_PBS.cxx b/src/PBS/Batch_JobInfo_PBS.cxx new file mode 100644 index 0000000..3a474fc --- /dev/null +++ b/src/PBS/Batch_JobInfo_PBS.cxx @@ -0,0 +1,198 @@ +// Copyright (C) 2007-2008 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 "MEDMEM_STRING.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) { + //MEDMEM::STRING sst; + 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) { + _param[STATE] = value; + + } 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 + { + //MEDMEM::STRING sst; + 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_JobInfo_ePBS.cxx b/src/PBS/Batch_JobInfo_ePBS.cxx new file mode 100644 index 0000000..75768ea --- /dev/null +++ b/src/PBS/Batch_JobInfo_ePBS.cxx @@ -0,0 +1,118 @@ +// Copyright (C) 2007-2008 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_ePBS.cxx : emulation of PBS client + * + * Auteur : Bernard SECHER - CEA DEN + * Mail : mailto:bernard.secher@cea.fr + * Date : Thu Apr 24 10:17:22 2008 + * Projet : PAL Salome + * + */ + +#include +#include +#include +#include +#include "Batch_Parametre.hxx" +#include "Batch_Environnement.hxx" +#include "Batch_RunTimeException.hxx" +#include "Batch_APIInternalFailureException.hxx" +#include "Batch_JobInfo_ePBS.hxx" + +using namespace std; + +namespace Batch { + + + + // Constructeurs + JobInfo_ePBS::JobInfo_ePBS(int id, string logFile) : JobInfo() + { + // On remplit les membres _param et _env + ostringstream oss; + oss << id; + _param[ID] = oss.str(); + + // read of log file + char line[128]; + ifstream fp(logFile.c_str(),ios::in); + + string status; + string sline; + size_t pos = string::npos; + while( (pos == string::npos) && fp.getline(line,80,'\n') ){ + sline = string(line); + pos = sline.find("job_state"); + }; + + if(pos!=string::npos){ + istringstream iss(sline); + iss >> status; + iss >> status; + iss >> status; + } + else + status = "U"; + + _param[STATE] = status; + + if( status.find("R") != string::npos) + _running = true; + + } + + // Teste si un job est present en machine + bool JobInfo_ePBS::isRunning() const + { + return _running; + } + + + // Destructeur + JobInfo_ePBS::~JobInfo_ePBS() + { + // Nothing to do + } + + // Convertit une date HH:MM:SS en secondes + long JobInfo_ePBS::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_ePBS::__str__() const + { + ostringstream sst; + sst << " +#include +#include +#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 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, "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 new file mode 100644 index 0000000..8124f1c --- /dev/null +++ b/src/PBS/Batch_Job_PBS.hxx @@ -0,0 +1,96 @@ +// Copyright (C) 2007-2008 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 new file mode 100644 index 0000000..9a0a2da --- /dev/null +++ b/src/PBS/CMakeLists.txt @@ -0,0 +1,40 @@ +# Copyright (C) 2007-2008 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 +# + +SET(CLASS_LIST PBS/Batch_BatchManager_ePBS + PBS/Batch_FactBatchManager_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}) +APPEND_CLASSES_TO_HDR_FILES(${CLASS_LIST}) + +add_subdirectory(Test) diff --git a/src/PBS/Test/CMakeLists.txt b/src/PBS/Test/CMakeLists.txt new file mode 100644 index 0000000..9fd7272 --- /dev/null +++ b/src/PBS/Test/CMakeLists.txt @@ -0,0 +1,49 @@ +# Copyright (C) 2007-2008 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 +# + +# Declare the configuration variables for the test scripts +SET (TEST_PBS_HOST "localhost" CACHE STRING + "PBS server host (only necessary for test target)") +SET (TEST_PBS_USER "username" CACHE STRING + "Login for the PBS server (only necessary for test target)") +SET (TEST_PBS_HOMEDIR "/home/username" CACHE STRING + "Home directory on PBS server (only necessary for test target)") +SET (TEST_PBS_QUEUE "queuename" CACHE STRING + "Queue to submit test job on PBS server (only necessary for test target)") + +# Configure the config file for all the test scripts +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Test_PBS_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/Test_PBS_config.h) + +# Just copy the test scripts to the binary dir +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/seta.sh ${CMAKE_CURRENT_BINARY_DIR}/seta.sh COPYONLY) +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/setb.sh ${CMAKE_CURRENT_BINARY_DIR}/setb.sh COPYONLY) +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test-script.sh ${CMAKE_CURRENT_BINARY_DIR}/test-script.sh COPYONLY) + +# set the include directories +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../Core) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +# Build the test program and add the test +add_executable(Test_ePBS Test_ePBS.cxx) +target_link_libraries(Test_ePBS Batch) +ADD_TEST(ePBS Test_ePBS) diff --git a/src/PBS/Test/Test_PBS_config.h.in b/src/PBS/Test/Test_PBS_config.h.in new file mode 100644 index 0000000..9534b79 --- /dev/null +++ b/src/PBS/Test/Test_PBS_config.h.in @@ -0,0 +1,26 @@ +// Copyright (C) 2007-2008 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 +// + +#define TEST_PBS_HOST "${TEST_PBS_HOST}" +#define TEST_PBS_USER "${TEST_PBS_USER}" +#define TEST_PBS_HOMEDIR "${TEST_PBS_HOMEDIR}" +#define TEST_PBS_QUEUE "${TEST_PBS_QUEUE}" diff --git a/src/PBS/Test/Test_ePBS.cxx b/src/PBS/Test/Test_ePBS.cxx new file mode 100644 index 0000000..a5bf92c --- /dev/null +++ b/src/PBS/Test/Test_ePBS.cxx @@ -0,0 +1,126 @@ +// Copyright (C) 2007-2008 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_ePBS.cxx : + * + * Author : Renaud BARATE - EDF R&D + * Date : April 2009 + * + */ + +#include +#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 emulation. Passwordless SSH" << endl; + cout << "authentication must be used for this test to pass (this can be configured with ssh-agent" << endl; + cout << "for instance). You also need to create a directory \"tmp/Batch\" in your home directory on" << endl; + cout << "the PBS server before running this test." << endl; + cout << "*******************************************************************************************" << endl; + + // eventually remove any previous result + remove("result.txt"); + + try { + // Define the job... + Job job; + // ... and its parameters ... + Parametre p; + p["EXECUTABLE"] = "./test-script.sh"; + p["NAME"] = "Test_ePBS"; + p["WORKDIR"] = string(TEST_PBS_HOMEDIR) + "/tmp/Batch"; + p["INFILE"] = Couple("seta.sh", "tmp/Batch/seta.sh"); + p["INFILE"] += Couple("setb.sh", "tmp/Batch/setb.sh"); + p["OUTFILE"] = Couple("result.txt", "tmp/Batch/result.txt"); + p["TMPDIR"] = "tmp/Batch/"; + p["USER"] = TEST_PBS_USER; + p["NBPROC"] = 1; + p["MAXWALLTIME"] = 1; + p["MAXRAMSIZE"] = 4; + p["HOMEDIR"] = TEST_PBS_HOMEDIR; + p["QUEUE"] = TEST_PBS_QUEUE; + job.setParametre(p); + // ... and its environment (SSH_AUTH_SOCK env var is important for ssh agent authentication) + Environnement e; + e["SSH_AUTH_SOCK"] = getenv("SSH_AUTH_SOCK"); + job.setEnvironnement(e); + cout << job << endl; + + // Get the catalog + BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); + + // Create a BatchManager of type ePBS on localhost + FactBatchManager_eClient * fbm = (FactBatchManager_eClient *)(c("ePBS")); + BatchManager_eClient * bm = (*fbm)(TEST_PBS_HOST, "ssh", "lam"); + + // Submit the job to the BatchManager + JobId jobid = bm->submitJob(job); + cout << jobid.__repr__() << endl; + + // Wait for the end of the job + string state = "Undefined"; + for (int i=0 ; i<10 && state != "U"; i++) { + sleep(2); + JobInfo jinfo = jobid.queryJob(); + state = jinfo.getParametre()["STATE"].str(); + cout << "State is \"" << state << "\"" << endl; + } + + if (state == "U") { + cout << "Job " << jobid.__repr__() << " is done" << endl; + bm->importOutputFiles(job, "."); + } else { + cerr << "Timeout while executing job" << endl; + return 1; + } + + } catch (GenericException e) { + cerr << "Batch library exception of type " << e.type << ": " << e.message << endl; + } + + // test the result file + string exp = "c = 12"; + string res; + ifstream f("result.txt"); + getline(f, res); + f.close(); + + cout << "result found : " << res << ", expected : " << exp << endl; + + if (res == exp) + return 0; + else + return 1; +} diff --git a/src/PBS/Test/seta.sh b/src/PBS/Test/seta.sh new file mode 100644 index 0000000..42d1e38 --- /dev/null +++ b/src/PBS/Test/seta.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +a=4 diff --git a/src/PBS/Test/setb.sh b/src/PBS/Test/setb.sh new file mode 100644 index 0000000..8969060 --- /dev/null +++ b/src/PBS/Test/setb.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +b=3 diff --git a/src/PBS/Test/test-script.sh b/src/PBS/Test/test-script.sh new file mode 100755 index 0000000..64eb2fa --- /dev/null +++ b/src/PBS/Test/test-script.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +source seta.sh +source setb.sh + +c=`expr $a "*" $b` + +echo "c = $c" > result.txt diff --git a/src/Python/Batch_PyVersatile.cxx b/src/Python/Batch_PyVersatile.cxx new file mode 100644 index 0000000..620cf5e --- /dev/null +++ b/src/Python/Batch_PyVersatile.cxx @@ -0,0 +1,202 @@ +// Copyright (C) 2007-2008 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 +// +/* + * PyVersatile.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Mon Oct 13 12:01:12 2003 + * Projet : Salome 2 + * + */ + +#include +#include "Batch_TypeMismatchException.hxx" +#include "Batch_ListIsFullException.hxx" +#include "Batch_InvalidArgumentException.hxx" +#include "Batch_PyVersatile.hxx" +#include + +using namespace std; + +namespace Batch { + + // Constructeur a partir d'un objet Versatile + PyVersatile::PyVersatile(const Versatile & V) : Versatile(V) + { + // Nothing to do + } + + + // Constructeur a partir d'un PyObject + // Les objets autorises sont les strings et les ints, + // ainsi que les listes de strings + PyVersatile::PyVersatile(const PyObject * PyO) throw(TypeMismatchException, ListIsFullException, InvalidArgumentException) : Versatile() + { + PyObject * _PyO = const_cast(PyO); + + if (PyList_Check(_PyO)) { // c'est une liste + _maxsize = PyList_Size(_PyO); + for(int i=0; i<_maxsize; i++) { + PyObject * val = PyList_GetItem(_PyO, i); + if (PyString_Check(val)) { + *this += PyString_AsString(val); + + } else if (PyTuple_Check(val) && + (PyTuple_Size(val) == 2) && + PyString_Check( PyTuple_GetItem(val,0) ) && + PyString_Check( PyTuple_GetItem(val,1) ) ) { + *this += Couple( PyString_AsString( PyTuple_GetItem(val,0) ), + PyString_AsString( PyTuple_GetItem(val,1) ) + ); + + } else { + PyErr_SetString(PyExc_RuntimeWarning, "PyVersatile::PyVersatile(const PyObject * PyO) : invalid PyObject"); + } + } + + } else if (PyString_Check(_PyO)) { // c'est une string + const char * s = PyString_AsString(_PyO); + Versatile V = string(s); + *this = V; + + } else if (PyInt_Check(_PyO)) { // c'est un int + *this = PyInt_AsLong(_PyO); + + } else { // erreur + PyErr_SetString(PyExc_RuntimeWarning, "PyVersatile::PyVersatile(const PyObject * PyO) : invalid PyObject"); + } + } + + + + // Conversion de type vers un PyObject + PyVersatile::operator PyObject *() const + { + PyObject * obj; + + if (_maxsize != 1) { // une liste + obj = PyList_New(0); + for(Versatile::const_iterator it=begin(); it!=end(); it++) { +// char ch[2] = {0, 0}; + string st; + Couple cp; +// PyObject * tuple; + switch (_discriminator) { + // case BOOL: + // PyList_Append(obj, PyInt_FromLong(* static_cast(*it))); + // break; + + // case CHAR: + // *ch = * static_cast(*it); + // PyList_Append(obj, PyString_FromString(ch)); + // break; + + // case INT: + // PyList_Append(obj, PyInt_FromLong(* static_cast(*it))); + // break; + + case LONG: + PyList_Append(obj, PyInt_FromLong(* static_cast(*it))); + break; + + case STRING: + st = * static_cast(*it); + PyList_Append(obj, PyString_FromString(st.c_str())); + break; + + case COUPLE: + cp = * static_cast(*it); +// tuple = PyTuple_New(2); +// PyTuple_SetItem(tuple, 0, PyString_FromString( cp.getLocal().c_str() ) ); +// PyTuple_SetItem(tuple, 1, PyString_FromString( cp.getRemote().c_str() ) ); +// PyList_Append(obj, tuple); + PyList_Append(obj, Py_BuildValue("(ss)", cp.getLocal().c_str(), cp.getRemote().c_str() )); + break; + + case UNDEFINED: + PyList_Append(obj, Py_None); + break; + } + + } + + } else { // un scalaire +// char ch[2] = {0, 0}; + string st; + Couple cp; +// PyObject * tuple; + switch (_discriminator) { + // case BOOL: + // obj = PyInt_FromLong(* static_cast(front())); + // break; + + // case CHAR: + // *ch = * static_cast(front()); + // obj = PyString_FromString(ch); + // break; + + // case INT: + // obj = PyInt_FromLong(* static_cast(front())); + // break; + + case LONG: + obj = PyInt_FromLong(* static_cast(front())); + break; + + case STRING: + st = * static_cast(front()); + obj = PyString_FromString(st.c_str()); + break; + + case COUPLE: + cp = * static_cast(front()); +// tuple = PyTuple_New(2); +// PyTuple_SetItem(tuple, 0, PyString_FromString( cp.getLocal().c_str() ) ); +// PyTuple_SetItem(tuple, 1, PyString_FromString( cp.getRemote().c_str() ) ); +// obj = PyList_New(0); +// PyList_Append(obj, tuple); + obj = Py_BuildValue("[(ss)]", cp.getLocal().c_str(), cp.getRemote().c_str() ); + break; + + case UNDEFINED: + obj = Py_None; + break; + } + } + + return obj; + } + + + // Operateur d'affectation a partir d'un objet Versatile + PyVersatile & PyVersatile::operator =(const Versatile & V) + { + Versatile * me = this; + *me = V; + return *this; + } + +} + + +// COMMENTS diff --git a/src/Python/Batch_PyVersatile.hxx b/src/Python/Batch_PyVersatile.hxx new file mode 100644 index 0000000..41439fc --- /dev/null +++ b/src/Python/Batch_PyVersatile.hxx @@ -0,0 +1,69 @@ +// Copyright (C) 2007-2008 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 +// +/* + * PyVersatile.hxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Mail : mailto:ivan.dutka-malen@der.edf.fr + * Date : Mon Oct 13 12:01:12 2003 + * Projet : Salome 2 + * + */ + +#ifndef _PYVERSATILE_H_ +#define _PYVERSATILE_H_ + + +#include "Batch_Defines.hxx" + +#include +#include "Batch_Versatile.hxx" +#include "Batch_TypeMismatchException.hxx" +#include "Batch_ListIsFullException.hxx" +#include "Batch_InvalidArgumentException.hxx" + +namespace Batch { + + class BATCH_EXPORT PyVersatile : public Versatile + { + public: + // Constructeur a partir d'un objet Versatile + PyVersatile(const Versatile &); + + // Constructeur a partir d'un PyObject + PyVersatile(const PyObject *) throw(TypeMismatchException, ListIsFullException, InvalidArgumentException); + + // Conversion de type vers un PyObject + operator PyObject *() const; + + // Operateur d'affectation a partir d'un objet Versatile + PyVersatile & operator =(const Versatile &); + + protected: + + private: + + }; + +} + +#endif diff --git a/src/Python/CMakeLists.txt b/src/Python/CMakeLists.txt new file mode 100644 index 0000000..f6e682c --- /dev/null +++ b/src/Python/CMakeLists.txt @@ -0,0 +1,41 @@ +# Copyright (C) 2007-2008 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 +# + +INCLUDE(UseSWIG) + +INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH}) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) + +SET(SWIG_SRC_FILE libBatch_Swig.i) +SET_SOURCE_FILES_PROPERTIES(${SWIG_SRC_FILE} PROPERTIES CPLUSPLUS ON + SWIG_FLAGS "-shadow") +SWIG_ADD_MODULE(libBatch_Swig python ${SWIG_SRC_FILE} Batch_PyVersatile.cxx) +SWIG_LINK_LIBRARIES(libBatch_Swig Batch ${PYTHON_LIBRARIES}) + +INSTALL(TARGETS ${SWIG_MODULE_libBatch_Swig_REAL_NAME} DESTINATION lib/python${PYTHON_VERSION}/site-packages) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libBatch_Swig.py + DESTINATION lib/python${PYTHON_VERSION}/site-packages) +INSTALL(FILES Batch_PyVersatile.hxx DESTINATION include/Batch) + +SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES libBatch_Swig.py) + +add_subdirectory(Test) diff --git a/src/Python/Test/CMakeLists.txt b/src/Python/Test/CMakeLists.txt new file mode 100644 index 0000000..33339d8 --- /dev/null +++ b/src/Python/Test/CMakeLists.txt @@ -0,0 +1,36 @@ +# Copyright (C) 2007-2008 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 +# + +# Configure the config file for all the test scripts +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.py.in ${CMAKE_CURRENT_BINARY_DIR}/config.py) + +# Just copy the test scripts to the binary dir +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/seta.sh ${CMAKE_CURRENT_BINARY_DIR}/seta.sh COPYONLY) +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/setb.sh ${CMAKE_CURRENT_BINARY_DIR}/setb.sh COPYONLY) +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/test-script.sh ${CMAKE_CURRENT_BINARY_DIR}/test-script.sh COPYONLY) +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Test_Python_Local_SH.py + ${CMAKE_CURRENT_BINARY_DIR}/Test_Python_Local_SH.py COPYONLY) + +# Add the test +IF (BUILD_LOCAL_SUBMISSION) + ADD_TEST(Python_Local_SH ${PYTHON_EXECUTABLE} Test_Python_Local_SH.py) +ENDIF (BUILD_LOCAL_SUBMISSION) diff --git a/src/Python/Test/Test_Python_Local_SH.py b/src/Python/Test/Test_Python_Local_SH.py new file mode 100644 index 0000000..34f44d1 --- /dev/null +++ b/src/Python/Test/Test_Python_Local_SH.py @@ -0,0 +1,99 @@ +# Copyright (C) 2007-2008 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 +# + +import config +import os +import sys +import time + +# Import libBatch library +from libBatch_Swig import * + +def work(): + print "*******************************************************************************************" + print "This script tests the local batch submission based on SH. No specific configuration is" + print "needed for this test." + print "*******************************************************************************************" + + # eventually remove any previous result + if (os.path.exists('result.txt')): + os.remove('result.txt') + + # Define the job... + job = Job() + # ... and its parameters ... + p = {} + p['EXECUTABLE'] = './copied-test-script.sh' + p['NAME'] = 'Test_Local_SH' + p['WORKDIR'] = '/tmp' + p['INFILE'] = [('seta.sh', 'copied-seta.sh'), ('setb.sh', 'copied-setb.sh'), + ('test-script.sh', 'copied-test-script.sh')] + p['OUTFILE'] = [('result.txt', 'orig-result.txt')] + job.setParametre(p) + # ... and its environment + e = {} + job.setEnvironnement(e) + print job + + # Get the catalog + c = BatchManagerCatalog.getInstance() + + # Create a BatchManager of type Local_SSH on localhost + bm = c('SH')('localhost') + + # Submit the job to the BatchManager + jobid = bm.submitJob(job) + print jobid + + # Query the job + jobid.queryJob() + + # Wait for the end of the job + state = 'Unknown' + while state != 'Done': + time.sleep(0.1) + jinfo = jobid.queryJob() + try: + state = jinfo.getParametre()['STATE'] + except KeyError: + pass + + print "Job", jobid, "is done" + + # wait for 2 more seconds for the copy of output files and the cleanup + # (there's no cleaner way to do that yet) + time.sleep(2) + + # test the result file + exp = "c = 12" + f = open('result.txt') + res = f.read().strip() + print "result found : %s, expected : %s" % (res, exp) + + if (res == exp): + return 0 + else: + return 1 + +if __name__ == "__main__": + retcode = work() + sys.exit(retcode) diff --git a/src/Python/Test/config.py.in b/src/Python/Test/config.py.in new file mode 100644 index 0000000..70e2f23 --- /dev/null +++ b/src/Python/Test/config.py.in @@ -0,0 +1,24 @@ +# Copyright (C) 2007-2008 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 +# + +import sys +sys.path.append('${CMAKE_CURRENT_BINARY_DIR}/..') diff --git a/src/Python/Test/seta.sh b/src/Python/Test/seta.sh new file mode 100644 index 0000000..42d1e38 --- /dev/null +++ b/src/Python/Test/seta.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +a=4 diff --git a/src/Python/Test/setb.sh b/src/Python/Test/setb.sh new file mode 100644 index 0000000..8969060 --- /dev/null +++ b/src/Python/Test/setb.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +b=3 diff --git a/src/Python/Test/test-script.sh b/src/Python/Test/test-script.sh new file mode 100755 index 0000000..afd53de --- /dev/null +++ b/src/Python/Test/test-script.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +source copied-seta.sh +source copied-setb.sh + +c=`expr $a "*" $b` + +echo "c = $c" > orig-result.txt diff --git a/src/Python/libBatch_Swig.i b/src/Python/libBatch_Swig.i new file mode 100644 index 0000000..9dd95f9 --- /dev/null +++ b/src/Python/libBatch_Swig.i @@ -0,0 +1,84 @@ +// Copyright (C) 2007-2008 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 +// +/* + * libBatch_Swig.i : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +/* ATTENTION: + ========== + Certaines classes ont des methodes surchargees et SWIG ne gere pas bien + ces surcharges, d'ou un probleme d'utilisation en Python de celles-ci. + En bref, �a ne marche pas et il faudra corriger le probleme... + + TODO : corriger le probleme de surcharge des methodes en Python + + IDM. +*/ + + +/* Le nom du module Python tel qu'il est importe */ +%module libBatch_Swig + +/* generate docstrings with types */ +%feature("autodoc", "1"); + +/* Inclusion des conversions de type */ +%include libBatch_Swig_typemap.i + +/* Inclusion de la gestion des exceptions */ +%include libBatch_Swig_exception.i + +%{ +#include "Batch_Defines.hxx" +#include "Batch_Job.hxx" +#include "Batch_JobId.hxx" +#include "Batch_JobInfo.hxx" + +#include "Batch_BatchManager.hxx" +#include "Batch_BatchManagerCatalog.hxx" +#include "Batch_FactBatchManager.hxx" +%} + +/* Les classes exportees en Python */ +%include Batch_Defines.hxx +%include Batch_Job.hxx +%include Batch_JobId.hxx +%include Batch_JobInfo.hxx + +%include Batch_BatchManager.hxx +%include Batch_BatchManagerCatalog.hxx +%include Batch_FactBatchManager.hxx + + + +/* Les methodes alterJob (surchargees et mal gerees en Python) sont + remplacees par des methodes setParametre et setEnvironnement. + cf. remarque ci-dessus. +*/ +%ignore JobId::alterJob(const Parametre & param, const Environnement & env) const; +%ignore JobId::alterJob(const Parametre & param) const; +%ignore JobId::alterJob(const Environnement & env) const; diff --git a/src/Python/libBatch_Swig_exception.i b/src/Python/libBatch_Swig_exception.i new file mode 100644 index 0000000..03c2b0e --- /dev/null +++ b/src/Python/libBatch_Swig_exception.i @@ -0,0 +1,45 @@ +// Copyright (C) 2007-2008 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 +// +/* + * _exception.i : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +%exception { + try { + $action + } + catch (Batch::GenericException & ex) { + std::string msg = ex.type + " : " + ex.message; + PyErr_SetString(PyExc_RuntimeWarning, msg.c_str()); + return NULL; + } + catch (...) { + PyErr_SetString(PyExc_RuntimeWarning, "unknown exception"); + return NULL; + } +} + diff --git a/src/Python/libBatch_Swig_typemap.i b/src/Python/libBatch_Swig_typemap.i new file mode 100644 index 0000000..6b2a011 --- /dev/null +++ b/src/Python/libBatch_Swig_typemap.i @@ -0,0 +1,247 @@ +// Copyright (C) 2007-2008 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 +// +/* + * _typemap.i : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +%{ +#include +#include +#include +#include "Batch_Parametre.hxx" +#include "Batch_PyVersatile.hxx" +#include "Batch_JobId.hxx" +#include "Batch_FactBatchManager.hxx" +#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) +typedef int Py_ssize_t; +#define PY_SSIZE_T_MAX INT_MAX +#define PY_SSIZE_T_MIN INT_MIN +#endif +%} + +# // supprime toutes les definitions par defaut => sert au debug +# %typemap(in) SWIGTYPE ; + + +# // construction d'un dictionnaire Python a partir d'un objet BatchManagerCatalog C++ +%typemap(out) std::map * +{ + $result = PyDict_New(); + + // on itere sur toutes les clefs de la map + for(std::map::const_iterator it=(* $1).begin(); it!=(* $1).end(); it++) { + std::string key = (*it).first; + PyObject * obj = SWIG_NewPointerObj((void *) (*it).second, SWIGTYPE_p_Batch__FactBatchManager, 0); + PyDict_SetItem($result, PyString_FromString(key.c_str()), obj); + } +} + +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) Batch::Parametre +{ + $1 = PyDict_Check($input)? 1 : 0; +} + +# // construction d'un dictionnaire Python a partir d'un objet Parametre C++ +%typemap(out) Batch::Parametre +{ + $result = PyDict_New(); + + // on itere sur toutes les clefs de la map, et on passe par la classe PyVersatile + // qui convertit un Versatile en PyObject et vice versa + for(Batch::Parametre::const_iterator it=$1.begin(); it!=$1.end(); it++) { + std::string key = (*it).first; + Batch::PyVersatile PyV = (*it).second; + PyDict_SetItem($result, PyString_FromString(key.c_str()), PyV); + } +} + + +# // construction d'un objet Parametre C++ a partir d'un dictionnaire Python +%typemap(in) Batch::Parametre & (Batch::Parametre PM) +{ + if (!PyDict_Check($input)) { + PyErr_SetString(PyExc_ValueError,"Expected a dictionnary"); + return NULL; + } + + try { + // on itere sur toutes les clefs du dictionnaire, et on passe par la classe PyVersatile + // qui convertit un Versatile en PyObject et vice versa + PyObject *key, *value; + Py_ssize_t pos = 0; + while (PyDict_Next($input, &pos, &key, &value)) { + std::string mk = PyString_AsString(key); + Batch::PyVersatile PyV = value; + PyV.setName(mk); + PM[mk] = PyV; + } + + $1 = &PM; // $1 est une reference donc on lui passe une adresse + } + catch (Batch::GenericException & ex) { + std::string msg = ex.type + " : " + ex.message; + PyErr_SetString(PyExc_RuntimeWarning, msg.c_str()); + return NULL; + } + catch (...) { + PyErr_SetString(PyExc_RuntimeWarning, "unknown exception"); + return NULL; + } +} + + +# // construction d'un objet Parametre C++ a partir d'un dictionnaire Python +%typemap(in) Batch::Parametre (Batch::Parametre PM) +{ + if (!PyDict_Check($input)) { + PyErr_SetString(PyExc_ValueError,"Expected a dictionnary"); + return NULL; + } + + try { + // on itere sur toutes les clefs du dictionnaire, et on passe par la classe PyVersatile + // qui convertit un Versatile en PyObject et vice versa + PyObject *key, *value; + Py_ssize_t pos = 0; + while (PyDict_Next($input, &pos, &key, &value)) { + std::string mk = PyString_AsString(key); + Batch::PyVersatile PyV = value; + PyV.setName(mk); + PM[mk] = PyV; + } + + $1 = PM; + } + catch (Batch::GenericException & ex) { + std::string msg = ex.type + " : " + ex.message; + PyErr_SetString(PyExc_RuntimeWarning, msg.c_str()); + return NULL; + } + catch (...) { + PyErr_SetString(PyExc_RuntimeWarning, "unknown exception"); + return NULL; + } +} + +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) Batch::Environnement +{ + $1 = PyDict_Check($input)? 1 : 0; +} + +# // construction d'un dictionnaire Python a partir d'un objet Environnement C++ +%typemap(out) Batch::Environnement +{ + $result = PyDict_New(); + + // on itere sur toutes les clefs de la map + for(Batch::Environnement::const_iterator it=$1.begin(); it!=$1.end(); it++) { + std::string key = (*it).first; + std::string val = (*it).second; + PyDict_SetItem($result, + PyString_FromString(key.c_str()), + PyString_FromString(val.c_str())); + } +} + + +# // construction d'un objet Environnement C++ a partir d'un dictionnaire Python +%typemap(in) Batch::Environnement & (Batch::Environnement E) +{ + if (!PyDict_Check($input)) { + PyErr_SetString(PyExc_ValueError,"Expected a dictionnary"); + return NULL; + } + + // on itere sur toutes les clefs du dictionnaire + PyObject *key, *value; + Py_ssize_t pos = 0; + while (PyDict_Next($input, &pos, &key, &value)) { + std::string mk = PyString_AsString(key); + std::string val = PyString_AsString(value); + E[mk] = val; + } + + $1 = &E; // $1 est une reference donc on lui passe une adresse +} + + + +# // construction d'un objet Environnement C++ a partir d'un dictionnaire Python +%typemap(in) Batch::Environnement (Batch::Environnement E) +{ + if (!PyDict_Check($input)) { + PyErr_SetString(PyExc_ValueError,"Expected a dictionnary"); + return NULL; + } + + // on itere sur toutes les clefs du dictionnaire + PyObject *key, *value; + Py_ssize_t pos = 0; + while (PyDict_Next($input, &pos, &key, &value)) { + std::string mk = PyString_AsString(key); + std::string val = PyString_AsString(value); + E[mk] = val; + } + + $1 = E; +} + + + +# // construction d'une string Python a partir d'une string STL +%typemap(python,out) std::string +{ + $result = PyString_FromString($1.c_str()); +} + + + +# // construction d'une string STL a partir d'une string Python +#%typemap(in) string & (string S) +#{ +## if (!PyString_Check($input)) { +# PyErr_SetString(PyExc_ValueError,"Expected a string"); +# return NULL; +# } +# +# S = string(PyString_AsString($input)); +# $1 = &S; // $1 est une reference donc on lui passe une adresse +#} + + + +# // construction d'une string STL a partir d'une string Python +#%typemap(in) string (string S) +#{ +## if (!PyString_Check($input)) { +# PyErr_SetString(PyExc_ValueError,"Expected a string"); +# return NULL; +# } +# +# S = string(PyString_AsString($input)); +# $1 = S; +#} diff --git a/src/SGE/Batch_BatchManager_eSGE.cxx b/src/SGE/Batch_BatchManager_eSGE.cxx new file mode 100644 index 0000000..cb4f960 --- /dev/null +++ b/src/SGE/Batch_BatchManager_eSGE.cxx @@ -0,0 +1,343 @@ +// Copyright (C) 2007-2008 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_eSGE.cxx : emulation of SGE client + * + * Auteur : Bernard SECHER - CEA DEN + * Mail : mailto:bernard.secher@cea.fr + * Date : Thu Apr 24 10:17:22 2008 + * Projet : PAL Salome + * + */ + +#include +#include +#include +#include +#include "Batch_BatchManager_eSGE.hxx" +#include +#ifdef WIN32 +# include +# include +#else +#include +#endif + +using namespace std; + +namespace Batch { + + BatchManager_eSGE::BatchManager_eSGE(const FactBatchManager * parent, const char * host, const char * protocol, const char * mpiImpl) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager_eClient(parent,host,protocol,mpiImpl) + { + // Nothing to do + } + + // Destructeur + BatchManager_eSGE::~BatchManager_eSGE() + { + // Nothing to do + } + + // Methode pour le controle des jobs : soumet un job au gestionnaire + const JobId BatchManager_eSGE::submitJob(const Job & job) + { + int status; + Parametre params = job.getParametre(); + const std::string dirForTmpFiles = params[TMPDIR]; + const string fileToExecute = params[EXECUTABLE]; + string::size_type p1 = fileToExecute.find_last_of("/"); + string::size_type p2 = fileToExecute.find_last_of("."); + std::string fileNameToExecute = fileToExecute.substr(p1+1,p2-p1-1); + + // export input files on cluster + exportInputFiles(job); + + // build batch script for job + buildBatchScript(job); + + // define name of log file + string logFile="/tmp/logs/"; + logFile += getenv("USER"); + logFile += "/batchSalome_"; + srand ( time(NULL) ); + int ir = rand(); + ostringstream oss; + oss << ir; + logFile += oss.str(); + logFile += ".log"; + + string command; + + // define command to submit batch + command = _protocol; + command += " "; + + if(_username != ""){ + command += _username; + command += "@"; + } + + command += _hostname; + command += " \"cd " ; + command += dirForTmpFiles ; + command += "; qsub " ; + command += fileNameToExecute ; + command += "_Batch.sh\" > "; + command += logFile; + cerr << command.c_str() << endl; + status = system(command.c_str()); + if(status) + throw EmulationException("Error of connection on remote host"); + + // read id of submitted job in log file + char line[128]; + FILE *fp = fopen(logFile.c_str(),"r"); + fgets( line, 128, fp); + fclose(fp); + + string strjob; + istringstream iss(line); + iss >> strjob >> strjob >> strjob; + + JobId id(this, strjob); + return id; + } + + // Methode pour le controle des jobs : retire un job du gestionnaire + void BatchManager_eSGE::deleteJob(const JobId & jobid) + { + int status; + int ref; + istringstream iss(jobid.getReference()); + iss >> ref; + + // define command to submit batch + string command; + command = _protocol; + command += " "; + + if (_username != ""){ + command += _username; + command += "@"; + } + + command += _hostname; + command += " \"qdel " ; + command += iss.str(); + command += "\""; + cerr << command.c_str() << endl; + status = system(command.c_str()); + if(status) + throw EmulationException("Error of connection on remote host"); + + cerr << "jobId = " << ref << "killed" << endl; + } + + // Methode pour le controle des jobs : suspend un job en file d'attente + void BatchManager_eSGE::holdJob(const JobId & jobid) + { + throw EmulationException("Not yet implemented"); + } + + // Methode pour le controle des jobs : relache un job suspendu + void BatchManager_eSGE::releaseJob(const JobId & jobid) + { + throw EmulationException("Not yet implemented"); + } + + + // Methode pour le controle des jobs : modifie un job en file d'attente + void BatchManager_eSGE::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env) + { + throw EmulationException("Not yet implemented"); + } + + // Methode pour le controle des jobs : modifie un job en file d'attente + void BatchManager_eSGE::alterJob(const JobId & jobid, const Parametre & param) + { + alterJob(jobid, param, Environnement()); + } + + // Methode pour le controle des jobs : modifie un job en file d'attente + void BatchManager_eSGE::alterJob(const JobId & jobid, const Environnement & env) + { + alterJob(jobid, Parametre(), env); + } + + // Methode pour le controle des jobs : renvoie l'etat du job + JobInfo BatchManager_eSGE::queryJob(const JobId & jobid) + { + int id; + istringstream iss(jobid.getReference()); + iss >> id; + + // define name of log file + string logFile="/tmp/logs/"; + logFile += getenv("USER"); + logFile += "/batchSalome_"; + + ostringstream oss; + oss << this << "_" << id; + logFile += oss.str(); + logFile += ".log"; + + string command; + int status; + + // define command to submit batch + command = _protocol; + command += " "; + + if (_username != ""){ + command += _username; + command += "@"; + } + + command += _hostname; + command += " \"qstat | grep " ; + command += iss.str(); + command += "\" > "; + command += logFile; + cerr << command.c_str() << endl; + status = system(command.c_str()); + if(status && status != 256) + throw EmulationException("Error of connection on remote host"); + + JobInfo_eSGE ji = JobInfo_eSGE(id,logFile); + return ji; + } + + // Methode pour le controle des jobs : teste si un job est present en machine + bool BatchManager_eSGE::isRunning(const JobId & jobid) + { + throw EmulationException("Not yet implemented"); + } + + void BatchManager_eSGE::buildBatchScript(const Job & job) + { +#ifndef WIN32 + //TODO porting on Win32 platform + int status; + Parametre params = job.getParametre(); + Environnement env = job.getEnvironnement(); + const long nbproc = params[NBPROC]; + const long edt = params[MAXWALLTIME]; + const long mem = params[MAXRAMSIZE]; + const string workDir = params[WORKDIR]; + const std::string dirForTmpFiles = params[TMPDIR]; + const string fileToExecute = params[EXECUTABLE]; + const string home = params[HOMEDIR]; + 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); + fileNameToExecute = "~/" + dirForTmpFiles + "/" + string(basename((char *) fileToExecute.c_str())); + + int idx = dirForTmpFiles.find("Batch/"); + filelogtemp = dirForTmpFiles.substr(idx+6, dirForTmpFiles.length()); + } + else{ + rootNameToExecute = "command"; + } + + ofstream tempOutputFile; + std::string TmpFileName = createAndOpenTemporaryFile(tempOutputFile); + + tempOutputFile << "#! /bin/sh -f" << endl; + if (queue != "") + tempOutputFile << "#$ -q " << queue << endl; + tempOutputFile << "#$ -pe mpich " << nbproc << endl; + if( edt > 0 ) + tempOutputFile << "#$ -l h_rt=" << getWallTime(edt) << endl ; + if( mem > 0 ) + tempOutputFile << "#$ -l h_vmem=" << mem << "M" << endl ; + if( fileToExecute.size() > 0 ){ + tempOutputFile << "#$ -o " << home << "/" << dirForTmpFiles << "/output.log." << filelogtemp << endl ; + tempOutputFile << "#$ -e " << home << "/" << dirForTmpFiles << "/error.log." << filelogtemp << endl ; + } + else{ + tempOutputFile << "#$ -o " << dirForTmpFiles << "/" << env["LOGFILE"] << ".output.log" << endl ; + tempOutputFile << "#$ -e " << dirForTmpFiles << "/" << env["LOGFILE"] << ".error.log" << endl ; + } + if( workDir.size() > 0 ) + tempOutputFile << "cd " << workDir << endl ; + if( fileToExecute.size() > 0 ){ + tempOutputFile << _mpiImpl->boot("",nbproc); + tempOutputFile << _mpiImpl->run("${TMPDIR}/machines",nbproc,fileNameToExecute); + tempOutputFile << _mpiImpl->halt(); + } + else{ + tempOutputFile << "source " << env["SOURCEFILE"] << endl ; + tempOutputFile << env["COMMAND"]; + } + + tempOutputFile.flush(); + tempOutputFile.close(); + chmod(TmpFileName.c_str(), 0x1ED); + cerr << TmpFileName.c_str() << endl; + + string command; + if( _protocol == "rsh" ) + command = "rcp "; + else if( _protocol == "ssh" ) + command = "scp "; + else + throw EmulationException("Unknown protocol"); + command += TmpFileName; + command += " "; + if(_username != ""){ + command += _username; + command += "@"; + } + command += _hostname; + command += ":"; + command += dirForTmpFiles ; + command += "/" ; + command += rootNameToExecute ; + command += "_Batch.sh" ; + cerr << command.c_str() << endl; + status = system(command.c_str()); + if(status) + throw EmulationException("Error of connection on remote host"); + + remove(TmpFileName.c_str()); +#endif //WIN32 + } + + std::string BatchManager_eSGE::getWallTime(const long edt) + { + long h, m; + h = edt / 60; + m = edt - h*60; + ostringstream oss; + if( m >= 10 ) + oss << h << ":" << m; + else + oss << h << ":0" << m; + return oss.str(); + } + +} diff --git a/src/SGE/Batch_BatchManager_eSGE.hxx b/src/SGE/Batch_BatchManager_eSGE.hxx new file mode 100644 index 0000000..4f7ca96 --- /dev/null +++ b/src/SGE/Batch_BatchManager_eSGE.hxx @@ -0,0 +1,95 @@ +// Copyright (C) 2007-2008 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_eSGE.hxx : emulation of SGE client + * + * Auteur : Bernard SECHER - CEA DEN + * Mail : mailto:bernard.secher@cea.fr + * Date : Thu Apr 24 10:17:22 2008 + * Projet : PAL Salome + * + */ + +#ifndef _BATCHMANAGER_eLSF_H_ +#define _BATCHMANAGER_eLSF_H_ + +#include "Batch_Defines.hxx" +#include "Batch_JobId.hxx" +#include "Batch_JobInfo.hxx" +#include "Batch_JobInfo_eSGE.hxx" +#include "Batch_InvalidArgumentException.hxx" +#include "Batch_ConnexionFailureException.hxx" +#include "Batch_APIInternalFailureException.hxx" +#include "Batch_NotYetImplementedException.hxx" +#include "Batch_BatchManager.hxx" +#include "Batch_BatchManager_eClient.hxx" + +namespace Batch { + + class Job; + class JobId; + class JobInfo; + class FactBatchManager; + + class BATCH_EXPORT BatchManager_eSGE : public BatchManager_eClient + { + public: + // Constructeur et destructeur + BatchManager_eSGE(const FactBatchManager * parent, const char * host="localhost", const char * protocol="ssh", const char * mpiImpl="nompi") throw(InvalidArgumentException,ConnexionFailureException); // connexion a la machine host + virtual ~BatchManager_eSGE(); + + // Recupere le nom du serveur par defaut + // static string BatchManager_LSF::getDefaultServer(); + + // Methodes pour le controle des jobs + virtual const JobId submitJob(const Job & job); // soumet un job au gestionnaire + virtual void deleteJob(const JobId & jobid); // retire un job du gestionnaire + virtual void holdJob(const JobId & jobid); // suspend un job en file d'attente + virtual void releaseJob(const JobId & jobid); // relache un job suspendu + virtual void alterJob(const JobId & jobid, const Parametre & param, const Environnement & env); // modifie un job en file d'attente + virtual void alterJob(const JobId & jobid, const Parametre & param); // modifie un job en file d'attente + virtual void alterJob(const JobId & jobid, const Environnement & env); // modifie un job en file d'attente + virtual JobInfo queryJob(const JobId & jobid); // renvoie l'etat du job + virtual bool isRunning(const JobId & jobid); // teste si un job est present en machine + + virtual void setParametre(const JobId & jobid, const Parametre & param) { return alterJob(jobid, param); } // modifie un job en file d'attente + virtual void setEnvironnement(const JobId & jobid, const Environnement & env) { return alterJob(jobid, env); } // modifie un job en file d'attente + + + protected: + void buildBatchScript(const Job & job); + std::string getWallTime(const long edt); + + private: + +#ifdef SWIG + public: + // Recupere le l'identifiant d'un job deja soumis au BatchManager + //virtual const JobId getJobIdByReference(const string & ref) { return BatchManager::getJobIdByReference(ref); } + virtual const JobId getJobIdByReference(const char * ref) { return BatchManager::getJobIdByReference(ref); } +#endif + + }; + +} + +#endif diff --git a/src/SGE/Batch_FactBatchManager_eSGE.cxx b/src/SGE/Batch_FactBatchManager_eSGE.cxx new file mode 100644 index 0000000..c7a6c9f --- /dev/null +++ b/src/SGE/Batch_FactBatchManager_eSGE.cxx @@ -0,0 +1,66 @@ +// Copyright (C) 2007-2008 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_eSGE.cxx : + * + * Auteur : Bernard SECHER - CEA DEN + * Date : Avril 2008 + * Projet : PAL Salome + * + */ + +#include +#include "Batch_BatchManager_eSGE.hxx" +#include "Batch_FactBatchManager_eSGE.hxx" +//#include "utilities.h" + +namespace Batch { + + static FactBatchManager_eSGE sFBM_eSGE; + + // Constructeur + FactBatchManager_eSGE::FactBatchManager_eSGE() : FactBatchManager_eClient("eSGE") + { + // Nothing to do + } + + // Destructeur + FactBatchManager_eSGE::~FactBatchManager_eSGE() + { + // Nothing to do + } + + // Functor + BatchManager * FactBatchManager_eSGE::operator() (const char * hostname) const + { + // MESSAGE("Building new BatchManager_SGE on host '" << hostname << "'"); + return new BatchManager_eSGE(this, hostname); + } + + BatchManager_eClient * FactBatchManager_eSGE::operator() (const char * hostname, const char * protocol, const char * mpiImpl) const + { + // MESSAGE("Building new BatchManager_SGE on host '" << hostname << "'"); + return new BatchManager_eSGE(this, hostname, protocol, mpiImpl); + } + + +} diff --git a/src/SGE/Batch_FactBatchManager_eSGE.hxx b/src/SGE/Batch_FactBatchManager_eSGE.hxx new file mode 100644 index 0000000..44f7f6c --- /dev/null +++ b/src/SGE/Batch_FactBatchManager_eSGE.hxx @@ -0,0 +1,61 @@ +// Copyright (C) 2007-2008 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_eSGE.hxx : + * + * Auteur : Bernard SECHER : CEA DEN + * Date : Avril 2008 + * Projet : PAL Salome + * + */ + +#ifndef _FACTBATCHMANAGER_eSGE_H_ +#define _FACTBATCHMANAGER_eSGE_H_ + +#include "Batch_Defines.hxx" + +#include "Batch_BatchManager_eClient.hxx" +#include "Batch_FactBatchManager_eClient.hxx" + +namespace Batch { + + class BatchManager_eSGE; + + class BATCH_EXPORT FactBatchManager_eSGE : public FactBatchManager_eClient + { + public: + // Constructeur et destructeur + FactBatchManager_eSGE(); + virtual ~FactBatchManager_eSGE(); + + virtual BatchManager * operator() (const char * hostname) const; + virtual BatchManager_eClient * operator() (const char * hostname, const char * protocol, const char * mpiImpl) const; + + protected: + + private: + + }; + +} + +#endif diff --git a/src/SGE/Batch_JobInfo_eSGE.cxx b/src/SGE/Batch_JobInfo_eSGE.cxx new file mode 100644 index 0000000..f441437 --- /dev/null +++ b/src/SGE/Batch_JobInfo_eSGE.cxx @@ -0,0 +1,113 @@ +// Copyright (C) 2007-2008 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_eSGE.cxx : emulation of SGE client + * + * Auteur : Bernard SECHER - CEA DEN + * Mail : mailto:bernard.secher@cea.fr + * Date : Thu Apr 24 10:17:22 2008 + * Projet : PAL Salome + * + */ + +#include +#include +#include +#include +#include "Batch_Parametre.hxx" +#include "Batch_Environnement.hxx" +#include "Batch_RunTimeException.hxx" +#include "Batch_APIInternalFailureException.hxx" +#include "Batch_JobInfo_eSGE.hxx" + +using namespace std; + +namespace Batch { + + + + // Constructeurs + JobInfo_eSGE::JobInfo_eSGE(int id, string logFile) : JobInfo() + { + // On remplit les membres _param et _env + ostringstream oss; + oss << id; + _param[ID] = oss.str(); + + // read of log file + char line[128]; + ifstream fp(logFile.c_str(),ios::in); + + string status; + string sline; + fp.getline(line,80,'\n'); + sline = string(line); + + if( sline.length() > 0 ){ + istringstream iss(sline); + iss >> status >> status >> status >> status >> status; + } + else + status = "e"; + + _param[STATE] = status; + + if( status.find("r") != string::npos) + _running = true; + + } + + // Teste si un job est present en machine + bool JobInfo_eSGE::isRunning() const + { + return _running; + } + + + // Destructeur + JobInfo_eSGE::~JobInfo_eSGE() + { + // Nothing to do + } + + // Convertit une date HH:MM:SS en secondes + long JobInfo_eSGE::HMStoLong(const string & s) + { + long hour, min, sec; + + sscanf( s.c_str(), "%ld:%ld:%ld", &hour, &min, &sec); + return ( ( ( hour * 60L ) + min ) * 60L ) + sec; + } + + // Methode pour l'interfacage avec Python (SWIG) : affichage en Python + string JobInfo_eSGE::__str__() const + { + ostringstream sst; + sst << "