From 81d83ed5bb4d235c5688dcec0e9458015e760e26 Mon Sep 17 00:00:00 2001 From: barate Date: Fri, 15 Feb 2013 12:49:52 +0000 Subject: [PATCH] Merge from BR_LIBBATCH_2_0 --- CMakeLists.txt | 28 +- CMakeModules/FindLSF.cmake | 51 - CMakeModules/FindMakeinfo.cmake | 47 - CMakeModules/FindPBS.cmake | 50 - CMakeModules/FindPython.cmake | 136 - CMakeModules/FindSWIG.cmake | 50 - CMakeModules/Summary.cmake | 32 +- Batch_config.h.in => config.h.in | 0 doc/Batch.texi | 4892 ----------------- doc/CMakeLists.txt | 31 - doc/version.texi.in | 2 - misc/CMakeLists.txt | 10 +- misc/check_libbatch.m4 | 50 +- ...onfig.cmake.in => libbatchConfig.cmake.in} | 2 +- ...hManager_eCCC.cxx => BatchManager_CCC.cxx} | 158 +- ...hManager_eCCC.hxx => BatchManager_CCC.hxx} | 25 +- src/CCC/Batch_FactBatchManager_eCCC.cxx | 67 - src/CCC/Batch_FactBatchManager_eCCC.hxx | 62 - src/CCC/CMakeLists.txt | 6 +- .../FactBatchManager_CCC.cxx} | 29 +- src/CCC/FactBatchManager_CCC.hxx | 55 + ...Batch_JobInfo_eCCC.cxx => JobInfo_CCC.cxx} | 32 +- ...Batch_JobInfo_eCCC.hxx => JobInfo_CCC.hxx} | 16 +- src/CMakeLists.txt | 45 +- ...on.cxx => APIInternalFailureException.cxx} | 2 +- ...on.hxx => APIInternalFailureException.hxx} | 6 +- src/Core/BatchManager.cxx | 326 ++ ...atch_BatchManager.hxx => BatchManager.hxx} | 50 +- ...gerCatalog.cxx => BatchManagerCatalog.cxx} | 4 +- ...gerCatalog.hxx => BatchManagerCatalog.hxx} | 2 +- src/Core/Batch_BatchManager.cxx | 208 - src/Core/Batch_BatchManager_eClient.cxx | 380 -- src/Core/Batch_BatchManager_eClient.hxx | 76 - src/Core/Batch_CharType.cxx | 66 - src/Core/Batch_CharType.hxx | 70 - src/Core/Batch_ConnexionFailureException.cxx | 37 - 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_EmulationException.cxx | 35 - src/Core/Batch_EmulationException.hxx | 48 - src/Core/{Batch_BoolType.cxx => BoolType.cxx} | 2 +- src/Core/{Batch_BoolType.hxx => BoolType.hxx} | 4 +- src/Core/CMakeLists.txt | 74 +- ...Protocol.cxx => CommunicationProtocol.cxx} | 35 +- ...Protocol.hxx => CommunicationProtocol.hxx} | 10 +- ...olRSH.cxx => CommunicationProtocolRSH.cxx} | 18 +- ...olRSH.hxx => CommunicationProtocolRSH.hxx} | 14 +- ...ocolSH.cxx => CommunicationProtocolSH.cxx} | 31 +- ...ocolSH.hxx => CommunicationProtocolSH.hxx} | 12 +- ...olSSH.cxx => CommunicationProtocolSSH.cxx} | 11 +- ...olSSH.hxx => CommunicationProtocolSSH.hxx} | 10 +- .../{Batch_Constants.cxx => Constants.cxx} | 30 +- .../{Batch_Constants.hxx => Constants.hxx} | 30 +- src/Core/{Batch_Couple.cxx => Couple.cxx} | 2 +- src/Core/{Batch_Couple.hxx => Couple.hxx} | 2 +- .../{Batch_CoupleType.cxx => CoupleType.cxx} | 2 +- .../{Batch_CoupleType.hxx => CoupleType.hxx} | 6 +- src/Core/{Batch_Defines.hxx => Defines.hxx} | 10 +- ...ch_Environnement.cxx => Environnement.cxx} | 2 +- ...ch_Environnement.hxx => Environnement.hxx} | 2 +- ...tBatchManager.cxx => FactBatchManager.cxx} | 12 +- ...tBatchManager.hxx => FactBatchManager.hxx} | 15 +- ...ericException.cxx => GenericException.cxx} | 2 +- ...ericException.hxx => GenericException.hxx} | 2 +- ...{Batch_GenericType.cxx => GenericType.cxx} | 2 +- ...{Batch_GenericType.hxx => GenericType.hxx} | 2 +- ...ption.cxx => InvalidArgumentException.cxx} | 2 +- ...ption.hxx => InvalidArgumentException.hxx} | 4 +- ...yException.cxx => InvalidKeyException.cxx} | 2 +- ...yException.hxx => InvalidKeyException.hxx} | 4 +- src/Core/{Batch_Job.cxx => Job.cxx} | 4 +- src/Core/{Batch_Job.hxx => Job.hxx} | 6 +- src/Core/{Batch_JobId.cxx => JobId.cxx} | 6 +- src/Core/{Batch_JobId.hxx => JobId.hxx} | 8 +- src/Core/{Batch_JobInfo.cxx => JobInfo.cxx} | 4 +- src/Core/{Batch_JobInfo.hxx => JobInfo.hxx} | 6 +- ...lException.cxx => ListIsFullException.cxx} | 2 +- ...lException.hxx => ListIsFullException.hxx} | 4 +- src/Core/{Batch_Utils.cxx => Log.cxx} | 63 +- src/Core/Log.hxx | 65 + src/Core/{Batch_LongType.cxx => LongType.cxx} | 2 +- src/Core/{Batch_LongType.hxx => LongType.hxx} | 4 +- src/Core/{Batch_MpiImpl.cxx => MpiImpl.cxx} | 2 +- src/Core/{Batch_MpiImpl.hxx => MpiImpl.hxx} | 2 +- ...ion.cxx => NotYetImplementedException.cxx} | 2 +- ...ion.hxx => NotYetImplementedException.hxx} | 4 +- ...ameterTypeMap.cxx => ParameterTypeMap.cxx} | 34 +- ...ameterTypeMap.hxx => ParameterTypeMap.hxx} | 6 +- .../{Batch_Parametre.cxx => Parametre.cxx} | 8 +- .../{Batch_Parametre.hxx => Parametre.hxx} | 4 +- ...TimeException.cxx => RunTimeException.cxx} | 2 +- ...TimeException.hxx => RunTimeException.hxx} | 4 +- .../{Batch_StringType.cxx => StringType.cxx} | 2 +- .../{Batch_StringType.hxx => StringType.hxx} | 4 +- src/Core/Test/CMakeLists.txt | 7 +- src/Core/Test/SimpleParser.cxx | 30 + src/Core/Test/SimpleParser.hxx | 4 + .../Test/Test_BatchManager.cxx} | 100 +- src/Core/Test/Test_config.h.in | 4 + src/Core/Test/batchtest.conf | 61 +- src/Core/Test/seta.py | 3 + src/Core/Test/setb.py | 3 + src/Core/Test/test_script.py | 16 + ...xception.cxx => TypeMismatchException.cxx} | 2 +- ...xception.hxx => TypeMismatchException.hxx} | 4 +- src/Core/Utils.cxx | 170 + src/Core/Utils.hxx | 91 + .../{Batch_Versatile.cxx => Versatile.cxx} | 15 +- .../{Batch_Versatile.hxx => Versatile.hxx} | 19 +- ...hManager_eLSF.cxx => BatchManager_LSF.cxx} | 123 +- ...hManager_eLSF.hxx => BatchManager_LSF.hxx} | 25 +- src/LSF/Batch_BatchManager_LSF.cxx | 201 - src/LSF/Batch_BatchManager_LSF.hxx | 98 - src/LSF/Batch_FactBatchManager_eLSF.cxx | 67 - src/LSF/Batch_FactBatchManager_eLSF.hxx | 62 - src/LSF/Batch_JobInfo_LSF.cxx | 207 - src/LSF/Batch_JobInfo_LSF.hxx | 76 - src/LSF/Batch_Job_LSF.cxx | 266 - src/LSF/CMakeLists.txt | 21 +- ...nager_LSF.cxx => FactBatchManager_LSF.cxx} | 21 +- ...nager_LSF.hxx => FactBatchManager_LSF.hxx} | 25 +- ...Batch_JobInfo_eLSF.cxx => JobInfo_LSF.cxx} | 21 +- ...Batch_JobInfo_eLSF.hxx => JobInfo_LSF.hxx} | 14 +- src/LSF/Test/CMakeLists.txt | 44 - src/LSF/Test/Test_eLSF.cxx | 163 - src/LSF/Test/seta.sh | 3 - src/LSF/Test/setb.sh | 3 - src/LSF/Test/test-script.sh | 9 - ...tchManager_eLL.cxx => BatchManager_LL.cxx} | 130 +- ...tchManager_eLL.hxx => BatchManager_LL.hxx} | 29 +- .../Batch_FactBatchManager_eLL.cxx | 67 - src/LoadLeveler/CMakeLists.txt | 10 +- src/LoadLeveler/FactBatchManager_LL.cxx | 59 + ...anager_eLL.hxx => FactBatchManager_LL.hxx} | 29 +- .../{Batch_JobInfo_eLL.cxx => JobInfo_LL.cxx} | 16 +- .../{Batch_JobInfo_eLL.hxx => JobInfo_LL.hxx} | 10 +- src/LoadLeveler/Test/CMakeLists.txt | 44 - src/LoadLeveler/Test/seta.sh | 3 - src/LoadLeveler/Test/setb.sh | 3 - src/LoadLeveler/Test/test-script.sh | 9 - ...nager_Local.cxx => BatchManager_Local.cxx} | 484 +- ...nager_Local.hxx => BatchManager_Local.hxx} | 43 +- src/Local/CMakeLists.txt | 22 +- ...r_Local.cxx => FactBatchManager_Local.cxx} | 37 +- ...r_Local.hxx => FactBatchManager_Local.hxx} | 19 +- src/Local/{Batch_IOMutex.cxx => IOMutex.cxx} | 2 +- src/Local/{Batch_IOMutex.hxx => IOMutex.hxx} | 0 ...ch_JobInfo_Local.cxx => JobInfo_Local.cxx} | 6 +- ...ch_JobInfo_Local.hxx => JobInfo_Local.hxx} | 2 +- .../{Batch_Job_Local.cxx => Job_Local.cxx} | 10 +- .../{Batch_Job_Local.hxx => Job_Local.hxx} | 6 +- src/Local/Test/CMakeLists.txt | 62 - src/Local/Test/Exec_Test.cxx | 80 - src/Local/Test/Test_Local_RSH.cxx | 128 - src/Local/Test/Test_Local_SH.cxx | 128 - src/Local/Test/Test_Local_SSH.cxx | 131 - src/Local/Test/Test_Local_config.h.in | 23 - src/Local/Test/seta.sh | 3 - src/Local/Test/setb.sh | 3 - src/Local/Test/test-script.sh | 8 - ...hManager_ePBS.cxx => BatchManager_PBS.cxx} | 128 +- ...hManager_ePBS.hxx => BatchManager_PBS.hxx} | 31 +- src/PBS/Batch_BatchManager_PBS.cxx | 218 - src/PBS/Batch_BatchManager_PBS.hxx | 102 - src/PBS/Batch_FactBatchManager_ePBS.cxx | 70 - src/PBS/Batch_FactBatchManager_ePBS.hxx | 67 - src/PBS/Batch_JobInfo_PBS.cxx | 218 - src/PBS/Batch_JobInfo_PBS.hxx | 72 - src/PBS/Batch_Job_PBS.cxx | 474 -- src/PBS/Batch_Job_PBS.hxx | 96 - src/PBS/CMakeLists.txt | 19 +- ...nager_PBS.cxx => FactBatchManager_PBS.cxx} | 22 +- ...nager_PBS.hxx => FactBatchManager_PBS.hxx} | 22 +- ...Batch_JobInfo_ePBS.cxx => JobInfo_PBS.cxx} | 19 +- ...Batch_JobInfo_ePBS.hxx => JobInfo_PBS.hxx} | 16 +- src/PBS/Test/CMakeLists.txt | 50 - src/PBS/Test/Test_PBS.cxx | 140 - src/PBS/Test/Test_ePBS.cxx | 160 - src/PBS/Test/seta.sh | 3 - src/PBS/Test/setb.sh | 3 - src/PBS/Test/test-script.sh | 9 - src/Python/CMakeLists.txt | 11 +- src/Python/Test/CMakeLists.txt | 4 +- src/Python/Test/Test_Python_Local_SH.py | 54 +- src/Python/Test/config.py.in | 4 +- src/Python/Test/seta.sh | 3 - src/Python/Test/setb.sh | 3 - src/Python/libBatch_Swig.i | 46 +- src/Python/libBatch_Swig_typemap.i | 19 +- ...hManager_eSGE.cxx => BatchManager_SGE.cxx} | 140 +- ...hManager_eSGE.hxx => BatchManager_SGE.hxx} | 25 +- src/SGE/Batch_FactBatchManager_eSGE.cxx | 68 - src/SGE/Batch_FactBatchManager_eSGE.hxx | 63 - src/SGE/CMakeLists.txt | 6 +- src/SGE/FactBatchManager_SGE.cxx | 59 + .../FactBatchManager_SGE.hxx} | 42 +- ...Batch_JobInfo_eSGE.cxx => JobInfo_SGE.cxx} | 34 +- ...Batch_JobInfo_eSGE.hxx => JobInfo_SGE.hxx} | 18 +- src/SSH/Batch_BatchManager_eSSH.cxx | 228 - src/SSH/Batch_BatchManager_eSSH.hxx | 82 - src/SSH/Batch_FactBatchManager_eSSH.cxx | 57 - src/SSH/Batch_FactBatchManager_eSSH.hxx | 58 - src/SSH/Batch_JobInfo_eSSH.cxx | 73 - src/SSH/Batch_JobInfo_eSSH.hxx | 54 - src/SSH/CMakeLists.txt | 32 - ...ager_eSlurm.cxx => BatchManager_Slurm.cxx} | 101 +- ...ager_eSlurm.hxx => BatchManager_Slurm.hxx} | 29 +- src/Slurm/Batch_FactBatchManager_eSlurm.cxx | 62 - src/Slurm/Batch_FactBatchManager_eSlurm.hxx | 57 - src/Slurm/CMakeLists.txt | 12 +- .../FactBatchManager_Slurm.cxx} | 48 +- .../FactBatchManager_Slurm.hxx} | 33 +- ...h_JobInfo_eSlurm.cxx => JobInfo_Slurm.cxx} | 12 +- ...h_JobInfo_eSlurm.hxx => JobInfo_Slurm.hxx} | 10 +- src/Slurm/Test/CMakeLists.txt | 44 - src/Slurm/Test/Test_eSlurm.cxx | 163 - src/Slurm/Test/seta.sh | 3 - src/Slurm/Test/setb.sh | 3 - src/Slurm/Test/test-script.sh | 9 - ...er_eVishnu.cxx => BatchManager_Vishnu.cxx} | 124 +- ...er_eVishnu.hxx => BatchManager_Vishnu.hxx} | 29 +- src/Vishnu/Batch_FactBatchManager_eVishnu.cxx | 62 - src/Vishnu/CMakeLists.txt | 8 +- ...Vishnu.hxx => FactBatchManager_Vishnu.cxx} | 40 +- .../FactBatchManager_Vishnu.hxx} | 43 +- ...JobInfo_eVishnu.cxx => JobInfo_Vishnu.cxx} | 12 +- ...JobInfo_eVishnu.hxx => JobInfo_Vishnu.hxx} | 10 +- src/Vishnu/Test/CMakeLists.txt | 44 - src/Vishnu/Test/Test_eVishnu.cxx | 137 - src/Vishnu/Test/seta.sh | 3 - src/Vishnu/Test/setb.sh | 3 - src/Vishnu/Test/test-script.sh | 9 - 234 files changed, 2327 insertions(+), 13688 deletions(-) delete mode 100644 CMakeModules/FindLSF.cmake delete mode 100644 CMakeModules/FindMakeinfo.cmake delete mode 100644 CMakeModules/FindPBS.cmake delete mode 100644 CMakeModules/FindPython.cmake delete mode 100644 CMakeModules/FindSWIG.cmake rename Batch_config.h.in => config.h.in (100%) delete mode 100644 doc/Batch.texi delete mode 100644 doc/CMakeLists.txt delete mode 100644 doc/version.texi.in rename misc/{libBatchConfig.cmake.in => libbatchConfig.cmake.in} (95%) rename src/CCC/{Batch_BatchManager_eCCC.cxx => BatchManager_CCC.cxx} (62%) rename src/CCC/{Batch_BatchManager_eCCC.hxx => BatchManager_CCC.hxx} (71%) delete mode 100644 src/CCC/Batch_FactBatchManager_eCCC.cxx delete mode 100644 src/CCC/Batch_FactBatchManager_eCCC.hxx rename src/{Core/Batch_FactBatchManager_eClient.cxx => CCC/FactBatchManager_CCC.cxx} (58%) create mode 100644 src/CCC/FactBatchManager_CCC.hxx rename src/CCC/{Batch_JobInfo_eCCC.cxx => JobInfo_CCC.cxx} (80%) rename src/CCC/{Batch_JobInfo_eCCC.hxx => JobInfo_CCC.hxx} (84%) rename src/Core/{Batch_APIInternalFailureException.cxx => APIInternalFailureException.cxx} (96%) rename src/Core/{Batch_APIInternalFailureException.hxx => APIInternalFailureException.hxx} (93%) create mode 100644 src/Core/BatchManager.cxx rename src/Core/{Batch_BatchManager.hxx => BatchManager.hxx} (59%) rename src/Core/{Batch_BatchManagerCatalog.cxx => BatchManagerCatalog.cxx} (97%) rename src/Core/{Batch_BatchManagerCatalog.hxx => BatchManagerCatalog.hxx} (98%) delete mode 100644 src/Core/Batch_BatchManager.cxx delete mode 100644 src/Core/Batch_BatchManager_eClient.cxx delete mode 100644 src/Core/Batch_BatchManager_eClient.hxx delete mode 100644 src/Core/Batch_CharType.cxx delete mode 100644 src/Core/Batch_CharType.hxx delete mode 100644 src/Core/Batch_ConnexionFailureException.cxx delete mode 100644 src/Core/Batch_Date.cxx delete mode 100644 src/Core/Batch_Date.hxx delete mode 100644 src/Core/Batch_DateType.cxx delete mode 100644 src/Core/Batch_DateType.hxx delete mode 100644 src/Core/Batch_EmulationException.cxx delete mode 100644 src/Core/Batch_EmulationException.hxx rename src/Core/{Batch_BoolType.cxx => BoolType.cxx} (98%) rename src/Core/{Batch_BoolType.hxx => BoolType.hxx} (96%) rename src/Core/{Batch_CommunicationProtocol.cxx => CommunicationProtocol.cxx} (90%) rename src/Core/{Batch_CommunicationProtocol.hxx => CommunicationProtocol.hxx} (94%) rename src/Core/{Batch_CommunicationProtocolRSH.cxx => CommunicationProtocolRSH.cxx} (95%) rename src/Core/{Batch_CommunicationProtocolRSH.hxx => CommunicationProtocolRSH.hxx} (93%) rename src/Core/{Batch_CommunicationProtocolSH.cxx => CommunicationProtocolSH.cxx} (75%) rename src/Core/{Batch_CommunicationProtocolSH.hxx => CommunicationProtocolSH.hxx} (92%) rename src/Core/{Batch_CommunicationProtocolSSH.cxx => CommunicationProtocolSSH.cxx} (94%) rename src/Core/{Batch_CommunicationProtocolSSH.hxx => CommunicationProtocolSSH.hxx} (92%) rename src/Core/{Batch_Constants.cxx => Constants.cxx} (71%) rename src/Core/{Batch_Constants.hxx => Constants.hxx} (72%) rename src/Core/{Batch_Couple.cxx => Couple.cxx} (98%) rename src/Core/{Batch_Couple.hxx => Couple.hxx} (98%) rename src/Core/{Batch_CoupleType.cxx => CoupleType.cxx} (98%) rename src/Core/{Batch_CoupleType.hxx => CoupleType.hxx} (95%) rename src/Core/{Batch_Defines.hxx => Defines.hxx} (87%) rename src/Core/{Batch_Environnement.cxx => Environnement.cxx} (97%) rename src/Core/{Batch_Environnement.hxx => Environnement.hxx} (97%) rename src/Core/{Batch_FactBatchManager.cxx => FactBatchManager.cxx} (85%) rename src/Core/{Batch_FactBatchManager.hxx => FactBatchManager.hxx} (81%) rename src/Core/{Batch_GenericException.cxx => GenericException.cxx} (97%) rename src/Core/{Batch_GenericException.hxx => GenericException.hxx} (98%) rename src/Core/{Batch_GenericType.cxx => GenericType.cxx} (98%) rename src/Core/{Batch_GenericType.hxx => GenericType.hxx} (98%) rename src/Core/{Batch_InvalidArgumentException.cxx => InvalidArgumentException.cxx} (96%) rename src/Core/{Batch_InvalidArgumentException.hxx => InvalidArgumentException.hxx} (95%) rename src/Core/{Batch_InvalidKeyException.cxx => InvalidKeyException.cxx} (96%) rename src/Core/{Batch_InvalidKeyException.hxx => InvalidKeyException.hxx} (95%) rename src/Core/{Batch_Job.cxx => Job.cxx} (98%) rename src/Core/{Batch_Job.hxx => Job.hxx} (95%) rename src/Core/{Batch_JobId.cxx => JobId.cxx} (96%) rename src/Core/{Batch_JobId.hxx => JobId.hxx} (95%) rename src/Core/{Batch_JobInfo.cxx => JobInfo.cxx} (97%) rename src/Core/{Batch_JobInfo.hxx => JobInfo.hxx} (96%) rename src/Core/{Batch_ListIsFullException.cxx => ListIsFullException.cxx} (96%) rename src/Core/{Batch_ListIsFullException.hxx => ListIsFullException.hxx} (95%) rename src/Core/{Batch_Utils.cxx => Log.cxx} (59%) create mode 100644 src/Core/Log.hxx rename src/Core/{Batch_LongType.cxx => LongType.cxx} (98%) rename src/Core/{Batch_LongType.hxx => LongType.hxx} (96%) rename src/Core/{Batch_MpiImpl.cxx => MpiImpl.cxx} (99%) rename src/Core/{Batch_MpiImpl.hxx => MpiImpl.hxx} (99%) rename src/Core/{Batch_NotYetImplementedException.cxx => NotYetImplementedException.cxx} (96%) rename src/Core/{Batch_NotYetImplementedException.hxx => NotYetImplementedException.hxx} (95%) rename src/Core/{Batch_ParameterTypeMap.cxx => ParameterTypeMap.cxx} (73%) rename src/Core/{Batch_ParameterTypeMap.hxx => ParameterTypeMap.hxx} (95%) rename src/Core/{Batch_Parametre.cxx => Parametre.cxx} (95%) rename src/Core/{Batch_Parametre.hxx => Parametre.hxx} (96%) rename src/Core/{Batch_RunTimeException.cxx => RunTimeException.cxx} (96%) rename src/Core/{Batch_RunTimeException.hxx => RunTimeException.hxx} (95%) rename src/Core/{Batch_StringType.cxx => StringType.cxx} (98%) rename src/Core/{Batch_StringType.hxx => StringType.hxx} (96%) rename src/{LoadLeveler/Test/Test_eLL.cxx => Core/Test/Test_BatchManager.cxx} (57%) create mode 100644 src/Core/Test/seta.py create mode 100644 src/Core/Test/setb.py create mode 100755 src/Core/Test/test_script.py rename src/Core/{Batch_TypeMismatchException.cxx => TypeMismatchException.cxx} (96%) rename src/Core/{Batch_TypeMismatchException.hxx => TypeMismatchException.hxx} (95%) create mode 100644 src/Core/Utils.cxx create mode 100644 src/Core/Utils.hxx rename src/Core/{Batch_Versatile.cxx => Versatile.cxx} (96%) rename src/Core/{Batch_Versatile.hxx => Versatile.hxx} (92%) rename src/LSF/{Batch_BatchManager_eLSF.cxx => BatchManager_LSF.cxx} (69%) rename src/LSF/{Batch_BatchManager_eLSF.hxx => BatchManager_LSF.hxx} (72%) delete mode 100644 src/LSF/Batch_BatchManager_LSF.cxx delete mode 100644 src/LSF/Batch_BatchManager_LSF.hxx delete mode 100644 src/LSF/Batch_FactBatchManager_eLSF.cxx delete mode 100644 src/LSF/Batch_FactBatchManager_eLSF.hxx delete mode 100644 src/LSF/Batch_JobInfo_LSF.cxx delete mode 100644 src/LSF/Batch_JobInfo_LSF.hxx delete mode 100644 src/LSF/Batch_Job_LSF.cxx rename src/LSF/{Batch_FactBatchManager_LSF.cxx => FactBatchManager_LSF.cxx} (74%) rename src/LSF/{Batch_FactBatchManager_LSF.hxx => FactBatchManager_LSF.hxx} (70%) rename src/LSF/{Batch_JobInfo_eLSF.cxx => JobInfo_LSF.cxx} (87%) rename src/LSF/{Batch_JobInfo_eLSF.hxx => JobInfo_LSF.hxx} (85%) delete mode 100644 src/LSF/Test/CMakeLists.txt delete mode 100644 src/LSF/Test/Test_eLSF.cxx delete mode 100644 src/LSF/Test/seta.sh delete mode 100644 src/LSF/Test/setb.sh delete mode 100755 src/LSF/Test/test-script.sh rename src/LoadLeveler/{Batch_BatchManager_eLL.cxx => BatchManager_LL.cxx} (63%) rename src/LoadLeveler/{Batch_BatchManager_eLL.hxx => BatchManager_LL.hxx} (62%) delete mode 100644 src/LoadLeveler/Batch_FactBatchManager_eLL.cxx create mode 100644 src/LoadLeveler/FactBatchManager_LL.cxx rename src/LoadLeveler/{Batch_FactBatchManager_eLL.hxx => FactBatchManager_LL.hxx} (61%) rename src/LoadLeveler/{Batch_JobInfo_eLL.cxx => JobInfo_LL.cxx} (92%) rename src/LoadLeveler/{Batch_JobInfo_eLL.hxx => JobInfo_LL.hxx} (86%) delete mode 100644 src/LoadLeveler/Test/CMakeLists.txt delete mode 100644 src/LoadLeveler/Test/seta.sh delete mode 100644 src/LoadLeveler/Test/setb.sh delete mode 100755 src/LoadLeveler/Test/test-script.sh rename src/Local/{Batch_BatchManager_Local.cxx => BatchManager_Local.cxx} (60%) rename src/Local/{Batch_BatchManager_Local.hxx => BatchManager_Local.hxx} (80%) rename src/Local/{Batch_FactBatchManager_Local.cxx => FactBatchManager_Local.cxx} (63%) rename src/Local/{Batch_FactBatchManager_Local.hxx => FactBatchManager_Local.hxx} (79%) rename src/Local/{Batch_IOMutex.cxx => IOMutex.cxx} (97%) rename src/Local/{Batch_IOMutex.hxx => IOMutex.hxx} (100%) rename src/Local/{Batch_JobInfo_Local.cxx => JobInfo_Local.cxx} (93%) rename src/Local/{Batch_JobInfo_Local.hxx => JobInfo_Local.hxx} (98%) rename src/Local/{Batch_Job_Local.cxx => Job_Local.cxx} (91%) rename src/Local/{Batch_Job_Local.hxx => Job_Local.hxx} (95%) delete mode 100644 src/Local/Test/CMakeLists.txt delete mode 100644 src/Local/Test/Exec_Test.cxx delete mode 100644 src/Local/Test/Test_Local_RSH.cxx delete mode 100644 src/Local/Test/Test_Local_SH.cxx delete mode 100644 src/Local/Test/Test_Local_SSH.cxx delete mode 100644 src/Local/Test/Test_Local_config.h.in delete mode 100644 src/Local/Test/seta.sh delete mode 100644 src/Local/Test/setb.sh delete mode 100755 src/Local/Test/test-script.sh rename src/PBS/{Batch_BatchManager_ePBS.cxx => BatchManager_PBS.cxx} (63%) rename src/PBS/{Batch_BatchManager_ePBS.hxx => BatchManager_PBS.hxx} (68%) delete mode 100644 src/PBS/Batch_BatchManager_PBS.cxx delete mode 100644 src/PBS/Batch_BatchManager_PBS.hxx delete mode 100644 src/PBS/Batch_FactBatchManager_ePBS.cxx delete mode 100644 src/PBS/Batch_FactBatchManager_ePBS.hxx delete mode 100644 src/PBS/Batch_JobInfo_PBS.cxx delete mode 100644 src/PBS/Batch_JobInfo_PBS.hxx delete mode 100644 src/PBS/Batch_Job_PBS.cxx delete mode 100644 src/PBS/Batch_Job_PBS.hxx rename src/PBS/{Batch_FactBatchManager_PBS.cxx => FactBatchManager_PBS.cxx} (72%) rename src/PBS/{Batch_FactBatchManager_PBS.hxx => FactBatchManager_PBS.hxx} (71%) rename src/PBS/{Batch_JobInfo_ePBS.cxx => JobInfo_PBS.cxx} (88%) rename src/PBS/{Batch_JobInfo_ePBS.hxx => JobInfo_PBS.hxx} (84%) delete mode 100644 src/PBS/Test/CMakeLists.txt delete mode 100644 src/PBS/Test/Test_PBS.cxx delete mode 100644 src/PBS/Test/Test_ePBS.cxx delete mode 100644 src/PBS/Test/seta.sh delete mode 100644 src/PBS/Test/setb.sh delete mode 100755 src/PBS/Test/test-script.sh delete mode 100644 src/Python/Test/seta.sh delete mode 100644 src/Python/Test/setb.sh rename src/SGE/{Batch_BatchManager_eSGE.cxx => BatchManager_SGE.cxx} (60%) rename src/SGE/{Batch_BatchManager_eSGE.hxx => BatchManager_SGE.hxx} (71%) delete mode 100644 src/SGE/Batch_FactBatchManager_eSGE.cxx delete mode 100644 src/SGE/Batch_FactBatchManager_eSGE.hxx create mode 100644 src/SGE/FactBatchManager_SGE.cxx rename src/{LSF/Batch_Job_LSF.hxx => SGE/FactBatchManager_SGE.hxx} (61%) rename src/SGE/{Batch_JobInfo_eSGE.cxx => JobInfo_SGE.cxx} (81%) rename src/SGE/{Batch_JobInfo_eSGE.hxx => JobInfo_SGE.hxx} (83%) delete mode 100644 src/SSH/Batch_BatchManager_eSSH.cxx delete mode 100644 src/SSH/Batch_BatchManager_eSSH.hxx delete mode 100644 src/SSH/Batch_FactBatchManager_eSSH.cxx delete mode 100644 src/SSH/Batch_FactBatchManager_eSSH.hxx delete mode 100644 src/SSH/Batch_JobInfo_eSSH.cxx delete mode 100644 src/SSH/Batch_JobInfo_eSSH.hxx delete mode 100644 src/SSH/CMakeLists.txt rename src/Slurm/{Batch_BatchManager_eSlurm.cxx => BatchManager_Slurm.cxx} (68%) rename src/Slurm/{Batch_BatchManager_eSlurm.hxx => BatchManager_Slurm.hxx} (63%) delete mode 100644 src/Slurm/Batch_FactBatchManager_eSlurm.cxx delete mode 100644 src/Slurm/Batch_FactBatchManager_eSlurm.hxx rename src/{Core/Batch_FactBatchManager_eClient.hxx => Slurm/FactBatchManager_Slurm.cxx} (59%) rename src/{Core/Batch_ConnexionFailureException.hxx => Slurm/FactBatchManager_Slurm.hxx} (61%) rename src/Slurm/{Batch_JobInfo_eSlurm.cxx => JobInfo_Slurm.cxx} (90%) rename src/Slurm/{Batch_JobInfo_eSlurm.hxx => JobInfo_Slurm.hxx} (85%) delete mode 100644 src/Slurm/Test/CMakeLists.txt delete mode 100644 src/Slurm/Test/Test_eSlurm.cxx delete mode 100644 src/Slurm/Test/seta.sh delete mode 100644 src/Slurm/Test/setb.sh delete mode 100755 src/Slurm/Test/test-script.sh rename src/Vishnu/{Batch_BatchManager_eVishnu.cxx => BatchManager_Vishnu.cxx} (72%) rename src/Vishnu/{Batch_BatchManager_eVishnu.hxx => BatchManager_Vishnu.hxx} (65%) delete mode 100644 src/Vishnu/Batch_FactBatchManager_eVishnu.cxx rename src/Vishnu/{Batch_FactBatchManager_eVishnu.hxx => FactBatchManager_Vishnu.cxx} (55%) rename src/{Core/Batch_Utils.hxx => Vishnu/FactBatchManager_Vishnu.hxx} (60%) rename src/Vishnu/{Batch_JobInfo_eVishnu.cxx => JobInfo_Vishnu.cxx} (91%) rename src/Vishnu/{Batch_JobInfo_eVishnu.hxx => JobInfo_Vishnu.hxx} (84%) delete mode 100644 src/Vishnu/Test/CMakeLists.txt delete mode 100644 src/Vishnu/Test/Test_eVishnu.cxx delete mode 100644 src/Vishnu/Test/seta.sh delete mode 100644 src/Vishnu/Test/setb.sh delete mode 100755 src/Vishnu/Test/test-script.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 41ec665..f671fce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,16 +20,13 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -project (libBatch) +project (libbatch) -cmake_minimum_required (VERSION 2.4) +cmake_minimum_required (VERSION 2.8) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules/) find_package (PThread REQUIRED) -find_package (Makeinfo) -SET (BUILD_LSF_INTERFACE TRUE CACHE BOOL "Build interface for LSF batch system") -SET (BUILD_PBS_INTERFACE TRUE CACHE BOOL "Build interface for PBS batch system") SET (BUILD_LOCAL_SUBMISSION TRUE CACHE BOOL "Build classes for local submission") SET (BUILD_PYTHON_WRAPPING TRUE CACHE BOOL "Generate Python wrapping") SET (TEST_ENABLED FALSE CACHE BOOL "Enable testing") @@ -38,39 +35,30 @@ IF (TEST_ENABLED) ENABLE_TESTING() ENDIF (TEST_ENABLED) -IF (BUILD_LSF_INTERFACE) - find_package (LSF) -ENDIF (BUILD_LSF_INTERFACE) -IF (BUILD_PBS_INTERFACE) - find_package (PBS) -ENDIF (BUILD_PBS_INTERFACE) IF (BUILD_LOCAL_SUBMISSION) find_package (Local) ENDIF (BUILD_LOCAL_SUBMISSION) IF (BUILD_PYTHON_WRAPPING) - FIND_PACKAGE(Python) + FIND_PACKAGE(PythonInterp) + SET(PythonLibs_FIND_VERSION ${PYTHON_VERSION_STRING}) + FIND_PACKAGE(PythonLibs) FIND_PACKAGE(SWIG) ENDIF (BUILD_PYTHON_WRAPPING) SET(CPACK_GENERATOR TGZ) SET(CPACK_SOURCE_GENERATOR TGZ ZIP) -SET(CPACK_PACKAGE_VERSION_MAJOR 1) -SET(CPACK_PACKAGE_VERSION_MINOR 6) +SET(CPACK_PACKAGE_VERSION_MAJOR 2) +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}) -configure_file (${CMAKE_CURRENT_SOURCE_DIR}/Batch_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/Batch_config.h) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) INCLUDE(Summary) add_subdirectory (src) - -IF (Makeinfo_FOUND) - add_subdirectory (doc) -ENDIF (Makeinfo_FOUND) - add_subdirectory (misc) INCLUDE(CPack) diff --git a/CMakeModules/FindLSF.cmake b/CMakeModules/FindLSF.cmake deleted file mode 100644 index 1f07877..0000000 --- a/CMakeModules/FindLSF.cmake +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -IF (NOT LSF_FIND_QUIETLY) - MESSAGE(STATUS "Looking for LSF...") -ENDIF (NOT LSF_FIND_QUIETLY) - -FIND_PATH(LSF_INCLUDE_DIR lsf/lsbatch.h) -FIND_LIBRARY(LSF_LIBRARY lsf) -FIND_LIBRARY(LSF_BAT_LIBRARY bat) - -IF (LSF_INCLUDE_DIR AND LSF_LIBRARY AND LSF_BAT_LIBRARY) - SET(LSF_FOUND True) -ENDIF (LSF_INCLUDE_DIR AND LSF_LIBRARY AND LSF_BAT_LIBRARY) - -IF (LSF_FOUND) - - IF (NOT LSF_FIND_QUIETLY) - MESSAGE(STATUS "Found LSF: ${LSF_LIBRARY}") - ENDIF (NOT LSF_FIND_QUIETLY) - -ELSE (LSF_FOUND) - - IF (LSF_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "LSF not found") - ELSE (LSF_FIND_REQUIRED) - IF (NOT LSF_FIND_QUIETLY) - MESSAGE(STATUS "LSF not found") - ENDIF (NOT LSF_FIND_QUIETLY) - ENDIF (LSF_FIND_REQUIRED) - -ENDIF (LSF_FOUND) diff --git a/CMakeModules/FindMakeinfo.cmake b/CMakeModules/FindMakeinfo.cmake deleted file mode 100644 index 4b51d1a..0000000 --- a/CMakeModules/FindMakeinfo.cmake +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -IF (NOT 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 deleted file mode 100644 index 5f54a49..0000000 --- a/CMakeModules/FindPBS.cmake +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -IF (NOT PBS_FIND_QUIETLY) - MESSAGE(STATUS "Looking for PBS...") -ENDIF (NOT PBS_FIND_QUIETLY) - -FIND_PATH(PBS_INCLUDE_DIR pbs_ifl.h) -FIND_LIBRARY(PBS_LIBRARY NAMES pbs torque) - -IF (PBS_INCLUDE_DIR AND PBS_LIBRARY) - SET(PBS_FOUND True) -ENDIF (PBS_INCLUDE_DIR AND PBS_LIBRARY) - -IF (PBS_FOUND) - - IF (NOT PBS_FIND_QUIETLY) - MESSAGE(STATUS "Found PBS: ${PBS_LIBRARY}") - ENDIF (NOT PBS_FIND_QUIETLY) - -ELSE (PBS_FOUND) - - IF (PBS_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "PBS not found") - ELSE (PBS_FIND_REQUIRED) - IF (NOT PBS_FIND_QUIETLY) - MESSAGE(STATUS "PBS not found") - ENDIF (NOT PBS_FIND_QUIETLY) - ENDIF (PBS_FIND_REQUIRED) - -ENDIF (PBS_FOUND) diff --git a/CMakeModules/FindPython.cmake b/CMakeModules/FindPython.cmake deleted file mode 100644 index a6a3c82..0000000 --- a/CMakeModules/FindPython.cmake +++ /dev/null @@ -1,136 +0,0 @@ -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# 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(WIN32 AND NOT CMAKE_BUILD_TYPE STREQUAL Release) - FIND_PROGRAM(PYTHON_DEBUG python_d) - mark_as_advanced(PYTHON_DEBUG) -ENDIF(WIN32 AND NOT CMAKE_BUILD_TYPE STREQUAL Release) - -IF (PYTHON_DEBUG) - SET(PYTHON_EXECUTABLE ${PYTHON_DEBUG} CACHE STRING "Python interpreter") -ELSE (PYTHON_DEBUG) - IF(MSVC AND NOT CMAKE_BUILD_TYPE STREQUAL Release) - MESSAGE(STATUS "Warning! Python debug executable not found. To build Swig module, you will need to install it or compile in Release mode") - ELSE(MSVC AND NOT CMAKE_BUILD_TYPE STREQUAL Release) - FIND_PROGRAM(PYTHON_EXECUTABLE python DOC "Python interpreter") - ENDIF(MSVC AND NOT CMAKE_BUILD_TYPE STREQUAL Release) -ENDIF (PYTHON_DEBUG) - -IF (PYTHON_EXECUTABLE) - IF (NOT Python_FIND_QUIETLY) - MESSAGE(STATUS "Python executable: ${PYTHON_EXECUTABLE}") - ENDIF (NOT Python_FIND_QUIETLY) - - EXECUTE_PROCESS( - COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(sys.version[:3])" - OUTPUT_VARIABLE PYTHON_VERSION - ) - - IF (NOT Python_FIND_QUIETLY) - MESSAGE(STATUS "Python version: ${PYTHON_VERSION}") - ENDIF (NOT Python_FIND_QUIETLY) - - EXECUTE_PROCESS( - COMMAND ${PYTHON_EXECUTABLE} -c "import sys; import distutils.sysconfig; sys.stdout.write(distutils.sysconfig.get_python_inc())" - OUTPUT_VARIABLE PYTHON_DETECTED_INCLUDE_DIR - ) - - SET(PYTHON_HEADER Python.h) - FIND_PATH(PYTHON_INCLUDE_DIRS ${PYTHON_HEADER} - PATHS ${PYTHON_DETECTED_INCLUDE_DIR} - DOC "Python include directories") - - IF (NOT Python_FIND_QUIETLY) - IF (PYTHON_INCLUDE_DIRS) - MESSAGE(STATUS "Python include directories: ${PYTHON_INCLUDE_DIRS}") - ELSE (PYTHON_INCLUDE_DIRS) - MESSAGE(STATUS "Could not find Python include directories (looked for file ${PYTHON_HEADER} in directory ${PYTHON_DETECTED_INCLUDE_DIR})") - ENDIF (PYTHON_INCLUDE_DIRS) - ENDIF (NOT Python_FIND_QUIETLY) - - FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/findpythonlib.py - "import sys\n" - "import os\n" - "import distutils.sysconfig\n" - "libdir = distutils.sysconfig.get_config_var('LIBDIR')\n" - "if libdir is None:\n" - " prefix = distutils.sysconfig.get_config_var('prefix')\n" - " libdir = prefix + ';' + os.path.join(prefix, 'lib') + ';' + os.path.join(prefix, 'libs')\n" - "sys.stdout.write(libdir)" - ) - - EXECUTE_PROCESS( - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/findpythonlib.py - OUTPUT_VARIABLE PYTHON_DETECTED_LIB_DIRS - ) - - IF(WIN32) - STRING(REPLACE "." "" PYTHON_VERSION_WITHOUT_DOT ${PYTHON_VERSION}) - IF(PYTHON_DEBUG) - SET(LIB_NAME python${PYTHON_VERSION_WITHOUT_DOT}_d) - ELSE(PYTHON_DEBUG) - SET(LIB_NAME python${PYTHON_VERSION_WITHOUT_DOT}) - ENDIF(PYTHON_DEBUG) - ELSE(WIN32) - SET(LIB_NAME python${PYTHON_VERSION}) - ENDIF(WIN32) - - FIND_LIBRARY(PYTHON_LIBRARIES ${LIB_NAME} ${PYTHON_DETECTED_LIB_DIRS} DOC "Python libraries") - - IF (NOT Python_FIND_QUIETLY) - IF (PYTHON_LIBRARIES) - MESSAGE(STATUS "Python libraries: ${PYTHON_LIBRARIES}") - ELSE (PYTHON_LIBRARIES) - MESSAGE(STATUS "Could not find Python libraries (looked for library ${LIB_NAME} in directory ${PYTHON_DETECTED_LIB_DIRS})") - ENDIF (PYTHON_LIBRARIES) - ENDIF (NOT Python_FIND_QUIETLY) - -ENDIF (PYTHON_EXECUTABLE) - -IF(PYTHON_EXECUTABLE AND PYTHON_LIBRARIES AND PYTHON_INCLUDE_DIRS) - SET(Python_FOUND True) -ENDIF(PYTHON_EXECUTABLE AND PYTHON_LIBRARIES AND PYTHON_INCLUDE_DIRS) - -IF (Python_FOUND) - - IF (NOT Python_FIND_QUIETLY) - MESSAGE(STATUS "OK, working Python installation found") - ENDIF (NOT Python_FIND_QUIETLY) - -ELSE (Python_FOUND) - - IF (Python_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "No working Python installation found") - ELSE (Python_FIND_REQUIRED) - IF (NOT Python_FIND_QUIETLY) - MESSAGE(STATUS "No working Python installation found") - ENDIF (NOT Python_FIND_QUIETLY) - ENDIF (Python_FIND_REQUIRED) - -ENDIF (Python_FOUND) diff --git a/CMakeModules/FindSWIG.cmake b/CMakeModules/FindSWIG.cmake deleted file mode 100644 index 87d95a8..0000000 --- a/CMakeModules/FindSWIG.cmake +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# 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 index 83e9843..8d713b4 100644 --- a/CMakeModules/Summary.cmake +++ b/CMakeModules/Summary.cmake @@ -23,26 +23,6 @@ MESSAGE(STATUS "") MESSAGE(STATUS "**************** Summary ****************") MESSAGE(STATUS "") -IF (BUILD_LSF_INTERFACE) - IF (LSF_FOUND) - MESSAGE(STATUS "LSF ................................. Yes") - ELSE (LSF_FOUND) - MESSAGE(STATUS "LSF ........................... Not found") - ENDIF (LSF_FOUND) -ELSE (BUILD_LSF_INTERFACE) - MESSAGE(STATUS "LSF ....................... Not requested") -ENDIF (BUILD_LSF_INTERFACE) - -IF (BUILD_PBS_INTERFACE) - IF (PBS_FOUND) - MESSAGE(STATUS "PBS ................................. Yes") - ELSE (PBS_FOUND) - MESSAGE(STATUS "PBS ........................... Not found") - ENDIF (PBS_FOUND) -ELSE (BUILD_PBS_INTERFACE) - MESSAGE(STATUS "PBS ....................... Not requested") -ENDIF (BUILD_PBS_INTERFACE) - IF (BUILD_LOCAL_SUBMISSION) MESSAGE(STATUS "Local submission .................... Yes") ELSE (BUILD_LOCAL_SUBMISSION) @@ -50,21 +30,15 @@ ELSE (BUILD_LOCAL_SUBMISSION) ENDIF (BUILD_LOCAL_SUBMISSION) IF (BUILD_PYTHON_WRAPPING) - IF (Python_FOUND AND SWIG_FOUND) + IF (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND SWIG_FOUND) MESSAGE(STATUS "Python wrapping ..................... Yes") - ELSE (Python_FOUND AND SWIG_FOUND) + ELSE (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND SWIG_FOUND) MESSAGE(STATUS "Python wrapping ............... Not found") - ENDIF (Python_FOUND AND SWIG_FOUND) + ENDIF (PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND SWIG_FOUND) ELSE (BUILD_PYTHON_WRAPPING) MESSAGE(STATUS "Python wrapping ........... Not requested") ENDIF (BUILD_PYTHON_WRAPPING) -IF (Makeinfo_FOUND) - MESSAGE(STATUS "Makeinfo ............................ Yes") -ELSE (Makeinfo_FOUND) - MESSAGE(STATUS "Makeinfo ...................... Not found") -ENDIF (Makeinfo_FOUND) - MESSAGE(STATUS "") MESSAGE(STATUS "************** End Summary **************") MESSAGE(STATUS "") diff --git a/Batch_config.h.in b/config.h.in similarity index 100% rename from Batch_config.h.in rename to config.h.in diff --git a/doc/Batch.texi b/doc/Batch.texi deleted file mode 100644 index d8bc55c..0000000 --- a/doc/Batch.texi +++ /dev/null @@ -1,4892 +0,0 @@ -\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 deleted file mode 100644 index c85a28a..0000000 --- a/doc/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.texi.in ${CMAKE_CURRENT_BINARY_DIR}/version.texi) - -SET (TEXI_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Batch.texi) - -ADD_CUSTOM_TARGET(doc ALL ${MAKEINFO_EXECUTABLE} --html ${TEXI_FILE}) - -FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Batch) - -INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Batch/ DESTINATION share/Batch/doc) diff --git a/doc/version.texi.in b/doc/version.texi.in deleted file mode 100644 index ea149e8..0000000 --- a/doc/version.texi.in +++ /dev/null @@ -1,2 +0,0 @@ -@set UPDATED 23 April 2010 -@set VERSION @CPACK_PACKAGE_VERSION_MAJOR@.@CPACK_PACKAGE_VERSION_MINOR@.@CPACK_PACKAGE_VERSION_PATCH@ diff --git a/misc/CMakeLists.txt b/misc/CMakeLists.txt index c0ec92b..3266b56 100644 --- a/misc/CMakeLists.txt +++ b/misc/CMakeLists.txt @@ -21,12 +21,12 @@ # email : webmaster.salome@opencascade.com INSTALL(FILES check_libbatch.m4 - DESTINATION share/Batch/misc) + DESTINATION share/libbatch/misc) -GET_TARGET_PROPERTY(LIBBATCH_ABS_PATH Batch LOCATION) +GET_TARGET_PROPERTY(LIBBATCH_ABS_PATH batch LOCATION) GET_FILENAME_COMPONENT(LIBBATCH_REAL_NAME ${LIBBATCH_ABS_PATH} NAME) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libBatchConfig.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/libBatchConfig.cmake @ONLY) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libbatchConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/libbatchConfig.cmake @ONLY) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libBatchConfig.cmake +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libbatchConfig.cmake DESTINATION lib) diff --git a/misc/check_libbatch.m4 b/misc/check_libbatch.m4 index 9fb0f1b..bd2dd2b 100644 --- a/misc/check_libbatch.m4 +++ b/misc/check_libbatch.m4 @@ -1,35 +1,35 @@ -dnl Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +dnl Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE dnl -dnl Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +dnl Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS dnl -dnl This library is free software; you can redistribute it and/or -dnl modify it under the terms of the GNU Lesser General Public -dnl License as published by the Free Software Foundation; either -dnl version 2.1 of the License. +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License. dnl -dnl This library is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -dnl Lesser General Public License for more details. +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. dnl -dnl You should have received a copy of the GNU Lesser General Public -dnl License along with this library; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA dnl -dnl See http://www.salome-platform.org/ or -dnl email : webmaster.salome@opencascade.com +dnl See http://www.salome-platform.org/ or +dnl email : webmaster.salome@opencascade.com dnl # CHECK_LIBBATCH -# This macro can be used to find libBatch and set the associated variables in +# This macro can be used to find libbatch and set the associated variables in # a project based on autoconf. You can copy this file in your own project and # eventually modify it according to your own needs. # ---------------------------------------------------------------------------- AC_DEFUN([CHECK_LIBBATCH],[ -AC_MSG_NOTICE(Checking for libBatch library) +AC_MSG_NOTICE(Checking for libbatch library) AC_SUBST(LIBBATCH_INCLUDES) AC_SUBST(LIBBATCH_LIBS) @@ -59,27 +59,27 @@ LOCAL_LIBS="" if test "x$LIBBATCH_DIR" != "x" ; then LOCAL_INCLUDES="-I$LIBBATCH_DIR/include" if test "x$LIBBATCH_DIR" = "x/usr" ; then - LOCAL_LIBS="-lBatch" + LOCAL_LIBS="-lbatch" else - LOCAL_LIBS="-L$LIBBATCH_DIR/lib -lBatch" + LOCAL_LIBS="-L$LIBBATCH_DIR/lib -lbatch" fi else LOCAL_INCLUDES="-I/usr/include" - LOCAL_LIBS="-lBatch" + LOCAL_LIBS="-lbatch" fi -# libBatch headers +# libbatch headers CPPFLAGS_old="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $LOCAL_INCLUDES" -AC_CHECK_HEADER(Batch/Batch_BatchManager.hxx, +AC_CHECK_HEADER(libbatch/BatchManager.hxx, libbatch_ok="yes", libbatch_ok="no") CPPFLAGS="$CPPFLAGS_old" if test "x$libbatch_ok" = "xyes" ; then - # libBatch library + # libbatch library LIBS_old=$LIBS LIBS="$LIBS $LOCAL_LIBS" @@ -110,6 +110,6 @@ if test "x$libbatch_ok" = "xyes" ; then LIBBATCH_LIBS="$LOCAL_LIBS" fi -AC_MSG_RESULT(for libBatch: $libbatch_ok) +AC_MSG_RESULT(for libbatch: $libbatch_ok) ]) diff --git a/misc/libBatchConfig.cmake.in b/misc/libbatchConfig.cmake.in similarity index 95% rename from misc/libBatchConfig.cmake.in rename to misc/libbatchConfig.cmake.in index 5e457c1..3d1345a 100644 --- a/misc/libBatchConfig.cmake.in +++ b/misc/libbatchConfig.cmake.in @@ -22,7 +22,7 @@ get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) get_filename_component(LIBBATCH_ROOT_DIR "${SELF_DIR}/.." ABSOLUTE) -set(LIBBATCH_INCLUDE_DIRS "${LIBBATCH_ROOT_DIR}/include/Batch") +set(LIBBATCH_INCLUDE_DIRS "${LIBBATCH_ROOT_DIR}/include/libbatch") set(LIBBATCH_LIBRARIES "${LIBBATCH_ROOT_DIR}/lib/@LIBBATCH_REAL_NAME@") set(LIBBATCH_RUNTIME_LIBRARY_DIRS "${LIBBATCH_ROOT_DIR}/lib") set(LIBBATCH_PYTHONPATH "${LIBBATCH_ROOT_DIR}/lib/python@PYTHON_VERSION@/site-packages") diff --git a/src/CCC/Batch_BatchManager_eCCC.cxx b/src/CCC/BatchManager_CCC.cxx similarity index 62% rename from src/CCC/Batch_BatchManager_eCCC.cxx rename to src/CCC/BatchManager_CCC.cxx index 83443ee..e24c171 100644 --- a/src/CCC/Batch_BatchManager_eCCC.cxx +++ b/src/CCC/BatchManager_CCC.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * BatchManager_eCCC.cxx : emulation of CCC client for CCRT machines + * BatchManager_CCC.cxx : emulation of CCC client for CCRT machines * * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -47,33 +46,35 @@ #include #endif -#include "Batch_Constants.hxx" -#include "Batch_BatchManager_eCCC.hxx" -#include "Batch_JobInfo_eCCC.hxx" +#include +#include +#include + +#include "BatchManager_CCC.hxx" +#include "JobInfo_CCC.hxx" +#include "Log.hxx" using namespace std; namespace Batch { - BatchManager_eCCC::BatchManager_eCCC(const FactBatchManager * parent, const char * host, + BatchManager_CCC::BatchManager_CCC(const FactBatchManager * parent, const char * host, const char * username, CommunicationProtocolType protocolType, const char * mpiImpl) - : BatchManager(parent, host), - BatchManager_eClient(parent, host, username, protocolType, mpiImpl) + : BatchManager(parent, host, username, protocolType, mpiImpl) { // Nothing to do } // Destructeur - BatchManager_eCCC::~BatchManager_eCCC() + BatchManager_CCC::~BatchManager_CCC() { // Nothing to do } // Methode pour le controle des jobs : soumet un job au gestionnaire - const JobId BatchManager_eCCC::submitJob(const Job & job) + const JobId BatchManager_CCC::submitJob(const Job & job) { - int status; Parametre params = job.getParametre(); const std::string workDir = params[WORKDIR]; const string fileToExecute = params[EXECUTABLE]; @@ -82,60 +83,42 @@ namespace Batch { std::string fileNameToExecute = fileToExecute.substr(p1+1,p2-p1-1); // export input files on cluster - cerr << "Export des fichiers en entree" << endl; + LOG("Export des fichiers en entree"); exportInputFiles(job); // build batch script for job - cerr << "Construction du script de batch" << endl; + LOG("Construction du script de batch"); buildBatchScript(job); - cerr << "Script envoye" << endl; - - // define name of log file (local) - string logFile = generateTemporaryFileName("CCC-submitlog"); + LOG("Script envoye"); // define command to submit batch string subCommand = string("bash -l -c \\\"cd ") + workDir + "; ccc_msub " + fileNameToExecute + "_Batch.sh\\\""; string command = _protocol.getExecCommand(subCommand, _hostname, _username); - command += " > "; - command += logFile; command += " 2>&1"; - cerr << command.c_str() << endl; - status = system(command.c_str()); - if(status) - { - ifstream error_message(logFile.c_str()); - std::string mess; - std::string temp; - while(std::getline(error_message, temp)) - mess += temp; - error_message.close(); - throw EmulationException("Error of connection on remote host, error was: " + mess); - } + LOG(command); + + // submit job + string output; + int status = Utils::getCommandOutput(command, output); + LOG(output); + if (status != 0) throw RunTimeException("Can't submit job, error was: " + output); - // read id of submitted job in log file - ifstream idfile(logFile.c_str()); + // find id of submitted job in output + istringstream idfile(output); string sidj; idfile >> sidj; idfile >> sidj; idfile >> sidj; idfile >> sidj; - idfile.close(); if (sidj.size() == 0) - throw EmulationException("Error in the submission of the job on the remote host"); + throw RunTimeException("Error in the submission of the job on the remote host"); JobId id(this, sidj); return id; } - // Ce manager permet de faire de la reprise - const Batch::JobId - BatchManager_eCCC::addJob(const Batch::Job & job, const std::string reference) - { - return JobId(this, reference); - } - // Methode pour le controle des jobs : retire un job du gestionnaire - void BatchManager_eCCC::deleteJob(const JobId & jobid) + void BatchManager_CCC::deleteJob(const JobId & jobid) { int status; int ref; @@ -145,78 +128,44 @@ namespace Batch { // define command to delete batch string subCommand = string("bash -l -c \\\"ccc_mdel ") + iss.str() + string("\\\""); string command = _protocol.getExecCommand(subCommand, _hostname, _username); - cerr << command.c_str() << endl; + LOG(command); 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_eCCC::holdJob(const JobId & jobid) - { - throw EmulationException("Not yet implemented"); - } - - // Methode pour le controle des jobs : relache un job suspendu - void BatchManager_eCCC::releaseJob(const JobId & jobid) - { - throw EmulationException("Not yet implemented"); - } - - - // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager_eCCC::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env) - { - throw EmulationException("Not yet implemented"); - } + throw RunTimeException("Error of connection on remote host"); - // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager_eCCC::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_eCCC::alterJob(const JobId & jobid, const Environnement & env) - { - alterJob(jobid, Parametre(), env); + LOG("jobId = " << ref << "killed"); } // Methode pour le controle des jobs : renvoie l'etat du job - JobInfo BatchManager_eCCC::queryJob(const JobId & jobid) + JobInfo BatchManager_CCC::queryJob(const JobId & jobid) { int id; istringstream iss(jobid.getReference()); iss >> id; - // define name of log file (local) - string logFile = generateTemporaryFileName(string("CCC-querylog-id") + jobid.getReference()); - // define command to query batch string subCommand = string("bash -l -c \\\"bjobs ") + iss.str() + string("\\\""); string command = _protocol.getExecCommand(subCommand, _hostname, _username); - command += " > "; - command += logFile; - cerr << command.c_str() << endl; - int status = system(command.c_str()); + LOG(command); + + string output; + int status = Utils::getCommandOutput(command, output); if (status) - throw EmulationException("Error of connection on remote host"); + throw RunTimeException("Error of connection on remote host"); - JobInfo_eCCC ji = JobInfo_eCCC(id,logFile); + JobInfo_CCC ji = JobInfo_CCC(id, output); return ji; } // Methode pour le controle des jobs : teste si un job est present en machine - bool BatchManager_eCCC::isRunning(const JobId & jobid) + bool BatchManager_CCC::isRunning(const JobId & jobid) { - throw EmulationException("Not yet implemented"); + throw NotYetImplementedException("BatchManager_CCC::isRunning"); } - void BatchManager_eCCC::buildBatchScript(const Job & job) + void BatchManager_CCC::buildBatchScript(const Job & job) { #ifndef WIN32 //TODO: need for porting on Windows Parametre params = job.getParametre(); @@ -233,11 +182,11 @@ namespace Batch { if (params.find(WORKDIR) != params.end()) workDir = params[WORKDIR].str(); else - throw EmulationException("params[WORKDIR] is not defined ! Please defined it, cannot submit this job"); + throw RunTimeException("params[WORKDIR] is not defined ! Please defined it, cannot submit this job"); if (params.find(EXECUTABLE) != params.end()) fileToExecute = params[EXECUTABLE].str(); else - throw EmulationException("params[EXECUTABLE] is not defined ! Please defined it, cannot submit this job"); + throw RunTimeException("params[EXECUTABLE] is not defined ! Please defined it, cannot submit this job"); // Optional parameters if (params.find(NBPROC) != params.end()) @@ -256,7 +205,7 @@ namespace Batch { // Create batch submit file ofstream tempOutputFile; - std::string TmpFileName = createAndOpenTemporaryFile("LSF-script", tempOutputFile); + std::string TmpFileName = Utils::createAndOpenTemporaryFile("LSF-script", tempOutputFile); tempOutputFile << "#!/bin/bash" << endl ; if (queue != "") @@ -307,35 +256,36 @@ namespace Batch { tempOutputFile.flush(); tempOutputFile.close(); - BATCH_CHMOD(TmpFileName.c_str(), 0x1ED); - cerr << "Batch script file generated is: " << TmpFileName.c_str() << endl; + Utils::chmod(TmpFileName.c_str(), 0x1ED); + LOG("Batch script file generated is: " << TmpFileName.c_str()); int status = _protocol.copyFile(TmpFileName, "", "", workDir + "/" + rootNameToExecute + "_Batch.sh", _hostname, _username); if (status) - throw EmulationException("Error of connection on remote host"); + throw RunTimeException("Error of connection on remote host"); #endif } - std::string BatchManager_eCCC::getHomeDir(std::string tmpdir) + std::string BatchManager_CCC::getHomeDir(std::string tmpdir) { std::string home; - std::string filelogtemp = generateTemporaryFileName("gethomedir"); string subCommand = string("echo "); subCommand += tmpdir; - string command = _protocol.getExecCommand(subCommand, _hostname, _username) + " > " + filelogtemp; - cerr << command.c_str() << endl; - int status = system(command.c_str()); + string command = _protocol.getExecCommand(subCommand, _hostname, _username); + LOG(command); + + string output; + int status = Utils::getCommandOutput(command, output); + if (status) - throw EmulationException("Error of launching home command on remote host"); + throw RunTimeException("Error of launching home command on remote host"); - std::ifstream file_home(filelogtemp.c_str()); + std::istringstream file_home(output); std::getline(file_home, home); - file_home.close(); return home; } diff --git a/src/CCC/Batch_BatchManager_eCCC.hxx b/src/CCC/BatchManager_CCC.hxx similarity index 71% rename from src/CCC/Batch_BatchManager_eCCC.hxx rename to src/CCC/BatchManager_CCC.hxx index de93827..67a5228 100644 --- a/src/CCC/Batch_BatchManager_eCCC.hxx +++ b/src/CCC/BatchManager_CCC.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * BatchManager_eCCC.hxx : emulation of CCC client for CCRT machines + * BatchManager_CCC.hxx : emulation of CCC client for CCRT machines * * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr @@ -32,22 +32,22 @@ #ifndef _BATCHMANAGER_ECCC_H_ #define _BATCHMANAGER_ECCC_H_ -#include "Batch_Defines.hxx" -#include "Batch_JobId.hxx" -#include "Batch_JobInfo.hxx" -#include "Batch_FactBatchManager.hxx" -#include "Batch_BatchManager_eClient.hxx" +#include "Defines.hxx" +#include "JobId.hxx" +#include "JobInfo.hxx" +#include "FactBatchManager.hxx" +#include "BatchManager.hxx" namespace Batch { - class BATCH_EXPORT BatchManager_eCCC : public BatchManager_eClient + class BATCH_EXPORT BatchManager_CCC : public BatchManager { public: // Constructeur et destructeur - BatchManager_eCCC(const FactBatchManager * parent, const char * host="localhost", + BatchManager_CCC(const FactBatchManager * parent, const char * host="localhost", const char * username="", CommunicationProtocolType protocolType = SSH, const char * mpiImpl="nompi"); // connexion a la machine host - virtual ~BatchManager_eCCC(); + virtual ~BatchManager_CCC(); // Recupere le nom du serveur par defaut // static string BatchManager_LSF::getDefaultServer(); @@ -55,19 +55,12 @@ namespace Batch { // Methodes pour le controle des jobs virtual const JobId submitJob(const Job & job); // soumet un job au gestionnaire virtual void deleteJob(const JobId & jobid); // retire un job du gestionnaire - virtual void holdJob(const JobId & jobid); // suspend un job en file d'attente - virtual void releaseJob(const JobId & jobid); // relache un job suspendu - virtual void alterJob(const JobId & jobid, const Parametre & param, const Environnement & env); // modifie un job en file d'attente - virtual void alterJob(const JobId & jobid, const Parametre & param); // modifie un job en file d'attente - virtual void alterJob(const JobId & jobid, const Environnement & env); // modifie un job en file d'attente virtual JobInfo queryJob(const JobId & jobid); // renvoie l'etat du job virtual bool isRunning(const JobId & jobid); // teste si un job est present en machine virtual void setParametre(const JobId & jobid, const Parametre & param) { return alterJob(jobid, param); } // modifie un job en file d'attente virtual void setEnvironnement(const JobId & jobid, const Environnement & env) { return alterJob(jobid, env); } // modifie un job en file d'attente - virtual const Batch::JobId addJob(const Batch::Job & job, const std::string reference); // ajoute un nouveau job sans le soumettre - protected: void buildBatchScript(const Job & job); std::string getWallTime(const long edt); diff --git a/src/CCC/Batch_FactBatchManager_eCCC.cxx b/src/CCC/Batch_FactBatchManager_eCCC.cxx deleted file mode 100644 index 080d89f..0000000 --- a/src/CCC/Batch_FactBatchManager_eCCC.cxx +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * FactBatchManager_eCCC.cxx : - * - * Auteur : Bernard SECHER - CEA DEN - * Date : Avril 2010 - * Projet : PAL Salome - * - */ - -#include "Batch_BatchManager_eCCC.hxx" -#include "Batch_FactBatchManager_eCCC.hxx" - -namespace Batch { - - static FactBatchManager_eCCC sFBM_eCCC; - - // Constructeur - FactBatchManager_eCCC::FactBatchManager_eCCC() : FactBatchManager_eClient("eCCC") - { - // Nothing to do - } - - // Destructeur - FactBatchManager_eCCC::~FactBatchManager_eCCC() - { - // Nothing to do - } - - // Functor - BatchManager * FactBatchManager_eCCC::operator() (const char * hostname) const - { - // MESSAGE("Building new BatchManager_CCC on host '" << hostname << "'"); - return new BatchManager_eCCC(this, hostname); - } - - BatchManager_eClient * FactBatchManager_eCCC::operator() (const char * hostname, - const char * username, - CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node) const - { - // MESSAGE("Building new BatchManager_CCC on host '" << hostname << "'"); - return new BatchManager_eCCC(this, hostname, username, protocolType, mpiImpl); - } - -} diff --git a/src/CCC/Batch_FactBatchManager_eCCC.hxx b/src/CCC/Batch_FactBatchManager_eCCC.hxx deleted file mode 100644 index 9070abe..0000000 --- a/src/CCC/Batch_FactBatchManager_eCCC.hxx +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * FactBatchManager_eCCC.hxx : - * - * Auteur : Bernard SECHER : CEA DEN - * Date : Avril 2010 - * Projet : PAL Salome - * - */ - -#ifndef _FACTBATCHMANAGER_eCCC_H_ -#define _FACTBATCHMANAGER_eCCC_H_ - -#include "Batch_Defines.hxx" -#include "Batch_BatchManager_eClient.hxx" -#include "Batch_FactBatchManager_eClient.hxx" - -namespace Batch { - - class BATCH_EXPORT FactBatchManager_eCCC : public FactBatchManager_eClient - { - public: - // Constructeur et destructeur - FactBatchManager_eCCC(); - virtual ~FactBatchManager_eCCC(); - - virtual BatchManager * operator() (const char * hostname) const; - virtual BatchManager_eClient * operator() (const char * hostname, - const char * username, - CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node = 1) const; - - protected: - - private: - - }; - -} - -#endif diff --git a/src/CCC/CMakeLists.txt b/src/CCC/CMakeLists.txt index 272eadb..55c1e27 100644 --- a/src/CCC/CMakeLists.txt +++ b/src/CCC/CMakeLists.txt @@ -20,9 +20,9 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -SET(CLASS_LIST CCC/Batch_BatchManager_eCCC - CCC/Batch_FactBatchManager_eCCC - CCC/Batch_JobInfo_eCCC +SET(CLASS_LIST CCC/BatchManager_CCC + CCC/FactBatchManager_CCC + CCC/JobInfo_CCC ) APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST}) diff --git a/src/Core/Batch_FactBatchManager_eClient.cxx b/src/CCC/FactBatchManager_CCC.cxx similarity index 58% rename from src/Core/Batch_FactBatchManager_eClient.cxx rename to src/CCC/FactBatchManager_CCC.cxx index 69a571c..a065daa 100644 --- a/src/Core/Batch_FactBatchManager_eClient.cxx +++ b/src/CCC/FactBatchManager_CCC.cxx @@ -20,31 +20,40 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * FactBatchManager_eClient.cxx : emulation of client + * FactBatchManager_CCC.cxx : * * Auteur : Bernard SECHER - CEA DEN - * Mail : mailto:bernard.secher@cea.fr - * Date : Thu Apr 24 10:17:22 2008 - * Projet : PAL Salome + * Date : Avril 2010 + * Projet : PAL Salome * */ -#include -#include -#include "Batch_FactBatchManager_eClient.hxx" -using namespace std; +#include "BatchManager_CCC.hxx" +#include "FactBatchManager_CCC.hxx" namespace Batch { + static FactBatchManager_CCC sFBM_CCC; + // Constructeur - FactBatchManager_eClient::FactBatchManager_eClient(const string & _t) : FactBatchManager(_t) + FactBatchManager_CCC::FactBatchManager_CCC() : FactBatchManager("CCC") { + // Nothing to do } // Destructeur - FactBatchManager_eClient::~FactBatchManager_eClient() + FactBatchManager_CCC::~FactBatchManager_CCC() { // Nothing to do } + BatchManager * FactBatchManager_CCC::operator() (const char * hostname, + const char * username, + CommunicationProtocolType protocolType, + const char * mpiImpl) const + { + // MESSAGE("Building new BatchManager_CCC on host '" << hostname << "'"); + return new BatchManager_CCC(this, hostname, username, protocolType, mpiImpl); + } + } diff --git a/src/CCC/FactBatchManager_CCC.hxx b/src/CCC/FactBatchManager_CCC.hxx new file mode 100644 index 0000000..dafabae --- /dev/null +++ b/src/CCC/FactBatchManager_CCC.hxx @@ -0,0 +1,55 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +/* + * FactBatchManager_CCC.hxx : + * + * Auteur : Bernard SECHER : CEA DEN + * Date : Avril 2010 + * Projet : PAL Salome + * + */ + +#ifndef _FACTBATCHMANAGER_CCC_H_ +#define _FACTBATCHMANAGER_CCC_H_ + +#include "Defines.hxx" +#include "BatchManager.hxx" +#include "FactBatchManager.hxx" + +namespace Batch { + + class BATCH_EXPORT FactBatchManager_CCC : public FactBatchManager + { + public: + // Constructeur et destructeur + FactBatchManager_CCC(); + virtual ~FactBatchManager_CCC(); + + virtual BatchManager * operator() (const char * hostname, + const char * username, + CommunicationProtocolType protocolType, + const char * mpiImpl) const; + }; + +} + +#endif diff --git a/src/CCC/Batch_JobInfo_eCCC.cxx b/src/CCC/JobInfo_CCC.cxx similarity index 80% rename from src/CCC/Batch_JobInfo_eCCC.cxx rename to src/CCC/JobInfo_CCC.cxx index ff56a35..510d967 100644 --- a/src/CCC/Batch_JobInfo_eCCC.cxx +++ b/src/CCC/JobInfo_CCC.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * JobInfo_eCCC.cxx : emulation of CCC client for CCRT machines + * JobInfo_CCC.cxx : emulation of CCC client for CCRT machines * * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr @@ -31,15 +31,13 @@ #include #include -#include #include -#include "Batch_Constants.hxx" -#include "Batch_Parametre.hxx" -#include "Batch_Environnement.hxx" -#include "Batch_RunTimeException.hxx" -#include "Batch_APIInternalFailureException.hxx" -#include "Batch_JobInfo_eCCC.hxx" +#include "Constants.hxx" +#include "Parametre.hxx" +#include "Environnement.hxx" +#include "JobInfo_CCC.hxx" +#include "Log.hxx" using namespace std; @@ -48,16 +46,16 @@ namespace Batch { // Constructeurs - JobInfo_eCCC::JobInfo_eCCC(int id, string logFile) : JobInfo() + JobInfo_CCC::JobInfo_CCC(int id, string output) : JobInfo() { - // On remplit les membres _param et _env + // On remplit les membres _param et _nv 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); + istringstream fp(output); fp.getline(line,80,'\n'); string sjobid, username, status; @@ -84,7 +82,7 @@ namespace Batch { } else if (status == "ZOMBI") { // Zombie _param[STATE] = FAILED; } else { - cerr << "Unknown job state code: " << status << endl; + LOG("Unknown job state code: " << status); } if( status.find("RUN") != string::npos) @@ -93,20 +91,20 @@ namespace Batch { } // Teste si un job est present en machine - bool JobInfo_eCCC::isRunning() const + bool JobInfo_CCC::isRunning() const { return _running; } // Destructeur - JobInfo_eCCC::~JobInfo_eCCC() + JobInfo_CCC::~JobInfo_CCC() { // Nothing to do } // Convertit une date HH:MM:SS en secondes - long JobInfo_eCCC::HMStoLong(const string & s) + long JobInfo_CCC::HMStoLong(const string & s) { long hour, min, sec; @@ -115,10 +113,10 @@ namespace Batch { } // Methode pour l'interfacage avec Python (SWIG) : affichage en Python - string JobInfo_eCCC::__str__() const + string JobInfo_CCC::__str__() const { ostringstream sst; - sst << " namespace Batch { - class JobInfo_eCCC : public JobInfo + class JobInfo_CCC : public JobInfo { public: // Constructeurs et destructeur - JobInfo_eCCC() : _running(false) {}; - JobInfo_eCCC(int id,std::string logFile); - virtual ~JobInfo_eCCC(); + JobInfo_CCC() : _running(false) {}; + JobInfo_CCC(int id,std::string output); + virtual ~JobInfo_CCC(); // Constructeur par recopie - JobInfo_eCCC(const JobInfo_eCCC & jinfo) : JobInfo(jinfo) {}; + JobInfo_CCC(const JobInfo_CCC & jinfo) : JobInfo(jinfo) {}; // Teste si un job est present en machine virtual bool isRunning() const; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e88e974..69ccb0e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -20,22 +20,18 @@ # 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) + LIST(APPEND SRC_FILES ${CLASS}.cxx) ENDFOREACH(CLASS ${ARGV}) + SET(SRC_FILES ${SRC_FILES} PARENT_SCOPE) ENDMACRO(APPEND_CLASSES_TO_SRC_FILES) MACRO(APPEND_CLASSES_TO_HDR_FILES) FOREACH(CLASS ${ARGV}) - APPEND_TO_GLOBAL_VAR(HDR_FILES_BUILD ${CLASS}.hxx) + LIST(APPEND HDR_FILES ${CLASS}.hxx) ENDFOREACH(CLASS ${ARGV}) + SET(HDR_FILES ${HDR_FILES} PARENT_SCOPE) ENDMACRO(APPEND_CLASSES_TO_HDR_FILES) IF (MSVC) @@ -54,7 +50,6 @@ add_subdirectory (CCC) add_subdirectory (LSF) add_subdirectory (PBS) add_subdirectory (SGE) -add_subdirectory (SSH) add_subdirectory (LoadLeveler) add_subdirectory (Slurm) @@ -63,40 +58,22 @@ IF (NOT WIN32) add_subdirectory (Vishnu) ENDIF (NOT WIN32) -# 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}) +add_library(batch SHARED ${SRC_FILES}) include_directories(${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/Core) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Local) -target_link_libraries(Batch ${PTHREAD_LIBRARY}) +target_link_libraries(batch ${PTHREAD_LIBRARY}) IF (WIN32) - target_link_libraries(Batch ws2_32) + target_link_libraries(batch ws2_32) ENDIF (WIN32) # 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) +INSTALL(TARGETS batch DESTINATION lib) +INSTALL(FILES ${HDR_FILES} DESTINATION include/libbatch) -IF (BUILD_PYTHON_WRAPPING AND Python_FOUND AND SWIG_FOUND) +IF (BUILD_PYTHON_WRAPPING AND PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND SWIG_FOUND) add_subdirectory (Python) -ENDIF (BUILD_PYTHON_WRAPPING AND Python_FOUND AND SWIG_FOUND) +ENDIF (BUILD_PYTHON_WRAPPING AND PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND AND SWIG_FOUND) diff --git a/src/Core/Batch_APIInternalFailureException.cxx b/src/Core/APIInternalFailureException.cxx similarity index 96% rename from src/Core/Batch_APIInternalFailureException.cxx rename to src/Core/APIInternalFailureException.cxx index 515b554..5170a7c 100644 --- a/src/Core/Batch_APIInternalFailureException.cxx +++ b/src/Core/APIInternalFailureException.cxx @@ -29,7 +29,7 @@ * */ -#include "Batch_APIInternalFailureException.hxx" +#include "APIInternalFailureException.hxx" using namespace std; namespace Batch { diff --git a/src/Core/Batch_APIInternalFailureException.hxx b/src/Core/APIInternalFailureException.hxx similarity index 93% rename from src/Core/Batch_APIInternalFailureException.hxx rename to src/Core/APIInternalFailureException.hxx index c1a7dd6..2e1a6d8 100644 --- a/src/Core/Batch_APIInternalFailureException.hxx +++ b/src/Core/APIInternalFailureException.hxx @@ -32,10 +32,10 @@ #ifndef _APIINTERNALFAILUREEXCEPTION_H_ #define _APIINTERNALFAILUREEXCEPTION_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" -#include "Batch_GenericException.hxx" -#include "Batch_GenericException.hxx" +#include "GenericException.hxx" +#include "GenericException.hxx" namespace Batch { diff --git a/src/Core/BatchManager.cxx b/src/Core/BatchManager.cxx new file mode 100644 index 0000000..7ee7a56 --- /dev/null +++ b/src/Core/BatchManager.cxx @@ -0,0 +1,326 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +/* + * BatchManager.cxx : + * + * Auteur : Ivan DUTKA-MALEN - EDF R&D + * Date : Septembre 2003 + * Projet : SALOME 2 + * + */ + +#include +#include +#include + +#include "Constants.hxx" +#include "Job.hxx" +#include "JobId.hxx" +#include "JobInfo.hxx" +#include "FactBatchManager.hxx" +#include "BatchManager.hxx" +#include "Utils.hxx" +#include "NotYetImplementedException.hxx" +#include "Log.hxx" + +using namespace std; + +namespace Batch { + + BatchManager::BatchManager(const Batch::FactBatchManager * parent, const char* host, + const char * username, + CommunicationProtocolType protocolType, const char* mpiImpl) + : _hostname(host), jobid_map(), _type(parent->getType()), + _protocol(CommunicationProtocol::getInstance(protocolType)), + _username(username), _mpiImpl(FactoryMpiImpl(mpiImpl)) + { + } + + + // Destructeur + BatchManager::~BatchManager() + { + delete _mpiImpl; + } + + string BatchManager::__repr__() const + { + ostringstream oss; + oss << ""; + return oss.str(); + } + + // Recupere le l'identifiant d'un job deja soumis au BatchManager + 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) + { + throw NotYetImplementedException("Method submitJob not implemented by Batch Manager \"" + _type + "\""); + } + + // Methode pour le controle des jobs : retire un job du gestionnaire + void BatchManager::deleteJob(const JobId & jobid) + { + throw NotYetImplementedException("Method deleteJob not implemented by Batch Manager \"" + _type + "\""); + } + + // Methode pour le controle des jobs : suspend un job en file d'attente + void BatchManager::holdJob(const JobId & jobid) + { + throw NotYetImplementedException("Method holdJob not implemented by Batch Manager \"" + _type + "\""); + } + + // Methode pour le controle des jobs : relache un job suspendu + void BatchManager::releaseJob(const JobId & jobid) + { + throw NotYetImplementedException("Method releaseJob not implemented by Batch Manager \"" + _type + "\""); + } + + // 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) + { + throw NotYetImplementedException("Method alterJob not implemented by Batch Manager \"" + _type + "\""); + } + + // Methode pour le controle des jobs : modifie un job en file d'attente + void BatchManager::alterJob(const JobId & jobid, const Parametre & param) + { + throw NotYetImplementedException("Method alterJob not implemented by Batch Manager \"" + _type + "\""); + } + + // Methode pour le controle des jobs : modifie un job en file d'attente + void BatchManager::alterJob(const JobId & jobid, const Environnement & env) + { + throw NotYetImplementedException("Method alterJob not implemented by Batch Manager \"" + _type + "\""); + } + + // Methode pour le controle des jobs : renvoie l'etat du job + JobInfo BatchManager::queryJob(const JobId & jobid) + { + throw NotYetImplementedException("Method queryJob not implemented by Batch Manager \"" + _type + "\""); + } + + const JobId BatchManager::addJob(const Job & job, const string & reference) + { + return JobId(this, reference); + } + + //! Wait for the end of a job + /*! + * This method is a simple way to wait for a job to end. It will query the job state at + * increasing intervals and return when the job is finished (whether successfully or not) or + * when the timeout is reached. This method is not intended to be generic. In many cases you + * will have to write your own loop to wait for the end of a job. + * \param jobid ID of the job to wait for. + * \param timeout Maximum time to wait in seconds. If -1 (default), wait indefinitely. + * \param initSleepTime Initial time in seconds between two queries for the job state (default is 1). + * \param maxSleepTime Maximum time in seconds between two queries for the job state (default is 600). + * \return The job state as returned by the last query. + */ + string BatchManager::waitForJobEnd(const JobId & jobid, long timeout, + long initSleepTime, long maxSleepTime) + { + int time = 0; + int sleeptime = initSleepTime; + bool testTimeout = (timeout > -1); + bool timeoutReached = (testTimeout && time >= timeout); + JobInfo jinfo = jobid.queryJob(); + string state = jinfo.getParametre()[STATE].str(); + while (!timeoutReached && state != FINISHED && state != FAILED) { + LOG("State is \"" << state << "\"" << ", sleeping " << sleeptime << "s..."); + Utils::sleep(sleeptime); + time += sleeptime; + timeoutReached = (testTimeout && time >= timeout); + sleeptime *= 2; + if (testTimeout && sleeptime > timeout - time) + sleeptime = timeout - time; + if (sleeptime > maxSleepTime) + sleeptime = maxSleepTime; + jinfo = jobid.queryJob(); + state = jinfo.getParametre()[STATE].str(); + } + LOG("State is \"" << state << "\""); + return state; + } + + + void BatchManager::exportInputFiles(const Job& job) + { + int status; + Parametre params = job.getParametre(); + const Versatile & V = params[INFILE]; + Versatile::const_iterator Vit; + + // Create remote directories + string logdir = string(params[WORKDIR]) + "/logs"; + status = _protocol.makeDirectory(logdir, _hostname, _username); + if (status) { + std::ostringstream oss; + oss << "Cannot create directory " << logdir << " on host " << _hostname; + oss << ". Return status is " << status; + throw RunTimeException(oss.str()); + } + + // Copy the file to execute into the remote working directory + string executeFile = params[EXECUTABLE]; + if (executeFile.size() != 0) { + status = _protocol.copyFile(executeFile, "", "", + params[WORKDIR], _hostname, _username); + if (status) { + std::ostringstream oss; + oss << "Cannot copy file " << executeFile << " on host " << _hostname; + oss << ". Return status is " << status; + throw RunTimeException(oss.str()); + } + +#ifdef WIN32 + if (_protocol.getType() != SH) { + // On Windows, we make the remote file executable afterward because + // pscp does not preserve access permissions on files + + string remoteExec = string(params[EXECUTABLE]); + remoteExec = remoteExec.substr(remoteExec.rfind("/") + 1, remoteExec.length()); + remoteExec = string(params[WORKDIR]) + "/" + remoteExec; + + string subCommand = string("chmod u+x ") + remoteExec; + string command = _protocol.getExecCommand(subCommand, _hostname, _username); + LOG(command); + status = system(command.c_str()); + if (status) { + std::ostringstream oss; + oss << "Cannot change permissions of file " << remoteExec << " on host " << _hostname; + oss << ". Return status is " << status; + throw RunTimeException(oss.str()); + } + } +#endif + } + + // Copy input files into the remote working directory + for (Vit=V.begin() ; Vit!=V.end() ; Vit++) { + CoupleType cpt = *static_cast< CoupleType * >(*Vit); + Couple inputFile = cpt; + string remotePath = inputFile.getRemote(); + if (!Utils::isAbsolutePath(remotePath)) { + remotePath = params[WORKDIR].str() + "/" + remotePath; + } + status = _protocol.copyFile(inputFile.getLocal(), "", "", + remotePath, _hostname, _username); + if (status) { + std::ostringstream oss; + oss << "Cannot copy file " << inputFile.getLocal() << " on host " << _hostname; + oss << ". Return status is " << status; + throw RunTimeException(oss.str()); + } + } + + } + + void BatchManager::importOutputFiles( const Job & job, const string directory ) + { + Parametre params = job.getParametre(); + const Versatile & V = params[OUTFILE]; + Versatile::const_iterator Vit; + + // Create local result directory + int status = CommunicationProtocol::getInstance(SH).makeDirectory(directory, "", ""); + if (status) + LOG("Directory creation failed. Status is: " << status); + + for(Vit=V.begin(); Vit!=V.end(); Vit++) { + CoupleType cpt = *static_cast< CoupleType * >(*Vit); + Couple outputFile = cpt; + string remotePath = outputFile.getRemote(); + if (!Utils::isAbsolutePath(remotePath)) { + remotePath = params[WORKDIR].str() + "/" + remotePath; + } + string localPath = outputFile.getLocal(); + if (!Utils::isAbsolutePath(localPath)) { + localPath = directory + "/" + localPath; + } + status = _protocol.copyFile(remotePath, _hostname, _username, + localPath, "", ""); + if (status) + LOG("Copy command failed. Status is: " << status); + } + + // Copy logs + status = _protocol.copyFile(string(params[WORKDIR]) + string("/logs"), _hostname, _username, + directory, "", ""); + if (status) + LOG("Copy logs directory failed. Status is: " << status); + } + + bool BatchManager::importDumpStateFile( const Job & job, const string directory ) + { + Parametre params = job.getParametre(); + + // Create local result directory + int status = CommunicationProtocol::getInstance(SH).makeDirectory(directory, "", ""); + if (status) + LOG("Directory creation failed. Status is: " << status); + + bool ret = true; + status = _protocol.copyFile(string(params[WORKDIR]) + string("/dumpState*.xml"), _hostname, _username, + directory, "", ""); + if (status) { + LOG("Copy command failed. Status is: " << status); + ret = false; + } + return ret; + } + + MpiImpl *BatchManager::FactoryMpiImpl(string mpiImpl) + { + 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 == "ompi") + return new MpiImpl_OMPI(); + else if(mpiImpl == "slurm") + return new MpiImpl_SLURM(); + else if(mpiImpl == "prun") + return new MpiImpl_PRUN(); + else if(mpiImpl == "nompi") + return NULL; + else{ + ostringstream oss; + oss << mpiImpl << " : not yet implemented"; + throw RunTimeException(oss.str().c_str()); + } + } + + const CommunicationProtocol & BatchManager::getProtocol() const + { + return _protocol; + } + +} diff --git a/src/Core/Batch_BatchManager.hxx b/src/Core/BatchManager.hxx similarity index 59% rename from src/Core/Batch_BatchManager.hxx rename to src/Core/BatchManager.hxx index 1deb9ff..c5ad00d 100644 --- a/src/Core/Batch_BatchManager.hxx +++ b/src/Core/BatchManager.hxx @@ -31,14 +31,16 @@ #ifndef _BATCHMANAGER_H_ #define _BATCHMANAGER_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" #include #include -#include "Batch_Job.hxx" -#include "Batch_JobId.hxx" -#include "Batch_JobInfo.hxx" -#include "Batch_InvalidArgumentException.hxx" +#include "Job.hxx" +#include "JobId.hxx" +#include "JobInfo.hxx" +#include "InvalidArgumentException.hxx" +#include "CommunicationProtocol.hxx" +#include "MpiImpl.hxx" namespace Batch { @@ -51,8 +53,9 @@ namespace Batch { { 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 + BatchManager(const Batch::FactBatchManager * parent, const char * host = "localhost", + const char * username = "", + CommunicationProtocolType protocolType = SSH, const char * mpiImpl = "nompi"); virtual ~BatchManager(); virtual std::string __repr__() const; @@ -60,24 +63,35 @@ namespace Batch { //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 - virtual const Batch::JobId addJob(const Batch::Job & job, const std::string reference) = 0; // ajoute un nouveau job sans le soumettre + // Methodes pour le controle des jobs : doivent etre implementees dans les classes filles + virtual const Batch::JobId submitJob(const Batch::Job & job); // soumet un job au gestionnaire + virtual void deleteJob(const Batch::JobId & jobid); // retire un job du gestionnaire + virtual void holdJob(const Batch::JobId & jobid); // suspend un job en file d'attente + virtual void releaseJob(const Batch::JobId & jobid); // relache un job suspendu + virtual void alterJob(const Batch::JobId & jobid, const Batch::Parametre & param, const Batch::Environnement & env); // modifie un job en file d'attente + virtual void alterJob(const Batch::JobId & jobid, const Batch::Parametre & param); // modifie un job en file d'attente + virtual void alterJob(const Batch::JobId & jobid, const Batch::Environnement & env); // modifie un job en file d'attente + virtual Batch::JobInfo queryJob(const Batch::JobId & jobid); // renvoie l'etat du job + virtual const Batch::JobId addJob(const Batch::Job & job, const std::string & reference); // ajoute un nouveau job sans le soumettre virtual std::string waitForJobEnd(const Batch::JobId & jobid, long timeout = -1, long initSleepTime = 1, long maxSleepTime = 600); + virtual void importOutputFiles( const Job & job, const std::string directory ); + bool importDumpStateFile( const Job & job, const std::string directory ); + + // Get the underlying communication protocol + const CommunicationProtocol & getProtocol() const; 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; + const std::string & _type; + const CommunicationProtocol & _protocol; // protocol to access _hostname + const std::string _username; // username to access _hostname + MpiImpl *_mpiImpl; // Mpi implementation to launch executable in batch script + + MpiImpl* FactoryMpiImpl(std::string mpiImpl); + void exportInputFiles(const Job & job); private: diff --git a/src/Core/Batch_BatchManagerCatalog.cxx b/src/Core/BatchManagerCatalog.cxx similarity index 97% rename from src/Core/Batch_BatchManagerCatalog.cxx rename to src/Core/BatchManagerCatalog.cxx index 8597688..44d2844 100644 --- a/src/Core/Batch_BatchManagerCatalog.cxx +++ b/src/Core/BatchManagerCatalog.cxx @@ -32,8 +32,8 @@ #include #include #include -#include "Batch_BatchManagerCatalog.hxx" -#include "Batch_FactBatchManager.hxx" +#include "BatchManagerCatalog.hxx" +#include "FactBatchManager.hxx" using namespace std; namespace Batch { diff --git a/src/Core/Batch_BatchManagerCatalog.hxx b/src/Core/BatchManagerCatalog.hxx similarity index 98% rename from src/Core/Batch_BatchManagerCatalog.hxx rename to src/Core/BatchManagerCatalog.hxx index dad4388..a26a64e 100644 --- a/src/Core/Batch_BatchManagerCatalog.hxx +++ b/src/Core/BatchManagerCatalog.hxx @@ -32,7 +32,7 @@ #ifndef _CATALOG_H_ #define _CATALOG_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" #include #include diff --git a/src/Core/Batch_BatchManager.cxx b/src/Core/Batch_BatchManager.cxx deleted file mode 100644 index 3d0b8d9..0000000 --- a/src/Core/Batch_BatchManager.cxx +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * BatchManager.cxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Date : Septembre 2003 - * Projet : SALOME 2 - * - */ - -#include -#include -#include -#ifdef WIN32 -# include -#else -#include -# include -#endif - -#include "Batch_Constants.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" - -#ifdef WIN32 -#define sleep(seconds) Sleep((seconds)*1000) -#endif - -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) - { - /* -#ifdef WIN32 - WSADATA wsaData; - WSAStartup(MAKEWORD(2, 2), &wsaData); // Initialize Winsock -#endif - - // On verifie que le hostname est correct - struct hostent* res = gethostbyname(_hostname.c_str()); - -#ifdef WIN32 - WSACleanup(); // Finalize Winsock -#endif - - if (!res) { // 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(); -// } - - //! Wait for the end of a job - /*! - * This method is a simple way to wait for a job to end. It will query the job state at - * increasing intervals and return when the job is finished (whether successfully or not) or - * when the timeout is reached. This method is not intended to be generic. In many cases you - * will have to write your own loop to wait for the end of a job. - * \param jobid ID of the job to wait for. - * \param timeout Maximum time to wait in seconds. If -1 (default), wait indefinitely. - * \param initSleepTime Initial time in seconds between two queries for the job state (default is 1). - * \param maxSleepTime Maximum time in seconds between two queries for the job state (default is 600). - * \return The job state as returned by the last query. - */ - string BatchManager::waitForJobEnd(const JobId & jobid, long timeout, - long initSleepTime, long maxSleepTime) - { - int time = 0; - int sleeptime = initSleepTime; - bool testTimeout = (timeout > -1); - bool timeoutReached = (testTimeout && time >= timeout); - JobInfo jinfo = jobid.queryJob(); - string state = jinfo.getParametre()[STATE].str(); - cout << "State is \"" << state << "\""; - while (!timeoutReached && state != FINISHED && state != FAILED) { - cout << ", sleeping " << sleeptime << "s..." << endl; - sleep(sleeptime); - time += sleeptime; - timeoutReached = (testTimeout && time >= timeout); - sleeptime *= 2; - if (testTimeout && sleeptime > timeout - time) - sleeptime = timeout - time; - if (sleeptime > maxSleepTime) - sleeptime = maxSleepTime; - jinfo = jobid.queryJob(); - state = jinfo.getParametre()[STATE].str(); - cout << "State is \"" << state << "\""; - } - cout << endl; - return state; - } - -} diff --git a/src/Core/Batch_BatchManager_eClient.cxx b/src/Core/Batch_BatchManager_eClient.cxx deleted file mode 100644 index 92162b2..0000000 --- a/src/Core/Batch_BatchManager_eClient.cxx +++ /dev/null @@ -1,380 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* -* BatchManager_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 - -#ifdef WIN32 -#include -#include -#else -#include -#endif - -#include - -#include "Batch_Constants.hxx" -#include "Batch_BatchManager_eClient.hxx" -#include "Batch_RunTimeException.hxx" -#include "Batch_Utils.hxx" - -#ifdef MSVC -#define EXISTS(path) _access_s(path, 0) == 0 -#else -#define EXISTS(path) access(path, F_OK) == 0 -#endif - -using namespace std; - - -namespace Batch { - - BatchManager_eClient::BatchManager_eClient(const Batch::FactBatchManager * parent, const char* host, - const char * username, - CommunicationProtocolType protocolType, const char* mpiImpl) - : BatchManager(parent, host), _protocol(CommunicationProtocol::getInstance(protocolType)), - _username(username) - { - // instanciation of mpi implementation needed to launch executable in batch script - _mpiImpl = FactoryMpiImpl(mpiImpl); - } - - // Destructeur - BatchManager_eClient::~BatchManager_eClient() - { - if (_mpiImpl) - delete _mpiImpl; - } - - void BatchManager_eClient::exportInputFiles(const Job& job) - { - int status; - Parametre params = job.getParametre(); - const Versatile & V = params[INFILE]; - Versatile::const_iterator Vit; - - status = _protocol.makeDirectory(string(params[TMPDIR]) + "/logs", _hostname, _username); - 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) { - status = _protocol.copyFile(executeFile, "", "", - params[TMPDIR], _hostname, _username); - 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()); - } - -#ifdef WIN32 - // On Windows, we make the remote file executable afterward because - // pscp does not preserve access permissions on files - - string executable = string(params[EXECUTABLE]); - executable = executable.substr(executable.rfind("\\") + 1,executable.length()); - - string subCommand = string("chmod u+x ") + string(params[TMPDIR]) + "/" + executable; - string command = _protocol.getExecCommand(subCommand, _hostname, _username); - 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()); - } -#endif - } - - // 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; - status = _protocol.copyFile(inputFile.getLocal(), "", "", - inputFile.getRemote(), _hostname, _username); - 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 ) - { - Parametre params = job.getParametre(); - const Versatile & V = params[OUTFILE]; - Versatile::const_iterator Vit; - - // Create local result directory - int status = CommunicationProtocol::getInstance(SH).makeDirectory(directory, "", ""); - if (status) { - string mess("Directory creation failed. Status is :"); - ostringstream status_str; - status_str << status; - mess += status_str.str(); - cerr << mess << endl; - } - - for(Vit=V.begin(); Vit!=V.end(); Vit++) { - CoupleType cpt = *static_cast< CoupleType * >(*Vit); - Couple outputFile = cpt; - string localPath = outputFile.getLocal(); - if (!Utils::isAbsolutePath(localPath)) { - localPath = directory + "/" + localPath; - } - status = _protocol.copyFile(outputFile.getRemote(), _hostname, _username, - localPath, "", ""); - 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; - } - } - - // Copy logs - status = _protocol.copyFile(string(params[TMPDIR]) + string("/logs"), _hostname, _username, - directory, "", ""); - if (status) { - std::string mess("Copy logs directory failed ! status is :"); - ostringstream status_str; - status_str << status; - mess += status_str.str(); - cerr << mess << endl; - } - - } - - bool BatchManager_eClient::importDumpStateFile( const Job & job, const string directory ) - { - Parametre params = job.getParametre(); - - // Create local result directory - int status = CommunicationProtocol::getInstance(SH).makeDirectory(directory, "", ""); - if (status) { - string mess("Directory creation failed. Status is :"); - ostringstream status_str; - status_str << status; - mess += status_str.str(); - cerr << mess << endl; - } - - bool ret = true; - status = _protocol.copyFile(string(params[TMPDIR]) + string("/dumpState*.xml"), _hostname, _username, - directory, "", ""); - 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; - ret = false; - } - return ret; - } - - MpiImpl *BatchManager_eClient::FactoryMpiImpl(string mpiImpl) - { - 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 == "ompi") - return new MpiImpl_OMPI(); - else if(mpiImpl == "slurm") - return new MpiImpl_SLURM(); - else if(mpiImpl == "prun") - return new MpiImpl_PRUN(); - else if(mpiImpl == "nompi") - return NULL; - else{ - ostringstream oss; - oss << mpiImpl << " : not yet implemented"; - throw EmulationException(oss.str().c_str()); - } - } - - /** - * This method generates a temporary file name with the pattern "/-XXXXXX" where - * is the directory for temporary files (see BatchManager_eClient::getTmpDir()) and the - * X's are replaced by random characters. Note that this method is less secure than - * BatchManager_eClient::createAndOpenTemporaryFile, so use the latter whenever possible. - * \param prefix the prefix to use for the temporary file. - * \return a name usable for a temporary file. - */ - string BatchManager_eClient::generateTemporaryFileName(const string & prefix) - { - string fileName = getTmpDir() + "/" + prefix + "-XXXXXX"; - char randstr[7]; - - do { - sprintf(randstr, "%06d", rand() % 1000000); - fileName.replace(fileName.size()-6, 6, randstr); - } while (EXISTS(fileName.c_str())); - - return fileName; - } - - /** - * This method creates a temporary file and opens an output stream to write into this file. - * The file is created with the pattern "/-XXXXXX" where is the directory - * for temporary files (see BatchManager_eClient::getTmpDir()) and 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 prefix the prefix to use for the temporary file. - * \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(const string & prefix, ofstream & outputStream) - { - if (outputStream.is_open()) - outputStream.close(); - -#ifdef WIN32 - - string fileName = generateTemporaryFileName(prefix); - // Open the file as binary to avoid problems with Windows newlines - outputStream.open(fileName.c_str(), ios_base::binary | ios_base::out); - -#else - - string fileName = getTmpDir() + "/" + prefix + "-XXXXXX"; - char * buf = new char[fileName.size()+1]; - fileName.copy(buf, fileName.size()); - buf[fileName.size()] = '\0'; - - int fd = mkstemp(buf); - if (fd == -1) { - delete[] buf; - throw RunTimeException(string("Can't create temporary file ") + fileName); - } - fileName = buf; - delete[] buf; - - outputStream.open(fileName.c_str()); - close(fd); // Close the file descriptor so that the file is not opened twice - -#endif - - if (outputStream.fail()) - throw RunTimeException(string("Can't open temporary file ") + fileName); - - return fileName; - } - - /** - * This method finds the name of the directory to use for temporary files in libBatch. This name - * is /libBatch--XXXXXX. is found by looking for environment - * variables TEMP, TMP, TEMPDIR, TMPDIR, and defaults to "/tmp" if none of them is defined. - * is found by looking for environment variables USER and USERNAME, and defaults to - * "unknown". XXXXXX represents random characters. The directory name is generated only once for - * each BatchManager_eClient instance, and the directory is created at this moment. Subsequent - * calls will always return the same path and the existence of the directory will not be - * rechecked. - * \return the name of the directory to use for temporary files. - */ - const std::string & BatchManager_eClient::getTmpDir() - { - if (tmpDirName.empty()) { - const char * baseDir = getenv("TEMP"); - if (baseDir == NULL) baseDir = getenv("TMP"); - if (baseDir == NULL) baseDir = getenv("TEMPDIR"); - if (baseDir == NULL) baseDir = getenv("TMPDIR"); - if (baseDir == NULL) baseDir = "/tmp"; - - const char * userName = getenv("USER"); - if (userName == NULL) userName = getenv("USERNAME"); - if (userName == NULL) userName = "unknown"; - - string baseName = string(baseDir) + "/libBatch-" + userName + "-XXXXXX"; - srand(time(NULL)); - -#ifdef WIN32 - - char randstr[7]; - do { - sprintf(randstr, "%06d", rand() % 1000000); - baseName.replace(baseName.size()-6, 6, randstr); - } while (EXISTS(baseName.c_str())); - if (_mkdir(baseName.c_str()) != 0) - throw RunTimeException(string("Can't create temporary directory ") + baseName); - tmpDirName = baseName; - -#else - - char * buf = new char[baseName.size() + 1]; - baseName.copy(buf, baseName.size()); - buf[baseName.size()] = '\0'; - if (mkdtemp(buf) == NULL) { - delete[] buf; - throw RunTimeException(string("Can't create temporary directory ") + baseName); - } - tmpDirName = buf; - delete[] buf; - -#endif - - } - - return tmpDirName; - } - -} diff --git a/src/Core/Batch_BatchManager_eClient.hxx b/src/Core/Batch_BatchManager_eClient.hxx deleted file mode 100644 index bc4396b..0000000 --- a/src/Core/Batch_BatchManager_eClient.hxx +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * BatchManager_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 "Batch_CommunicationProtocol.hxx" - -#include - -namespace Batch { - - class Job; - - class BATCH_EXPORT BatchManager_eClient : virtual public BatchManager - { - public: - // Constructeur et destructeur - BatchManager_eClient(const Batch::FactBatchManager * parent, const char* host="localhost", - const char * username="", - CommunicationProtocolType protocolType = SSH, const char* mpiImpl="mpich1"); - virtual ~BatchManager_eClient(); - virtual void importOutputFiles( const Job & job, const std::string directory ); - bool importDumpStateFile( const Job & job, const std::string directory ); - - protected: - const CommunicationProtocol & _protocol; // protocol to access _hostname - const std::string _username; // username to access _hostname - MpiImpl *_mpiImpl; // Mpi implementation to launch executable in batch script - - std::string generateTemporaryFileName(const std::string & prefix); - std::string createAndOpenTemporaryFile(const std::string & prefix, std::ofstream & outputStream); - MpiImpl* FactoryMpiImpl(std::string mpiImpl); - void exportInputFiles(const Job & job); - const std::string & getTmpDir(); - - private: - std::string tmpDirName; // Path to the directory for temporary files - - }; - -} - -#endif diff --git a/src/Core/Batch_CharType.cxx b/src/Core/Batch_CharType.cxx deleted file mode 100644 index f4e5da1..0000000 --- a/src/Core/Batch_CharType.cxx +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * 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 deleted file mode 100644 index 864e181..0000000 --- a/src/Core/Batch_CharType.hxx +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * 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 deleted file mode 100644 index 0c6b97c..0000000 --- a/src/Core/Batch_ConnexionFailureException.cxx +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * 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_Date.cxx b/src/Core/Batch_Date.cxx deleted file mode 100644 index a81bc87..0000000 --- a/src/Core/Batch_Date.cxx +++ /dev/null @@ -1,195 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * 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 deleted file mode 100644 index 0a38a91..0000000 --- a/src/Core/Batch_Date.hxx +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * 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 deleted file mode 100644 index c94b3fd..0000000 --- a/src/Core/Batch_DateType.cxx +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * 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 deleted file mode 100644 index 24723df..0000000 --- a/src/Core/Batch_DateType.hxx +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * 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_EmulationException.cxx b/src/Core/Batch_EmulationException.cxx deleted file mode 100644 index 627655c..0000000 --- a/src/Core/Batch_EmulationException.cxx +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * 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 deleted file mode 100644 index a34e82b..0000000 --- a/src/Core/Batch_EmulationException.hxx +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * 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_BoolType.cxx b/src/Core/BoolType.cxx similarity index 98% rename from src/Core/Batch_BoolType.cxx rename to src/Core/BoolType.cxx index a5dec46..66b4f07 100644 --- a/src/Core/Batch_BoolType.cxx +++ b/src/Core/BoolType.cxx @@ -30,7 +30,7 @@ #include #include -#include "Batch_BoolType.hxx" +#include "BoolType.hxx" using namespace std; namespace Batch { diff --git a/src/Core/Batch_BoolType.hxx b/src/Core/BoolType.hxx similarity index 96% rename from src/Core/Batch_BoolType.hxx rename to src/Core/BoolType.hxx index 7695320..e7a27c3 100644 --- a/src/Core/Batch_BoolType.hxx +++ b/src/Core/BoolType.hxx @@ -31,10 +31,10 @@ #ifndef _BOOLTYPE_H_ #define _BOOLTYPE_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" #include -#include "Batch_GenericType.hxx" +#include "GenericType.hxx" namespace Batch { diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt index 8b0136a..0e53214 100644 --- a/src/Core/CMakeLists.txt +++ b/src/Core/CMakeLists.txt @@ -20,57 +20,51 @@ # 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_CommunicationProtocol - Core/Batch_ConnexionFailureException - Core/Batch_Constants - 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_InvalidArgumentException - Core/Batch_InvalidKeyException - Core/Batch_Job - Core/Batch_JobId - Core/Batch_JobInfo - Core/Batch_ListIsFullException - Core/Batch_LongType - Core/Batch_MpiImpl - Core/Batch_NotYetImplementedException - Core/Batch_ParameterTypeMap - Core/Batch_Parametre - Core/Batch_RunTimeException - Core/Batch_StringType - Core/Batch_TypeMismatchException - Core/Batch_Versatile - Core/Batch_Utils +SET(CLASS_LIST Core/APIInternalFailureException + Core/BatchManager + Core/BatchManagerCatalog + Core/BoolType + Core/CommunicationProtocol + Core/Constants + Core/Couple + Core/CoupleType + Core/Environnement + Core/FactBatchManager + Core/GenericException + Core/GenericType + Core/InvalidArgumentException + Core/InvalidKeyException + Core/Job + Core/JobId + Core/JobInfo + Core/ListIsFullException + Core/LongType + Core/MpiImpl + Core/NotYetImplementedException + Core/ParameterTypeMap + Core/Parametre + Core/RunTimeException + Core/StringType + Core/TypeMismatchException + Core/Versatile ) -APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST}) +APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST} + Core/Utils + Core/Log) APPEND_CLASSES_TO_HDR_FILES(${CLASS_LIST}) -APPEND_CLASSES_TO_HDR_FILES(Core/Batch_Defines) +APPEND_CLASSES_TO_HDR_FILES(Core/Defines) IF (HAS_SH) - APPEND_CLASSES_TO_SRC_FILES(Core/Batch_CommunicationProtocolSH) + APPEND_CLASSES_TO_SRC_FILES(Core/CommunicationProtocolSH) ENDIF (HAS_SH) IF (HAS_RSH) - APPEND_CLASSES_TO_SRC_FILES(Core/Batch_CommunicationProtocolRSH) + APPEND_CLASSES_TO_SRC_FILES(Core/CommunicationProtocolRSH) ENDIF (HAS_RSH) IF (HAS_SSH) - APPEND_CLASSES_TO_SRC_FILES(Core/Batch_CommunicationProtocolSSH) + APPEND_CLASSES_TO_SRC_FILES(Core/CommunicationProtocolSSH) ENDIF (HAS_SSH) diff --git a/src/Core/Batch_CommunicationProtocol.cxx b/src/Core/CommunicationProtocol.cxx similarity index 90% rename from src/Core/Batch_CommunicationProtocol.cxx rename to src/Core/CommunicationProtocol.cxx index 8a3ef6a..371ba8d 100644 --- a/src/Core/Batch_CommunicationProtocol.cxx +++ b/src/Core/CommunicationProtocol.cxx @@ -20,35 +20,39 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_CommunicationProtocol.cxx : + * CommunicationProtocol.cxx : * * Created on: 14 sept. 2009 * Author : Renaud BARATE - EDF R&D */ #include -#include -#include -#include +#include -#include "Batch_CommunicationProtocol.hxx" +#include "CommunicationProtocol.hxx" #ifdef HAS_RSH - #include "Batch_CommunicationProtocolRSH.hxx" + #include "CommunicationProtocolRSH.hxx" #endif #ifdef HAS_SH - #include "Batch_CommunicationProtocolSH.hxx" + #include "CommunicationProtocolSH.hxx" #endif #ifdef HAS_SSH - #include "Batch_CommunicationProtocolSSH.hxx" + #include "CommunicationProtocolSSH.hxx" #endif -#include "Batch_APIInternalFailureException.hxx" -#include "Batch_RunTimeException.hxx" +#include "APIInternalFailureException.hxx" +#include "RunTimeException.hxx" +#include "Log.hxx" using namespace std; namespace Batch { + CommunicationProtocol::CommunicationProtocol(CommunicationProtocolType type) + : _type(type) + { + } + CommunicationProtocol::~CommunicationProtocol() { } @@ -100,7 +104,7 @@ namespace Batch { string command = commandStringFromArgs(getCopyCommandArgs(sourcePath, sourceHost, sourceUser, destinationPath, destinationHost, destinationUser)); - cout << command.c_str() << endl; + LOG(command); int status = system(command.c_str()); return status; } @@ -120,7 +124,7 @@ namespace Batch { const std::string & user) const { string command = getExecCommand(getRemoveSubCommand(path), host, user); - cout << command.c_str() << endl; + LOG(command); int status = system(command.c_str()); return status; } @@ -130,7 +134,7 @@ namespace Batch { const std::string & user) const { string command = getExecCommand(getMakeDirectorySubCommand(path), host, user); - cout << command.c_str() << endl; + LOG(command); int status = system(command.c_str()); return status; } @@ -164,4 +168,9 @@ namespace Batch { return commandStr; } + CommunicationProtocolType CommunicationProtocol::getType() const + { + return _type; + } + } diff --git a/src/Core/Batch_CommunicationProtocol.hxx b/src/Core/CommunicationProtocol.hxx similarity index 94% rename from src/Core/Batch_CommunicationProtocol.hxx rename to src/Core/CommunicationProtocol.hxx index a300ff1..43c31fa 100644 --- a/src/Core/Batch_CommunicationProtocol.hxx +++ b/src/Core/CommunicationProtocol.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_CommunicationProtocol.hxx : + * CommunicationProtocol.hxx : * * Created on: 14 sept. 2009 * Author : Renaud BARATE - EDF R&D @@ -32,7 +32,7 @@ #include #include -#include "Batch_Defines.hxx" +#include "Defines.hxx" namespace Batch { @@ -68,8 +68,12 @@ namespace Batch { const std::string & host, const std::string & user) const; + CommunicationProtocolType getType() const; + protected: + CommunicationProtocol(CommunicationProtocolType type = SH); + virtual std::vector getCopyCommandArgs(const std::string & sourcePath, const std::string & sourceHost, const std::string & sourceUser, @@ -83,6 +87,8 @@ namespace Batch { std::string commandStringFromArgs(const std::vector & args) const; + CommunicationProtocolType _type; + }; } diff --git a/src/Core/Batch_CommunicationProtocolRSH.cxx b/src/Core/CommunicationProtocolRSH.cxx similarity index 95% rename from src/Core/Batch_CommunicationProtocolRSH.cxx rename to src/Core/CommunicationProtocolRSH.cxx index 99f28ba..7c69d15 100644 --- a/src/Core/Batch_CommunicationProtocolRSH.cxx +++ b/src/Core/CommunicationProtocolRSH.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_CommunicationProtocolRSH.cxx : + * CommunicationProtocolRSH.cxx : * * Created on: 14 sept. 2009 * Author : Renaud BARATE - EDF R&D @@ -30,17 +30,23 @@ #include #include -#include +#include #endif -#include +#include -#include "Batch_CommunicationProtocolRSH.hxx" +#include "CommunicationProtocolRSH.hxx" +#include "Log.hxx" using namespace std; namespace Batch { + CommunicationProtocolRSH::CommunicationProtocolRSH() + : CommunicationProtocol(RSH) + { + } + vector CommunicationProtocolRSH::getExecCommandArgs(const string & subCommand, const string & host, const string & user) const @@ -155,7 +161,7 @@ namespace Batch { newdir[0] = driveLetter; newdir[1] = ':'; newdir[2] = '\0'; - cout << "Changing directory: " << newdir << endl; + LOG("Changing directory: " << newdir); _chdir(newdir); } @@ -164,7 +170,7 @@ namespace Batch { // Go back to previous directory if necessary if (driveLetter != '\0' && driveLetter != currentDrive) { - cout << "Changing directory: " << cwd << endl; + LOG("Changing directory: " << cwd); _chdir(cwd); } diff --git a/src/Core/Batch_CommunicationProtocolRSH.hxx b/src/Core/CommunicationProtocolRSH.hxx similarity index 93% rename from src/Core/Batch_CommunicationProtocolRSH.hxx rename to src/Core/CommunicationProtocolRSH.hxx index e2a475d..c62fc9a 100644 --- a/src/Core/Batch_CommunicationProtocolRSH.hxx +++ b/src/Core/CommunicationProtocolRSH.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_CommunicationProtocolRSH.hxx : + * CommunicationProtocolRSH.hxx : * * Created on: 14 sept. 2009 * Author : Renaud BARATE - EDF R&D @@ -32,13 +32,15 @@ #include #include -#include "Batch_Defines.hxx" -#include "Batch_CommunicationProtocol.hxx" +#include "Defines.hxx" +#include "CommunicationProtocol.hxx" namespace Batch { class BATCH_EXPORT CommunicationProtocolRSH : public CommunicationProtocol { + friend class CommunicationProtocol; + public: std::vector getExecCommandArgs(const std::string & subCommand, const std::string & host, @@ -62,12 +64,18 @@ namespace Batch { const std::string & destinationHost, const std::string & destinationUser) const; +#endif + protected: +#ifdef WIN32 + char getDriveLetter(const std::string & path, std::string * pathWithoutDrive = NULL) const; #endif + CommunicationProtocolRSH(); + }; } diff --git a/src/Core/Batch_CommunicationProtocolSH.cxx b/src/Core/CommunicationProtocolSH.cxx similarity index 75% rename from src/Core/Batch_CommunicationProtocolSH.cxx rename to src/Core/CommunicationProtocolSH.cxx index 3ef7180..89968d9 100644 --- a/src/Core/Batch_CommunicationProtocolSH.cxx +++ b/src/Core/CommunicationProtocolSH.cxx @@ -20,31 +20,24 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_CommunicationProtocolSH.cxx : + * CommunicationProtocolSH.cxx : * * Created on: 16 sept. 2009 * Author : Renaud BARATE - EDF R&D */ -#include +#include -#include "Batch_CommunicationProtocolSH.hxx" +#include "CommunicationProtocolSH.hxx" +#include "Utils.hxx" using namespace std; namespace Batch { - // Simple method to fix path strings depending on the platform. On Windows, it will replace - // forward slashes '/' by backslashes '\'. On Unix, the path is just copied without change. - string CommunicationProtocolSH::fixPath(const string & path) const + CommunicationProtocolSH::CommunicationProtocolSH() + : CommunicationProtocol(SH) { - string fixedPath = path; - #ifdef WIN32 - for (unsigned int i=0 ; i CommunicationProtocolSH::getExecCommandArgs(const string & subCommand, @@ -53,7 +46,7 @@ namespace Batch { { vector cmd; - cmd.push_back(fixPath(SH_COMMAND)); + cmd.push_back(Utils::fixPath(SH_COMMAND)); #ifdef WIN32 cmd.push_back("/c"); @@ -61,7 +54,7 @@ namespace Batch { cmd.push_back("-c"); #endif - cmd.push_back(fixPath(subCommand)); + cmd.push_back(Utils::fixPath(subCommand)); return cmd; } @@ -78,14 +71,14 @@ namespace Batch { #ifndef WIN32 cmd.push_back("-r"); #endif - cmd.push_back(fixPath(sourcePath)); - cmd.push_back(fixPath(destinationPath)); + cmd.push_back(Utils::fixPath(sourcePath)); + cmd.push_back(Utils::fixPath(destinationPath)); return cmd; } string CommunicationProtocolSH::getRemoveSubCommand(const string & path) const { - return string(RM_COMMAND) + " " + fixPath(path); + return string(RM_COMMAND) + " " + Utils::fixPath(path); } string CommunicationProtocolSH::getMakeDirectorySubCommand(const string & path) const @@ -94,7 +87,7 @@ namespace Batch { #ifndef WIN32 subCommand += " -p"; #endif - subCommand += " " + fixPath(path); + subCommand += " " + Utils::fixPath(path); return subCommand; } diff --git a/src/Core/Batch_CommunicationProtocolSH.hxx b/src/Core/CommunicationProtocolSH.hxx similarity index 92% rename from src/Core/Batch_CommunicationProtocolSH.hxx rename to src/Core/CommunicationProtocolSH.hxx index 46e0d8c..b6b9a78 100644 --- a/src/Core/Batch_CommunicationProtocolSH.hxx +++ b/src/Core/CommunicationProtocolSH.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_CommunicationProtocolSH.hxx : + * CommunicationProtocolSH.hxx : * * Created on: 16 sept. 2009 * Author : Renaud BARATE - EDF R&D @@ -32,13 +32,15 @@ #include #include -#include "Batch_Defines.hxx" -#include "Batch_CommunicationProtocol.hxx" +#include "Defines.hxx" +#include "CommunicationProtocol.hxx" namespace Batch { class BATCH_EXPORT CommunicationProtocolSH : public CommunicationProtocol { + friend class CommunicationProtocol; + public: std::vector getExecCommandArgs(const std::string & subCommand, const std::string & host, @@ -53,12 +55,12 @@ namespace Batch { protected: + CommunicationProtocolSH(); + std::string getRemoveSubCommand(const std::string & path) const; std::string getMakeDirectorySubCommand(const std::string & path) const; - std::string fixPath(const std::string & path) const; - }; } diff --git a/src/Core/Batch_CommunicationProtocolSSH.cxx b/src/Core/CommunicationProtocolSSH.cxx similarity index 94% rename from src/Core/Batch_CommunicationProtocolSSH.cxx rename to src/Core/CommunicationProtocolSSH.cxx index deac559..b6883a4 100644 --- a/src/Core/Batch_CommunicationProtocolSSH.cxx +++ b/src/Core/CommunicationProtocolSSH.cxx @@ -20,20 +20,25 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_CommunicationProtocolSSH.cxx : + * CommunicationProtocolSSH.cxx : * * Created on: 14 sept. 2009 * Author : Renaud BARATE - EDF R&D */ -#include +#include -#include "Batch_CommunicationProtocolSSH.hxx" +#include "CommunicationProtocolSSH.hxx" using namespace std; namespace Batch { + CommunicationProtocolSSH::CommunicationProtocolSSH() + : CommunicationProtocol(SSH) + { + } + vector CommunicationProtocolSSH::getExecCommandArgs(const string & subCommand, const string & host, const string & user) const diff --git a/src/Core/Batch_CommunicationProtocolSSH.hxx b/src/Core/CommunicationProtocolSSH.hxx similarity index 92% rename from src/Core/Batch_CommunicationProtocolSSH.hxx rename to src/Core/CommunicationProtocolSSH.hxx index 24743ff..3aadcce 100644 --- a/src/Core/Batch_CommunicationProtocolSSH.hxx +++ b/src/Core/CommunicationProtocolSSH.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_CommunicationProtocolSSH.hxx : + * CommunicationProtocolSSH.hxx : * * Created on: 14 sept. 2009 * Author : Renaud BARATE - EDF R&D @@ -32,13 +32,15 @@ #include #include -#include "Batch_Defines.hxx" -#include "Batch_CommunicationProtocol.hxx" +#include "Defines.hxx" +#include "CommunicationProtocol.hxx" namespace Batch { class BATCH_EXPORT CommunicationProtocolSSH : public CommunicationProtocol { + friend class CommunicationProtocol; + public: std::vector getExecCommandArgs(const std::string & subCommand, const std::string & host, @@ -53,6 +55,8 @@ namespace Batch { protected: + CommunicationProtocolSSH(); + }; } diff --git a/src/Core/Batch_Constants.cxx b/src/Core/Constants.cxx similarity index 71% rename from src/Core/Batch_Constants.cxx rename to src/Core/Constants.cxx index 778a3c7..c6df750 100644 --- a/src/Core/Batch_Constants.cxx +++ b/src/Core/Constants.cxx @@ -20,57 +20,33 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_Constants.cxx : + * Constants.cxx : * * Auteur : Renaud BARATE - EDF R&D * Date : January 2010 * */ -#include "Batch_Constants.hxx" +#include "Constants.hxx" namespace Batch { // Definition of the string constants (keys for the parameter map) - def_Constant(ACCOUNT); def_Constant(ARGUMENTS); - def_Constant(CHECKPOINT); - def_Constant(CKPTINTERVAL); - def_Constant(CREATIONTIME); - def_Constant(EGROUP); - def_Constant(ELIGIBLETIME); - def_Constant(ENDTIME); - def_Constant(EUSER); def_Constant(EXECUTABLE); - def_Constant(EXECUTIONHOST); - def_Constant(EXITCODE); - def_Constant(HOLD); def_Constant(ID); def_Constant(INFILE); - def_Constant(MAIL); def_Constant(MAXCPUTIME); def_Constant(MAXDISKSIZE); def_Constant(MAXRAMSIZE); def_Constant(MAXWALLTIME); - def_Constant(MODIFICATIONTIME); def_Constant(NAME); def_Constant(NBPROC); + def_Constant(NBPROCPERNODE); def_Constant(OUTFILE); - def_Constant(PID); def_Constant(QUEUE); - def_Constant(QUEUEDTIME); - def_Constant(SERVER); - def_Constant(STARTTIME); def_Constant(STATE); - def_Constant(TEXT); - def_Constant(TMPDIR); - def_Constant(USEDCPUTIME); - def_Constant(USEDDISKSIZE); - def_Constant(USEDRAMSIZE); - def_Constant(USEDWALLTIME); - def_Constant(USER); def_Constant(WORKDIR); - def_Constant(HOMEDIR); def_Constant(EXCLUSIVE); // These constants define the status of a job (parameter STATE); diff --git a/src/Core/Batch_Constants.hxx b/src/Core/Constants.hxx similarity index 72% rename from src/Core/Batch_Constants.hxx rename to src/Core/Constants.hxx index 332a163..46cbaf1 100644 --- a/src/Core/Batch_Constants.hxx +++ b/src/Core/Constants.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_Constants.hxx : + * Constants.hxx : * * Auteur : Renaud BARATE - EDF R&D * Date : January 2010 @@ -32,7 +32,7 @@ #include -#include "Batch_Defines.hxx" +#include "Defines.hxx" // These macros simplify the creation of new string constants for keys and // values in parameters map. @@ -43,45 +43,21 @@ namespace Batch { // Declaration of the keys for the parameter map - decl_extern_Constant(ACCOUNT); decl_extern_Constant(ARGUMENTS); - decl_extern_Constant(CHECKPOINT); - decl_extern_Constant(CKPTINTERVAL); - decl_extern_Constant(CREATIONTIME); - decl_extern_Constant(EGROUP); - decl_extern_Constant(ELIGIBLETIME); - decl_extern_Constant(ENDTIME); - decl_extern_Constant(EUSER); decl_extern_Constant(EXECUTABLE); - decl_extern_Constant(EXECUTIONHOST); - decl_extern_Constant(EXITCODE); - decl_extern_Constant(HOLD); decl_extern_Constant(ID); decl_extern_Constant(INFILE); - decl_extern_Constant(MAIL); decl_extern_Constant(MAXCPUTIME); decl_extern_Constant(MAXDISKSIZE); decl_extern_Constant(MAXRAMSIZE); decl_extern_Constant(MAXWALLTIME); - decl_extern_Constant(MODIFICATIONTIME); decl_extern_Constant(NAME); decl_extern_Constant(NBPROC); + decl_extern_Constant(NBPROCPERNODE); decl_extern_Constant(OUTFILE); - decl_extern_Constant(PID); decl_extern_Constant(QUEUE); - decl_extern_Constant(QUEUEDTIME); - decl_extern_Constant(SERVER); - decl_extern_Constant(STARTTIME); decl_extern_Constant(STATE); - decl_extern_Constant(TEXT); - decl_extern_Constant(TMPDIR); - decl_extern_Constant(USEDCPUTIME); - decl_extern_Constant(USEDDISKSIZE); - decl_extern_Constant(USEDRAMSIZE); - decl_extern_Constant(USEDWALLTIME); - decl_extern_Constant(USER); decl_extern_Constant(WORKDIR); - decl_extern_Constant(HOMEDIR); decl_extern_Constant(EXCLUSIVE); // These constants define the status of a job (parameter STATE) diff --git a/src/Core/Batch_Couple.cxx b/src/Core/Couple.cxx similarity index 98% rename from src/Core/Batch_Couple.cxx rename to src/Core/Couple.cxx index d1e49f3..4782efb 100644 --- a/src/Core/Batch_Couple.cxx +++ b/src/Core/Couple.cxx @@ -29,7 +29,7 @@ * */ -#include "Batch_Couple.hxx" +#include "Couple.hxx" using namespace std; namespace Batch { diff --git a/src/Core/Batch_Couple.hxx b/src/Core/Couple.hxx similarity index 98% rename from src/Core/Batch_Couple.hxx rename to src/Core/Couple.hxx index ec7238f..fe41fbc 100644 --- a/src/Core/Batch_Couple.hxx +++ b/src/Core/Couple.hxx @@ -32,7 +32,7 @@ #ifndef _COUPLE_H_ #define _COUPLE_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" #include diff --git a/src/Core/Batch_CoupleType.cxx b/src/Core/CoupleType.cxx similarity index 98% rename from src/Core/Batch_CoupleType.cxx rename to src/Core/CoupleType.cxx index 20f1852..0b7144b 100644 --- a/src/Core/Batch_CoupleType.cxx +++ b/src/Core/CoupleType.cxx @@ -30,7 +30,7 @@ */ #include -#include "Batch_CoupleType.hxx" +#include "CoupleType.hxx" using namespace std; namespace Batch { diff --git a/src/Core/Batch_CoupleType.hxx b/src/Core/CoupleType.hxx similarity index 95% rename from src/Core/Batch_CoupleType.hxx rename to src/Core/CoupleType.hxx index 9b66562..b6fcf7a 100644 --- a/src/Core/Batch_CoupleType.hxx +++ b/src/Core/CoupleType.hxx @@ -32,11 +32,11 @@ #ifndef _COUPLETYPE_H_ #define _COUPLETYPE_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" #include -#include "Batch_GenericType.hxx" -#include "Batch_Couple.hxx" +#include "GenericType.hxx" +#include "Couple.hxx" namespace Batch { diff --git a/src/Core/Batch_Defines.hxx b/src/Core/Defines.hxx similarity index 87% rename from src/Core/Batch_Defines.hxx rename to src/Core/Defines.hxx index d53cfdb..0cecc1a 100644 --- a/src/Core/Batch_Defines.hxx +++ b/src/Core/Defines.hxx @@ -19,7 +19,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File : Batch_Defines.hxx +// File : Defines.hxx // Author : Alexander A. BORODIN // Module : SALOME // @@ -27,7 +27,7 @@ #define _BATCH_Defines_HXX_ #ifdef WIN32 -# if defined Batch_EXPORTS +# if defined batch_EXPORTS # define BATCH_EXPORT __declspec( dllexport ) # else # define BATCH_EXPORT __declspec( dllimport ) @@ -36,10 +36,4 @@ # define BATCH_EXPORT #endif -#ifdef WIN32 -#define BATCH_CHMOD(name, mode) _chmod(name, mode) -#else -#define BATCH_CHMOD(name, mode) chmod(name, mode) -#endif - #endif diff --git a/src/Core/Batch_Environnement.cxx b/src/Core/Environnement.cxx similarity index 97% rename from src/Core/Batch_Environnement.cxx rename to src/Core/Environnement.cxx index 0f4dcdc..db85263 100644 --- a/src/Core/Batch_Environnement.cxx +++ b/src/Core/Environnement.cxx @@ -29,7 +29,7 @@ * */ -#include "Batch_Environnement.hxx" +#include "Environnement.hxx" using namespace std; namespace Batch { diff --git a/src/Core/Batch_Environnement.hxx b/src/Core/Environnement.hxx similarity index 97% rename from src/Core/Batch_Environnement.hxx rename to src/Core/Environnement.hxx index e99fc7f..75eb7a7 100644 --- a/src/Core/Batch_Environnement.hxx +++ b/src/Core/Environnement.hxx @@ -32,7 +32,7 @@ #ifndef _ENVIRONNEMENT_H_ #define _ENVIRONNEMENT_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" #include diff --git a/src/Core/Batch_FactBatchManager.cxx b/src/Core/FactBatchManager.cxx similarity index 85% rename from src/Core/Batch_FactBatchManager.cxx rename to src/Core/FactBatchManager.cxx index df74a91..dae5f12 100644 --- a/src/Core/Batch_FactBatchManager.cxx +++ b/src/Core/FactBatchManager.cxx @@ -31,8 +31,8 @@ #include #include #include -#include "Batch_BatchManagerCatalog.hxx" -#include "Batch_FactBatchManager.hxx" +#include "BatchManagerCatalog.hxx" +#include "FactBatchManager.hxx" using namespace std; namespace Batch { @@ -41,12 +41,6 @@ namespace Batch { 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 @@ -56,7 +50,7 @@ namespace Batch { } // Accesseur - string FactBatchManager::getType() const + const string & FactBatchManager::getType() const { return type; } diff --git a/src/Core/Batch_FactBatchManager.hxx b/src/Core/FactBatchManager.hxx similarity index 81% rename from src/Core/Batch_FactBatchManager.hxx rename to src/Core/FactBatchManager.hxx index a51a596..9b4fd73 100644 --- a/src/Core/Batch_FactBatchManager.hxx +++ b/src/Core/FactBatchManager.hxx @@ -31,10 +31,10 @@ #ifndef _FACTBATCHMANAGER_H_ #define _FACTBATCHMANAGER_H_ -#include "Batch_Defines.hxx" - #include -#include + +#include "Defines.hxx" +#include "CommunicationProtocol.hxx" namespace Batch { @@ -47,15 +47,16 @@ namespace Batch { FactBatchManager(const std::string & type); virtual ~FactBatchManager(); - virtual Batch::BatchManager * operator() (const char * hostname) const = 0; - std::string getType() const; + virtual Batch::BatchManager * operator() (const char * hostname, + const char * username = "", + CommunicationProtocolType protocolType = SSH, + const char * mpi = "nompi") const = 0; + const std::string & getType() const; std::string __repr__() const; protected: std::string type; - private: - }; } diff --git a/src/Core/Batch_GenericException.cxx b/src/Core/GenericException.cxx similarity index 97% rename from src/Core/Batch_GenericException.cxx rename to src/Core/GenericException.cxx index 67b29c1..5636488 100644 --- a/src/Core/Batch_GenericException.cxx +++ b/src/Core/GenericException.cxx @@ -30,7 +30,7 @@ */ #include -#include "Batch_GenericException.hxx" +#include "GenericException.hxx" using namespace std; diff --git a/src/Core/Batch_GenericException.hxx b/src/Core/GenericException.hxx similarity index 98% rename from src/Core/Batch_GenericException.hxx rename to src/Core/GenericException.hxx index 435911b..cbeaa93 100644 --- a/src/Core/Batch_GenericException.hxx +++ b/src/Core/GenericException.hxx @@ -32,7 +32,7 @@ #ifndef _GENERICEXCEPTION_H_ #define _GENERICEXCEPTION_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" #include diff --git a/src/Core/Batch_GenericType.cxx b/src/Core/GenericType.cxx similarity index 98% rename from src/Core/Batch_GenericType.cxx rename to src/Core/GenericType.cxx index 810d837..b8aa499 100644 --- a/src/Core/Batch_GenericType.cxx +++ b/src/Core/GenericType.cxx @@ -32,7 +32,7 @@ #include #include #include -#include "Batch_GenericType.hxx" +#include "GenericType.hxx" using namespace std; namespace Batch { diff --git a/src/Core/Batch_GenericType.hxx b/src/Core/GenericType.hxx similarity index 98% rename from src/Core/Batch_GenericType.hxx rename to src/Core/GenericType.hxx index a2520d6..2b3ede3 100644 --- a/src/Core/Batch_GenericType.hxx +++ b/src/Core/GenericType.hxx @@ -31,7 +31,7 @@ #ifndef _GENERICTYPE_H_ #define _GENERICTYPE_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" #include diff --git a/src/Core/Batch_InvalidArgumentException.cxx b/src/Core/InvalidArgumentException.cxx similarity index 96% rename from src/Core/Batch_InvalidArgumentException.cxx rename to src/Core/InvalidArgumentException.cxx index a027307..9e7534d 100644 --- a/src/Core/Batch_InvalidArgumentException.cxx +++ b/src/Core/InvalidArgumentException.cxx @@ -29,7 +29,7 @@ * */ -#include "Batch_InvalidArgumentException.hxx" +#include "InvalidArgumentException.hxx" using namespace std; namespace Batch { diff --git a/src/Core/Batch_InvalidArgumentException.hxx b/src/Core/InvalidArgumentException.hxx similarity index 95% rename from src/Core/Batch_InvalidArgumentException.hxx rename to src/Core/InvalidArgumentException.hxx index fbd55b6..fd7d77c 100644 --- a/src/Core/Batch_InvalidArgumentException.hxx +++ b/src/Core/InvalidArgumentException.hxx @@ -33,9 +33,9 @@ #define _INVALIDARGUMENTEXCEPTION_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" -#include "Batch_GenericException.hxx" +#include "GenericException.hxx" namespace Batch { diff --git a/src/Core/Batch_InvalidKeyException.cxx b/src/Core/InvalidKeyException.cxx similarity index 96% rename from src/Core/Batch_InvalidKeyException.cxx rename to src/Core/InvalidKeyException.cxx index 3f0b173..7e6f49a 100644 --- a/src/Core/Batch_InvalidKeyException.cxx +++ b/src/Core/InvalidKeyException.cxx @@ -29,7 +29,7 @@ * */ -#include "Batch_InvalidKeyException.hxx" +#include "InvalidKeyException.hxx" using namespace std; namespace Batch { diff --git a/src/Core/Batch_InvalidKeyException.hxx b/src/Core/InvalidKeyException.hxx similarity index 95% rename from src/Core/Batch_InvalidKeyException.hxx rename to src/Core/InvalidKeyException.hxx index ff9dddc..d70466a 100644 --- a/src/Core/Batch_InvalidKeyException.hxx +++ b/src/Core/InvalidKeyException.hxx @@ -32,10 +32,10 @@ #ifndef _INVALIDKEYEXCEPTION_H_ #define _INVALIDKEYEXCEPTION_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" -#include "Batch_GenericException.hxx" +#include "GenericException.hxx" namespace Batch { diff --git a/src/Core/Batch_Job.cxx b/src/Core/Job.cxx similarity index 98% rename from src/Core/Batch_Job.cxx rename to src/Core/Job.cxx index 9c93a3b..f87a905 100644 --- a/src/Core/Batch_Job.cxx +++ b/src/Core/Job.cxx @@ -28,8 +28,8 @@ * */ -#include "Batch_Job.hxx" -#include "Batch_Parametre.hxx" +#include "Job.hxx" +#include "Parametre.hxx" #include //#include "MEDMEM_STRING.hxx" using namespace std; diff --git a/src/Core/Batch_Job.hxx b/src/Core/Job.hxx similarity index 95% rename from src/Core/Batch_Job.hxx rename to src/Core/Job.hxx index e3045c7..5433fdd 100644 --- a/src/Core/Batch_Job.hxx +++ b/src/Core/Job.hxx @@ -31,11 +31,11 @@ #ifndef _JOB_H_ #define _JOB_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" -#include "Batch_Parametre.hxx" -#include "Batch_Environnement.hxx" +#include "Parametre.hxx" +#include "Environnement.hxx" namespace Batch { diff --git a/src/Core/Batch_JobId.cxx b/src/Core/JobId.cxx similarity index 96% rename from src/Core/Batch_JobId.cxx rename to src/Core/JobId.cxx index 048ef27..1ff3c58 100644 --- a/src/Core/Batch_JobId.cxx +++ b/src/Core/JobId.cxx @@ -28,8 +28,8 @@ * */ -#include "Batch_JobId.hxx" -#include "Batch_BatchManager.hxx" +#include "JobId.hxx" +#include "BatchManager.hxx" #include #include //#include "MEDMEM_STRING.hxx" @@ -44,7 +44,7 @@ namespace Batch { } // 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) + JobId::JobId(BatchManager * _p_bm, const string & ref) : _p_batchmanager(_p_bm), _reference(ref) { // Nothing to do } diff --git a/src/Core/Batch_JobId.hxx b/src/Core/JobId.hxx similarity index 95% rename from src/Core/Batch_JobId.hxx rename to src/Core/JobId.hxx index 831c5cf..48a3c02 100644 --- a/src/Core/Batch_JobId.hxx +++ b/src/Core/JobId.hxx @@ -32,10 +32,10 @@ #define _JOBID_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" -#include "Batch_JobInfo.hxx" -#include "Batch_BatchManager.hxx" +#include "JobInfo.hxx" +#include "BatchManager.hxx" namespace Batch { @@ -51,7 +51,7 @@ namespace Batch { virtual ~JobId(); // Constructeur avec le pointeur sur le BatchManager associe et avec une reference - JobId(Batch::BatchManager *, std::string ref); + JobId(Batch::BatchManager *, const std::string & ref); // Operateur d'affectation entre objets virtual JobId & operator =(const Batch::JobId &); diff --git a/src/Core/Batch_JobInfo.cxx b/src/Core/JobInfo.cxx similarity index 97% rename from src/Core/Batch_JobInfo.cxx rename to src/Core/JobInfo.cxx index 6f50309..8353ecd 100644 --- a/src/Core/Batch_JobInfo.cxx +++ b/src/Core/JobInfo.cxx @@ -33,8 +33,8 @@ #include #include -#include "Batch_Constants.hxx" -#include "Batch_JobInfo.hxx" +#include "Constants.hxx" +#include "JobInfo.hxx" using namespace std; diff --git a/src/Core/Batch_JobInfo.hxx b/src/Core/JobInfo.hxx similarity index 96% rename from src/Core/Batch_JobInfo.hxx rename to src/Core/JobInfo.hxx index 7e09a18..817c60e 100644 --- a/src/Core/Batch_JobInfo.hxx +++ b/src/Core/JobInfo.hxx @@ -32,12 +32,12 @@ #ifndef _JOBINFO_H_ #define _JOBINFO_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" #include #include -#include "Batch_Parametre.hxx" -#include "Batch_Environnement.hxx" +#include "Parametre.hxx" +#include "Environnement.hxx" namespace Batch { diff --git a/src/Core/Batch_ListIsFullException.cxx b/src/Core/ListIsFullException.cxx similarity index 96% rename from src/Core/Batch_ListIsFullException.cxx rename to src/Core/ListIsFullException.cxx index 3a46ebc..2b0cd56 100644 --- a/src/Core/Batch_ListIsFullException.cxx +++ b/src/Core/ListIsFullException.cxx @@ -28,7 +28,7 @@ * */ -#include "Batch_ListIsFullException.hxx" +#include "ListIsFullException.hxx" using namespace std; diff --git a/src/Core/Batch_ListIsFullException.hxx b/src/Core/ListIsFullException.hxx similarity index 95% rename from src/Core/Batch_ListIsFullException.hxx rename to src/Core/ListIsFullException.hxx index 4020927..e1df097 100644 --- a/src/Core/Batch_ListIsFullException.hxx +++ b/src/Core/ListIsFullException.hxx @@ -31,9 +31,9 @@ #ifndef _LISTISFULLEXCEPTION_H_ #define _LISTISFULLEXCEPTION_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" -#include "Batch_GenericException.hxx" +#include "GenericException.hxx" namespace Batch { diff --git a/src/Core/Batch_Utils.cxx b/src/Core/Log.cxx similarity index 59% rename from src/Core/Batch_Utils.cxx rename to src/Core/Log.cxx index e3c864a..7d4f359 100644 --- a/src/Core/Batch_Utils.cxx +++ b/src/Core/Log.cxx @@ -20,52 +20,47 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_Utils.cxx + * Log.cxx : * - * Created on: 30 jan. 2012 + * Created on: 28 jan. 2013 * Author : Renaud BARATE - EDF R&D */ -#include - -#include -#include "Batch_Utils.hxx" - -#ifdef MSVC -#define popen _popen -#define pclose _pclose -#endif +#include "Utils.hxx" +#include "Log.hxx" using namespace std; -namespace Batch { -int Utils::getCommandOutput(const string & command, string & output) -{ - // Reinitialize output - output = ""; +namespace Batch { - // Call command - FILE * fp = popen(command.c_str(), "r"); - if (fp == NULL) { - return -1; + Log::Log() + { + const size_t BUFSIZE = 32; + char date[BUFSIZE]; + time_t curtime = time(NULL); + strftime(date, BUFSIZE, "%Y-%m-%d_%H-%M-%S", localtime(&curtime)); + string prefix = string("log-") + date; + Utils::createAndOpenTemporaryFile(prefix, _stream); } - // Read the output and store it - char buf[1024]; - while (fgets(buf, sizeof(buf), fp) != NULL) { - output += buf; + Log::~Log() + { + _stream.close(); } - // close and get status - int status = pclose(fp); - return status; -} + void Log::log(const string & msg) + { + const size_t BUFSIZE = 32; + char timestamp[BUFSIZE]; + time_t curtime = time(NULL); + strftime(timestamp, BUFSIZE, "%Y-%m-%d_%H-%M-%S", localtime(&curtime)); + getInstance()._stream << timestamp << ": " << msg << endl; + } -bool Utils::isAbsolutePath(const string & path) -{ - if (path.size() == 0) - return false; - return path[0] == '/'; -} + Log & Log::getInstance() + { + static Log instance; + return instance; + } } diff --git a/src/Core/Log.hxx b/src/Core/Log.hxx new file mode 100644 index 0000000..6647d95 --- /dev/null +++ b/src/Core/Log.hxx @@ -0,0 +1,65 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +/* + * Log.hxx : + * + * Created on: 28 jan. 2013 + * Author : Renaud BARATE - EDF R&D + */ + +#ifndef _LOG_H_ +#define _LOG_H_ + +#include +#include +#include + +#include "Defines.hxx" + +#define LOG(msg) {std::ostringstream sstream; sstream << msg; Log::log(sstream.str());} + +namespace Batch { + + class BATCH_EXPORT Log + { + public: + virtual ~Log(); + + static void log(const std::string & msg); + + private: + + Log(); + + static Log & getInstance(); + + // Forbid the use of copy constructor and assignment operator + Log(const Log & orig) {} + void operator=(const Log & orig) {} + + std::ofstream _stream; + + }; + +} + +#endif diff --git a/src/Core/Batch_LongType.cxx b/src/Core/LongType.cxx similarity index 98% rename from src/Core/Batch_LongType.cxx rename to src/Core/LongType.cxx index 48a9b86..f600081 100644 --- a/src/Core/Batch_LongType.cxx +++ b/src/Core/LongType.cxx @@ -32,7 +32,7 @@ #include #include //#include "MEDMEM_STRING.hxx" -#include "Batch_LongType.hxx" +#include "LongType.hxx" using namespace std; namespace Batch { diff --git a/src/Core/Batch_LongType.hxx b/src/Core/LongType.hxx similarity index 96% rename from src/Core/Batch_LongType.hxx rename to src/Core/LongType.hxx index 8e9f3ba..dfdeccb 100644 --- a/src/Core/Batch_LongType.hxx +++ b/src/Core/LongType.hxx @@ -31,10 +31,10 @@ #ifndef _LONGTYPE_H_ #define _LONGTYPE_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" #include -#include "Batch_GenericType.hxx" +#include "GenericType.hxx" namespace Batch { diff --git a/src/Core/Batch_MpiImpl.cxx b/src/Core/MpiImpl.cxx similarity index 99% rename from src/Core/Batch_MpiImpl.cxx rename to src/Core/MpiImpl.cxx index dcd68b0..a319861 100644 --- a/src/Core/Batch_MpiImpl.cxx +++ b/src/Core/MpiImpl.cxx @@ -23,7 +23,7 @@ #include #include #include -#include "Batch_MpiImpl.hxx" +#include "MpiImpl.hxx" using namespace std; diff --git a/src/Core/Batch_MpiImpl.hxx b/src/Core/MpiImpl.hxx similarity index 99% rename from src/Core/Batch_MpiImpl.hxx rename to src/Core/MpiImpl.hxx index 9bc323f..a1345d8 100644 --- a/src/Core/Batch_MpiImpl.hxx +++ b/src/Core/MpiImpl.hxx @@ -23,7 +23,7 @@ #ifndef _BL_MPIIMPL_H_ #define _BL_MPIIMPL_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" #include class BATCH_EXPORT MpiImplException diff --git a/src/Core/Batch_NotYetImplementedException.cxx b/src/Core/NotYetImplementedException.cxx similarity index 96% rename from src/Core/Batch_NotYetImplementedException.cxx rename to src/Core/NotYetImplementedException.cxx index 40df58b..a4e38c9 100644 --- a/src/Core/Batch_NotYetImplementedException.cxx +++ b/src/Core/NotYetImplementedException.cxx @@ -29,7 +29,7 @@ * */ -#include "Batch_NotYetImplementedException.hxx" +#include "NotYetImplementedException.hxx" namespace Batch { diff --git a/src/Core/Batch_NotYetImplementedException.hxx b/src/Core/NotYetImplementedException.hxx similarity index 95% rename from src/Core/Batch_NotYetImplementedException.hxx rename to src/Core/NotYetImplementedException.hxx index 8e5ee7e..42001da 100644 --- a/src/Core/Batch_NotYetImplementedException.hxx +++ b/src/Core/NotYetImplementedException.hxx @@ -32,8 +32,8 @@ #ifndef _NOTYETIMPLEMENTEDEXCEPTION_H_ #define _NOTYETIMPLEMENTEDEXCEPTION_H_ -#include "Batch_Defines.hxx" -#include "Batch_GenericException.hxx" +#include "Defines.hxx" +#include "GenericException.hxx" #include diff --git a/src/Core/Batch_ParameterTypeMap.cxx b/src/Core/ParameterTypeMap.cxx similarity index 73% rename from src/Core/Batch_ParameterTypeMap.cxx rename to src/Core/ParameterTypeMap.cxx index dcda3bb..0e5973d 100644 --- a/src/Core/Batch_ParameterTypeMap.cxx +++ b/src/Core/ParameterTypeMap.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_ParameterTypeMap.cxx : + * ParameterTypeMap.cxx : * * Auteur : Renaud Barate - EDF R&D * Date : Mars 2011 @@ -30,9 +30,9 @@ #include #include -#include "Batch_Constants.hxx" -#include "Batch_InvalidKeyException.hxx" -#include "Batch_ParameterTypeMap.hxx" +#include "Constants.hxx" +#include "InvalidKeyException.hxx" +#include "ParameterTypeMap.hxx" using namespace std; @@ -45,45 +45,21 @@ namespace Batch { ParameterTypeMap::ParameterTypeMap() { // Don't use the string constants in this constructor because they might be uninitialized - addParameter("ACCOUNT", STRING, 1); addParameter("ARGUMENTS", STRING, 0); - addParameter("CHECKPOINT", LONG, 1); - addParameter("CKPTINTERVAL", LONG, 1); - addParameter("CREATIONTIME", LONG, 1); - addParameter("EGROUP", STRING, 1); - addParameter("ELIGIBLETIME", LONG, 1); - addParameter("ENDTIME", LONG, 1); - addParameter("EUSER", STRING, 1); addParameter("EXECUTABLE", STRING, 1); - addParameter("EXECUTIONHOST", STRING, 0); - addParameter("EXITCODE", LONG, 1); - addParameter("HOLD", LONG, 1); addParameter("ID", STRING, 1); addParameter("INFILE", COUPLE, 0); - addParameter("MAIL", STRING, 1); addParameter("MAXCPUTIME", LONG, 1); addParameter("MAXDISKSIZE", LONG, 1); addParameter("MAXRAMSIZE", LONG, 1); addParameter("MAXWALLTIME", LONG, 1); - addParameter("MODIFICATIONTIME", LONG, 1); addParameter("NAME", STRING, 1); addParameter("NBPROC", LONG, 1); + addParameter("NBPROCPERNODE", LONG, 1); addParameter("OUTFILE", COUPLE, 0); - addParameter("PID", LONG, 1); addParameter("QUEUE", STRING, 1); - addParameter("QUEUEDTIME", LONG, 1); - addParameter("SERVER", STRING, 1); - addParameter("STARTTIME", LONG, 1); addParameter("STATE", STRING, 1); - addParameter("TEXT", STRING, 1); - addParameter("TMPDIR", STRING, 1); - addParameter("USEDCPUTIME", LONG, 1); - addParameter("USEDDISKSIZE", LONG, 1); - addParameter("USEDRAMSIZE", LONG, 1); - addParameter("USEDWALLTIME", LONG, 1); - addParameter("USER", STRING, 1); addParameter("WORKDIR", STRING, 1); - addParameter("HOMEDIR", STRING, 1); addParameter("EXCLUSIVE", BOOL, 1); } diff --git a/src/Core/Batch_ParameterTypeMap.hxx b/src/Core/ParameterTypeMap.hxx similarity index 95% rename from src/Core/Batch_ParameterTypeMap.hxx rename to src/Core/ParameterTypeMap.hxx index b565552..5854741 100644 --- a/src/Core/Batch_ParameterTypeMap.hxx +++ b/src/Core/ParameterTypeMap.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_ParameterTypeMap.hxx : + * ParameterTypeMap.hxx : * * Auteur : Renaud Barate - EDF R&D * Date : Mars 2011 @@ -30,8 +30,8 @@ #ifndef _PARAMETERTYPEMAP_H_ #define _PARAMETERTYPEMAP_H_ -#include "Batch_Defines.hxx" -#include "Batch_Versatile.hxx" +#include "Defines.hxx" +#include "Versatile.hxx" #include #include diff --git a/src/Core/Batch_Parametre.cxx b/src/Core/Parametre.cxx similarity index 95% rename from src/Core/Batch_Parametre.cxx rename to src/Core/Parametre.cxx index 70ffadd..5336981 100644 --- a/src/Core/Batch_Parametre.cxx +++ b/src/Core/Parametre.cxx @@ -28,10 +28,10 @@ * */ -#include "Batch_Versatile.hxx" -#include "Batch_InvalidKeyException.hxx" -#include "Batch_ParameterTypeMap.hxx" -#include "Batch_Parametre.hxx" +#include "Versatile.hxx" +#include "InvalidKeyException.hxx" +#include "ParameterTypeMap.hxx" +#include "Parametre.hxx" using namespace std; diff --git a/src/Core/Batch_Parametre.hxx b/src/Core/Parametre.hxx similarity index 96% rename from src/Core/Batch_Parametre.hxx rename to src/Core/Parametre.hxx index 7312c0f..574d366 100644 --- a/src/Core/Batch_Parametre.hxx +++ b/src/Core/Parametre.hxx @@ -34,8 +34,8 @@ #include #include -#include "Batch_Defines.hxx" -#include "Batch_Versatile.hxx" +#include "Defines.hxx" +#include "Versatile.hxx" namespace Batch { diff --git a/src/Core/Batch_RunTimeException.cxx b/src/Core/RunTimeException.cxx similarity index 96% rename from src/Core/Batch_RunTimeException.cxx rename to src/Core/RunTimeException.cxx index a983e24..22100e4 100644 --- a/src/Core/Batch_RunTimeException.cxx +++ b/src/Core/RunTimeException.cxx @@ -29,7 +29,7 @@ * */ -#include "Batch_RunTimeException.hxx" +#include "RunTimeException.hxx" using namespace std; namespace Batch { diff --git a/src/Core/Batch_RunTimeException.hxx b/src/Core/RunTimeException.hxx similarity index 95% rename from src/Core/Batch_RunTimeException.hxx rename to src/Core/RunTimeException.hxx index 87878bf..c792517 100644 --- a/src/Core/Batch_RunTimeException.hxx +++ b/src/Core/RunTimeException.hxx @@ -32,10 +32,10 @@ #ifndef _RUNTIMEEXCEPTION_H_ #define _RUNTIMEEXCEPTION_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" -#include "Batch_GenericException.hxx" +#include "GenericException.hxx" namespace Batch { diff --git a/src/Core/Batch_StringType.cxx b/src/Core/StringType.cxx similarity index 98% rename from src/Core/Batch_StringType.cxx rename to src/Core/StringType.cxx index d7d418f..e762037 100644 --- a/src/Core/Batch_StringType.cxx +++ b/src/Core/StringType.cxx @@ -30,7 +30,7 @@ #include #include -#include "Batch_StringType.hxx" +#include "StringType.hxx" using namespace std; namespace Batch { diff --git a/src/Core/Batch_StringType.hxx b/src/Core/StringType.hxx similarity index 96% rename from src/Core/Batch_StringType.hxx rename to src/Core/StringType.hxx index ab7246c..4e75778 100644 --- a/src/Core/Batch_StringType.hxx +++ b/src/Core/StringType.hxx @@ -31,10 +31,10 @@ #ifndef _STRINGTYPE_H_ #define _STRINGTYPE_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" #include -#include "Batch_GenericType.hxx" +#include "GenericType.hxx" namespace Batch { diff --git a/src/Core/Test/CMakeLists.txt b/src/Core/Test/CMakeLists.txt index a2e81cc..b2244cb 100644 --- a/src/Core/Test/CMakeLists.txt +++ b/src/Core/Test/CMakeLists.txt @@ -29,13 +29,18 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Test_config.h.in ${CMAKE_CURRENT_BINA # Set the include directories include_directories(${CMAKE_CURRENT_BINARY_DIR}) +include_directories(${CMAKE_SOURCE_DIR}/src/Core) # Build SimpleParser library add_library (SimpleParser STATIC SimpleParser.cxx) -# Build the test program +# Build the test program for SimpleParser add_executable(Test_SimpleParser Test_SimpleParser.cxx) target_link_libraries(Test_SimpleParser SimpleParser) # Add the test itself ADD_TEST(SimpleParser Test_SimpleParser) + +# Build the test program for the batch managers +add_executable(Test_BatchManager Test_BatchManager.cxx) +target_link_libraries(Test_BatchManager batch SimpleParser) diff --git a/src/Core/Test/SimpleParser.cxx b/src/Core/Test/SimpleParser.cxx index f20eb27..e40a56b 100644 --- a/src/Core/Test/SimpleParser.cxx +++ b/src/Core/Test/SimpleParser.cxx @@ -128,6 +128,21 @@ const string & SimpleParser::getValue(const string & key) const throw(ParserExce return iter->second; } +const string & SimpleParser::getTestValue(const string & bmType, const string & protocolStr, + const string & key) const throw(ParserException) +{ + string fullkey = string("TEST_") + bmType + "_" + protocolStr + "_" + key; + try { + return getValue(fullkey); + } catch (const ParserException &) {} + fullkey = string("TEST_") + bmType + "_" + key; + try { + return getValue(fullkey); + } catch (const ParserException &) {} + fullkey = string("TEST_") + key; + return getValue(fullkey); +} + int SimpleParser::getValueAsInt(const string & key) const throw(ParserException) { const string & valueStr = getValue(key); @@ -140,6 +155,21 @@ int SimpleParser::getValueAsInt(const string & key) const throw(ParserException) return res; } +int SimpleParser::getTestValueAsInt(const string & bmType, const string & protocolStr, + const string & key) const throw(ParserException) +{ + string fullkey = string("TEST_") + bmType + "_" + protocolStr + "_" + key; + try { + return getValueAsInt(fullkey); + } catch (const ParserException &) {} + fullkey = string("TEST_") + bmType + "_" + key; + try { + return getValueAsInt(fullkey); + } catch (const ParserException &) {} + fullkey = string("TEST_") + key; + return getValueAsInt(fullkey); +} + ostream & operator <<(ostream & os, const SimpleParser & parser) throw() { if (parser._configmap.empty()) { diff --git a/src/Core/Test/SimpleParser.hxx b/src/Core/Test/SimpleParser.hxx index cccee1f..43e8ec8 100644 --- a/src/Core/Test/SimpleParser.hxx +++ b/src/Core/Test/SimpleParser.hxx @@ -54,7 +54,11 @@ public: void parse(const std::string & filename) throw(ParserException); void parseTestConfigFile() throw(ParserException); const std::string & getValue(const std::string & key) const throw(ParserException); + const std::string & getTestValue(const std::string & bmType, const std::string & protocolStr, + const std::string & key) const throw(ParserException); int getValueAsInt(const std::string & key) const throw(ParserException); + int getTestValueAsInt(const std::string & bmType, const std::string & protocolStr, + const std::string & key) const throw(ParserException); friend std::ostream & operator <<(std::ostream & os, const SimpleParser & parser) throw(); diff --git a/src/LoadLeveler/Test/Test_eLL.cxx b/src/Core/Test/Test_BatchManager.cxx similarity index 57% rename from src/LoadLeveler/Test/Test_eLL.cxx rename to src/Core/Test/Test_BatchManager.cxx index 62156d7..e1940cb 100644 --- a/src/LoadLeveler/Test/Test_eLL.cxx +++ b/src/Core/Test/Test_BatchManager.cxx @@ -20,10 +20,10 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Test_ePBS.cxx : + * Test_BatchManager.cxx : * * Author : Renaud BARATE - EDF R&D - * Date : April 2009 + * Date : Jan 2013 * */ @@ -31,81 +31,93 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include +#include "SimpleParser.hxx" + +#include using namespace std; using namespace Batch; void print_usage() { - cout << "usage: Test_eLL PROTOCOL" << endl; - cout << " PROTOCOL \"SSH\" or \"RSH\"" << endl; + cout << "usage: Test_BatchManager BATCH_MANAGER PROTOCOL" << endl; + cout << " BATCH_MANAGER \"CCC\", \"LL\", \"LOCAL\", \"LSF\", \"PBS\", " << + "\"SGE\", \"SLURM\" or \"VISHNU\"" << endl; + cout << " PROTOCOL \"SH\", \"SSH\" or \"RSH\"" << endl; } int main(int argc, char** argv) { // Parse argument - if (argc != 2) { + if (argc != 3) { print_usage(); return 1; } + const char * bmType = argv[1]; + const char * protocolStr = argv[2]; CommunicationProtocolType protocol; - if (strcmp(argv[1], "SSH") == 0) + if (strcmp(protocolStr, "SSH") == 0) protocol = SSH; - else if (strcmp(argv[1], "RSH") == 0) + else if (strcmp(protocolStr, "RSH") == 0) protocol = RSH; + else if (strcmp(protocolStr, "SH") == 0) + protocol = SH; else { print_usage(); return 1; } cout << "*******************************************************************************************" << endl; - cout << "This program tests the batch submission based on LoadLeveler emulation. Passwordless" << endl; - cout << "authentication must be used for this test to pass. For SSH, this can be configured with" << endl; - cout << "ssh-agent for instance. For RSH, this can be configured with the .rhosts file." << endl; + cout << "This program tests the batch submission of a job using the batch manager \"" << bmType << "\"" << endl; + cout << "and the communication protocol \"" << protocolStr << "\"." << endl; + if (protocol == RSH || protocol == SSH) { + cout << "Passwordless authentication must be used for this test to pass." << endl; + if (protocol == SSH) { + cout << "This can be configured with ssh-agent for instance." << endl; + } else if (protocol == RSH) { + cout << "This can be configured with the .rhosts file." << endl; + } + } cout << "*******************************************************************************************" << endl; // eventually remove any previous result - remove("result.txt"); + remove("resultdir/seconddirname/result.txt"); try { + // Get the catalog and the BatchManager factory + BatchManagerCatalog& cata = BatchManagerCatalog::getInstance(); + FactBatchManager * fbm = cata(bmType); + // Parse the test configuration file SimpleParser parser; parser.parseTestConfigFile(); - const string & homedir = parser.getValue("TEST_ELL_HOMEDIR"); - const string & host = parser.getValue("TEST_ELL_HOST"); - const string & user = parser.getValue("TEST_ELL_USER"); - const string & queue = parser.getValue("TEST_ELL_QUEUE"); - const string & jobType = parser.getValue("TEST_ELL_JOBTYPE"); - int timeout = parser.getValueAsInt("TEST_ELL_TIMEOUT"); + const string & workdir = parser.getTestValue(bmType, protocolStr, "WORKDIR"); + const string & host = parser.getTestValue(bmType, protocolStr, "HOST"); + const string & user = parser.getTestValue(bmType, protocolStr, "USER"); + int timeout = parser.getTestValueAsInt(bmType, protocolStr, "TIMEOUT"); // Define the job... Job job; // ... and its parameters ... Parametre p; - p[EXECUTABLE] = "./test-script.sh"; - p[NAME] = string("Test_eLL_") + argv[1]; - p[WORKDIR] = 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[EXECUTABLE] = string(CMAKE_CURRENT_SOURCE_DIR) + "/test_script.py"; + p[ARGUMENTS] = "copied_seta.py"; + p[ARGUMENTS] += "copied_setb.py"; + p[ARGUMENTS] += "orig_result.txt"; + p[NAME] = string("Test ") + bmType + " " + argv[2]; + p[WORKDIR] = workdir; + p[INFILE] = Couple(string(CMAKE_CURRENT_SOURCE_DIR) + "/seta.py", "copied_seta.py"); + p[INFILE] += Couple(string(CMAKE_CURRENT_SOURCE_DIR) + "/setb.py", "copied_setb.py"); + p[OUTFILE] = Couple("result.txt", "orig_result.txt"); p[NBPROC] = 1; p[MAXWALLTIME] = 1; p[MAXRAMSIZE] = 50; - p[HOMEDIR] = homedir; - p[QUEUE] = queue; - p[LL_JOBTYPE] = jobType; - p[EXCLUSIVE] = false; job.setParametre(p); // ... and its environment Environnement e; @@ -113,12 +125,8 @@ int main(int argc, char** argv) 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("eLL")); - BatchManager_eClient * bm = (*fbm)(host.c_str(), user.c_str(), protocol); + // Create the BatchManager + BatchManager * bm = (*fbm)(host.c_str(), user.c_str(), protocol); // Submit the job to the BatchManager JobId jobid = bm->submitJob(job); @@ -139,10 +147,10 @@ int main(int argc, char** argv) return 1; } - } catch (GenericException e) { + } catch (const GenericException & e) { cerr << "Error: " << e << endl; return 1; - } catch (ParserException e) { + } catch (const ParserException & e) { cerr << "Parser error: " << e.what() << endl; return 1; } @@ -161,7 +169,7 @@ int main(int argc, char** argv) cerr << "Error, result is not the expected one (MYENVVAR = MYVALUE, c = 12)." << endl; return 1; } - } catch (ParserException e) { + } catch (const ParserException & e) { cerr << "Parser error on result file: " << e.what() << endl; return 1; } diff --git a/src/Core/Test/Test_config.h.in b/src/Core/Test/Test_config.h.in index 8e5ab00..a116412 100644 --- a/src/Core/Test/Test_config.h.in +++ b/src/Core/Test/Test_config.h.in @@ -20,4 +20,8 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +/* Environment variable containing the path of the test configuration file */ #define TEST_CONFIG_FILE_ENV_VAR "${TEST_CONFIG_FILE_ENV_VAR}" + +/* Current source directory */ +#define CMAKE_CURRENT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" diff --git a/src/Core/Test/batchtest.conf b/src/Core/Test/batchtest.conf index 2d30ca9..f8cdcf3 100644 --- a/src/Core/Test/batchtest.conf +++ b/src/Core/Test/batchtest.conf @@ -5,46 +5,27 @@ # Note that BATCH_TEST_CONFIG_FILE is the default name for this environment variable. It can be # changed at compilation time by setting CMake option TEST_CONFIG_FILE_ENV_VAR. +TEST_LOCAL_SH_HOST = "localhost" # Not used +TEST_LOCAL_SH_USER = "me" # Not used TEST_LOCAL_SH_WORK_DIR = "/tmp" # Work directory for local SH Batch test TEST_LOCAL_SH_TIMEOUT = 2 # Execution timeout (in seconds) for local SH Batch test -TEST_LOCAL_SH_FINALIZATION_TIME = 2 # Finalization time (in seconds) for local SH Batch test -TEST_LOCAL_RSH_EXECUTION_HOST = "localhost" # Execution host for RSH Batch test -TEST_LOCAL_RSH_USER = "username" # User name on the execution host for RSH Batch test -TEST_LOCAL_RSH_WORK_DIR = "/tmp" # Work directory for RSH Batch test -TEST_LOCAL_RSH_TIMEOUT = 10 # Execution timeout (in seconds) for local RSH Batch test -TEST_LOCAL_RSH_FINALIZATION_TIME = 5 # Finalization time (in seconds) for local RSH Batch test - -TEST_LOCAL_SSH_EXECUTION_HOST = "localhost" # Execution host for SSH Batch test -TEST_LOCAL_SSH_USER = "username" # User name on the execution host for SSH Batch test -TEST_LOCAL_SSH_WORK_DIR = "/tmp" # Work directory for SSH Batch test -TEST_LOCAL_SSH_TIMEOUT = 10 # Execution timeout (in seconds) for local SSH Batch test -TEST_LOCAL_SSH_FINALIZATION_TIME = 5 # Finalization time (in seconds) for local SSH Batch test - -TEST_PBS_HOST = "localhost" # PBS server host -TEST_PBS_USER = "username" # Login for the PBS server -TEST_PBS_QUEUE = "queuename" # Queue to submit test job on PBS server -TEST_PBS_TIMEOUT = 120 # Execution timeout (in seconds) for PBS Batch test - -TEST_EPBS_HOST = "localhost" # PBS server host -TEST_EPBS_USER = "username" # Login for the PBS server -TEST_EPBS_HOMEDIR = "/home/username" # Home directory on PBS server -TEST_EPBS_QUEUE = "queuename" # Queue to submit test job on PBS server -TEST_EPBS_TIMEOUT = 120 # Execution timeout (in seconds) for PBS Batch test - -TEST_ELL_HOST = "localhost" # LoadLeveler server host -TEST_ELL_USER = "username" # Login for the LoadLeveler server -TEST_ELL_HOMEDIR = "/home/username" # Home directory on LoadLeveler server -TEST_ELL_QUEUE = "classname" # Class for the test job test job on LoadLeveler server -TEST_ELL_JOBTYPE = "serial" # Job type for LoadLeveler -TEST_ELL_TIMEOUT = 120 # Execution timeout (in seconds) for LoadLeveler Batch test - -TEST_ESLURM_HOST = "localhost" # Slurm server host -TEST_ESLURM_USER = "username" # Login for the Slurm server -TEST_ESLURM_HOMEDIR = "/home/username" # Home directory on Slurm server -TEST_ESLURM_TIMEOUT = 120 # Execution timeout (in seconds) for Slurm Batch test - -TEST_EVISHNU_HOST = "localhost" # Machine ID of the target cluster -TEST_EVISHNU_USER = "username" # Vishnu login (unused) -TEST_EVISHNU_HOMEDIR = "/home/username" # Home directory on the target cluster -TEST_EVISHNU_TIMEOUT = 120 # Execution timeout (in seconds) for Vishnu Batch test +TEST_LOCAL_HOST = "localhost" # Execution host for LOCAL Batch test +TEST_LOCAL_USER = "username" # User name on the execution host for LOCAL Batch test +TEST_LOCAL_WORKDIR = "/tmp" # Work directory for LOCAL Batch test +TEST_LOCAL_TIMEOUT = 10 # Execution timeout (in seconds) for LOCAL Batch test + +TEST_LSF_HOST = "localhost" # LSF server host +TEST_LSF_USER = "username" # Login for the LSF server +TEST_LSF_WORKDIR = "/home/username/wrk" # Work directory on LSF server +TEST_LSF_TIMEOUT = 120 # Execution timeout (in seconds) for LSF Batch test + +TEST_SLURM_HOST = "localhost" # Slurm server host +TEST_SLURM_USER = "username" # Login for the Slurm server +TEST_SLURM_WORKDIR = "/home/username/wrk" # Work directory on Slurm server +TEST_SLURM_TIMEOUT = 120 # Execution timeout (in seconds) for Slurm Batch test + +TEST_VISHNU_HOST = "localhost" # Machine ID of the target cluster +TEST_VISHNU_USER = "username" # Vishnu login (unused) +TEST_VISHNU_WORKDIR = "/home/username/wrk" # Work directory on the target cluster +TEST_VISHNU_TIMEOUT = 120 # Execution timeout (in seconds) for Vishnu Batch test diff --git a/src/Core/Test/seta.py b/src/Core/Test/seta.py new file mode 100644 index 0000000..da718ba --- /dev/null +++ b/src/Core/Test/seta.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python + +a=4 diff --git a/src/Core/Test/setb.py b/src/Core/Test/setb.py new file mode 100644 index 0000000..070121a --- /dev/null +++ b/src/Core/Test/setb.py @@ -0,0 +1,3 @@ +#!/usr/bin/env python + +b=3 diff --git a/src/Core/Test/test_script.py b/src/Core/Test/test_script.py new file mode 100755 index 0000000..f4073ce --- /dev/null +++ b/src/Core/Test/test_script.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python + +import sys +import os + +if len(sys.argv) != 4: + print "Usage: test-script.py seta.py setb.py result.txt" + +execfile(sys.argv[1]) +execfile(sys.argv[2]) + +c = a * b + +f = open(sys.argv[3], "w") +f.write('MYENVVAR = "%s"\n' % os.getenv("MYENVVAR")) +f.write("c = %d\n" % c) diff --git a/src/Core/Batch_TypeMismatchException.cxx b/src/Core/TypeMismatchException.cxx similarity index 96% rename from src/Core/Batch_TypeMismatchException.cxx rename to src/Core/TypeMismatchException.cxx index 48884ae..904fbc5 100644 --- a/src/Core/Batch_TypeMismatchException.cxx +++ b/src/Core/TypeMismatchException.cxx @@ -28,7 +28,7 @@ * */ -#include "Batch_TypeMismatchException.hxx" +#include "TypeMismatchException.hxx" using namespace std; namespace Batch { diff --git a/src/Core/Batch_TypeMismatchException.hxx b/src/Core/TypeMismatchException.hxx similarity index 95% rename from src/Core/Batch_TypeMismatchException.hxx rename to src/Core/TypeMismatchException.hxx index cd24cc5..de84fdb 100644 --- a/src/Core/Batch_TypeMismatchException.hxx +++ b/src/Core/TypeMismatchException.hxx @@ -31,10 +31,10 @@ #ifndef _TYPEMISMATCHEXCEPTION_H_ #define _TYPEMISMATCHEXCEPTION_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" -#include "Batch_GenericException.hxx" +#include "GenericException.hxx" namespace Batch { diff --git a/src/Core/Utils.cxx b/src/Core/Utils.cxx new file mode 100644 index 0000000..623bb60 --- /dev/null +++ b/src/Core/Utils.cxx @@ -0,0 +1,170 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +/* + * Utils.cxx + * + * Created on: 30 jan. 2012 + * Author : Renaud BARATE - EDF R&D + */ + +#include +#include +#include +#include + +#ifdef WIN32 +#include +#include +#include +#else +#include +#include +#endif + +#include +#include "Utils.hxx" +#include "RunTimeException.hxx" + +#ifdef MSVC +#define popen _popen +#define pclose _pclose +#endif + +using namespace std; +namespace Batch { + +int Utils::getCommandOutput(const string & command, string & output) +{ + // Reinitialize output + output = ""; + + // Call command + FILE * fp = popen(command.c_str(), "r"); + if (fp == NULL) { + return -1; + } + + // Read the output and store it + char buf[1024]; + while (fgets(buf, sizeof(buf), fp) != NULL) { + output += buf; + } + + // close and get status + int status = pclose(fp); + return status; +} + +bool Utils::isAbsolutePath(const string & path) +{ + if (path.size() == 0) + return false; +#ifdef WIN32 + // On Windows, absolute paths may begin with something like "C:" + if (path[1] == ':') + return true; +#endif + return path[0] == '/'; +} + +string Utils::createAndOpenTemporaryFile(const string & prefix, ofstream & outputStream) +{ + if (outputStream.is_open()) + outputStream.close(); + + // Find directory for temporary files + const char * tmpDirName = getenv("TEMP"); + if (tmpDirName == NULL) tmpDirName = getenv("TMP"); + if (tmpDirName == NULL) tmpDirName = getenv("TEMPDIR"); + if (tmpDirName == NULL) tmpDirName = getenv("TMPDIR"); + if (tmpDirName == NULL) tmpDirName = "/tmp"; + + string fileName = (string)tmpDirName + "/libbatch-" + prefix + "-XXXXXX"; + +#ifdef WIN32 + + char randstr[7]; + srand(time(NULL)); + + do { + sprintf(randstr, "%06d", rand() % 1000000); + fileName.replace(fileName.size()-6, 6, randstr); + } while (_access_s(fileName.c_str(), 0) == 0); + + // Open the file as binary to avoid problems with Windows newlines + outputStream.open(fileName.c_str(), ios_base::binary | ios_base::out); + +#else + + char * buf = new char[fileName.size()+1]; + fileName.copy(buf, fileName.size()); + buf[fileName.size()] = '\0'; + + int fd = mkstemp(buf); + if (fd == -1) { + delete[] buf; + throw RunTimeException(string("Can't create temporary file ") + fileName); + } + fileName = buf; + delete[] buf; + + outputStream.open(fileName.c_str()); + close(fd); // Close the file descriptor so that the file is not opened twice + +#endif + + if (outputStream.fail()) + throw RunTimeException(string("Can't open temporary file ") + fileName); + + return fileName; +} + +int Utils::chmod(const char *path, int mode) +{ +#ifdef WIN32 + return _chmod(path, mode); +#else + return ::chmod(path, mode); +#endif +} + +void Utils::sleep(unsigned int seconds) +{ +#ifdef WIN32 + Sleep((seconds)*1000); +#else + ::sleep(seconds); +#endif +} + +string Utils::fixPath(const string & path) +{ + string fixedPath = path; +#ifdef WIN32 + for (unsigned int i=0 ; i + +namespace Batch { + +class Utils { +public: + + /** + * Call a command with the system shell and stores its output in parameter "output". + * Returns the return code of the command. + */ + static int getCommandOutput(const std::string & command, std::string & output); + + /** + * Test if the path in parameter is an absolute path (does not test the existence of + * a file or directory at this path). + */ + static bool isAbsolutePath(const std::string & path); + + /** + * Create a temporary file and open an output stream to write into this file. + * The file is created with the pattern "/libbatch--XXXXXX" where is the + * directory for temporary files and the X's are replaced by random characters. The caller is + * responsible for closing and deleting the file when it is no more used. + * is found by looking for environment variables TEMP, TMP, TEMPDIR, TMPDIR, and defaults + * to "/tmp" if none of them is defined. + * \param prefix the prefix to use for the temporary file. + * \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. + */ + static std::string createAndOpenTemporaryFile(const std::string & prefix, + std::ofstream & outputStream); + + /** + * Change permissions of a file + */ + static int chmod(const char *path, int mode); + + /** + * Sleep for the number of specified seconds + */ + static void sleep(unsigned int seconds); + + /** + * Simple method to fix path strings depending on the platform. On Windows, it will replace + * forward slashes '/' by backslashes '\'. On Unix, the path is just copied without change. + */ + static std::string fixPath(const std::string & path); + +private: + + // No instanciation possible as this class provides only static methods + Utils() { } + +}; + +} + +#endif /* BATCH_UTILS_HXX_ */ diff --git a/src/Core/Batch_Versatile.cxx b/src/Core/Versatile.cxx similarity index 96% rename from src/Core/Batch_Versatile.cxx rename to src/Core/Versatile.cxx index 834caff..06bfbad 100644 --- a/src/Core/Batch_Versatile.cxx +++ b/src/Core/Versatile.cxx @@ -32,14 +32,13 @@ #include #include -#include "Batch_GenericType.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" +#include "GenericType.hxx" +#include "BoolType.hxx" +#include "LongType.hxx" +#include "StringType.hxx" +#include "Versatile.hxx" +#include "TypeMismatchException.hxx" +#include "ListIsFullException.hxx" using namespace std; diff --git a/src/Core/Batch_Versatile.hxx b/src/Core/Versatile.hxx similarity index 92% rename from src/Core/Batch_Versatile.hxx rename to src/Core/Versatile.hxx index 2f909b6..b1e7462 100644 --- a/src/Core/Batch_Versatile.hxx +++ b/src/Core/Versatile.hxx @@ -30,20 +30,19 @@ #ifndef _VERSATILE_H_ #define _VERSATILE_H_ -#include "Batch_Defines.hxx" +#include "Defines.hxx" #include #include #include -#include "Batch_GenericType.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" -#include "Batch_RunTimeException.hxx" +#include "GenericType.hxx" +#include "BoolType.hxx" +#include "LongType.hxx" +#include "StringType.hxx" +#include "CoupleType.hxx" +#include "TypeMismatchException.hxx" +#include "ListIsFullException.hxx" +#include "RunTimeException.hxx" namespace Batch { diff --git a/src/LSF/Batch_BatchManager_eLSF.cxx b/src/LSF/BatchManager_LSF.cxx similarity index 69% rename from src/LSF/Batch_BatchManager_eLSF.cxx rename to src/LSF/BatchManager_LSF.cxx index 560b994..a1b0daf 100644 --- a/src/LSF/Batch_BatchManager_eLSF.cxx +++ b/src/LSF/BatchManager_LSF.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * BatchManager_eLSF.cxx : emulation of LSF client + * BatchManager_LSF.cxx : emulation of LSF client * * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr @@ -33,56 +33,56 @@ #include #include -#include -#include -#include "Batch_BatchManager_eLSF.hxx" -#include "Batch_JobInfo_eLSF.hxx" +#include +#include +#include +#include "BatchManager_LSF.hxx" +#include "JobInfo_LSF.hxx" +#include "Log.hxx" using namespace std; namespace Batch { - BatchManager_eLSF::BatchManager_eLSF(const FactBatchManager * parent, const char * host, + BatchManager_LSF::BatchManager_LSF(const FactBatchManager * parent, const char * host, const char * username, CommunicationProtocolType protocolType, const char * mpiImpl) - : BatchManager(parent, host), - BatchManager_eClient(parent, host, username, protocolType, mpiImpl) - + : BatchManager(parent, host, username, protocolType, mpiImpl) { // Nothing to do } // Destructeur - BatchManager_eLSF::~BatchManager_eLSF() + BatchManager_LSF::~BatchManager_LSF() { // Nothing to do } // Methode pour le controle des jobs : soumet un job au gestionnaire - const JobId BatchManager_eLSF::submitJob(const Job & job) + const JobId BatchManager_LSF::submitJob(const Job & job) { Parametre params = job.getParametre(); const std::string workDir = params[WORKDIR]; // export input files on cluster - cerr << "Export des fichiers en entree" << endl; + LOG("Export des fichiers en entree"); exportInputFiles(job); // build batch script for job - cerr << "Construction du script de batch" << endl; + LOG("Construction du script de batch"); string scriptFile = buildSubmissionScript(job); - cerr << "Script envoye" << endl; + LOG("Script envoye"); // define command to submit batch string subCommand = string("cd ") + workDir + "; bsub < " + scriptFile; string command = _protocol.getExecCommand(subCommand, _hostname, _username); command += " 2>&1"; - cerr << command.c_str() << endl; + LOG(command); string output; int status = Utils::getCommandOutput(command, output); - cout << output; - if (status != 0) throw EmulationException("Can't submit job, error was: " + output); + LOG(output); + if (status != 0) throw RunTimeException("Can't submit job, error was: " + output); // read id of submitted job in output int p10 = output.find("<"); @@ -93,15 +93,8 @@ namespace Batch { return id; } - // Ce manager permet de faire de la reprise - const Batch::JobId - BatchManager_eLSF::addJob(const Batch::Job & job, const std::string reference) - { - return JobId(this, reference); - } - // Methode pour le controle des jobs : retire un job du gestionnaire - void BatchManager_eLSF::deleteJob(const JobId & jobid) + void BatchManager_LSF::deleteJob(const JobId & jobid) { int status; int ref; @@ -111,47 +104,16 @@ namespace Batch { // define command to delete batch string subCommand = string("bkill ") + iss.str(); string command = _protocol.getExecCommand(subCommand, _hostname, _username); - cerr << command.c_str() << endl; + LOG(command); status = system(command.c_str()); if (status) - throw EmulationException("Error of connection on remote host"); + throw RunTimeException("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); + LOG("jobId = " << ref << "killed"); } // Methode pour le controle des jobs : renvoie l'etat du job - JobInfo BatchManager_eLSF::queryJob(const JobId & jobid) + JobInfo BatchManager_LSF::queryJob(const JobId & jobid) { int id; istringstream iss(jobid.getReference()); @@ -160,25 +122,25 @@ namespace Batch { // define command to query batch string subCommand = string("bjobs ") + iss.str(); string command = _protocol.getExecCommand(subCommand, _hostname, _username); - cerr << command.c_str() << endl; + LOG(command); string output; int status = Utils::getCommandOutput(command, output); - if (status) throw EmulationException("Error of connection on remote host"); + if (status) throw RunTimeException("Error of connection on remote host"); - JobInfo_eLSF ji = JobInfo_eLSF(id, output); + JobInfo_LSF ji = JobInfo_LSF(id, output); return ji; } // Methode pour le controle des jobs : teste si un job est present en machine - bool BatchManager_eLSF::isRunning(const JobId & jobid) + bool BatchManager_LSF::isRunning(const JobId & jobid) { - throw EmulationException("Not yet implemented"); + throw NotYetImplementedException("BatchManager_LSF::isRunning"); } - std::string BatchManager_eLSF::buildSubmissionScript(const Job & job) + std::string BatchManager_LSF::buildSubmissionScript(const Job & job) { Parametre params = job.getParametre(); @@ -194,11 +156,11 @@ namespace Batch { if (params.find(WORKDIR) != params.end()) workDir = params[WORKDIR].str(); else - throw EmulationException("params[WORKDIR] is not defined ! Please defined it, cannot submit this job"); + throw RunTimeException("params[WORKDIR] is not defined ! Please defined it, cannot submit this job"); if (params.find(EXECUTABLE) != params.end()) fileToExecute = params[EXECUTABLE].str(); else - throw EmulationException("params[EXECUTABLE] is not defined ! Please defined it, cannot submit this job"); + throw RunTimeException("params[EXECUTABLE] is not defined ! Please defined it, cannot submit this job"); // Optional parameters if (params.find(NBPROC) != params.end()) @@ -217,7 +179,7 @@ namespace Batch { // Create batch submit file ofstream tempOutputFile; - std::string TmpFileName = createAndOpenTemporaryFile("LSF-script", tempOutputFile); + std::string TmpFileName = Utils::createAndOpenTemporaryFile("LSF-script", tempOutputFile); tempOutputFile << "#! /bin/sh -f" << endl ; if (params.find(NAME) != params.end()) @@ -273,7 +235,16 @@ namespace Batch { tempOutputFile << "export LIBBATCH_NODEFILE" << endl; // Launch the executable - tempOutputFile << "./" + fileNameToExecute << endl; + tempOutputFile << "./" + fileNameToExecute; + if (params.find(ARGUMENTS) != params.end()) { + Versatile V = params[ARGUMENTS]; + for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++) { + StringType argt = * static_cast(*it); + string arg = argt; + tempOutputFile << " " << arg; + } + } + tempOutputFile << endl; // Remove the node file tempOutputFile << "rm $LIBBATCH_NODEFILE" << endl; @@ -281,18 +252,18 @@ namespace Batch { tempOutputFile.flush(); tempOutputFile.close(); - cerr << "Batch script file generated is: " << TmpFileName.c_str() << endl; + LOG("Batch script file generated is: " << TmpFileName.c_str()); string remoteFileName = rootNameToExecute + "_Batch.sh"; int status = _protocol.copyFile(TmpFileName, "", "", workDir + "/" + remoteFileName, _hostname, _username); if (status) - throw EmulationException("Error of connection on remote host"); + throw RunTimeException("Error of connection on remote host"); return remoteFileName; } - std::string BatchManager_eLSF::getWallTime(const long edt) + std::string BatchManager_LSF::getWallTime(const long edt) { long h, m; h = edt / 60; @@ -305,7 +276,7 @@ namespace Batch { return oss.str(); } - std::string BatchManager_eLSF::getHomeDir(std::string tmpdir) + std::string BatchManager_LSF::getHomeDir(std::string tmpdir) { std::string home; int idx = tmpdir.find("Batch/"); @@ -314,10 +285,10 @@ namespace Batch { string subCommand = string("echo $HOME"); string command = _protocol.getExecCommand(subCommand, _hostname, _username) + " > " + filelogtemp; - cerr << command.c_str() << endl; + LOG(command); int status = system(command.c_str()); if (status) - throw EmulationException("Error of launching home command on remote host"); + throw RunTimeException("Error of launching home command on remote host"); std::ifstream file_home(filelogtemp.c_str()); std::getline(file_home, home); diff --git a/src/LSF/Batch_BatchManager_eLSF.hxx b/src/LSF/BatchManager_LSF.hxx similarity index 72% rename from src/LSF/Batch_BatchManager_eLSF.hxx rename to src/LSF/BatchManager_LSF.hxx index 57fa621..a794d91 100644 --- a/src/LSF/Batch_BatchManager_eLSF.hxx +++ b/src/LSF/BatchManager_LSF.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * BatchManager_eLSF.hxx : emulation of LSF client + * BatchManager_LSF.hxx : emulation of LSF client * * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr @@ -32,22 +32,22 @@ #ifndef _BATCHMANAGER_ELSF_H_ #define _BATCHMANAGER_ELSF_H_ -#include "Batch_Defines.hxx" -#include "Batch_JobId.hxx" -#include "Batch_JobInfo.hxx" -#include "Batch_FactBatchManager.hxx" -#include "Batch_BatchManager_eClient.hxx" +#include "Defines.hxx" +#include "JobId.hxx" +#include "JobInfo.hxx" +#include "FactBatchManager.hxx" +#include "BatchManager.hxx" namespace Batch { - class BATCH_EXPORT BatchManager_eLSF : public BatchManager_eClient + class BATCH_EXPORT BatchManager_LSF : public BatchManager { public: // Constructeur et destructeur - BatchManager_eLSF(const FactBatchManager * parent, const char * host="localhost", + BatchManager_LSF(const FactBatchManager * parent, const char * host="localhost", const char * username="", CommunicationProtocolType protocolType = SSH, const char * mpiImpl="nompi"); // connexion a la machine host - virtual ~BatchManager_eLSF(); + virtual ~BatchManager_LSF(); // Recupere le nom du serveur par defaut // static string BatchManager_LSF::getDefaultServer(); @@ -55,19 +55,12 @@ namespace Batch { // Methodes pour le controle des jobs virtual const JobId submitJob(const Job & job); // soumet un job au gestionnaire virtual void deleteJob(const JobId & jobid); // retire un job du gestionnaire - virtual void holdJob(const JobId & jobid); // suspend un job en file d'attente - virtual void releaseJob(const JobId & jobid); // relache un job suspendu - virtual void alterJob(const JobId & jobid, const Parametre & param, const Environnement & env); // modifie un job en file d'attente - virtual void alterJob(const JobId & jobid, const Parametre & param); // modifie un job en file d'attente - virtual void alterJob(const JobId & jobid, const Environnement & env); // modifie un job en file d'attente virtual JobInfo queryJob(const JobId & jobid); // renvoie l'etat du job virtual bool isRunning(const JobId & jobid); // teste si un job est present en machine virtual void setParametre(const JobId & jobid, const Parametre & param) { return alterJob(jobid, param); } // modifie un job en file d'attente virtual void setEnvironnement(const JobId & jobid, const Environnement & env) { return alterJob(jobid, env); } // modifie un job en file d'attente - virtual const Batch::JobId addJob(const Batch::Job & job, const std::string reference); // ajoute un nouveau job sans le soumettre - protected: std::string buildSubmissionScript(const Job & job); std::string getWallTime(const long edt); diff --git a/src/LSF/Batch_BatchManager_LSF.cxx b/src/LSF/Batch_BatchManager_LSF.cxx deleted file mode 100644 index 19f9613..0000000 --- a/src/LSF/Batch_BatchManager_LSF.cxx +++ /dev/null @@ -1,201 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * BatchManager_LSF.cxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Mail : mailto:ivan.dutka-malen@der.edf.fr - * Date : Thu Nov 6 10:17:22 2003 - * Projet : Salome 2 - * - */ - -extern "C" { -#include -#include -} -#include -#include -#include -#include -#include "Batch_BatchManager_LSF.hxx" - -using namespace std; - -namespace Batch { - - BatchManager_LSF::BatchManager_LSF(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager(parent, host) - { - // On se connecte au serveur LSF - _connect = lsb_init("Salome2 Batch library"); - if (_connect < 0) { // si erreur - char * errmsg = lsb_sysmsg(); - string msg = "LSF Server on host \""; - msg += _hostname; - msg += "\" : "; - msg += errmsg ? errmsg : "Reason unknown"; - throw ConnexionFailureException(msg.c_str()); - } - } - - // Destructeur - BatchManager_LSF::~BatchManager_LSF() - { - // Nothing to do - } - - // Methode pour le controle des jobs : soumet un job au gestionnaire - const JobId BatchManager_LSF::submitJob(const Job & job) - { - Job_LSF joblsf = job; - struct submitReply reply; - int ref = lsb_submit(joblsf.getSubmitStruct(), - &reply); - if (ref < 0) { // si erreur - char * msg = lsb_sysmsg(); - if (!msg) msg = "unknown"; - throw APIInternalFailureException(string("LSF submit error. Reason : ") + msg); - } - - ostringstream oss; - oss << ref; - JobId id(this, oss.str()); - return id; - } - - // Ce manager permet de faire de la reprise - const Batch::JobId - BatchManager_LSF::addJob(const Batch::Job & job, const std::string reference) - { - return JobId(this, reference); - } - - // Methode pour le controle des jobs : retire un job du gestionnaire - void BatchManager_LSF::deleteJob(const JobId & jobid) - { - int ref; - istringstream iss(jobid.getReference()); - iss >> ref; - int rc = lsb_deletejob(ref, 0, 0); - if (rc < 0) { // si erreur - char * msg = lsb_sysmsg(); - if (!msg) msg = "unknown"; - throw APIInternalFailureException(string("LSF deljob error. Reason : ") + msg); - } - } - - // Methode pour le controle des jobs : suspend un job en file d'attente - void BatchManager_LSF::holdJob(const JobId & jobid) - { - int ref; - istringstream iss(jobid.getReference()); - iss >> ref; - int rc = lsb_signaljob(ref, SIGSTOP); - if (rc < 0) { // si erreur - char * msg = lsb_sysmsg(); - if (!msg) msg = "unknown"; - throw APIInternalFailureException(string("LSF signaljob error. Reason : ") + msg); - } - } - - // Methode pour le controle des jobs : relache un job suspendu - void BatchManager_LSF::releaseJob(const JobId & jobid) - { - int ref; - istringstream iss(jobid.getReference()); - iss >> ref; - int rc = lsb_signaljob(ref, SIGCONT); - if (rc < 0) { // si erreur - char * msg = lsb_sysmsg(); - if (!msg) msg = "unknown"; - throw APIInternalFailureException(string("LSF signaljob error. Reason : ") + msg); - } - } - - - // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager_LSF::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env) - { - int ref; - istringstream iss(jobid.getReference()); - iss >> ref; - - Job_LSF joblsf = Job(param, env); - struct submitReply reply; - ref = lsb_modify(joblsf.getSubmitStruct(), - &reply, - ref); - if (ref < 0) { // si erreur - ostringstream msg_sst; - char * msg = lsb_sysmsg(); - if (!msg) msg = "unknown"; - msg_sst << msg << endl; -// msg_sst << "BadJobId = " << (long) reply.badJobId << endl -// << "BadJobName = " << reply.badJobName << endl -// << "BadReqIndx = " << reply.badReqIndx << endl; - throw APIInternalFailureException(string("LSF modify error. Reason : ") + msg_sst.str()); - } - } - - // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager_LSF::alterJob(const JobId & jobid, const Parametre & param) - { - alterJob(jobid, param, Environnement()); - } - - // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager_LSF::alterJob(const JobId & jobid, const Environnement & env) - { - alterJob(jobid, Parametre(), env); - } - - - - // Methode pour le controle des jobs : renvoie l'etat du job - JobInfo BatchManager_LSF::queryJob(const JobId & jobid) - { - int id; - istringstream iss(jobid.getReference()); - iss >> id; - - JobInfo_LSF ji = JobInfo_LSF(id); - - return ji; - } - - - - // Methode pour le controle des jobs : teste si un job est present en machine - bool BatchManager_LSF::isRunning(const JobId & jobid) - { - int id; - istringstream iss(jobid.getReference()); - iss >> id; - - JobInfo_LSF ji = JobInfo_LSF(id); - - return ji.isRunning(); - } - - - -} diff --git a/src/LSF/Batch_BatchManager_LSF.hxx b/src/LSF/Batch_BatchManager_LSF.hxx deleted file mode 100644 index d906b81..0000000 --- a/src/LSF/Batch_BatchManager_LSF.hxx +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * BatchManager_LSF.hxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Mail : mailto:ivan.dutka-malen@der.edf.fr - * Date : Thu Nov 6 10:17:22 2003 - * Projet : Salome 2 - * - */ - -#ifndef _BATCHMANAGER_LSF_H_ -#define _BATCHMANAGER_LSF_H_ - -#include "Batch_Defines.hxx" - -#include "Batch_Job.hxx" -#include "Batch_Job.hxx" -#include "Batch_JobId.hxx" -#include "Batch_JobInfo.hxx" -#include "Batch_JobInfo_LSF.hxx" -#include "Batch_Job_LSF.hxx" -#include "Batch_InvalidArgumentException.hxx" -#include "Batch_ConnexionFailureException.hxx" -#include "Batch_APIInternalFailureException.hxx" -#include "Batch_NotYetImplementedException.hxx" -#include "Batch_BatchManager.hxx" - -namespace Batch { - - class Job; - class JobId; - class JobInfo; - class FactBatchManager; - - class BATCH_EXPORT BatchManager_LSF : public BatchManager - { - public: - // Constructeur et destructeur - BatchManager_LSF(const FactBatchManager * parent, const char * host="localhost") throw(InvalidArgumentException,ConnexionFailureException); // connexion a la machine host - virtual ~BatchManager_LSF(); - - // Recupere le nom du serveur par defaut - // static string BatchManager_LSF::getDefaultServer(); - - // Methodes pour le controle des jobs - virtual const JobId submitJob(const Job & job); // soumet un job au gestionnaire - virtual void deleteJob(const JobId & jobid); // retire un job du gestionnaire - virtual void holdJob(const JobId & jobid); // suspend un job en file d'attente - virtual void releaseJob(const JobId & jobid); // relache un job suspendu - virtual void alterJob(const JobId & jobid, const Parametre & param, const Environnement & env); // modifie un job en file d'attente - virtual void alterJob(const JobId & jobid, const Parametre & param); // modifie un job en file d'attente - virtual void alterJob(const JobId & jobid, const Environnement & env); // modifie un job en file d'attente - virtual JobInfo queryJob(const JobId & jobid); // renvoie l'etat du job - virtual bool isRunning(const JobId & jobid); // teste si un job est present en machine - - virtual void setParametre(const JobId & jobid, const Parametre & param) { return alterJob(jobid, param); } // modifie un job en file d'attente - virtual void setEnvironnement(const JobId & jobid, const Environnement & env) { return alterJob(jobid, env); } // modifie un job en file d'attente - - virtual const Batch::JobId addJob(const Batch::Job & job, const std::string reference); // ajoute un nouveau job sans le soumettre - - protected: - int _connect; // LSF connect id - - private: - -#ifdef SWIG - public: - // Recupere le l'identifiant d'un job deja soumis au BatchManager - //virtual const JobId getJobIdByReference(const string & ref) { return BatchManager::getJobIdByReference(ref); } - virtual const JobId getJobIdByReference(const char * ref) { return BatchManager::getJobIdByReference(ref); } -#endif - - }; - -} - -#endif diff --git a/src/LSF/Batch_FactBatchManager_eLSF.cxx b/src/LSF/Batch_FactBatchManager_eLSF.cxx deleted file mode 100644 index e5387bf..0000000 --- a/src/LSF/Batch_FactBatchManager_eLSF.cxx +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * FactBatchManager_eLSF.cxx : - * - * Auteur : Bernard SECHER - CEA DEN - * Date : Avril 2008 - * Projet : PAL Salome - * - */ - -#include "Batch_BatchManager_eLSF.hxx" -#include "Batch_FactBatchManager_eLSF.hxx" - -namespace Batch { - - static FactBatchManager_eLSF sFBM_eLSF; - - // 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 * username, - CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node) const - { - // MESSAGE("Building new BatchManager_LSF on host '" << hostname << "'"); - return new BatchManager_eLSF(this, hostname, username, protocolType, mpiImpl); - } - -} diff --git a/src/LSF/Batch_FactBatchManager_eLSF.hxx b/src/LSF/Batch_FactBatchManager_eLSF.hxx deleted file mode 100644 index 6668068..0000000 --- a/src/LSF/Batch_FactBatchManager_eLSF.hxx +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * FactBatchManager_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 "Batch_BatchManager_eClient.hxx" -#include "Batch_FactBatchManager_eClient.hxx" - -namespace Batch { - - 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 * username, - CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node = 1) const; - - protected: - - private: - - }; - -} - -#endif diff --git a/src/LSF/Batch_JobInfo_LSF.cxx b/src/LSF/Batch_JobInfo_LSF.cxx deleted file mode 100644 index 66b84cc..0000000 --- a/src/LSF/Batch_JobInfo_LSF.cxx +++ /dev/null @@ -1,207 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * JobInfo_LSF.cxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Mail : mailto:ivan.dutka-malen@der.edf.fr - * Date : Fri Nov 21 09:42:06 2003 - * Projet : Salome 2 - * - */ - -#include -#include -#include - -#include "Batch_Constants.hxx" -#include "Batch_Parametre.hxx" -#include "Batch_Environnement.hxx" -#include "Batch_RunTimeException.hxx" -#include "Batch_APIInternalFailureException.hxx" -#include "Batch_JobInfo_LSF.hxx" - -using namespace std; - -namespace Batch { - - - - // Constructeurs - JobInfo_LSF::JobInfo_LSF(int id) : JobInfo() - { - struct loadIndexLog * p_ld = new struct loadIndexLog; - struct jobInfoHead * p_jInfoHead = lsb_openjobinfo_a(id, NULL, NULL, NULL, NULL, ALL_JOB); - - int more = p_jInfoHead->numJobs; - if (more != 1) { - char * msg = lsb_sysmsg(); - if (!msg) msg = "unknown"; - throw APIInternalFailureException(string("LSF lsb_openjobinfo error. Reason : ") + msg); - } - - // on remplit une structure contenant elements - struct jobInfoEnt & jobInfo = * lsb_readjobinfo(&more); - - - // On remplit les membres _param et _env - _param[ACCOUNT] = jobInfo.submit.projectName; - _param[CHECKPOINT] = jobInfo.submit.chkpntPeriod != 0; - _param[CKPTINTERVAL] = jobInfo.submit.chkpntPeriod; - _param[CREATIONTIME] = jobInfo.submitTime; - // _param[EGROUP] = jobInfo.; - _param[ELIGIBLETIME] = jobInfo.reserveTime; - _param[ENDTIME] = jobInfo.endTime; - _param[EUSER] = jobInfo.execUsername; - _param[EXECUTABLE] = jobInfo.submit.command; - _param[EXITCODE] = jobInfo.exitStatus; - _param[HOLD] = jobInfo.status & (JOB_STAT_PSUSP | JOB_STAT_SSUSP | JOB_STAT_USUSP); - _param[MAIL] = jobInfo.submit.mailUser; - _param[MAXCPUTIME] = jobInfo.submit.rLimits[LSF_RLIMIT_CPU]; - _param[MAXDISKSIZE] = jobInfo.submit.rLimits[LSF_RLIMIT_FSIZE]; - _param[MAXRAMSIZE] = jobInfo.submit.rLimits[LSF_RLIMIT_SWAP]; - _param[MAXWALLTIME] = jobInfo.submit.rLimits[LSF_RLIMIT_RUN]; - _param[MODIFICATIONTIME] = jobInfo.lastEvent; - _param[NAME] = jobInfo.jName; - _param[NBPROC] = jobInfo.submit.numProcessors; - _param[PID] = jobInfo.jobPid; - _param[QUEUE] = jobInfo.submit.queue; - _param[QUEUEDTIME] = jobInfo.submitTime; - // _param[SERVER] = jobInfo.; - _param[STARTTIME] = jobInfo.startTime; - _param[TEXT] = jobInfo.numReasons ? lsb_pendreason(jobInfo.numReasons, - jobInfo.reasonTb, - p_jInfoHead, - p_ld,0) : ""; - // _param[TMPDIR] = jobInfo.; - _param[USEDCPUTIME] = static_cast(jobInfo.cpuTime); - // _param[USEDDISKSIZE] = jobInfo.; - _param[USEDRAMSIZE] = jobInfo.runRusage.mem; - _param[USEDWALLTIME] = jobInfo.duration * 60L; - _param[USER] = jobInfo.user; - - - ostringstream oss; - int jobid = jobInfo.jobId; - oss << jobid; - _param[ID] = oss.str(); - - - string hosts, sep; - for(int i=0; i < jobInfo.numExHosts; i++, sep="+") { - hosts += jobInfo.exHosts[i]; - hosts += sep; - } - _param[EXECUTIONHOST] = hosts; - - ostringstream status; - - if (IS_PEND(jobInfo.status)) - status << " Job is pending;"; - if (IS_START(jobInfo.status)) - status << " Job is started;"; - if (IS_FINISH(jobInfo.status)) - status << " Job is finished;"; - if (IS_SUSP(jobInfo.status)) - status << " Job is suspended;"; - if (IS_POST_DONE(jobInfo.status)) - status << " Job is post-done;"; - if (IS_POST_ERR(jobInfo.status)) - status << " Job is post-error;"; - - // TODO: Use constants for STATE instead - _param[STATE] = status.str(); - _running = IS_FINISH(jobInfo.status) ? false : true; - - - if (strlen(jobInfo.submit.inFile)) - _param[INFILE] += Couple(jobInfo.submit.inFile, "stdin"); - if (strlen(jobInfo.submit.outFile)) - _param[OUTFILE] += Couple(jobInfo.submit.outFile, "stdout"); - if (strlen(jobInfo.submit.errFile)) - _param[OUTFILE] += Couple(jobInfo.submit.errFile, "stderr"); - - for(int i=0; i < jobInfo.submit.nxf; i++) { - switch (jobInfo.submit.xf[i].options) { - case XF_OP_SUB2EXEC: - _param[INFILE] += Couple(jobInfo.submit.xf[i].subFn, jobInfo.submit.xf[i].execFn); - break; - - case XF_OP_EXEC2SUB: - _param[OUTFILE] += Couple(jobInfo.submit.xf[i].subFn, jobInfo.submit.xf[i].execFn); - break; - - default: - break; - } - } - - - lsb_closejobinfo(); - delete p_ld; - } - - - - // Teste si un job est present en machine - bool JobInfo_LSF::isRunning() const - { - return _running; - } - - - // Destructeur - JobInfo_LSF::~JobInfo_LSF() - { - // Nothing to do - } - - - - // Convertit une date HH:MM:SS en secondes - long JobInfo_LSF::HMStoLong(const string & s) - { - long hour, min, sec; - - sscanf( s.c_str(), "%ld:%ld:%ld", &hour, &min, &sec); - return ( ( ( hour * 60L ) + min ) * 60L ) + sec; - } - - // Methode pour l'interfacage avec Python (SWIG) : affichage en Python - string JobInfo_LSF::__str__() const - { - ostringstream sst; - sst << " -#include -} -#include -#include "Batch_RunTimeException.hxx" -#include "Batch_JobInfo.hxx" - -namespace Batch { - - class JobInfo_LSF : public JobInfo - { - public: - // Constructeurs et destructeur - JobInfo_LSF() : _running(false) {}; - JobInfo_LSF(int id); - virtual ~JobInfo_LSF(); - - // Constructeur par recopie - JobInfo_LSF(const JobInfo_LSF & jinfo) : JobInfo(jinfo) {}; - - // Teste si un job est present en machine - virtual bool isRunning() const; - - // Methodes pour l'interfacage avec Python (SWIG) - // TODO : supprimer ces methodes et transferer leur definitions dans SWIG - std::string __str__() const; // SWIG : affichage en Python - std::string __repr__() const { return __str__(); }; // SWIG : affichage en Python - - protected: - bool _running; // etat du job en machine - - private: - // Convertit une date HH:MM:SS en secondes - long HMStoLong(const std::string &); - - }; - -} - -#endif diff --git a/src/LSF/Batch_Job_LSF.cxx b/src/LSF/Batch_Job_LSF.cxx deleted file mode 100644 index 4a3cd9c..0000000 --- a/src/LSF/Batch_Job_LSF.cxx +++ /dev/null @@ -1,266 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Job_LSF.cxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Mail : mailto:ivan.dutka-malen@der.edf.fr - * Date : Fri Nov 14 11:00:39 2003 - * Projet : Salome 2 - * - */ - -#include -#include -#include -#include -#include - -#include "Batch_Constants.hxx" -#include "Batch_Job_LSF.hxx" - -using namespace std; - -namespace Batch { - - - // Constructeur - Job_LSF::Job_LSF(const Job & job) : _p_submit(0) - { - Parametre P = job.getParametre(); - _p_submit = ParametreToSubmitStruct(P); - } - - - // Destructeur - Job_LSF::~Job_LSF() - { - if (_p_submit) { - if (_p_submit->jobName) delete [] _p_submit->jobName; - if (_p_submit->queue) delete [] _p_submit->queue; - if (_p_submit->askedHosts) { - delete [] *(_p_submit->askedHosts); - delete [] _p_submit->askedHosts; - } - if (_p_submit->resReq) delete [] _p_submit->resReq; - if (_p_submit->hostSpec) delete [] _p_submit->hostSpec; - if (_p_submit->dependCond) delete [] _p_submit->dependCond; - if (_p_submit->timeEvent) delete [] _p_submit->timeEvent; - if (_p_submit->inFile) delete [] _p_submit->inFile; - if (_p_submit->outFile) delete [] _p_submit->outFile; - if (_p_submit->errFile) delete [] _p_submit->errFile; - if (_p_submit->command) delete [] _p_submit->command; - if (_p_submit->newCommand) delete [] _p_submit->newCommand; - if (_p_submit->chkpntDir) delete [] _p_submit->chkpntDir; - if (_p_submit->xf) delete [] _p_submit->xf; - if (_p_submit->preExecCmd) delete [] _p_submit->preExecCmd; - if (_p_submit->mailUser) delete [] _p_submit->mailUser; - if (_p_submit->projectName) delete [] _p_submit->projectName; - if (_p_submit->loginShell) delete [] _p_submit->loginShell; - if (_p_submit->exceptList) delete [] _p_submit->exceptList; - delete _p_submit; - } - } - - - // Accesseur - struct submit * Job_LSF::getSubmitStruct() - { - return _p_submit; - } - - - char * Job_LSF::string2char(const string & s) - { - char * ch = new char [s.size() + 1]; - memset(ch, 0, s.size() + 1); - strncat(ch, s.c_str(), s.size()); - return ch; - } - - - struct submit * Job_LSF::ParametreToSubmitStruct(const Parametre & P) - { - if (! _p_submit) _p_submit = new struct submit; - - memset( (void *) _p_submit, 0, sizeof(struct submit)); - - struct submit & sub = * _p_submit; - sub.options = 0; - sub.options2 = 0; - - sub.beginTime = 0; // job can run as soon as possible (default) - sub.termTime = 0; // job can run as long as it wishes (default) - - sub.numProcessors = 1; // job can run on one single processor (default) - sub.maxNumProcessors = 1; // job can run on one single processor (default) - - for(int i = 0; i< LSF_RLIM_NLIMITS; i++) sub.rLimits[i] = DEFAULT_RLIMIT; - - typedef std::vector< struct xFile > XFTAB; - XFTAB xf_tab; - - string st_second; - for(Parametre::const_iterator it = P.begin(); it != P.end(); it++) { - if ( (*it).first == ACCOUNT ) { - sub.options |= SUB_PROJECT_NAME; - st_second = (*it).second.str(); - sub.projectName = string2char(st_second); - - } else if ( (*it).first == CHECKPOINT ) { - if (static_cast< long >((*it).second)) - sub.options |= SUB_CHKPNT_PERIOD; - else - sub.options &= ~ SUB_CHKPNT_PERIOD; - - } else if ( (*it).first == CKPTINTERVAL ) { - sub.chkpntPeriod = static_cast< long >((*it).second); - - } else if ( (*it).first == EXECUTABLE ) { - st_second = (*it).second.str(); - sub.command = string2char(st_second); - - } else if ( (*it).first == EXECUTIONHOST ) { - sub.options |= SUB_HOST; - if (! sub.numAskedHosts) { - sub.numAskedHosts = 1; - sub.askedHosts = new char* [1]; - } - st_second = (*it).second.str(); - sub.askedHosts[0] = string2char(st_second); - - } else if ( (*it).first == HOLD ) { - if (static_cast< long >((*it).second)) - sub.options2 |= SUB2_HOLD; - else - sub.options2 &= ~ SUB2_HOLD; - - } else if ( (*it).first == INFILE ) { - Versatile V = (*it).second; - Versatile::iterator Vit; - - for(Vit=V.begin(); Vit!=V.end(); Vit++) { - CoupleType cpt = *static_cast< CoupleType * >(*Vit); - Couple cp = cpt; - string local = cp.getLocal(); - string remote = cp.getRemote(); - - // ATTENTION : les notions de fichier "local" ou "remote" sont inverses de celle de PBS qui a un point de vue serveur et non pas utilisateur - if (remote == "stdin"){ - sub.options |= SUB_IN_FILE; - sub.inFile = string2char(local); - - } else { - struct xFile xf; - strncpy(xf.subFn, local.c_str(), MAXFILENAMELEN - 1); xf.subFn[MAXFILENAMELEN - 1] = 0; - strncpy(xf.execFn, remote.c_str(), MAXFILENAMELEN - 1); xf.execFn[MAXFILENAMELEN - 1] = 0; - xf.options = XF_OP_SUB2EXEC; - xf_tab.push_back(xf); - } - } - - } else if ( (*it).first == MAIL ) { - sub.options |= SUB_MAIL_USER; - st_second = (*it).second.str(); - sub.mailUser = string2char(st_second); - - } else if ( (*it).first == MAXCPUTIME ) { - sub.rLimits[LSF_RLIMIT_CPU] = static_cast< long >((*it).second); - - } else if ( (*it).first == MAXDISKSIZE ) { - sub.rLimits[LSF_RLIMIT_FSIZE] = static_cast< long >((*it).second); - - } else if ( (*it).first == MAXRAMSIZE ) { - sub.rLimits[LSF_RLIMIT_SWAP] = static_cast< long >((*it).second); - - } else if ( (*it).first == MAXWALLTIME ) { - sub.rLimits[LSF_RLIMIT_RUN] = static_cast< long >((*it).second); - - } else if ( (*it).first == NAME ) { - sub.options |= SUB_JOB_NAME; - st_second = (*it).second.str(); - sub.jobName = string2char(st_second); - - } else if ( (*it).first == NBPROC ) { - sub.numProcessors = static_cast< long >((*it).second); - sub.maxNumProcessors = static_cast< long >((*it).second); - - } else if ( (*it).first == OUTFILE ) { - Versatile V = (*it).second; - Versatile::iterator Vit; - - for(Vit=V.begin(); Vit!=V.end(); Vit++) { - CoupleType cpt = *static_cast< CoupleType * >(*Vit); - Couple cp = cpt; - string local = cp.getLocal(); - string remote = cp.getRemote(); - - // ATTENTION : les notions de fichier "local" ou "remote" sont inverses de celle de PBS qui a un point de vue serveur et non pas utilisateur - if (remote == "stdout"){ - sub.options |= SUB_OUT_FILE; - sub.outFile = string2char(local); - - } else if (remote == "stderr"){ - sub.options |= SUB_ERR_FILE; - sub.errFile = string2char(local); - - } else { - struct xFile xf; - strncpy(xf.subFn, local.c_str(), MAXFILENAMELEN - 1); xf.subFn[MAXFILENAMELEN - 1] = 0; - strncpy(xf.execFn, remote.c_str(), MAXFILENAMELEN - 1); xf.execFn[MAXFILENAMELEN - 1] = 0; - xf.options = XF_OP_EXEC2SUB; - xf_tab.push_back(xf); - } - } - - - } else if ( (*it).first == QUEUE ) { - sub.options |= SUB_QUEUE; - st_second = (*it).second.str(); - sub.queue = string2char(st_second); - - } else if ( (*it).first == STARTTIME ) { - sub.beginTime = static_cast< long >((*it).second); - - } else if ( (*it).first == TMPDIR ) { - // TODO - - } else if ( (*it).first == USER ) { - // TODO - - } - } - - - // Transfert de fichiers en entree et sortie - sub.options |= SUB_OTHER_FILES; - sub.nxf = xf_tab.size(); - sub.xf = new struct xFile [sub.nxf]; - int ixf = 0; - for(XFTAB::const_iterator it_xf=xf_tab.begin(); it_xf != xf_tab.end(); it_xf++, ixf++) - sub.xf[ixf] = *it_xf; // *it_xf == xf_tab[ixf] - - - return _p_submit; - } - -} diff --git a/src/LSF/CMakeLists.txt b/src/LSF/CMakeLists.txt index 53602e9..7268633 100644 --- a/src/LSF/CMakeLists.txt +++ b/src/LSF/CMakeLists.txt @@ -20,22 +20,13 @@ # 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 +SET(CLASS_LIST LSF/BatchManager_LSF + LSF/FactBatchManager_LSF + LSF/JobInfo_LSF ) -IF (BUILD_LSF_INTERFACE AND LSF_FOUND) - SET(CLASS_LIST ${CLASS_LIST} - LSF/Batch_BatchManager_LSF - LSF/Batch_FactBatchManager_LSF - LSF/Batch_Job_LSF - LSF/Batch_JobInfo_LSF - ) -ENDIF (BUILD_LSF_INTERFACE AND LSF_FOUND) - APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST}) -IF (TEST_ENABLED) - add_subdirectory(Test) -ENDIF (TEST_ENABLED) +IF (TEST_ENABLED AND HAS_SSH) + ADD_TEST(LSF_SSH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager LSF SSH) +ENDIF (TEST_ENABLED AND HAS_SSH) diff --git a/src/LSF/Batch_FactBatchManager_LSF.cxx b/src/LSF/FactBatchManager_LSF.cxx similarity index 74% rename from src/LSF/Batch_FactBatchManager_LSF.cxx rename to src/LSF/FactBatchManager_LSF.cxx index 93f5434..cb6990c 100644 --- a/src/LSF/Batch_FactBatchManager_LSF.cxx +++ b/src/LSF/FactBatchManager_LSF.cxx @@ -22,16 +22,14 @@ /* * FactBatchManager_LSF.cxx : * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Date : Septembre 2004 - * Projet : SALOME 2 + * Auteur : Bernard SECHER - CEA DEN + * Date : Avril 2008 + * Projet : PAL Salome * */ -#include -#include "Batch_BatchManager_LSF.hxx" -#include "Batch_FactBatchManager_LSF.hxx" -//#include "utilities.h" +#include "BatchManager_LSF.hxx" +#include "FactBatchManager_LSF.hxx" namespace Batch { @@ -49,12 +47,13 @@ namespace Batch { // Nothing to do } - // Functor - BatchManager * FactBatchManager_LSF::operator() (const char * hostname) const + BatchManager * FactBatchManager_LSF::operator() (const char * hostname, + const char * username, + CommunicationProtocolType protocolType, + const char * mpiImpl) const { // MESSAGE("Building new BatchManager_LSF on host '" << hostname << "'"); - return new BatchManager_LSF(this, hostname); + return new BatchManager_LSF(this, hostname, username, protocolType, mpiImpl); } - } diff --git a/src/LSF/Batch_FactBatchManager_LSF.hxx b/src/LSF/FactBatchManager_LSF.hxx similarity index 70% rename from src/LSF/Batch_FactBatchManager_LSF.hxx rename to src/LSF/FactBatchManager_LSF.hxx index b6770ce..fc191cb 100644 --- a/src/LSF/Batch_FactBatchManager_LSF.hxx +++ b/src/LSF/FactBatchManager_LSF.hxx @@ -22,33 +22,32 @@ /* * FactBatchManager_LSF.hxx : * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Date : Septembre 2004 - * Projet : SALOME 2 + * Auteur : Bernard SECHER : CEA DEN + * Date : Avril 2008 + * Projet : PAL Salome * */ #ifndef _FACTBATCHMANAGER_LSF_H_ #define _FACTBATCHMANAGER_LSF_H_ -#include "Batch_FactBatchManager.hxx" +#include "Defines.hxx" +#include "BatchManager.hxx" +#include "FactBatchManager.hxx" namespace Batch { - class BatchManager_LSF; - - class FactBatchManager_LSF : public FactBatchManager + class BATCH_EXPORT FactBatchManager_LSF : public FactBatchManager { public: - // Constructeur et destructeur + FactBatchManager_LSF(); virtual ~FactBatchManager_LSF(); - virtual BatchManager * operator() (const char * hostname) const; - - protected: - - private: + virtual BatchManager * operator() (const char * hostname, + const char * username, + CommunicationProtocolType protocolType, + const char * mpiImpl) const; }; diff --git a/src/LSF/Batch_JobInfo_eLSF.cxx b/src/LSF/JobInfo_LSF.cxx similarity index 87% rename from src/LSF/Batch_JobInfo_eLSF.cxx rename to src/LSF/JobInfo_LSF.cxx index 3f7ddec..2413b48 100644 --- a/src/LSF/Batch_JobInfo_eLSF.cxx +++ b/src/LSF/JobInfo_LSF.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * JobInfo_eLSF.cxx : emulation of LSF client + * JobInfo_LSF.cxx : emulation of LSF client * * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr @@ -32,15 +32,16 @@ #include #include -#include -#include "Batch_JobInfo_eLSF.hxx" +#include +#include "JobInfo_LSF.hxx" +#include "Log.hxx" using namespace std; namespace Batch { // Constructeurs - JobInfo_eLSF::JobInfo_eLSF(int id, const std::string & queryOutput) : JobInfo() + JobInfo_LSF::JobInfo_LSF(int id, const std::string & queryOutput) : JobInfo() { // Fill ID parameter ostringstream oss; @@ -82,7 +83,7 @@ namespace Batch { } else if (status == "ZOMBI") { // Zombie _param[STATE] = FAILED; } else { - cerr << "Unknown job state code: " << status << endl; + LOG("Unknown job state code: " << status); } if( status.find("RUN") != string::npos) @@ -91,20 +92,20 @@ namespace Batch { } // Teste si un job est present en machine - bool JobInfo_eLSF::isRunning() const + bool JobInfo_LSF::isRunning() const { return _running; } // Destructeur - JobInfo_eLSF::~JobInfo_eLSF() + JobInfo_LSF::~JobInfo_LSF() { // Nothing to do } // Convertit une date HH:MM:SS en secondes - long JobInfo_eLSF::HMStoLong(const string & s) + long JobInfo_LSF::HMStoLong(const string & s) { long hour, min, sec; @@ -113,10 +114,10 @@ namespace Batch { } // Methode pour l'interfacage avec Python (SWIG) : affichage en Python - string JobInfo_eLSF::__str__() const + string JobInfo_LSF::__str__() const { ostringstream sst; - sst << " namespace Batch { - class JobInfo_eLSF : public JobInfo + class JobInfo_LSF : public JobInfo { public: // Constructeurs et destructeur - JobInfo_eLSF() : _running(false) {}; - JobInfo_eLSF(int id, const std::string & queryOutput); - virtual ~JobInfo_eLSF(); + JobInfo_LSF() : _running(false) {}; + JobInfo_LSF(int id, const std::string & queryOutput); + virtual ~JobInfo_LSF(); // Constructeur par recopie - JobInfo_eLSF(const JobInfo_eLSF & jinfo) : JobInfo(jinfo) {}; + JobInfo_LSF(const JobInfo_LSF & jinfo) : JobInfo(jinfo) {}; // Teste si un job est present en machine virtual bool isRunning() const; diff --git a/src/LSF/Test/CMakeLists.txt b/src/LSF/Test/CMakeLists.txt deleted file mode 100644 index de1db94..0000000 --- a/src/LSF/Test/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# 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_SOURCE_DIR}/src/Core/Test) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -# Build the test programs and add the tests -add_executable(Test_eLSF Test_eLSF.cxx) -target_link_libraries(Test_eLSF Batch SimpleParser) - -IF (HAS_SSH) - ADD_TEST(eLSF_SSH Test_eLSF SSH) -ENDIF (HAS_SSH) - -#IF (HAS_RSH) -# ADD_TEST(eLSF_RSH Test_eLSF RSH) -#ENDIF (HAS_RSH) diff --git a/src/LSF/Test/Test_eLSF.cxx b/src/LSF/Test/Test_eLSF.cxx deleted file mode 100644 index 420e1ad..0000000 --- a/src/LSF/Test/Test_eLSF.cxx +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Test_eLSF.cxx : - * - * Author : Renaud BARATE - EDF R&D - * Date : September 2011 - * - */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -using namespace std; -using namespace Batch; - -void print_usage() -{ - cout << "usage: Test_eLSF PROTOCOL" << endl; - cout << " PROTOCOL \"SSH\" or \"RSH\"" << endl; -} - -int main(int argc, char** argv) -{ - // Parse argument - if (argc != 2) { - print_usage(); - return 1; - } - CommunicationProtocolType protocol; - if (strcmp(argv[1], "SSH") == 0) - protocol = SSH; - else if (strcmp(argv[1], "RSH") == 0) - protocol = RSH; - else { - print_usage(); - return 1; - } - - cout << "*******************************************************************************************" << endl; - cout << "This program tests the batch submission based on LSF emulation. Passwordless" << endl; - cout << "authentication must be used for this test to pass. For SSH, this can be configured with" << endl; - cout << "ssh-agent for instance. For RSH, this can be configured with the .rhosts file." << endl; - cout << "*******************************************************************************************" << endl; - - // eventually remove any previous result - remove("result.txt"); - - try { - // Parse the test configuration file - SimpleParser parser; - parser.parseTestConfigFile(); - const string & homedir = parser.getValue("TEST_ELSF_HOMEDIR"); - const string & host = parser.getValue("TEST_ELSF_HOST"); - const string & user = parser.getValue("TEST_ELSF_USER"); - int timeout = parser.getValueAsInt("TEST_ELSF_TIMEOUT"); - - // Define the job... - Job job; - // ... and its parameters ... - Parametre p; - p[EXECUTABLE] = "./test-script.sh"; - p[NAME] = string("Test_eLSF_") + argv[1]; - p[WORKDIR] = 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[NBPROC] = 1; - p[MAXWALLTIME] = 1; - p[MAXRAMSIZE] = 128; - p[HOMEDIR] = homedir; - p[EXCLUSIVE] = true; - job.setParametre(p); - // ... and its environment - Environnement e; - e["MYENVVAR"] = "MYVALUE"; - job.setEnvironnement(e); - cout << job << endl; - - // Get the catalog - BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); - - // Create a BatchManager of type ePBS on localhost - FactBatchManager_eClient * fbm = (FactBatchManager_eClient *)(c("eLSF")); - BatchManager_eClient * bm = (*fbm)(host.c_str(), user.c_str(), protocol); - - // Submit the job to the BatchManager - JobId jobid = bm->submitJob(job); - cout << jobid.__repr__() << endl; - - // Wait for the end of the job - string state = bm->waitForJobEnd(jobid, timeout); - - if (state == FINISHED) { - cout << "Job " << jobid.__repr__() << " is done" << endl; - bm->importOutputFiles(job, "resultdir/seconddirname"); - } else if (state == FAILED) { - cerr << "Job " << jobid.__repr__() << " finished in error" << endl; - bm->importOutputFiles(job, "resultdir/seconddirname"); - return 1; - } else { - cerr << "Timeout while executing job" << endl; - return 1; - } - - } catch (GenericException e) { - cerr << "Error: " << e << endl; - return 1; - } catch (ParserException e) { - cerr << "Parser error: " << e.what() << endl; - return 1; - } - - // test the result file - try { - SimpleParser resultParser; - resultParser.parse("resultdir/seconddirname/result.txt"); - cout << "Result:" << endl << resultParser; - const string & envvar = resultParser.getValue("MYENVVAR"); - int result = resultParser.getValueAsInt("c"); - if (envvar == "MYVALUE" && result == 12) { - cout << "OK, Expected result found." << endl; - return 0; - } else { - cerr << "Error, result is not the expected one (MYENVVAR = MYVALUE, c = 12)." << endl; - return 1; - } - } catch (ParserException e) { - cerr << "Parser error on result file: " << e.what() << endl; - return 1; - } -} diff --git a/src/LSF/Test/seta.sh b/src/LSF/Test/seta.sh deleted file mode 100644 index 42d1e38..0000000 --- a/src/LSF/Test/seta.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -a=4 diff --git a/src/LSF/Test/setb.sh b/src/LSF/Test/setb.sh deleted file mode 100644 index 8969060..0000000 --- a/src/LSF/Test/setb.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -b=3 diff --git a/src/LSF/Test/test-script.sh b/src/LSF/Test/test-script.sh deleted file mode 100755 index 1d56247..0000000 --- a/src/LSF/Test/test-script.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -. ./seta.sh -. ./setb.sh - -c=`expr $a "*" $b` - -echo "MYENVVAR = $MYENVVAR" > result.txt -echo "c = $c" >> result.txt diff --git a/src/LoadLeveler/Batch_BatchManager_eLL.cxx b/src/LoadLeveler/BatchManager_LL.cxx similarity index 63% rename from src/LoadLeveler/Batch_BatchManager_eLL.cxx rename to src/LoadLeveler/BatchManager_LL.cxx index 91ba2ca..f62871e 100644 --- a/src/LoadLeveler/Batch_BatchManager_eLL.cxx +++ b/src/LoadLeveler/BatchManager_LL.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_BatchManager_eLL.cxx : + * BatchManager_LL.cxx : * * Created on: 25 nov. 2010 * Author : Renaud BARATE - EDF R&D @@ -29,38 +29,36 @@ #include #include #include +#include -#include -#include +#include +#include -#include "Batch_FactBatchManager_eLL.hxx" -#include "Batch_BatchManager_eLL.hxx" -#include "Batch_JobInfo_eLL.hxx" +#include "FactBatchManager_LL.hxx" +#include "BatchManager_LL.hxx" +#include "JobInfo_LL.hxx" +#include "Log.hxx" using namespace std; namespace Batch { - BatchManager_eLL::BatchManager_eLL(const FactBatchManager * parent, const char * host, + BatchManager_LL::BatchManager_LL(const FactBatchManager * parent, const char * host, const char * username, - CommunicationProtocolType protocolType, const char * mpiImpl, - int nb_proc_per_node) - : BatchManager(parent, host), - BatchManager_eClient(parent, host, username, protocolType, mpiImpl), - _nb_proc_per_node(nb_proc_per_node) + CommunicationProtocolType protocolType, const char * mpiImpl) + : BatchManager(parent, host, username, protocolType, mpiImpl) { // Nothing to do } - BatchManager_eLL::~BatchManager_eLL() + BatchManager_LL::~BatchManager_LL() { // Nothing to do } // Method to submit a job to the batch manager - const JobId BatchManager_eLL::submitJob(const Job & job) + const JobId BatchManager_LL::submitJob(const Job & job) { - int status; Parametre params = job.getParametre(); const string workDir = params[WORKDIR]; @@ -70,34 +68,23 @@ namespace Batch { // build command file to submit the job and copy it on the server string cmdFile = buildCommandFile(job); - // define name of log file (local) - string logFile = generateTemporaryFileName("LL-submitlog"); - // define command to submit batch string subCommand = string("cd ") + workDir + "; llsubmit " + cmdFile; string command = _protocol.getExecCommand(subCommand, _hostname, _username); - command += " > "; - command += logFile; - cerr << command.c_str() << endl; - status = system(command.c_str()); - if (status) - { - ifstream error_message(logFile.c_str()); - string mess; - string temp; - while(getline(error_message, temp)) - mess += temp; - error_message.close(); - throw EmulationException("Error of connection on remote host, error was: " + mess); - } + LOG(command); - // read id of submitted job in log file + // submit job + string output; + int status = Utils::getCommandOutput(command, output); + LOG(output); + if (status != 0) throw RunTimeException("Can't submit job, error was: " + output); + + // find id of submitted job in output string jobref; - ifstream idfile(logFile.c_str()); + istringstream idfile(output); string line; while (idfile && line.compare(0, 9, "llsubmit:") != 0) getline(idfile, line); - idfile.close(); if (line.compare(0, 9, "llsubmit:") == 0) { string::size_type p1 = line.find_first_of("\""); @@ -106,7 +93,7 @@ namespace Batch { jobref = line.substr(p1 + 1, p2 - p1 - 1); } if (jobref.size() == 0) - throw EmulationException("Error in the submission of the job on the remote host"); + throw RunTimeException("Error in the submission of the job on the remote host"); JobId id(this, jobref); return id; @@ -116,7 +103,7 @@ namespace Batch { * Create LoadLeveler command file and copy it on the server. * Return the name of the remote file. */ - string BatchManager_eLL::buildCommandFile(const Job & job) + string BatchManager_LL::buildCommandFile(const Job & job) { Parametre params = job.getParametre(); @@ -129,11 +116,11 @@ namespace Batch { if (params.find(WORKDIR) != params.end()) workDir = params[WORKDIR].str(); else - throw EmulationException("params[WORKDIR] is not defined. Please define it, cannot submit this job."); + throw RunTimeException("params[WORKDIR] is not defined. Please define it, cannot submit this job."); if (params.find(EXECUTABLE) != params.end()) fileToExecute = params[EXECUTABLE].str(); else - throw EmulationException("params[EXECUTABLE] is not defined. Please define it, cannot submit this job."); + throw RunTimeException("params[EXECUTABLE] is not defined. Please define it, cannot submit this job."); string::size_type p1 = fileToExecute.find_last_of("/"); string::size_type p2 = fileToExecute.find_last_of("."); @@ -142,7 +129,7 @@ namespace Batch { // Create batch submit file ofstream tempOutputFile; - string tmpFileName = createAndOpenTemporaryFile("LL-script", tempOutputFile); + string tmpFileName = Utils::createAndOpenTemporaryFile("LL-script", tempOutputFile); tempOutputFile << "#!/bin/bash" << endl; tempOutputFile << "# @ output = " << workDir << "/logs/output.log." << rootNameToExecute << endl; @@ -155,6 +142,9 @@ namespace Batch { int nbproc = 1; if (params.find(NBPROC) != params.end()) nbproc = params[NBPROC]; + int nbprocpernode = 1; + if (params.find(NBPROCPERNODE) != params.end()) + nbprocpernode = params[NBPROCPERNODE]; if (params.find(EXCLUSIVE) != params.end()) { if (params[EXCLUSIVE]) @@ -175,7 +165,7 @@ namespace Batch { tempOutputFile << "# @ job_type = " << job_type << endl; if (job_type == "mpich") { - int nodes_requested = (nbproc + _nb_proc_per_node -1) / _nb_proc_per_node; + int nodes_requested = (nbproc + nbprocpernode -1) / nbprocpernode; tempOutputFile << "# @ node = " << nodes_requested << endl; tempOutputFile << "# @ total_tasks = " << nbproc << endl; } @@ -210,79 +200,45 @@ namespace Batch { tempOutputFile.flush(); tempOutputFile.close(); - cerr << "Batch script file generated is: " << tmpFileName << endl; + LOG("Batch script file generated is: " << tmpFileName); string remoteFileName = rootNameToExecute + "_LL.cmd"; int status = _protocol.copyFile(tmpFileName, "", "", workDir + "/" + remoteFileName, _hostname, _username); if (status) - throw EmulationException("Cannot copy command file on host " + _hostname); + throw RunTimeException("Cannot copy command file on host " + _hostname); return remoteFileName; } - void BatchManager_eLL::deleteJob(const JobId & jobid) + void BatchManager_LL::deleteJob(const JobId & jobid) { // define command to delete job string subCommand = "llcancel " + jobid.getReference(); string command = _protocol.getExecCommand(subCommand, _hostname, _username); - cerr << command.c_str() << endl; + LOG(command); int status = system(command.c_str()); if (status) - throw EmulationException("Can't delete job " + jobid.getReference()); + throw RunTimeException("Can't delete job " + jobid.getReference()); - cerr << "job " << jobid.getReference() << " killed" << endl; + LOG("job " << jobid.getReference() << " killed"); } - void BatchManager_eLL::holdJob(const JobId & jobid) + JobInfo BatchManager_LL::queryJob(const JobId & jobid) { - throw NotYetImplementedException("BatchManager_eLL::holdJob"); - } - - void BatchManager_eLL::releaseJob(const JobId & jobid) - { - throw NotYetImplementedException("BatchManager_eLL::releaseJob"); - } - - void BatchManager_eLL::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env) - { - throw NotYetImplementedException("BatchManager_eLL::alterJob"); - } - - void BatchManager_eLL::alterJob(const JobId & jobid, const Parametre & param) - { - throw NotYetImplementedException("BatchManager_eLL::alterJob"); - } - - void BatchManager_eLL::alterJob(const JobId & jobid, const Environnement & env) - { - throw NotYetImplementedException("BatchManager_eLL::alterJob"); - } - - JobInfo BatchManager_eLL::queryJob(const JobId & jobid) - { - // define name of log file (local) - string logFile = generateTemporaryFileName("LL-querylog-" + jobid.getReference()); - // define command to query batch string subCommand = "llq -f %st " + jobid.getReference(); string command = _protocol.getExecCommand(subCommand, _hostname, _username); - command += " > "; - command += logFile; - cerr << command.c_str() << endl; - int status = system(command.c_str()); + LOG(command); + string output; + int status = Utils::getCommandOutput(command, output); if (status != 0) - throw EmulationException("Can't query job " + jobid.getReference()); + throw RunTimeException("Can't query job " + jobid.getReference()); - JobInfo_eLL jobinfo = JobInfo_eLL(jobid.getReference(), logFile); + JobInfo_LL jobinfo = JobInfo_LL(jobid.getReference(), output); return jobinfo; } - const JobId BatchManager_eLL::addJob(const Job & job, const string reference) - { - return JobId(this, reference); - } - } diff --git a/src/LoadLeveler/Batch_BatchManager_eLL.hxx b/src/LoadLeveler/BatchManager_LL.hxx similarity index 62% rename from src/LoadLeveler/Batch_BatchManager_eLL.hxx rename to src/LoadLeveler/BatchManager_LL.hxx index 6516c28..6bfd342 100644 --- a/src/LoadLeveler/Batch_BatchManager_eLL.hxx +++ b/src/LoadLeveler/BatchManager_LL.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_BatchManager_eLL.hxx : + * BatchManager_LL.hxx : * * Created on: 25 nov. 2010 * Author : Renaud BARATE - EDF R&D @@ -31,39 +31,30 @@ #include -#include "Batch_Defines.hxx" -#include "Batch_JobId.hxx" -#include "Batch_JobInfo.hxx" -#include "Batch_FactBatchManager.hxx" -#include "Batch_BatchManager_eClient.hxx" +#include "Defines.hxx" +#include "JobId.hxx" +#include "JobInfo.hxx" +#include "FactBatchManager.hxx" +#include "BatchManager.hxx" namespace Batch { - class BATCH_EXPORT BatchManager_eLL : public BatchManager_eClient + class BATCH_EXPORT BatchManager_LL : public BatchManager { public: - BatchManager_eLL(const FactBatchManager * parent, const char * host = "localhost", + BatchManager_LL(const FactBatchManager * parent, const char * host = "localhost", const char * username = "", - CommunicationProtocolType protocolType = SSH, const char * mpiImpl = "nompi", - int nb_proc_per_node=1); - virtual ~BatchManager_eLL(); + CommunicationProtocolType protocolType = SSH, const char * mpiImpl = "nompi"); + virtual ~BatchManager_LL(); // Methods to control jobs virtual const JobId submitJob(const Job & job); virtual void deleteJob(const JobId & jobid); - virtual void holdJob(const JobId & jobid); - virtual void releaseJob(const JobId & jobid); - 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); virtual JobInfo queryJob(const JobId & jobid); - virtual const JobId addJob(const Job & job, const std::string reference); protected: std::string buildCommandFile(const Job & job); - int _nb_proc_per_node; - }; } diff --git a/src/LoadLeveler/Batch_FactBatchManager_eLL.cxx b/src/LoadLeveler/Batch_FactBatchManager_eLL.cxx deleted file mode 100644 index c983f82..0000000 --- a/src/LoadLeveler/Batch_FactBatchManager_eLL.cxx +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Batch_FactBatchManager_eLL.cxx : - * - * Created on: 25 nov. 2010 - * Author : Renaud BARATE - EDF R&D - */ - -#include "Batch_ParameterTypeMap.hxx" -#include "Batch_BatchManager_eLL.hxx" -#include "Batch_FactBatchManager_eLL.hxx" - -namespace Batch { - - def_Constant(LL_JOBTYPE); - - static FactBatchManager_eLL sFBM_eLL; - - FactBatchManager_eLL::FactBatchManager_eLL() : FactBatchManager_eClient("eLL") - { - // Add specific parameters - ParameterTypeMap::getInstance().addParameter(LL_JOBTYPE, STRING, 1); - } - - FactBatchManager_eLL::~FactBatchManager_eLL() - { - // Nothing to do - } - - // Functor - BatchManager * FactBatchManager_eLL::operator() (const char * hostname) const - { - // MESSAGE("Building new BatchManager_eLL on host '" << hostname << "'"); - return new BatchManager_eLL(this, hostname); - } - - BatchManager_eClient * FactBatchManager_eLL::operator() (const char * hostname, - const char * username, - CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node) const - { - // MESSAGE("Building new BatchManager_eLL on host '" << hostname << "'"); - return new BatchManager_eLL(this, hostname, username, protocolType, mpiImpl, nb_proc_per_node); - } - -} diff --git a/src/LoadLeveler/CMakeLists.txt b/src/LoadLeveler/CMakeLists.txt index aa8445f..a063420 100644 --- a/src/LoadLeveler/CMakeLists.txt +++ b/src/LoadLeveler/CMakeLists.txt @@ -20,13 +20,9 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -SET(CLASS_LIST LoadLeveler/Batch_BatchManager_eLL - LoadLeveler/Batch_FactBatchManager_eLL - LoadLeveler/Batch_JobInfo_eLL +SET(CLASS_LIST LoadLeveler/BatchManager_LL + LoadLeveler/FactBatchManager_LL + LoadLeveler/JobInfo_LL ) APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST}) - -IF (TEST_ENABLED) - add_subdirectory(Test) -ENDIF (TEST_ENABLED) diff --git a/src/LoadLeveler/FactBatchManager_LL.cxx b/src/LoadLeveler/FactBatchManager_LL.cxx new file mode 100644 index 0000000..501118d --- /dev/null +++ b/src/LoadLeveler/FactBatchManager_LL.cxx @@ -0,0 +1,59 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +/* + * FactBatchManager_LL.cxx : + * + * Created on: 25 nov. 2010 + * Author : Renaud BARATE - EDF R&D + */ + +#include "ParameterTypeMap.hxx" +#include "BatchManager_LL.hxx" +#include "FactBatchManager_LL.hxx" + +namespace Batch { + + def_Constant(LL_JOBTYPE); + + static FactBatchManager_LL sFBM_LL; + + FactBatchManager_LL::FactBatchManager_LL() : FactBatchManager("LL") + { + // Add specific parameters + ParameterTypeMap::getInstance().addParameter(LL_JOBTYPE, STRING, 1); + } + + FactBatchManager_LL::~FactBatchManager_LL() + { + // Nothing to do + } + + BatchManager * FactBatchManager_LL::operator() (const char * hostname, + const char * username, + CommunicationProtocolType protocolType, + const char * mpiImpl) const + { + // MESSAGE("Building new BatchManager_LL on host '" << hostname << "'"); + return new BatchManager_LL(this, hostname, username, protocolType, mpiImpl); + } + +} diff --git a/src/LoadLeveler/Batch_FactBatchManager_eLL.hxx b/src/LoadLeveler/FactBatchManager_LL.hxx similarity index 61% rename from src/LoadLeveler/Batch_FactBatchManager_eLL.hxx rename to src/LoadLeveler/FactBatchManager_LL.hxx index a37cb6e..de5e242 100644 --- a/src/LoadLeveler/Batch_FactBatchManager_eLL.hxx +++ b/src/LoadLeveler/FactBatchManager_LL.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_FactBatchManager_eLL.hxx : + * FactBatchManager_LL.hxx : * * Created on: 25 nov. 2010 * Author : Renaud BARATE - EDF R&D @@ -29,32 +29,29 @@ #ifndef _FACTBATCHMANAGER_ELL_H_ #define _FACTBATCHMANAGER_ELL_H_ -#include -#include +#include +#include -#include "Batch_BatchManager_eClient.hxx" -#include "Batch_FactBatchManager_eClient.hxx" +#include "BatchManager.hxx" +#include "FactBatchManager.hxx" namespace Batch { decl_extern_Constant(LL_JOBTYPE); - class BatchManager_eLL; + class BatchManager_LL; - class BATCH_EXPORT FactBatchManager_eLL : public FactBatchManager_eClient + class BATCH_EXPORT FactBatchManager_LL : public FactBatchManager { public: // Constructeur et destructeur - FactBatchManager_eLL(); - virtual ~FactBatchManager_eLL(); - - virtual BatchManager * operator() (const char * hostname) const; - virtual BatchManager_eClient * operator() (const char * hostname, - const char * username, - CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node = 1) const; + FactBatchManager_LL(); + virtual ~FactBatchManager_LL(); + virtual BatchManager * operator() (const char * hostname, + const char * username, + CommunicationProtocolType protocolType, + const char * mpiImpl) const; }; } diff --git a/src/LoadLeveler/Batch_JobInfo_eLL.cxx b/src/LoadLeveler/JobInfo_LL.cxx similarity index 92% rename from src/LoadLeveler/Batch_JobInfo_eLL.cxx rename to src/LoadLeveler/JobInfo_LL.cxx index 13ab39c..188f6b8 100644 --- a/src/LoadLeveler/Batch_JobInfo_eLL.cxx +++ b/src/LoadLeveler/JobInfo_LL.cxx @@ -20,38 +20,36 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_JobInfo_eLL.cxx : + * JobInfo_LL.cxx : * * Created on: 30 nov. 2010 * Author : Renaud BARATE - EDF R&D */ #include -#include #include -#include -#include +#include +#include -#include "Batch_JobInfo_eLL.hxx" +#include "JobInfo_LL.hxx" using namespace std; namespace Batch { - JobInfo_eLL::JobInfo_eLL(const std::string & id, const std::string & logFile) + JobInfo_LL::JobInfo_LL(const std::string & id, const std::string & output) : JobInfo() { _param[ID] = id; // read log file - ifstream log(logFile.c_str()); + istringstream log(output); string line; // status should be on the third line for (int i=0 ; i<3 ; i++) getline(log, line); - log.close(); string status; istringstream iss(line); iss >> status; @@ -114,7 +112,7 @@ namespace Batch { } } - JobInfo_eLL::~JobInfo_eLL() + JobInfo_LL::~JobInfo_LL() { // Nothing to do } diff --git a/src/LoadLeveler/Batch_JobInfo_eLL.hxx b/src/LoadLeveler/JobInfo_LL.hxx similarity index 86% rename from src/LoadLeveler/Batch_JobInfo_eLL.hxx rename to src/LoadLeveler/JobInfo_LL.hxx index a4ec9f1..770bc5c 100644 --- a/src/LoadLeveler/Batch_JobInfo_eLL.hxx +++ b/src/LoadLeveler/JobInfo_LL.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_JobInfo_eLL.hxx : + * JobInfo_LL.hxx : * * Created on: 30 nov. 2010 * Author : Renaud BARATE - EDF R&D @@ -31,15 +31,15 @@ #include -#include +#include namespace Batch { - class JobInfo_eLL : public JobInfo + class JobInfo_LL : public JobInfo { public: - JobInfo_eLL(const std::string & id, const std::string & logFile); - virtual ~JobInfo_eLL(); + JobInfo_LL(const std::string & id, const std::string & output); + virtual ~JobInfo_LL(); }; diff --git a/src/LoadLeveler/Test/CMakeLists.txt b/src/LoadLeveler/Test/CMakeLists.txt deleted file mode 100644 index 293c8ff..0000000 --- a/src/LoadLeveler/Test/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# 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_SOURCE_DIR}/src/Core/Test) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -# Build the test programs and add the tests -add_executable(Test_eLL Test_eLL.cxx) -target_link_libraries(Test_eLL Batch SimpleParser) - -IF (HAS_SSH) - ADD_TEST(eLL_SSH Test_eLL SSH) -ENDIF (HAS_SSH) - -#IF (HAS_RSH) -# ADD_TEST(eLL_RSH Test_eLL RSH) -#ENDIF (HAS_RSH) diff --git a/src/LoadLeveler/Test/seta.sh b/src/LoadLeveler/Test/seta.sh deleted file mode 100644 index 42d1e38..0000000 --- a/src/LoadLeveler/Test/seta.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -a=4 diff --git a/src/LoadLeveler/Test/setb.sh b/src/LoadLeveler/Test/setb.sh deleted file mode 100644 index 8969060..0000000 --- a/src/LoadLeveler/Test/setb.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -b=3 diff --git a/src/LoadLeveler/Test/test-script.sh b/src/LoadLeveler/Test/test-script.sh deleted file mode 100755 index ae952c8..0000000 --- a/src/LoadLeveler/Test/test-script.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -source seta.sh -source setb.sh - -c=`expr $a "*" $b` - -echo "MYENVVAR = $MYENVVAR" > result.txt -echo "c = $c" >> result.txt diff --git a/src/Local/Batch_BatchManager_Local.cxx b/src/Local/BatchManager_Local.cxx similarity index 60% rename from src/Local/Batch_BatchManager_Local.cxx rename to src/Local/BatchManager_Local.cxx index 2098e1c..6d1ae1a 100644 --- a/src/Local/Batch_BatchManager_Local.cxx +++ b/src/Local/BatchManager_Local.cxx @@ -51,10 +51,12 @@ #include #include -#include "Batch_Constants.hxx" -#include "Batch_IOMutex.hxx" -#include "Batch_BatchManager_Local.hxx" -#include "Batch_RunTimeException.hxx" +#include "Constants.hxx" +#include "IOMutex.hxx" +#include "BatchManager_Local.hxx" +#include "RunTimeException.hxx" +#include "Utils.hxx" +#include "Log.hxx" using namespace std; @@ -62,10 +64,10 @@ namespace Batch { // Constructeur - BatchManager_Local::BatchManager_Local(const FactBatchManager * parent, const char * host, - CommunicationProtocolType protocolType) - : BatchManager(parent, host), _connect(0), - _protocol(CommunicationProtocol::getInstance(protocolType)), + BatchManager_Local::BatchManager_Local(const Batch::FactBatchManager * parent, const char * host, + const char * username, + CommunicationProtocolType protocolType, const char * mpiImpl) + : BatchManager(parent, host, username, protocolType, mpiImpl), _connect(0), _idCounter(0) { pthread_mutex_init(&_threads_mutex, NULL); @@ -79,8 +81,8 @@ namespace Batch { pthread_mutex_lock(&_threads_mutex); string state = iter->second.param[STATE]; if (state != FINISHED && state != FAILED) { - UNDER_LOCK( cout << "Warning: Job " << iter->first << - " is not finished, it will now be canceled." << endl ); + UNDER_LOCK( LOG("Warning: Job " << iter->first << + " is not finished, it will now be canceled.")); pthread_cancel(iter->second.thread_id); pthread_cond_wait(&_threadSyncCondition, &_threads_mutex); } @@ -90,14 +92,12 @@ namespace Batch { pthread_cond_destroy(&_threadSyncCondition); } - const CommunicationProtocol & BatchManager_Local::getProtocol() const - { - return _protocol; - } - // Methode pour le controle des jobs : soumet un job au gestionnaire const JobId BatchManager_Local::submitJob(const Job & job) { + // export input files in the working directory of the execution host + exportInputFiles(job); + Job_Local jobLocal = job; Id id = _idCounter++; ThreadAdapter * p_ta = new ThreadAdapter(*this, job, id); @@ -148,8 +148,7 @@ namespace Batch { pthread_cancel(_threads[id].thread_id); pthread_cond_wait(&_threadSyncCondition, &_threads_mutex); } else { - cout << "Cannot delete job " << jobid.getReference() << - ". Job is already finished." << endl; + LOG("Cannot delete job " << jobid.getReference() << ". Job is already finished."); } } pthread_mutex_unlock(&_threads_mutex); @@ -166,7 +165,7 @@ namespace Batch { istringstream iss(jobid.getReference()); iss >> id; - UNDER_LOCK( cout << "BatchManager is sending HOLD command to the thread " << id << endl ); + UNDER_LOCK( LOG("BatchManager is sending HOLD command to the thread " << id) ); // On introduit une commande dans la queue du thread // @@@ --------> SECTION CRITIQUE <-------- @@@ @@ -184,7 +183,7 @@ namespace Batch { istringstream iss(jobid.getReference()); iss >> id; - UNDER_LOCK( cout << "BatchManager is sending RELEASE command to the thread " << id << endl ); + UNDER_LOCK( LOG("BatchManager is sending RELEASE command to the thread " << id) ); // On introduit une commande dans la queue du thread // @@@ --------> SECTION CRITIQUE <-------- @@@ @@ -195,26 +194,6 @@ namespace Batch { // @@@ --------> 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) { @@ -249,7 +228,7 @@ namespace Batch { // On force donc l'état du job à erreur - pour cela on ne donne pas d'Id // au JobId const Batch::JobId - BatchManager_Local::addJob(const Batch::Job & job, const std::string reference) + BatchManager_Local::addJob(const Batch::Job & job, const std::string & reference) { return JobId(this, "undefined"); } @@ -272,55 +251,158 @@ namespace Batch { return running; } - - vector BatchManager_Local::exec_command(const Parametre & param) const + string BatchManager_Local::ThreadAdapter::buildCommandFile(const Job_Local & job) { - ostringstream exec_sub_cmd; + Parametre param = job.getParametre(); + + // Mandatory parameters + string workDir = ""; + if (param.find(WORKDIR) != param.end()) + workDir = param[WORKDIR].str(); + else + throw RunTimeException("param[WORKDIR] is not defined. Please define it, cannot submit this job."); + string fileToExecute = ""; + if (param.find(EXECUTABLE) != param.end()) + fileToExecute = param[EXECUTABLE].str(); + else + throw RunTimeException("param[EXECUTABLE] is not defined. Please define it, cannot submit this job."); + + string::size_type p1 = fileToExecute.find_last_of("/"); + string::size_type p2 = fileToExecute.find_last_of("."); + string rootNameToExecute = fileToExecute.substr(p1+1,p2-p1-1); + string fileNameToExecute = fileToExecute.substr(p1+1); + string remotePath = workDir + "/" + rootNameToExecute + "_launch_job"; + + // Create batch submit file + ofstream tempOutputFile; + string tmpFileName = Utils::createAndOpenTemporaryFile("launch-job", tempOutputFile); #ifdef WIN32 - char drive[_MAX_DRIVE]; - _splitpath(string(param[WORKDIR]).c_str(), drive, NULL, NULL, NULL); - if (strlen(drive) > 0) exec_sub_cmd << drive << " && "; + if (_bm._protocol.getType() == SH) { + char drive[_MAX_DRIVE]; + _splitpath(workDir.c_str(), drive, NULL, NULL, NULL); + if (strlen(drive) > 0) tempOutputFile << drive << endl; + tempOutputFile << "cd " << Utils::fixPath(workDir) << endl; + // Define environment for the job + Environnement env = job.getEnvironnement(); + for (Environnement::const_iterator iter = env.begin() ; iter != env.end() ; ++iter) { + tempOutputFile << "set " << iter->first << "=" << iter->second << endl; + } + // Launch the executable + tempOutputFile << fileNameToExecute; + 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; + tempOutputFile << " " << arg; + } + } + remotePath += ".bat"; + } else { #endif - exec_sub_cmd << "cd " << param[WORKDIR] << " && " << param[EXECUTABLE]; + tempOutputFile << "#!/bin/sh" << endl; + tempOutputFile << "cd " << workDir << endl; + + // Optional parameters (system limits on the job process) + if (param.find(MAXCPUTIME) != param.end()) { + long maxcputime = (long)param[MAXCPUTIME] * 60; + tempOutputFile << "ulimit -H -t " << maxcputime << endl; + } + + if (param.find(MAXDISKSIZE) != param.end()) { + long maxdisksize = (long)param[MAXDISKSIZE] * 1024; + tempOutputFile << "ulimit -H -f " << maxdisksize << endl; + } + + if (param.find(MAXRAMSIZE) != param.end()) { + long maxramsize = (long)param[MAXRAMSIZE] * 1024; + tempOutputFile << "ulimit -H -v " << maxramsize << endl; + } + // Define environment for the job + Environnement env = job.getEnvironnement(); + for (Environnement::const_iterator iter = env.begin() ; iter != env.end() ; ++iter) { + tempOutputFile << "export " << iter->first << "=" << iter->second << endl; + } + + // generate nodes file + tempOutputFile << "LIBBATCH_NODEFILE=`mktemp nodefile-XXXXXXXXXX`" << endl; + tempOutputFile << "echo `hostname` > $LIBBATCH_NODEFILE" << endl; + tempOutputFile << "export LIBBATCH_NODEFILE" << endl; + + // Launch the executable + tempOutputFile << "./" + fileNameToExecute; 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; + tempOutputFile << " " << arg; } } + // Standard input and output if (param.find(INFILE) != param.end()) { Versatile V = param[INFILE]; for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++) { Couple cpl = * static_cast(*it); string remote = cpl.getRemote(); if (remote == "stdin") - exec_sub_cmd << " (*it); string remote = cpl.getRemote(); - if (remote == "stdout") exec_sub_cmd << " 1>stdout"; - if (remote == "stderr") exec_sub_cmd << " 2>stderr"; + if (remote == "stdout") stdoutFile = "stdout"; + if (remote == "stderr") stderrFile = "stderr"; } } + tempOutputFile << " 1>" << stdoutFile << " 2>" << stderrFile << endl; + + // Remove the node file + tempOutputFile << "rm $LIBBATCH_NODEFILE" << endl; - string user; - Parametre::const_iterator it = param.find(USER); - if (it != param.end()) { - user = string(it->second); +#ifdef WIN32 } +#endif + + tempOutputFile.flush(); + tempOutputFile.close(); - return _protocol.getExecCommandArgs(exec_sub_cmd.str(), param[EXECUTIONHOST], user); + LOG("Batch script file generated is: " << tmpFileName); + + Utils::chmod(tmpFileName.c_str(), 0x1ED); + int status = _bm._protocol.copyFile(tmpFileName, "", "", + remotePath, _bm._hostname, _bm._username); + if (status) + throw RunTimeException("Cannot copy command file on host " + _bm._hostname); + +#ifdef WIN32 + if (_bm._protocol.getType() != SH) { + // On Windows, we make the remote file executable afterward because + // pscp does not preserve access permissions on files + string subCommand = string("chmod u+x ") + remotePath; + string command = _bm._protocol.getExecCommand(subCommand, _bm._hostname, _bm._username); + LOG(command); + status = system(command.c_str()); + if (status) { + std::ostringstream oss; + oss << "Cannot change permissions of file " << remotePath << " on host " << _bm._hostname; + oss << ". Return status is " << status; + throw RunTimeException(oss.str()); + } + } +#endif + + return remotePath; } @@ -359,71 +441,6 @@ namespace Batch { pthread_cleanup_push(BatchManager_Local::setFailedOnCancel, arg); pthread_cleanup_push(BatchManager_Local::kill_child_on_exit, static_cast (&child)); - - // 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]); - string user; - if ( (it = param.find(USER)) != param.end() ) { - user = string(it->second); - } - - 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(); - - std::cerr << workdir << std::endl; - std::cerr << remote << std::endl; - - int status = p_ta->getBatchManager().getProtocol().copyFile(local, "", "", - workdir + "/" + remote, - executionhost, user); - if (status) { - // Echec de la copie - rc |= 1; - } else { - // On enregistre le fichier comme etant a detruire - files_to_delete.push_back(workdir + "/" + remote); - } - - } - } - - - - // On forke/exec un nouveau process pour pouvoir controler le fils // (plus finement qu'avec un appel system) // int rc = system(commande.c_str()); @@ -435,7 +452,7 @@ namespace Batch { #else child = fork(); if (child < 0) { // erreur - UNDER_LOCK( cerr << "Fork impossible (rc=" << child << ")" << endl ); + UNDER_LOCK( LOG("Fork impossible (rc=" << child << ")") ); } else if (child > 0) { // pere p_ta->pere(child); @@ -445,47 +462,6 @@ namespace Batch { } #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(); - - int status = p_ta->getBatchManager().getProtocol().copyFile(workdir + "/" + remote, - executionhost, user, - local, "", ""); - if (status) { - // 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++) { - p_ta->getBatchManager().getProtocol().removeFile(*it, executionhost, user); -/* string remove_cmd = p_ta->getBatchManager().remove_command(user, executionhost, *it); - UNDER_LOCK( cout << "Removing : " << remove_cmd << endl ); -#ifdef WIN32 - remove_cmd = string("\"") + remove_cmd + string("\""); -#endif - system(remove_cmd.c_str());*/ - } - } - pthread_mutex_lock(&p_ta->_bm._threads_mutex); // Set the job state to FINISHED or FAILED @@ -505,7 +481,7 @@ namespace Batch { // On invoque la fonction de nettoyage de la memoire delete_on_exit(arg); - UNDER_LOCK( cout << "Father is leaving" << endl ); + UNDER_LOCK( LOG("Father is leaving") ); pthread_exit(NULL); return NULL; } @@ -527,9 +503,6 @@ namespace Batch { id_sst << _id; param[ID] = id_sst.str(); param[STATE] = Batch::RUNNING; -#ifndef WIN32 - param[PID] = child; -#endif _bm._threads[_id].thread_id = thread_id; #ifndef WIN32 @@ -551,22 +524,22 @@ namespace Batch { DWORD exitCode; GetExitCodeProcess(child, &exitCode); if (exitCode != STILL_ACTIVE) { - UNDER_LOCK( cout << "Father sees his child is DONE: exit code = " << exitCode << endl ); + UNDER_LOCK( LOG("Father sees his child is DONE: exit code = " << exitCode) ); break; } #else int child_rc = 0; pid_t child_wait_rc = waitpid(child, &child_rc, WNOHANG /* | WUNTRACED */); if (child_wait_rc > 0) { - UNDER_LOCK( cout << "Status is: " << WIFEXITED( child_rc) << endl); - UNDER_LOCK( cout << "Status is: " << WEXITSTATUS( child_rc) << endl); - UNDER_LOCK( cout << "Status is: " << WIFSIGNALED( child_rc) << endl); - UNDER_LOCK( cout << "Status is: " << WTERMSIG( child_rc) << endl); - UNDER_LOCK( cout << "Status is: " << WCOREDUMP( child_rc) << endl); - UNDER_LOCK( cout << "Status is: " << WIFSTOPPED( child_rc) << endl); - UNDER_LOCK( cout << "Status is: " << WSTOPSIG( child_rc) << endl); + UNDER_LOCK( LOG("Status is: " << WIFEXITED( child_rc)) ); + UNDER_LOCK( LOG("Status is: " << WEXITSTATUS( child_rc)) ); + UNDER_LOCK( LOG("Status is: " << WIFSIGNALED( child_rc)) ); + UNDER_LOCK( LOG("Status is: " << WTERMSIG( child_rc)) ); + UNDER_LOCK( LOG("Status is: " << WCOREDUMP( child_rc)) ); + UNDER_LOCK( LOG("Status is: " << WIFSTOPPED( child_rc)) ); + UNDER_LOCK( LOG("Status is: " << WSTOPSIG( child_rc)) ); #ifdef WIFCONTINUED - UNDER_LOCK( cout << "Status is: " << WIFCONTINUED( child_rc) << endl); // not compilable on sarge + UNDER_LOCK( LOG("Status is: " << WIFCONTINUED( child_rc)) ); // not compilable on sarge #endif if (WIFSTOPPED(child_rc)) { // NOTA : pour rentrer dans cette section, il faut que le flag WUNTRACED @@ -580,12 +553,12 @@ namespace Batch { _bm._threads[_id].param[STATE] = Batch::PAUSED; pthread_mutex_unlock(&_bm._threads_mutex); // @@@ --------> SECTION CRITIQUE <-------- @@@ - UNDER_LOCK( cout << "Father sees his child is STOPPED : " << child_wait_rc << endl ); + UNDER_LOCK( LOG("Father sees his child is STOPPED : " << child_wait_rc) ); } else { // Le fils est termine, on sort de la boucle et du if englobant - UNDER_LOCK( cout << "Father sees his child is DONE : " << child_wait_rc << " (child_rc=" << (WIFEXITED(child_rc) ? WEXITSTATUS(child_rc) : -1) << ")" << endl ); + UNDER_LOCK( LOG("Father sees his child is DONE : " << child_wait_rc << " (child_rc=" << (WIFEXITED(child_rc) ? WEXITSTATUS(child_rc) : -1) << ")") ); break; } } @@ -596,7 +569,7 @@ namespace Batch { _bm._threads[_id].hasFailed = true; pthread_mutex_unlock(&_bm._threads_mutex); // @@@ --------> SECTION CRITIQUE <-------- @@@ - UNDER_LOCK( cout << "Father sees his child is DEAD : " << child_wait_rc << " (Reason : " << strerror(errno) << ")" << endl ); + UNDER_LOCK( LOG("Father sees his child is DEAD : " << child_wait_rc << " (Reason : " << strerror(errno) << ")") ); break; } #endif @@ -617,7 +590,7 @@ namespace Batch { // << "maxwalltime = " << maxwalltime << endl // << "int(maxwalltime * 1.1) = " << int(maxwalltime * 1.1) << endl; if (child_elapsedtime_minutes > long((float)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 ); + UNDER_LOCK( LOG("Father is sending KILL command to the thread " << _id) ); // On introduit une commande dans la queue du thread // @@@ --------> SECTION CRITIQUE <-------- @@@ pthread_mutex_lock(&_bm._threads_mutex); @@ -628,7 +601,7 @@ namespace Batch { } else if (child_elapsedtime_minutes > maxwalltime ) { - UNDER_LOCK( cout << "Father is sending TERM command to the thread " << _id << endl ); + UNDER_LOCK( LOG("Father is sending TERM command to the thread " << _id) ); // On introduit une commande dans la queue du thread // @@@ --------> SECTION CRITIQUE <-------- @@@ pthread_mutex_lock(&_bm._threads_mutex); @@ -651,26 +624,26 @@ namespace Batch { switch (cmd) { case NOP: - UNDER_LOCK( cout << "Father does nothing to his child" << endl ); + UNDER_LOCK( LOG("Father does nothing to his child") ); break; #ifndef WIN32 case HOLD: - UNDER_LOCK( cout << "Father is sending SIGSTOP signal to his child" << endl ); + UNDER_LOCK( LOG("Father is sending SIGSTOP signal to his child") ); kill(child, SIGSTOP); break; case RELEASE: - UNDER_LOCK( cout << "Father is sending SIGCONT signal to his child" << endl ); + UNDER_LOCK( LOG("Father is sending SIGCONT signal to his child") ); kill(child, SIGCONT); break; case TERM: - UNDER_LOCK( cout << "Father is sending SIGTERM signal to his child" << endl ); + UNDER_LOCK( LOG("Father is sending SIGTERM signal to his child") ); kill(child, SIGTERM); break; case KILL: - UNDER_LOCK( cout << "Father is sending SIGKILL signal to his child" << endl ); + UNDER_LOCK( LOG("Father is sending SIGKILL signal to his child") ); kill(child, SIGKILL); break; #endif @@ -706,17 +679,13 @@ namespace Batch { Parametre param = _job.getParametre(); Parametre::iterator it; - //char *const parmList[] = {"/usr/bin/ssh", "localhost", "-l", "aribes", "sleep 1 && echo end", NULL}; - //int result = execv("/usr/bin/ssh", parmList); - //UNDER_LOCK( cout << "*** debug_command = " << result << endl ); - //UNDER_LOCK( cout << "*** debug_command = " << strerror(errno) << endl ); try { - // EXECUTABLE is MANDATORY, if missing, we exit with failure notification - vector command; - if (param.find(EXECUTABLE) != param.end()) { - command = _bm.exec_command(param); - } else exit(1); + // build script file to launch the job and copy it on the server + string cmdFilePath = buildCommandFile(_job); + + // define command to submit the job + vector command = _bm._protocol.getExecCommandArgs(cmdFilePath, _bm._hostname, _bm._username); // Build the argument array argv from the command char ** argv = new char * [command.size() + 1]; @@ -724,94 +693,24 @@ namespace Batch { for (string::size_type i=0 ; i0) comstr += " # "; - comstr += command[i]; + comstr += command[i] + " "; } - argv[command.size()] = NULL; - - UNDER_LOCK( cout << "*** debug_command = " << comstr << endl ); - UNDER_LOCK( cout << "*** debug_command = " << argv[0] << endl ); - - // Create the environment for the new process. Note (RB): Here we change the environment for - // the process launched in local. It would seem more logical to set the environment for the - // remote process. - 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; - } - - //char *const parmList[] = {"/usr/bin/ssh", "localhost", "-l", "aribes", "sleep 1 && echo end", NULL}; - //int result = execv("/usr/bin/ssh", parmList); - //UNDER_LOCK( cout << "*** debug_command = " << result << endl ); - //UNDER_LOCK( cout << "*** debug_command = " << strerror(errno) << endl ); - - - - // On positionne les limites systeme imposees au fils - // This part is deactivated because those limits should be set on the job process, not on - // the ssh process. If it is done properly one day, beware of the types used (int is not enough) - /* - 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 * 1024; - limit.rlim_max = int(maxramsize * 1.1) * 1024 * 1024; - setrlimit(RLIMIT_AS, &limit); - } - */ - - - //char *const parmList[] = {"/usr/bin/ssh", "localhost", "-l", "aribes", "sleep 1 && echo end", NULL}; - //int result = execv("/usr/bin/ssh", parmList); - //UNDER_LOCK( cout << "*** debug_command = " << result << endl ); - //UNDER_LOCK( cout << "*** debug_command = " << strerror(errno) << endl ); + UNDER_LOCK( LOG("*** debug_command = " << comstr) ); // 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(argv[0], argv, envp); - UNDER_LOCK( cout << "*** debug_command = " << strerror(errno) << endl ); + execv(argv[0], argv); + UNDER_LOCK( LOG("*** debug_command = " << strerror(errno)) ); // No need to deallocate since nothing happens after a successful exec // Normalement on ne devrait jamais arriver ici @@ -820,7 +719,7 @@ namespace Batch { } catch (GenericException & e) { - std::cerr << "Caught exception : " << e.type << " : " << e.message << std::endl; + LOG("Caught exception : " << e.type << " : " << e.message); } exit(99); @@ -836,45 +735,20 @@ namespace Batch { try { - // EXECUTABLE is MANDATORY, if missing, we throw an exception - vector exec_command; - if (param.find(EXECUTABLE) != param.end()) { - exec_command = _bm.exec_command(param); - } else { - throw RunTimeException("Parameter \"EXECUTABLE\" is mandatory for local batch submission"); - } + // build script file to launch the job and copy it on the server + string cmdFilePath = buildCommandFile(_job); + + // define command to submit the job + vector command = _bm._protocol.getExecCommandArgs(cmdFilePath, _bm._hostname, _bm._username); // Build the command string from the command argument vector string comstr; - for (unsigned int i=0 ; i0) comstr += " "; - comstr += exec_command[i]; - } - - UNDER_LOCK( cout << "*** debug_command = " << comstr << endl ); - - // Create the environment for the new process. Note (RB): Here we change the environment for - // the process launched in local. It would seem more logical to set the environment for the - // remote process. - // Note that if no environment is specified, we reuse the current environment. - Environnement env = _job.getEnvironnement(); - char * chNewEnv = NULL; - - if(env.size() > 0) { - chNewEnv = new char[4096]; - LPTSTR lpszCurrentVariable = chNewEnv; - for(Environnement::const_iterator it=env.begin() ; it!=env.end() ; it++) { - const string & key = (*it).first; - const string & value = (*it).second; - string envvar = key + "=" + value; - envvar.copy(lpszCurrentVariable, envvar.size()); - lpszCurrentVariable[envvar.size()] = '\0'; - lpszCurrentVariable += lstrlen(lpszCurrentVariable) + 1; - } - // Terminate the block with a NULL byte. - *lpszCurrentVariable = '\0'; + comstr += command[i]; } + UNDER_LOCK( LOG("*** debug_command = " << comstr) ); STARTUPINFO si; ZeroMemory( &si, sizeof(si) ); @@ -886,7 +760,7 @@ namespace Batch { // launch the new process bool res = CreateProcess(NULL, buffer, NULL, NULL, FALSE, - CREATE_NO_WINDOW, chNewEnv, NULL, &si, &pi); + CREATE_NO_WINDOW, NULL, NULL, &si, &pi); if (buffer) free(buffer); if (!res) throw RunTimeException("Error while creating new process"); @@ -895,7 +769,7 @@ namespace Batch { } catch (GenericException & e) { - std::cerr << "Caught exception : " << e.type << " : " << e.message << std::endl; + LOG("Caught exception : " << e.type << " : " << e.message); } return pi.hProcess; diff --git a/src/Local/Batch_BatchManager_Local.hxx b/src/Local/BatchManager_Local.hxx similarity index 80% rename from src/Local/Batch_BatchManager_Local.hxx rename to src/Local/BatchManager_Local.hxx index fcc2f90..8058a3c 100644 --- a/src/Local/Batch_BatchManager_Local.hxx +++ b/src/Local/BatchManager_Local.hxx @@ -36,8 +36,8 @@ #ifndef _BATCHMANAGER_LOCAL_H_ #define _BATCHMANAGER_LOCAL_H_ -#include "Batch_Defines.hxx" -#include "Batch_CommunicationProtocol.hxx" +#include "Defines.hxx" +#include "CommunicationProtocol.hxx" #ifdef WIN32 #include @@ -47,12 +47,12 @@ #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_BatchManager.hxx" +#include "Job.hxx" +#include "JobId.hxx" +#include "JobInfo.hxx" +#include "JobInfo_Local.hxx" +#include "Job_Local.hxx" +#include "BatchManager.hxx" namespace Batch { @@ -92,6 +92,12 @@ namespace Batch { Process launchWin32ChildProcess(); #endif + /** + * Create script to launch the remote command and copy it on the server. + * Return the path of the remote script. + */ + std::string buildCommandFile(const Job_Local & job); + }; enum Commande { @@ -116,44 +122,33 @@ namespace Batch { public: - // Constructeur et destructeur - BatchManager_Local(const FactBatchManager * parent, - const char * host="localhost", - CommunicationProtocolType protocolType = SSH); // connexion a la machine host + + BatchManager_Local(const Batch::FactBatchManager * parent, const char * host = "localhost", + const char * username = "", + CommunicationProtocolType protocolType = SSH, const char * mpiImpl = "nompi"); virtual ~BatchManager_Local(); // Recupere le nom du serveur par defaut // static string BatchManager_Local::getDefaultServer(); - // Get the underlying communication protocol - const CommunicationProtocol & getProtocol() const; - // Methodes pour le controle des jobs virtual const JobId submitJob(const Job & job); // soumet un job au gestionnaire virtual void deleteJob(const JobId & jobid); // retire un job du gestionnaire virtual void holdJob(const JobId & jobid); // suspend un job en file d'attente virtual void releaseJob(const JobId & jobid); // relache un job suspendu - virtual void alterJob(const JobId & jobid, const Parametre & param, const Environnement & env); // modifie un job en file d'attente - virtual void alterJob(const JobId & jobid, const Parametre & param); // modifie un job en file d'attente - virtual void alterJob(const JobId & jobid, const Environnement & env); // modifie un job en file d'attente virtual JobInfo queryJob(const JobId & jobid); // renvoie l'etat du job virtual bool isRunning(const JobId & jobid); // teste si un job est present en machine virtual void setParametre(const JobId & jobid, const Parametre & param) { return alterJob(jobid, param); } // modifie un job en file d'attente virtual void setEnvironnement(const JobId & jobid, const Environnement & env) { return alterJob(jobid, env); } // modifie un job en file d'attente - virtual const Batch::JobId addJob(const Batch::Job & job, const std::string reference); // ajoute un nouveau job sans le soumettre + virtual const Batch::JobId addJob(const Batch::Job & job, const std::string & reference); // ajoute un nouveau job sans le soumettre protected: int _connect; // Local connect id pthread_mutex_t _threads_mutex; std::map _threads; - const CommunicationProtocol & _protocol; - - // Methode qui renvoie la commande a executer - std::vector exec_command(const Parametre & param) const; - private: static void kill_child_on_exit(void * p_pid); static void delete_on_exit(void * arg); diff --git a/src/Local/CMakeLists.txt b/src/Local/CMakeLists.txt index 93f746c..7d4d023 100644 --- a/src/Local/CMakeLists.txt +++ b/src/Local/CMakeLists.txt @@ -20,15 +20,25 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -SET(CLASS_LIST Local/Batch_BatchManager_Local - Local/Batch_FactBatchManager_Local - Local/Batch_IOMutex - Local/Batch_Job_Local - Local/Batch_JobInfo_Local +SET(CLASS_LIST Local/BatchManager_Local + Local/FactBatchManager_Local + Local/IOMutex + Local/Job_Local + Local/JobInfo_Local ) APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST}) IF (TEST_ENABLED) - add_subdirectory(Test) + IF (HAS_SH) + ADD_TEST(LOCAL_SH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager LOCAL SH) + ENDIF (HAS_SH) + + IF (HAS_SSH) + ADD_TEST(LOCAL_SSH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager LOCAL SSH) + ENDIF (HAS_SSH) + + IF (HAS_RSH) + ADD_TEST(LOCAL_RSH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager LOCAL RSH) + ENDIF (HAS_RSH) ENDIF (TEST_ENABLED) diff --git a/src/Local/Batch_FactBatchManager_Local.cxx b/src/Local/FactBatchManager_Local.cxx similarity index 63% rename from src/Local/Batch_FactBatchManager_Local.cxx rename to src/Local/FactBatchManager_Local.cxx index 16f6f47..935c2a9 100644 --- a/src/Local/Batch_FactBatchManager_Local.cxx +++ b/src/Local/FactBatchManager_Local.cxx @@ -32,45 +32,30 @@ * */ -#include +#include -#include "Batch_BatchManager_Local.hxx" -#include "Batch_FactBatchManager_Local.hxx" +#include "BatchManager_Local.hxx" +#include "FactBatchManager_Local.hxx" namespace Batch { -#ifdef HAS_SH - static FactBatchManager_Local sFBM_Local_SH("SH", SH); -#endif + static FactBatchManager_Local sFBM_Local; -#ifdef HAS_RSH - static FactBatchManager_Local sFBM_Local_RSH("RSH", RSH); -#endif - -#ifdef HAS_SSH - static FactBatchManager_Local sFBM_Local_SSH("SSH", SSH); -#endif - - // Constructeur - FactBatchManager_Local::FactBatchManager_Local(const char * name, - CommunicationProtocolType protocolType) - : FactBatchManager(name), - _protocolType(protocolType) + 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 + BatchManager * FactBatchManager_Local::operator() (const char * hostname, + const char * username, + CommunicationProtocolType protocolType, + const char * mpi) const { - // MESSAGE("Building new BatchManager_Local on host '" << hostname << "'"); - return new BatchManager_Local(this, hostname, _protocolType); + return new BatchManager_Local(this, hostname, username, protocolType, mpi); } } diff --git a/src/Local/Batch_FactBatchManager_Local.hxx b/src/Local/FactBatchManager_Local.hxx similarity index 79% rename from src/Local/Batch_FactBatchManager_Local.hxx rename to src/Local/FactBatchManager_Local.hxx index 4b01a4b..09fffff 100644 --- a/src/Local/Batch_FactBatchManager_Local.hxx +++ b/src/Local/FactBatchManager_Local.hxx @@ -35,25 +35,22 @@ #ifndef _FACTBATCHMANAGER_LOCAL_H_ #define _FACTBATCHMANAGER_LOCAL_H_ -#include "Batch_FactBatchManager.hxx" -#include "Batch_CommunicationProtocol.hxx" +#include "FactBatchManager.hxx" +#include "CommunicationProtocol.hxx" namespace Batch { class FactBatchManager_Local : public FactBatchManager { public: - // Constructeur et destructeur - FactBatchManager_Local(const char * name, CommunicationProtocolType protocolType); - virtual ~FactBatchManager_Local(); - - virtual BatchManager * operator() (const char * hostname) const; - protected: - - CommunicationProtocolType _protocolType; + FactBatchManager_Local(); + virtual ~FactBatchManager_Local(); - private: + virtual BatchManager * operator() (const char * hostname, + const char * username = "", + CommunicationProtocolType protocolType = SSH, + const char * mpi = "nompi") const; }; diff --git a/src/Local/Batch_IOMutex.cxx b/src/Local/IOMutex.cxx similarity index 97% rename from src/Local/Batch_IOMutex.cxx rename to src/Local/IOMutex.cxx index 37d9770..7991942 100644 --- a/src/Local/Batch_IOMutex.cxx +++ b/src/Local/IOMutex.cxx @@ -29,7 +29,7 @@ * */ -#include "Batch_IOMutex.hxx" +#include "IOMutex.hxx" namespace Batch { diff --git a/src/Local/Batch_IOMutex.hxx b/src/Local/IOMutex.hxx similarity index 100% rename from src/Local/Batch_IOMutex.hxx rename to src/Local/IOMutex.hxx diff --git a/src/Local/Batch_JobInfo_Local.cxx b/src/Local/JobInfo_Local.cxx similarity index 93% rename from src/Local/Batch_JobInfo_Local.cxx rename to src/Local/JobInfo_Local.cxx index 3a742bb..988d6cd 100644 --- a/src/Local/Batch_JobInfo_Local.cxx +++ b/src/Local/JobInfo_Local.cxx @@ -30,9 +30,9 @@ */ #include -#include "Batch_Parametre.hxx" -#include "Batch_Environnement.hxx" -#include "Batch_JobInfo_Local.hxx" +#include "Parametre.hxx" +#include "Environnement.hxx" +#include "JobInfo_Local.hxx" namespace Batch { diff --git a/src/Local/Batch_JobInfo_Local.hxx b/src/Local/JobInfo_Local.hxx similarity index 98% rename from src/Local/Batch_JobInfo_Local.hxx rename to src/Local/JobInfo_Local.hxx index f5f1160..4534b8f 100644 --- a/src/Local/Batch_JobInfo_Local.hxx +++ b/src/Local/JobInfo_Local.hxx @@ -33,7 +33,7 @@ #define _JOBINFO_LOCAL_H_ #include -#include "Batch_JobInfo.hxx" +#include "JobInfo.hxx" namespace Batch { diff --git a/src/Local/Batch_Job_Local.cxx b/src/Local/Job_Local.cxx similarity index 91% rename from src/Local/Batch_Job_Local.cxx rename to src/Local/Job_Local.cxx index 474c6df..f7109a7 100644 --- a/src/Local/Batch_Job_Local.cxx +++ b/src/Local/Job_Local.cxx @@ -35,8 +35,8 @@ #include #endif -#include "Batch_Constants.hxx" -#include "Batch_Job_Local.hxx" +#include "Constants.hxx" +#include "Job_Local.hxx" using namespace std; @@ -46,15 +46,9 @@ namespace Batch { 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 ); - } diff --git a/src/Local/Batch_Job_Local.hxx b/src/Local/Job_Local.hxx similarity index 95% rename from src/Local/Batch_Job_Local.hxx rename to src/Local/Job_Local.hxx index a07f115..d2c2e25 100644 --- a/src/Local/Batch_Job_Local.hxx +++ b/src/Local/Job_Local.hxx @@ -32,9 +32,9 @@ #ifndef _JOB_LOCAL_H_ #define _JOB_LOCAL_H_ -#include "Batch_Parametre.hxx" -#include "Batch_Environnement.hxx" -#include "Batch_Job.hxx" +#include "Parametre.hxx" +#include "Environnement.hxx" +#include "Job.hxx" namespace Batch { diff --git a/src/Local/Test/CMakeLists.txt b/src/Local/Test/CMakeLists.txt deleted file mode 100644 index 4ff10b4..0000000 --- a/src/Local/Test/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# 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_SOURCE_DIR}/src/Core/Test) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -# Build the test programs and add the tests -IF (HAS_SH) - - # Build the executable to use for the local test program - add_executable(Exec_Test Exec_Test.cxx) - GET_TARGET_PROPERTY(EXEC_TEST_FULL_PATH_TEMP Exec_Test LOCATION) - GET_FILENAME_COMPONENT(EXEC_TEST_NAME_TEMP ${EXEC_TEST_FULL_PATH_TEMP} NAME) - SET(EXEC_TEST_FULL_PATH ${EXEC_TEST_FULL_PATH_TEMP} CACHE INTERNAL "") - SET(EXEC_TEST_NAME ${EXEC_TEST_NAME_TEMP} CACHE INTERNAL "") - - # Configure the config file for the test - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Test_Local_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/Test_Local_config.h) - - add_executable(Test_Local_SH Test_Local_SH.cxx) - target_link_libraries(Test_Local_SH Batch SimpleParser) - ADD_TEST(Local_SH Test_Local_SH) - -ENDIF (HAS_SH) - -IF (HAS_SSH) - add_executable(Test_Local_SSH Test_Local_SSH.cxx) - target_link_libraries(Test_Local_SSH Batch SimpleParser) - ADD_TEST(Local_SSH Test_Local_SSH) -ENDIF (HAS_SSH) - -IF (HAS_RSH) - add_executable(Test_Local_RSH Test_Local_RSH.cxx) - target_link_libraries(Test_Local_RSH Batch SimpleParser) - ADD_TEST(Local_RSH Test_Local_RSH) -ENDIF (HAS_RSH) diff --git a/src/Local/Test/Exec_Test.cxx b/src/Local/Test/Exec_Test.cxx deleted file mode 100644 index 8ae8d65..0000000 --- a/src/Local/Test/Exec_Test.cxx +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Exec_Test.cxx : - * - * Author : Renaud BARATE - EDF R&D - * Date : May 2009 - * - */ - -#include -#include -#include -#include - -using namespace std; - -int main(int argc, char** argv) -{ - if (argc != 4) { - cerr << "Exec_Test expects three parameters, usage: Exec_Test " << endl; - return 1; - } - - const char * scriptAFileName = argv[1]; - const char * scriptBFileName = argv[2]; - const char * resultFileName = argv[3]; - - ifstream scriptAStream(scriptAFileName); - std::string line; - int a = 0; - while (getline(scriptAStream, line)) { - if (line.compare(0, 2, string("a=")) == 0) { - a = strtol(line.substr(2).c_str(), NULL, 10); - } - } - scriptAStream.close(); - if (a == 0) { - cerr << "Exec_Test couldn't parse value \"a\" in " << scriptAFileName << endl; - return 1; - } - - ifstream scriptBStream(scriptBFileName); - int b = 0; - while (getline(scriptBStream, line)) { - if (line.compare(0, 2, string("b=")) == 0) { - b = strtol(line.substr(2).c_str(), NULL, 10); - } - } - scriptBStream.close(); - if (b == 0) { - cerr << "Exec_Test couldn't parse value \"b\" in " << scriptBFileName << endl; - return 1; - } - - int c = a * b; - ofstream resultStream(resultFileName); - resultStream << "c = " << c; - resultStream.close(); - return 0; -} diff --git a/src/Local/Test/Test_Local_RSH.cxx b/src/Local/Test/Test_Local_RSH.cxx deleted file mode 100644 index 83622c3..0000000 --- a/src/Local/Test/Test_Local_RSH.cxx +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Test_Local_RSH.cxx : - * - * Author : Renaud BARATE - EDF R&D - * Date : April 2009 - * - */ - -#include -#include - -#include -#include -#include -#include -#include - -#include - -using namespace std; -using namespace Batch; - -int main(int argc, char** argv) -{ - cout << "*******************************************************************************************" << endl; - cout << "This program tests the 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"); - - try { - // Parse the test configuration file - SimpleParser parser; - parser.parseTestConfigFile(); - const string & workdir = parser.getValue("TEST_LOCAL_RSH_WORK_DIR"); - const string & exechost = parser.getValue("TEST_LOCAL_RSH_EXECUTION_HOST"); - const string & user = parser.getValue("TEST_LOCAL_RSH_USER"); - int timeout = parser.getValueAsInt("TEST_LOCAL_RSH_TIMEOUT"); - - // Define the job... - Job job; - // ... and its parameters ... - Parametre p; - p[EXECUTABLE] = "source copied-test-script.sh"; - p[NAME] = "Test_Local_RSH"; - p[WORKDIR] = workdir; - 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] = exechost; - p[USER] = user; - 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"); - if (fbm == NULL) { - cerr << "Can't get RSH batch manager factory" << endl; - return 1; - } - 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 = bm->waitForJobEnd(jobid, timeout); - - if (state != FINISHED && state != FAILED) { - cerr << "Error: Job not finished after timeout" << endl; - return 1; - } - - cout << "Job " << jobid.__repr__() << " is done" << endl; - - } catch (GenericException e) { - cerr << "Error: " << e << endl; - return 1; - } catch (ParserException e) { - cerr << "Parser error: " << e.what() << endl; - return 1; - } - - // 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 deleted file mode 100644 index 5c3c2e7..0000000 --- a/src/Local/Test/Test_Local_SH.cxx +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Test_Local_SH.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 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"); - - try { - // Parse the test configuration file - SimpleParser parser; - parser.parseTestConfigFile(); - const string & workdir = parser.getValue("TEST_LOCAL_SH_WORK_DIR"); - int timeout = parser.getValueAsInt("TEST_LOCAL_SH_TIMEOUT"); - - // Define the job... - Job job; - // ... and its parameters ... - Parametre p; - p[EXECUTABLE] = string("./copied-") + EXEC_TEST_NAME; - p[ARGUMENTS] = "copied-seta.sh"; - p[ARGUMENTS] += "copied-setb.sh"; - p[ARGUMENTS] += "orig-result.txt"; - p[NAME] = "Test_Local_SH"; - p[WORKDIR] = workdir; - p[INFILE] = Couple("seta.sh", "copied-seta.sh"); - p[INFILE] += Couple("setb.sh", "copied-setb.sh"); - p[INFILE] += Couple(EXEC_TEST_NAME, string("copied-") + EXEC_TEST_NAME); - 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"); - if (fbm == NULL) { - cerr << "Can't get SH batch manager factory" << endl; - return 1; - } - 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 = bm->waitForJobEnd(jobid, timeout); - - if (state != FINISHED && state != FAILED) { - cerr << "Error: Job not finished after timeout" << endl; - return 1; - } - - cout << "Job " << jobid.__repr__() << " is done" << endl; - - } catch (GenericException e) { - cerr << "Error: " << e << endl; - return 1; - } catch (ParserException e) { - cerr << "Parser error: " << e.what() << endl; - return 1; - } - - // 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 deleted file mode 100644 index b82740e..0000000 --- a/src/Local/Test/Test_Local_SSH.cxx +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Test_Local_SSH.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 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"); - - try { - // Parse the test configuration file - SimpleParser parser; - parser.parseTestConfigFile(); - const string & workdir = parser.getValue("TEST_LOCAL_SSH_WORK_DIR"); - const string & exechost = parser.getValue("TEST_LOCAL_SSH_EXECUTION_HOST"); - const string & user = parser.getValue("TEST_LOCAL_SSH_USER"); - int timeout = parser.getValueAsInt("TEST_LOCAL_SSH_TIMEOUT"); - - // Define the job... - Job job; - // ... and its parameters ... - Parametre p; - p[EXECUTABLE] = "source copied-test-script.sh"; - p[NAME] = "Test_Local_SSH"; - p[WORKDIR] = workdir; - 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] = exechost; - p[USER] = user; - job.setParametre(p); - // ... and its environment (SSH_AUTH_SOCK env var is important for ssh agent authentication) - Environnement e; - const char * sshAuthSock = getenv("SSH_AUTH_SOCK"); - if (sshAuthSock != NULL) e["SSH_AUTH_SOCK"] = sshAuthSock; - 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"); - if (fbm == NULL) { - cerr << "Can't get SSH batch manager factory" << endl; - return 1; - } - 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 = bm->waitForJobEnd(jobid, timeout); - - if (state != FINISHED && state != FAILED) { - cerr << "Error: Job not finished after timeout" << endl; - return 1; - } - - cout << "Job " << jobid.__repr__() << " is done" << endl; - - } catch (GenericException e) { - cerr << "Error: " << e << endl; - return 1; - } catch (ParserException e) { - cerr << "Parser error: " << e.what() << endl; - return 1; - } - - // 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 deleted file mode 100644 index 4b32fe6..0000000 --- a/src/Local/Test/Test_Local_config.h.in +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#define EXEC_TEST_NAME "${EXEC_TEST_NAME}" diff --git a/src/Local/Test/seta.sh b/src/Local/Test/seta.sh deleted file mode 100644 index 42d1e38..0000000 --- a/src/Local/Test/seta.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -a=4 diff --git a/src/Local/Test/setb.sh b/src/Local/Test/setb.sh deleted file mode 100644 index 8969060..0000000 --- a/src/Local/Test/setb.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -b=3 diff --git a/src/Local/Test/test-script.sh b/src/Local/Test/test-script.sh deleted file mode 100755 index afd53de..0000000 --- a/src/Local/Test/test-script.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/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_ePBS.cxx b/src/PBS/BatchManager_PBS.cxx similarity index 63% rename from src/PBS/Batch_BatchManager_ePBS.cxx rename to src/PBS/BatchManager_PBS.cxx index 2fbfb9e..ae18c23 100644 --- a/src/PBS/Batch_BatchManager_ePBS.cxx +++ b/src/PBS/BatchManager_PBS.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * BatchManager_ePBS.cxx : emulation of PBS client + * BatchManager_PBS.cxx : emulation of PBS client * * Auteur : Bernard SECHER - CEA DEN, André RIBES - EDF R&D * Mail : mailto:bernard.secher@cea.fr @@ -33,35 +33,34 @@ #include #include -#include -#include +#include +#include +#include -#include "Batch_BatchManager_ePBS.hxx" -#include "Batch_JobInfo_ePBS.hxx" +#include "BatchManager_PBS.hxx" +#include "JobInfo_PBS.hxx" +#include "Log.hxx" using namespace std; namespace Batch { - BatchManager_ePBS::BatchManager_ePBS(const FactBatchManager * parent, const char * host, + BatchManager_PBS::BatchManager_PBS(const FactBatchManager * parent, const char * host, const char * username, - CommunicationProtocolType protocolType, const char * mpiImpl, - int nb_proc_per_node) - : BatchManager(parent, host), - BatchManager_eClient(parent, host, username, protocolType, mpiImpl), - _nb_proc_per_node(nb_proc_per_node) + CommunicationProtocolType protocolType, const char * mpiImpl) + : BatchManager(parent, host, username, protocolType, mpiImpl) { // Nothing to do } // Destructeur - BatchManager_ePBS::~BatchManager_ePBS() + BatchManager_PBS::~BatchManager_PBS() { // Nothing to do } // Methode pour le controle des jobs : soumet un job au gestionnaire - const JobId BatchManager_ePBS::submitJob(const Job & job) + const JobId BatchManager_PBS::submitJob(const Job & job) { Parametre params = job.getParametre(); const std::string workDir = params[WORKDIR]; @@ -76,13 +75,13 @@ namespace Batch { string subCommand = string("cd ") + workDir + "; qsub " + scriptFile; string command = _protocol.getExecCommand(subCommand, _hostname, _username); command += " 2>&1"; - cerr << command.c_str() << endl; + LOG(command); // submit job string output; int status = Utils::getCommandOutput(command, output); - cout << output; - if (status != 0) throw EmulationException("Can't submit job, error was: " + output); + LOG(output); + if (status != 0) throw RunTimeException("Can't submit job, error was: " + output); // normally output contains only id of submitted job, we just need to remove the final \n string jobref = output.substr(0, output.size() - 1); @@ -91,15 +90,8 @@ namespace Batch { return id; } - // Ce manager permet de faire de la reprise - const Batch::JobId - BatchManager_ePBS::addJob(const Batch::Job & job, const std::string reference) - { - return JobId(this, reference); - } - // Methode pour le controle des jobs : retire un job du gestionnaire - void BatchManager_ePBS::deleteJob(const JobId & jobid) + void BatchManager_PBS::deleteJob(const JobId & jobid) { int status; int ref; @@ -109,47 +101,16 @@ namespace Batch { // define command to delete batch string subCommand = string("qdel ") + iss.str(); string command = _protocol.getExecCommand(subCommand, _hostname, _username); - cerr << command.c_str() << endl; + LOG(command); 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"); - } + throw RunTimeException("Error of connection on remote host"); - // 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); + LOG("jobId = " << ref << "killed"); } // Methode pour le controle des jobs : renvoie l'etat du job - JobInfo BatchManager_ePBS::queryJob(const JobId & jobid) + JobInfo BatchManager_PBS::queryJob(const JobId & jobid) { int id; istringstream iss(jobid.getReference()); @@ -158,53 +119,54 @@ namespace Batch { // define command to query batch string subCommand = string("qstat -f ") + iss.str(); string command = _protocol.getExecCommand(subCommand, _hostname, _username); - cerr << command.c_str() << endl; + LOG(command); string output; int status = Utils::getCommandOutput(command, output); if(status && status != 153 && status != 256*153) - throw EmulationException("Error of connection on remote host"); + throw RunTimeException("Error of connection on remote host"); - JobInfo_ePBS ji = JobInfo_ePBS(id, output); + JobInfo_PBS ji = JobInfo_PBS(id, output); return ji; } // Methode pour le controle des jobs : teste si un job est present en machine - bool BatchManager_ePBS::isRunning(const JobId & jobid) + bool BatchManager_PBS::isRunning(const JobId & jobid) { - throw EmulationException("Not yet implemented"); + throw NotYetImplementedException("BatchManager_PBS::isRunning"); } - std::string BatchManager_ePBS::buildSubmissionScript(const Job & job) + std::string BatchManager_PBS::buildSubmissionScript(const Job & job) { Parametre params = job.getParametre(); Environnement env = job.getEnvironnement(); - // Job Parameters - string workDir = ""; - string fileToExecute = ""; - int nbproc = 0; - int edt = 0; - int mem = 0; - string queue = ""; - // Mandatory parameters + string workDir; if (params.find(WORKDIR) != params.end()) workDir = params[WORKDIR].str(); else - throw EmulationException("params[WORKDIR] is not defined ! Please defined it, cannot submit this job"); + throw RunTimeException("params[WORKDIR] is not defined ! Please defined it, cannot submit this job"); + string fileToExecute; if (params.find(EXECUTABLE) != params.end()) fileToExecute = params[EXECUTABLE].str(); else - throw EmulationException("params[EXECUTABLE] is not defined ! Please defined it, cannot submit this job"); + throw RunTimeException("params[EXECUTABLE] is not defined ! Please defined it, cannot submit this job"); // Optional parameters - if (params.find(NBPROC) != params.end()) + int nbproc = 1; + if (params.find(NBPROC) != params.end()) nbproc = params[NBPROC]; + int nbprocpernode = 1; + if (params.find(NBPROCPERNODE) != params.end()) + nbprocpernode = params[NBPROCPERNODE]; + int edt = 0; if (params.find(MAXWALLTIME) != params.end()) edt = params[MAXWALLTIME]; + int mem = 0; if (params.find(MAXRAMSIZE) != params.end()) mem = params[MAXRAMSIZE]; + string queue = ""; if (params.find(QUEUE) != params.end()) queue = params[QUEUE].str(); @@ -215,7 +177,7 @@ namespace Batch { // Create batch submit file ofstream tempOutputFile; - std::string TmpFileName = createAndOpenTemporaryFile("PBS-script", tempOutputFile); + std::string TmpFileName = Utils::createAndOpenTemporaryFile("PBS-script", tempOutputFile); tempOutputFile << "#! /bin/sh -f" << endl; if (params.find(NAME) != params.end()) { @@ -224,8 +186,8 @@ namespace Batch { if (nbproc > 0) { - int nb_full_nodes = nbproc / _nb_proc_per_node; - int nb_proc_on_last_node = nbproc % _nb_proc_per_node; + int nb_full_nodes = nbproc / nbprocpernode; + int nb_proc_on_last_node = nbproc % nbprocpernode; // In exclusive mode, we reserve all procs on the nodes if (params.find(EXCLUSIVE) != params.end() && params[EXCLUSIVE] && nb_proc_on_last_node > 0) { @@ -237,7 +199,7 @@ namespace Batch { // Full nodes if (nb_full_nodes > 0) { - tempOutputFile << nb_full_nodes << ":ppn=" << _nb_proc_per_node; + tempOutputFile << nb_full_nodes << ":ppn=" << nbprocpernode; if (nb_proc_on_last_node > 0) { tempOutputFile << "+"; } @@ -269,7 +231,7 @@ namespace Batch { tempOutputFile << endl; } - // Abstraction of PBS_NODEFILE - TODO + // Define NODEFILE tempOutputFile << "export LIBBATCH_NODEFILE=$PBS_NODEFILE" << endl; // Launch the executable @@ -278,14 +240,14 @@ namespace Batch { tempOutputFile.flush(); tempOutputFile.close(); - cerr << "Batch script file generated is: " << TmpFileName.c_str() << endl; + LOG("Batch script file generated is: " << TmpFileName.c_str()); string remoteFileName = rootNameToExecute + "_Batch.sh"; int status = _protocol.copyFile(TmpFileName, "", "", workDir + "/" + remoteFileName, _hostname, _username); if (status) - throw EmulationException("Error of connection on remote host, cannot copy batch submission file"); + throw RunTimeException("Error of connection on remote host, cannot copy batch submission file"); return remoteFileName; } } diff --git a/src/PBS/Batch_BatchManager_ePBS.hxx b/src/PBS/BatchManager_PBS.hxx similarity index 68% rename from src/PBS/Batch_BatchManager_ePBS.hxx rename to src/PBS/BatchManager_PBS.hxx index a32fcc2..d0e9c3f 100644 --- a/src/PBS/Batch_BatchManager_ePBS.hxx +++ b/src/PBS/BatchManager_PBS.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * BatchManager_ePBS.hxx : emulation of PBS client + * BatchManager_PBS.hxx : emulation of PBS client * * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr @@ -32,23 +32,22 @@ #ifndef _BATCHMANAGER_EPBS_H_ #define _BATCHMANAGER_EPBS_H_ -#include "Batch_Defines.hxx" -#include "Batch_JobId.hxx" -#include "Batch_JobInfo.hxx" -#include "Batch_FactBatchManager.hxx" -#include "Batch_BatchManager_eClient.hxx" +#include "Defines.hxx" +#include "JobId.hxx" +#include "JobInfo.hxx" +#include "FactBatchManager.hxx" +#include "BatchManager.hxx" namespace Batch { - class BATCH_EXPORT BatchManager_ePBS : public BatchManager_eClient + class BATCH_EXPORT BatchManager_PBS : public BatchManager { public: // Constructeur et destructeur - BatchManager_ePBS(const FactBatchManager * parent, const char * host="localhost", + BatchManager_PBS(const FactBatchManager * parent, const char * host="localhost", const char * username="", - CommunicationProtocolType protocolType = SSH, const char * mpiImpl="nompi", - int nb_proc_per_node=1); // connexion a la machine host - virtual ~BatchManager_ePBS(); + CommunicationProtocolType protocolType = SSH, const char * mpiImpl="nompi"); + virtual ~BatchManager_PBS(); // Recupere le nom du serveur par defaut // static string BatchManager_LSF::getDefaultServer(); @@ -56,25 +55,15 @@ namespace Batch { // Methodes pour le controle des jobs virtual const JobId submitJob(const Job & job); // soumet un job au gestionnaire virtual void deleteJob(const JobId & jobid); // retire un job du gestionnaire - virtual void holdJob(const JobId & jobid); // suspend un job en file d'attente - virtual void releaseJob(const JobId & jobid); // relache un job suspendu - virtual void alterJob(const JobId & jobid, const Parametre & param, const Environnement & env); // modifie un job en file d'attente - virtual void alterJob(const JobId & jobid, const Parametre & param); // modifie un job en file d'attente - virtual void alterJob(const JobId & jobid, const Environnement & env); // modifie un job en file d'attente virtual JobInfo queryJob(const JobId & jobid); // renvoie l'etat du job virtual bool isRunning(const JobId & jobid); // teste si un job est present en machine virtual void setParametre(const JobId & jobid, const Parametre & param) { return alterJob(jobid, param); } // modifie un job en file d'attente virtual void setEnvironnement(const JobId & jobid, const Environnement & env) { return alterJob(jobid, env); } // modifie un job en file d'attente - virtual const Batch::JobId addJob(const Batch::Job & job, const std::string reference); // ajoute un nouveau job sans le soumettre - protected: std::string buildSubmissionScript(const Job & job); - private: - int _nb_proc_per_node; - #ifdef SWIG public: // Recupere le l'identifiant d'un job deja soumis au BatchManager diff --git a/src/PBS/Batch_BatchManager_PBS.cxx b/src/PBS/Batch_BatchManager_PBS.cxx deleted file mode 100644 index 2836571..0000000 --- a/src/PBS/Batch_BatchManager_PBS.cxx +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * BatchManager_PBS.cxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Mail : mailto:ivan.dutka-malen@der.edf.fr - * Date : Thu Nov 6 10:17:22 2003 - * Projet : Salome 2 - * - */ - -extern "C" { -#include -#include -} -#include -#include -#include -#include -//#include "MEDMEM_STRING.hxx" -#include "Batch_BatchManager_PBS.hxx" -using namespace std; - -namespace Batch { - - // Recupere le nom du serveur par defaut -// string BatchManager_PBS::getDefaultServer() { -// string server_name = "localhost"; - -// const char * server_name_path = "@openpbsspooldir@/server_name"; -// ifstream server_name_file(server_name_path); -// if (server_name_file) { -// server_name_file >> server_name; -// server_name_file.close(); -// } - -// return server_name; -// } - - // Constructeur -// BatchManager_PBS::BatchManager_PBS() throw(InvalidArgumentException,ConnexionFailureException) : BatchManager(BatchManager_PBS::getDefaultServer()) -// { -// // On se connecte au serveur PBS -// _connect = pbs_connect(const_cast< char * >(_hostname.c_str())); -// if (_connect < 0) { // si erreur -// char * errmsg = pbs_geterrmsg(_connect); -// string msg = "PBS Server on host \""; -// msg += _hostname; -// msg += "\" : "; -// msg += errmsg ? errmsg : "Reason unknown"; -// throw ConnexionFailureException(msg.c_str()); -// } -// } - - // Constructeur -// BatchManager_PBS::BatchManager_PBS(string host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager(host) -// { -// // On se connecte au serveur PBS -// _connect = pbs_connect(const_cast< char * >(_hostname.c_str())); -// if (_connect < 0) { // si erreur -// char * errmsg = pbs_geterrmsg(_connect); -// string msg = "PBS Server on host \""; -// msg += _hostname; -// msg += "\" : "; -// msg += errmsg ? errmsg : "Reason unknown"; -// throw ConnexionFailureException(msg.c_str()); -// } -// } - BatchManager_PBS::BatchManager_PBS(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager(parent, host) - { - // On se connecte au serveur PBS - _connect = pbs_connect(const_cast< char * >(_hostname.c_str())); - if (_connect < 0) { // si erreur - throw ConnexionFailureException(getErrorMessage("connect").c_str()); - } - } - - // Destructeur - BatchManager_PBS::~BatchManager_PBS() - { - // On se deconnecte du serveur PBS - int rc = pbs_disconnect(_connect); - if (rc < 0) { // si erreur - throw ConnexionFailureException(getErrorMessage("disconnect").c_str()); - } - } - - string BatchManager_PBS::getErrorMessage(const char * operation) const - { - char * msg = pbs_geterrmsg(_connect); - stringstream sstr; - sstr << "PBS " << operation << " error (host \"" << _hostname << "\"): "; - if (msg != NULL) { - sstr << msg; - } else { - sstr << "code = " << pbs_errno << " (" << pbse_to_txt(pbs_errno) << ")"; - } - return sstr.str(); - } - - // Methode pour le controle des jobs : soumet un job au gestionnaire - const JobId BatchManager_PBS::submitJob(const Job & job) - { - Job_PBS jobpbs = job; - char * ref = pbs_submit(_connect, - jobpbs.getAttributesOP(), - jobpbs.getScript(), - jobpbs.getDestination(), - NULL); - if (!ref) { // si erreur - throw APIInternalFailureException(getErrorMessage("submit").c_str()); - } - - JobId id(this, string(ref)); - free(ref); - return id; - } - - // Ce manager permet de faire de la reprise - const Batch::JobId - BatchManager_PBS::addJob(const Batch::Job & job, const std::string reference) - { - return JobId(this, reference); - } - - // Methode pour le controle des jobs : retire un job du gestionnaire - void BatchManager_PBS::deleteJob(const JobId & jobid) - { - char * ref = const_cast< char * >(jobid.getReference().c_str()); - int rc = pbs_deljob(_connect, ref, 0); - if (rc) { // si erreur - throw APIInternalFailureException(getErrorMessage("deljob").c_str()); - } - } - - // Methode pour le controle des jobs : suspend un job en file d'attente - void BatchManager_PBS::holdJob(const JobId & jobid) - { - char * ref = const_cast< char * >(jobid.getReference().c_str()); - int rc = pbs_holdjob(_connect, ref, const_cast< char * >(USER_HOLD), 0); - if (rc) { // si erreur - throw APIInternalFailureException(getErrorMessage("holdjob").c_str()); - } - } - - // Methode pour le controle des jobs : relache un job suspendu - void BatchManager_PBS::releaseJob(const JobId & jobid) - { - char * ref = const_cast< char * >(jobid.getReference().c_str()); - int rc = pbs_rlsjob(_connect, ref, const_cast< char * >(USER_HOLD), 0); - if (rc) { // si erreur - throw APIInternalFailureException(getErrorMessage("rlsjob").c_str()); - } - } - - - // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager_PBS::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env) - { - Job job(param, env); - Job_PBS jobpbs(job); - - char * ref = const_cast< char * >(jobid.getReference().c_str()); - int rc = pbs_alterjob(_connect, - ref, - jobpbs.getAttributes(), - NULL); - if (rc) { // si erreur - throw APIInternalFailureException(getErrorMessage("alterjob").c_str()); - } - - } - - // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager_PBS::alterJob(const JobId & jobid, const Parametre & param) - { - alterJob(jobid, param, Environnement()); - } - - // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager_PBS::alterJob(const JobId & jobid, const Environnement & env) - { - alterJob(jobid, Parametre(), env); - } - - - - // Methode pour le controle des jobs : renvoie l'etat du job - JobInfo BatchManager_PBS::queryJob(const JobId & jobid) - { - char * id = const_cast< char * >(jobid.getReference().c_str()); - JobInfo_PBS ji = JobInfo_PBS(pbs_statjob(_connect, id, 0, 0), true); - return ji; - } - - - -} diff --git a/src/PBS/Batch_BatchManager_PBS.hxx b/src/PBS/Batch_BatchManager_PBS.hxx deleted file mode 100644 index 5419580..0000000 --- a/src/PBS/Batch_BatchManager_PBS.hxx +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * BatchManager_PBS.hxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Mail : mailto:ivan.dutka-malen@der.edf.fr - * Date : Thu Nov 6 10:17:22 2003 - * Projet : Salome 2 - * - */ - -#ifndef _BATCHMANAGER_PBS_H_ -#define _BATCHMANAGER_PBS_H_ - -#include "Batch_Defines.hxx" - -#include "Batch_Job.hxx" -#include "Batch_Job.hxx" -#include "Batch_JobId.hxx" -#include "Batch_JobInfo.hxx" -#include "Batch_JobInfo_PBS.hxx" -#include "Batch_Job_PBS.hxx" -#include "Batch_InvalidArgumentException.hxx" -#include "Batch_ConnexionFailureException.hxx" -#include "Batch_APIInternalFailureException.hxx" -#include "Batch_NotYetImplementedException.hxx" -#include "Batch_BatchManager.hxx" - -namespace Batch { - - class Job; - class JobId; - class JobInfo; - class FactBatchManager; - - class BATCH_EXPORT BatchManager_PBS : public BatchManager - { - public: - // Constructeur et destructeur - //BatchManager_PBS() throw(InvalidArgumentException,ConnexionFailureException); // connexion au serveur par defaut - //BatchManager_PBS(std::string host) throw(InvalidArgumentException,ConnexionFailureException); // connexion a la machine host - BatchManager_PBS(const FactBatchManager * parent, const char * host="localhost") throw(InvalidArgumentException,ConnexionFailureException); // connexion a la machine host - virtual ~BatchManager_PBS(); - - // Recupere le nom du serveur par defaut - // static std::string BatchManager_PBS::getDefaultServer(); - - // Methodes pour le controle des jobs - virtual const JobId submitJob(const Job & job); // soumet un job au gestionnaire - virtual void deleteJob(const JobId & jobid); // retire un job du gestionnaire - virtual void holdJob(const JobId & jobid); // suspend un job en file d'attente - virtual void releaseJob(const JobId & jobid); // relache un job suspendu - virtual void alterJob(const JobId & jobid, const Parametre & param, const Environnement & env); // modifie un job en file d'attente - virtual void alterJob(const JobId & jobid, const Parametre & param); // modifie un job en file d'attente - virtual void alterJob(const JobId & jobid, const Environnement & env); // modifie un job en file d'attente - virtual JobInfo queryJob(const JobId & jobid); // renvoie l'etat du job - - virtual void setParametre(const JobId & jobid, const Parametre & param) { return alterJob(jobid, param); } // modifie un job en file d'attente - virtual void setEnvironnement(const JobId & jobid, const Environnement & env) { return alterJob(jobid, env); } // modifie un job en file d'attente - - virtual const Batch::JobId addJob(const Batch::Job & job, const std::string reference); // ajoute un nouveau job sans le soumettre - - - protected: - std::string getErrorMessage(const char * operation) const; - - int _connect; // PBS connect id - - private: - -#ifdef SWIG - public: - // Recupere le l'identifiant d'un job deja soumis au BatchManager - //virtual const JobId getJobIdByReference(const std::string & ref) { return BatchManager::getJobIdByReference(ref); } - virtual const JobId getJobIdByReference(const char * ref) { return BatchManager::getJobIdByReference(ref); } -#endif - - }; - -} - -#endif diff --git a/src/PBS/Batch_FactBatchManager_ePBS.cxx b/src/PBS/Batch_FactBatchManager_ePBS.cxx deleted file mode 100644 index 415ac58..0000000 --- a/src/PBS/Batch_FactBatchManager_ePBS.cxx +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * FactBatchManager_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 * username, - CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node) const - { - // MESSAGE("Building new BatchManager_PBS on host '" << hostname << "'"); - return new BatchManager_ePBS(this, hostname, username, protocolType, mpiImpl, nb_proc_per_node); - } - - -} diff --git a/src/PBS/Batch_FactBatchManager_ePBS.hxx b/src/PBS/Batch_FactBatchManager_ePBS.hxx deleted file mode 100644 index a379d5b..0000000 --- a/src/PBS/Batch_FactBatchManager_ePBS.hxx +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * FactBatchManager_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 * username, - CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node = 1) const; - - protected: - - private: - - }; - -} - -#endif diff --git a/src/PBS/Batch_JobInfo_PBS.cxx b/src/PBS/Batch_JobInfo_PBS.cxx deleted file mode 100644 index a7c19e1..0000000 --- a/src/PBS/Batch_JobInfo_PBS.cxx +++ /dev/null @@ -1,218 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * JobInfo_PBS.cxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Mail : mailto:ivan.dutka-malen@der.edf.fr - * Date : Fri Nov 21 09:42:06 2003 - * Projet : Salome 2 - * - */ - -#include -#include -#include -#include - -#include "Batch_Constants.hxx" -#include "Batch_Parametre.hxx" -#include "Batch_Environnement.hxx" -#include "Batch_RunTimeException.hxx" -#include "Batch_JobInfo_PBS.hxx" -using namespace std; - -namespace Batch { - - // Constructeurs - JobInfo_PBS::JobInfo_PBS(struct batch_status * list, bool tobedeleted) : JobInfo() - { - // On ne considere que le premier element de la liste - // Si tout est OK, la liste ne devrait contenir qu'un element - // Sinon on leve une exception. - struct batch_status * p_job = list; - int i; - for(i=0; p_job; p_job = p_job->next) i++; - if (i == 0) throw RunTimeException("Liste vide (le job est absent de la file)"); - if (i > 1) { - ostringstream sst; - sst << "JobInfo_PBS::JobInfo_PBS(struct batch_status * list, bool tobedeleted) : la liste contient " - << i << " elements" << " (1 seul requis)" << endl; - throw RunTimeException(sst.str()); - } - p_job = list; - - // On remplit les membres _param et _env - - if (p_job->name && strlen(p_job->name)) _param[ID] = p_job->name; - if (p_job->text && strlen(p_job->text)) _param[TEXT] = p_job->text; - - for(struct attrl * p_attr = p_job->attribs; p_attr; p_attr = p_attr->next) { - - string name, res, value; - if (p_attr->name && strlen(p_attr->name)) name = p_attr->name; - if (p_attr->resource && strlen(p_attr->resource)) res = p_attr->resource; - if (p_attr->value && strlen(p_attr->value)) value = p_attr->value; - - if (name == ATTR_N) { - _param[NAME] = value; - - } else if (name == ATTR_owner) { - _param[USER] = value; - - } else if (name == ATTR_state) { - string status = value; - if (status == "C") { // Completed - _param[STATE] = FINISHED; - } else if (status == "E") { // Exiting - _param[STATE] = RUNNING; - } else if (status == "H") { // Held - _param[STATE] = PAUSED; - } else if (status == "Q") { // Queued - _param[STATE] = QUEUED; - } else if (status == "R") { // Running - _param[STATE] = RUNNING; - } else if (status == "S") { // Suspend - _param[STATE] = PAUSED; - } else if (status == "T") { // Transiting - _param[STATE] = IN_PROCESS; - } else if (status == "W") { // Waiting - _param[STATE] = PAUSED; - } else { - cerr << "Unknown job state code: " << status << endl; - } - - } else if (name == ATTR_queue) { - _param[QUEUE] = value; - - } else if (name == ATTR_A) { - _param[ACCOUNT] = value; - - } else if (name == ATTR_M) { - _param[MAIL] = value; - - } else if (name == ATTR_c) { - if (!strcmp(value.c_str(), CHECKPOINT_UNSPECIFIED)) _param[CHECKPOINT] = 1L; - else _param[CHECKPOINT] = 0L; - - } else if (name == ATTR_h) { - if (!strcmp(value.c_str(), NO_HOLD)) _param[HOLD] = 0L; - else _param[HOLD] = 1L; - - } else if (name == ATTR_ctime) { - _param[CREATIONTIME] = atol(value.c_str()); - - } else if (name == ATTR_etime) { - _param[ELIGIBLETIME] = atol(value.c_str()); - - } else if (name == ATTR_mtime) { - _param[MODIFICATIONTIME] = atol(value.c_str()); - - } else if (name == ATTR_qtime) { - _param[QUEUEDTIME] = atol(value.c_str()); - - } else if (name == ATTR_exechost) { - _param[EXECUTIONHOST] = value; - - } else if (name == ATTR_session) { - _param[PID] = atol(value.c_str()); - - } else if (name == ATTR_euser) { - _param[EUSER] = value; - - } else if (name == ATTR_egroup) { - _param[EGROUP] = value; - - } else if (name == ATTR_l) { - if (res == "cput") { - _param[MAXCPUTIME] = HMStoLong(value); - - } else if (res == "walltime") { - _param[MAXWALLTIME] = HMStoLong(value); - - } - - } else if (name == ATTR_used) { - if (res == "cput") { - _param[USEDCPUTIME] = HMStoLong(value); - - } else if (res == "walltime") { - _param[USEDWALLTIME] = HMStoLong(value); - - } - - } else if (name == ATTR_v) { - int deb = 0; - int pos = 0; - bool ok = true; - - while (ok) { - pos = value.find(",", deb); - string sub = value.substr(deb, pos-deb); - deb = pos + 1; - if (pos < 0) ok = false; - - int eq = sub.find("="); - _env[sub.substr(0, eq)] = sub.substr(eq+1); - } - - } - } - - - if (tobedeleted) pbs_statfree(list); - } - - // Destructeur - JobInfo_PBS::~JobInfo_PBS() - { - // Nothing to do - } - - // Convertit une date HH:MM:SS en secondes - long JobInfo_PBS::HMStoLong(const string & s) - { - long hour, min, sec; - - sscanf( s.c_str(), "%ld:%ld:%ld", &hour, &min, &sec); - return ( ( ( hour * 60L ) + min ) * 60L ) + sec; - } - - // Methode pour l'interfacage avec Python (SWIG) : affichage en Python - string JobInfo_PBS::__str__() const - { - ostringstream sst; - sst << " -#include -} -#include -#include "Batch_RunTimeException.hxx" -#include "Batch_JobInfo.hxx" - -namespace Batch { - - class JobInfo_PBS : public JobInfo - { - public: - // Constructeurs et destructeur - JobInfo_PBS() : JobInfo() {}; - JobInfo_PBS(struct batch_status * stat_list, bool tobedeleted = false); - virtual ~JobInfo_PBS(); - - // Constructeur par recopie - JobInfo_PBS(const JobInfo_PBS & jinfo) : JobInfo(jinfo) {}; - - // Methodes pour l'interfacage avec Python (SWIG) - // TODO : supprimer ces methodes et transferer leur definitions dans SWIG - std::string __str__() const; // SWIG : affichage en Python - std::string __repr__() const { return __str__(); }; // SWIG : affichage en Python - - protected: - - private: - // Convertit une date HH:MM:SS en secondes - long HMStoLong(const std::string &); - - }; - -} - -#endif diff --git a/src/PBS/Batch_Job_PBS.cxx b/src/PBS/Batch_Job_PBS.cxx deleted file mode 100644 index 3186262..0000000 --- a/src/PBS/Batch_Job_PBS.cxx +++ /dev/null @@ -1,474 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Job_PBS.cxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Mail : mailto:ivan.dutka-malen@der.edf.fr - * Date : Fri Nov 14 11:00:39 2003 - * Projet : Salome 2 - * - */ - -#include -#include -#include -#include - -#include "Batch_Constants.hxx" -#include "Batch_Job_PBS.hxx" -using namespace std; - -namespace Batch { - - // Ajoute un element (name,resource,value) a la liste chainee d'attributs + operateur - void Job_PBS::setResourceAttributeOP(struct attropl ** attr_list, const char * attr_name, const char * attr_resource, const char * attr_value) - { - // L'element (name,resource,value) existe-t-il deja ? si oui ptr != 0 - struct attropl * ptr = findResourceAttributeOP(*attr_list, attr_name, attr_resource); - - if (!ptr) { // L'element n'existe pas, il faut le creer - if ((ptr = lastAttributeOP(*attr_list))) { // la liste n'est pas vide - ptr->next = new struct attropl; - ptr = ptr->next; - ptr->next = 0; - - } else { // la liste est completement vide - ptr = *attr_list = new struct attropl; - ptr->next = 0; - } - - // On remplit les champs (name,resource,value) - ptr->name = new char[strlen(attr_name) + 1]; - strncpy(ptr->name, attr_name, strlen(attr_name)); - ptr->name[strlen(attr_name)] = 0; - - ptr->resource = new char[strlen(attr_resource) + 1]; - strncpy(ptr->resource, attr_resource, strlen(attr_resource)); - ptr->resource[strlen(attr_resource)] = 0; - - ptr->value = new char[strlen(attr_value) + 1]; - strncpy(ptr->value, attr_value, strlen(attr_value)); - ptr->value[strlen(attr_value)] = 0; - - } else { // L'attribut existe, on change sa valeur - delete[] ptr->value; // On efface la valeur precedente - ptr->value = new char[strlen(attr_value) + 1]; - strncpy(ptr->value, attr_value, strlen(attr_value)); - ptr->value[strlen(attr_value)] = 0; - - } - } - - - // Recherche un element (name,resource,value) dans la liste chainee d'attributs + operateur - struct attropl * Job_PBS::findResourceAttributeOP(struct attropl * attr_list, const char * attr_name, const char * attr_resource) - { - // On parcoure la liste chainee pour trouver l'element dont les champs name et resource coincident - struct attropl * ptr = attr_list; - while (ptr) { - if (!strcmp(ptr->name, attr_name) && !strcmp(ptr->resource, attr_resource)) break; - ptr = ptr->next; - } - return ptr; - } - - - // Recherche le dernier element de la liste chainee d'attributs + operateur - struct attropl * Job_PBS::lastAttributeOP(struct attropl * attr_list) - { - struct attropl * ptr = attr_list; - while (ptr && ptr->next) { - ptr = ptr->next; - } - return ptr; - } - - - // Convertit un objet Parametre en liste chainee d'attributs + operateur - struct attropl * Job_PBS::ParametreToAttributeOPList(struct attropl ** _p_attr_list, Parametre & P) - { - Parametre::iterator it; - string st_second; - for(it=P.begin(); it!=P.end(); it++) { - if ( (*it).first == ACCOUNT ) { - st_second = (*it).second.str(); - setResourceAttributeOP(_p_attr_list, ATTR_A, "", st_second.c_str()); - - - } else if ( (*it).first == CHECKPOINT ) { - setResourceAttributeOP(_p_attr_list, ATTR_c, "", "u"); - - - } else if ( (*it).first == CKPTINTERVAL ) { - // Not significant - - } else if ( (*it).first == EXECUTABLE ) { - // Already done - - } else if ( (*it).first == HOLD ) { - if (static_cast< long >((*it).second)) - setResourceAttributeOP(_p_attr_list, ATTR_h, "", USER_HOLD); - else - setResourceAttributeOP(_p_attr_list, ATTR_h, "", NO_HOLD); - - } else if ( (*it).first == INFILE ) { - Versatile V = (*it).second; - Versatile::iterator Vit; - - string sep = ""; - string stagein; - - for(Vit=V.begin(); Vit!=V.end(); Vit++, sep=",") { - CoupleType cpt = *static_cast< CoupleType * >(*Vit); - Couple cp = cpt; - string local = cp.getLocal(); - string remote = cp.getRemote(); - - // ATTENTION : les notions de fichier "local" ou "remote" sont inverses de celle de PBS qui a un point de vue serveur et non pas utilisateur - stagein += sep + remote + "@" + local; - } - - if (stagein.size()) - setResourceAttributeOP(_p_attr_list, ATTR_stagein, "", stagein.c_str()); - - - } else if ( (*it).first == MAIL ) { - st_second = (*it).second.str(); - setResourceAttributeOP(_p_attr_list, ATTR_M, "", st_second.c_str()); - - } else if ( (*it).first == MAXCPUTIME ) { - char attr_value[32]; - long secondes = (*it).second; - long heures = secondes / 3600L; - long minutes = (secondes - 3600L * heures) / 60L; - secondes = secondes % 60L; - sprintf(attr_value, "%02ld:%02ld:%02ld", heures, minutes, secondes); - - setResourceAttributeOP(_p_attr_list, ATTR_l, "cput", attr_value); - - - } else if ( (*it).first == MAXDISKSIZE ) { - - } else if ( (*it).first == MAXRAMSIZE ) { - - } else if ( (*it).first == MAXWALLTIME ) { - char attr_value[32]; - long minutes = (*it).second; - long heures = minutes / 60L; - minutes -= 60L * heures; - sprintf(attr_value, "%02ld:%02ld:00", heures, minutes); - - setResourceAttributeOP(_p_attr_list, ATTR_l, "walltime", attr_value); - - - } else if ( (*it).first == NAME ) { - st_second = (*it).second.str(); - setResourceAttributeOP(_p_attr_list, ATTR_N, "", st_second.c_str()); - - - } else if ( (*it).first == OUTFILE ) { - Versatile V = (*it).second; - Versatile::iterator Vit; - - string sep = ""; - string stageout; - - for(Vit=V.begin(); Vit!=V.end(); Vit++, sep=",") { - CoupleType cpt = *static_cast< CoupleType * >(*Vit); - Couple cp = cpt; - string local = cp.getLocal(); - string remote = cp.getRemote(); - - if (remote == "stdout") - setResourceAttributeOP(_p_attr_list, ATTR_o, "", local.c_str()); - - else if (remote == "stderr") - setResourceAttributeOP(_p_attr_list, ATTR_e, "", local.c_str()); - - else - // ATTENTION : les notions de fichier "local" ou "remote" sont inverses de celle de PBS qui a un point de vue serveur et non pas utilisateur - stageout += sep + remote + "@" + local; - } - - if (stageout.size()) - setResourceAttributeOP(_p_attr_list, ATTR_stageout, "", stageout.c_str()); - - } else if ( (*it).first == QUEUE ) { - // Already done - - } else if ( (*it).first == STARTTIME ) { - - } else if ( (*it).first == TMPDIR ) { - - } else if ( (*it).first == USER ) { - st_second = (*it).second.str(); - setResourceAttributeOP(_p_attr_list, ATTR_u, "", st_second.c_str()); - - } - } - return *_p_attr_list; - } - - - // Convertit un objet Environnement en liste chainee d'attributs + operateur - struct attropl * Job_PBS::EnvironnementToAttributeOPList(struct attropl ** _p_attr_list, Environnement & E) - { - Environnement::iterator it; - for(it=E.begin(); it!=E.end(); it++) { - setResourceAttributeOP(_p_attr_list, ATTR_v, (*it).first.c_str(), ( (*it).first + "=" + (*it).second ).c_str()); - } - return *_p_attr_list; - } - - - // Ajoute les variables d'environnement presentes dans tout job PBS - void Job_PBS::addPBSEnvironnement(Environnement & E) - { - char * c; - - c = getenv("HOME"); - if (c) E["PBS_O_HOME"] = c; - - c = getenv("LANG"); - if (c) E["PBS_O_LANG"] = c; - - c = getenv("LOGNAME"); - if (c) E["PBS_O_LOGNAME"] = c; - - c = getenv("PATH"); - if (c) E["PBS_O_PATH"] = c; - - c = getenv("LD_LIBRARY_PATH"); - if (c) E["PBS_O_LD_LIBRARY_PATH"] = c; - - c = getenv("MAIL"); - if (c) E["PBS_O_MAIL"] = c; - - c = getenv("SHELL"); - if (c) E["PBS_O_SHELL"] = c; - - c = getenv("TZ"); - if (c) E["PBS_O_TZ"] = c; - - /* Recuperation du working directory */ - size_t size = 256; - char * buf = 0; - char * rc = 0; - do { - if (buf) delete[] buf; - buf = new char[size]; - rc = getcwd(buf, size); - size += size; - } while (!rc); - E["PBS_O_WORKDIR"] = buf; - delete[] buf; - } - - - // Ajoute un element (name,resource,value) a la liste chainee d'attributs - void Job_PBS::setResourceAttribute(struct attrl ** attr_list, const char * attr_name, const char * attr_resource, const char * attr_value) - { - // L'element (name,resource,value) existe-t-il deja ? si oui ptr != 0 - struct attrl * ptr = findResourceAttribute(*attr_list, attr_name, attr_resource); - - if (!ptr) { // L'attribut n'existe pas, il faut le creer - if ((ptr = lastAttribute(*attr_list))) { // la liste n'est pas vide - ptr->next = new struct attrl; - ptr = ptr->next; - ptr->next = 0; - - } else { // la liste est completement vide - ptr = *attr_list = new struct attrl; - ptr->next = 0; - } - - // On remplit les champs (name,resource,value) - ptr->name = new char[strlen(attr_name) + 1]; - strncpy(ptr->name, attr_name, strlen(attr_name)); - ptr->name[strlen(attr_name)] = 0; - - ptr->resource = new char[strlen(attr_resource) + 1]; - strncpy(ptr->resource, attr_resource, strlen(attr_resource)); - ptr->resource[strlen(attr_resource)] = 0; - - ptr->value = new char[strlen(attr_value) + 1]; - strncpy(ptr->value, attr_value, strlen(attr_value)); - ptr->value[strlen(attr_value)] = 0; - - } else { // L'attribut existe, on change sa valeur - delete[] ptr->value; // On efface la valeur precedente - ptr->value = new char[strlen(attr_value) + 1]; - strncpy(ptr->value, attr_value, strlen(attr_value)); - ptr->value[strlen(attr_value)] = 0; - - } - } - - // Recherche un element (name,resource,value) dans la liste chainee d'attributs - struct attrl * Job_PBS::findResourceAttribute(struct attrl * attr_list, const char * attr_name, const char * attr_resource) - { - // On parcoure la liste chainee pour trouver l'element dont les champs name et resource coincident - struct attrl * ptr = attr_list; - while (ptr) { - if (!strcmp(ptr->name, attr_name) && !strcmp(ptr->resource, attr_resource)) break; - ptr = ptr->next; - } - return ptr; - } - - - // Recherche le dernier element de la liste chainee d'attributs - struct attrl * Job_PBS::lastAttribute(struct attrl * attr_list) - { - struct attrl * ptr = attr_list; - while (ptr && ptr->next) { - ptr = ptr->next; - } - return ptr; - } - - - // Constructeur - Job_PBS::Job_PBS(const Job & job) : _p_attropl(0), _p_attrl(0), _script(0), _destination(0) - { - Parametre P = job.getParametre(); - Parametre::iterator it; - - // On extrait de l'objet Parametre le champ EXECUTABLE qui deviendra le script PBS - if ( (it=P.find(EXECUTABLE)) != P.end()) { - Versatile V = (*it).second; - string st_exe = V.str(); - const char * exe = st_exe.c_str(); - int lg = strlen(exe); - _script = new char[lg + 1]; - for (int ii=0; iinext; - delete[] current_p_attropl->name; - delete[] current_p_attropl->resource; - delete[] current_p_attropl->value; - delete current_p_attropl; - current_p_attropl = next; - } - - // On detruit la liste chainee d'attributs - struct attrl * current_p_attrl = _p_attrl; - while (current_p_attrl) { - struct attrl * next = current_p_attrl->next; - delete[] current_p_attrl->name; - delete[] current_p_attrl->resource; - delete[] current_p_attrl->value; - delete current_p_attrl; - current_p_attrl = next; - } - - // On detruit les champs alloues - delete[] _script; - delete[] _destination; - } - - - // Accesseur - struct attropl * Job_PBS::getAttributesOP() - { - return _p_attropl; - } - - // Accesseur - // Cette methode sert pour les pbs_alter de PBS - // Pbs_alter est bugg� par rapport a la specification ers_all.ps car les - // variables d'environnement ne sont pas supportees (ATTR_v) - struct attrl * Job_PBS::getAttributes() - { - if (_p_attrl == 0) { - - // On remplit la structure attrl a partir de la strucuture attropl - // (elles ne different que par le parametre op, mais elles ne sont pas interchangeables - // dans les appels) - - struct attropl * current_p_attropl = _p_attropl; - while (current_p_attropl) { - if (strcmp(current_p_attropl->name, ATTR_v)) // Bug fix for ATTR_v - setResourceAttribute(&_p_attrl, - current_p_attropl->name, - current_p_attropl->resource, - current_p_attropl->value); - - current_p_attropl = current_p_attropl->next; - } - - } - - return _p_attrl; - } - - // Accesseur - char * Job_PBS::getScript() - { - return _script; - } - - // Accesseur - char * Job_PBS::getDestination() - { - return _destination; - } - -} diff --git a/src/PBS/Batch_Job_PBS.hxx b/src/PBS/Batch_Job_PBS.hxx deleted file mode 100644 index 43a7b54..0000000 --- a/src/PBS/Batch_Job_PBS.hxx +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Job_PBS.hxx : - * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Mail : mailto:ivan.dutka-malen@der.edf.fr - * Date : Fri Nov 14 11:00:39 2003 - * Projet : Salome 2 - * - */ - -#ifndef _JOB_PBS_H_ -#define _JOB_PBS_H_ - -extern "C" { - -#include -#include -} -#include "Batch_Job.hxx" - -namespace Batch { - - class Job_PBS - { - public: - // Constructeur et destructeur - Job_PBS(const Job & job); - virtual ~Job_PBS(); - - // Accesseurs - struct attropl * getAttributesOP(); - struct attrl * getAttributes(); - char * getScript(); - char * getDestination(); - - protected: - struct attropl * _p_attropl; // liste chainee d'attributs + operateur - struct attrl * _p_attrl; // liste chainee d'attributs - char * _script; // chemin d'acces au script du job - char * _destination; // queue dans laquelle le job est soumis - - private: - // Ajoute un element (name,resource,value) a la liste chainee d'attributs + operateur - void setResourceAttributeOP(struct attropl ** attr_list, const char * attr_name, const char * attr_resource, const char * attr_value); - - // Recherche un element (name,resource,value) dans la liste chainee d'attributs + operateur - struct attropl * findResourceAttributeOP(struct attropl * attr_list, const char * attr_name, const char * attr_resource); - - // Recherche le dernier element de la liste chainee d'attributs + operateur - struct attropl * lastAttributeOP(struct attropl * attr_list); - - // Convertit un objet Parametre en liste chainee d'attributs + operateur - struct attropl * ParametreToAttributeOPList(struct attropl ** _p_attr_list, Parametre & param); - - // Convertit un objet Environnement en liste chainee d'attributs + operateur - struct attropl * EnvironnementToAttributeOPList(struct attropl ** _p_attr_list, Environnement & env); - - // Ajoute les variables d'environnement presentes dans tout job PBS - void addPBSEnvironnement(Environnement & E); - - - // Ajoute un element (name,resource,value) a la liste chainee d'attributs - void setResourceAttribute(struct attrl ** attr_list, const char * attr_name, const char * attr_resource, const char * attr_value); - - // Recherche un element (name,resource,value) dans la liste chainee d'attributs - struct attrl * findResourceAttribute(struct attrl * attr_list, const char * attr_name, const char * attr_resource); - - // Recherche le dernier element de la liste chainee d'attributs - struct attrl * lastAttribute(struct attrl * attr_list); - - }; - -} - -#endif diff --git a/src/PBS/CMakeLists.txt b/src/PBS/CMakeLists.txt index bf57649..9fc2dde 100644 --- a/src/PBS/CMakeLists.txt +++ b/src/PBS/CMakeLists.txt @@ -20,22 +20,9 @@ # 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 +SET(CLASS_LIST PBS/BatchManager_PBS + PBS/FactBatchManager_PBS + PBS/JobInfo_PBS ) -IF (BUILD_PBS_INTERFACE AND PBS_FOUND) - SET(CLASS_LIST ${CLASS_LIST} - PBS/Batch_BatchManager_PBS - PBS/Batch_FactBatchManager_PBS - PBS/Batch_Job_PBS - PBS/Batch_JobInfo_PBS - ) -ENDIF (BUILD_PBS_INTERFACE AND PBS_FOUND) - APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST}) - -IF (TEST_ENABLED) - add_subdirectory(Test) -ENDIF (TEST_ENABLED) diff --git a/src/PBS/Batch_FactBatchManager_PBS.cxx b/src/PBS/FactBatchManager_PBS.cxx similarity index 72% rename from src/PBS/Batch_FactBatchManager_PBS.cxx rename to src/PBS/FactBatchManager_PBS.cxx index 9a651c9..73eb776 100644 --- a/src/PBS/Batch_FactBatchManager_PBS.cxx +++ b/src/PBS/FactBatchManager_PBS.cxx @@ -20,17 +20,16 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * FactBatchManager_PBS.cxx : + * FactBatchManager_PBS.cxx : * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Date : Septembre 2004 - * Projet : SALOME 2 + * Auteur : Bernard SECHER - CEA DEN + * Date : Avril 2008 + * Projet : PAL Salome * */ -#include "Batch_BatchManager_PBS.hxx" -#include "Batch_FactBatchManager_PBS.hxx" -using namespace std; +#include "BatchManager_PBS.hxx" +#include "FactBatchManager_PBS.hxx" namespace Batch { @@ -48,11 +47,12 @@ namespace Batch { // Nothing to do } - // Functor - BatchManager * FactBatchManager_PBS::operator() (const char * hostname) const + BatchManager * FactBatchManager_PBS::operator() (const char * hostname, + const char * username, + CommunicationProtocolType protocolType, + const char * mpiImpl) const { - return new BatchManager_PBS(this, hostname); + return new BatchManager_PBS(this, hostname, username, protocolType, mpiImpl); } - } diff --git a/src/PBS/Batch_FactBatchManager_PBS.hxx b/src/PBS/FactBatchManager_PBS.hxx similarity index 71% rename from src/PBS/Batch_FactBatchManager_PBS.hxx rename to src/PBS/FactBatchManager_PBS.hxx index fea48dc..c26a8ad 100644 --- a/src/PBS/Batch_FactBatchManager_PBS.hxx +++ b/src/PBS/FactBatchManager_PBS.hxx @@ -22,33 +22,35 @@ /* * FactBatchManager_PBS.hxx : * - * Auteur : Ivan DUTKA-MALEN - EDF R&D - * Date : Septembre 2004 - * Projet : SALOME 2 + * Auteur : Bernard SECHER : CEA DEN + * Date : Avril 2008 + * Projet : PAL Salome * */ #ifndef _FACTBATCHMANAGER_PBS_H_ #define _FACTBATCHMANAGER_PBS_H_ -#include "Batch_FactBatchManager.hxx" +#include "Defines.hxx" + +#include "BatchManager.hxx" +#include "FactBatchManager.hxx" namespace Batch { class BatchManager_PBS; - class FactBatchManager_PBS : public FactBatchManager + class BATCH_EXPORT FactBatchManager_PBS : public FactBatchManager { public: // Constructeur et destructeur FactBatchManager_PBS(); virtual ~FactBatchManager_PBS(); - virtual BatchManager * operator() (const char * hostname) const; - - protected: - - private: + virtual BatchManager * operator() (const char * hostname, + const char * username, + CommunicationProtocolType protocolType, + const char * mpiImpl) const; }; diff --git a/src/PBS/Batch_JobInfo_ePBS.cxx b/src/PBS/JobInfo_PBS.cxx similarity index 88% rename from src/PBS/Batch_JobInfo_ePBS.cxx rename to src/PBS/JobInfo_PBS.cxx index 6211073..179b2c3 100644 --- a/src/PBS/Batch_JobInfo_ePBS.cxx +++ b/src/PBS/JobInfo_PBS.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * JobInfo_ePBS.cxx : emulation of PBS client + * JobInfo_PBS.cxx : emulation of PBS client * * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr @@ -33,15 +33,16 @@ #include #include -#include -#include "Batch_JobInfo_ePBS.hxx" +#include +#include "JobInfo_PBS.hxx" +#include "Log.hxx" using namespace std; namespace Batch { // Constructeurs - JobInfo_ePBS::JobInfo_ePBS(int id, string queryOutput) : JobInfo() + JobInfo_PBS::JobInfo_PBS(int id, string queryOutput) : JobInfo() { // Fill ID parameter ostringstream oss; @@ -80,7 +81,7 @@ namespace Batch { } else if (status == "W") { // Waiting _param[STATE] = PAUSED; } else { - cerr << "Unknown job state code: " << status << endl; + LOG("Unknown job state code: " << status); } } else { // On some batch managers, the job is deleted as soon as it is finished, @@ -91,13 +92,13 @@ namespace Batch { } // Destructeur - JobInfo_ePBS::~JobInfo_ePBS() + JobInfo_PBS::~JobInfo_PBS() { // Nothing to do } // Convertit une date HH:MM:SS en secondes - long JobInfo_ePBS::HMStoLong(const string & s) + long JobInfo_PBS::HMStoLong(const string & s) { long hour, min, sec; @@ -106,10 +107,10 @@ namespace Batch { } // Methode pour l'interfacage avec Python (SWIG) : affichage en Python - string JobInfo_ePBS::__str__() const + string JobInfo_PBS::__str__() const { ostringstream sst; - sst << " -#include - -#include -#include -#include -#include -#include - -#include - -using namespace std; -using namespace Batch; - -int main(int argc, char** argv) -{ - cout << "*******************************************************************************************" << endl; - cout << "This program tests the batch submission based on PBS." << endl; - cout << "*******************************************************************************************" << endl; - - // eventually remove any previous result - remove("result.txt"); - - try { - // Parse the test configuration file - SimpleParser parser; - parser.parseTestConfigFile(); - const string & host = parser.getValue("TEST_PBS_HOST"); - const string & user = parser.getValue("TEST_PBS_USER"); - const string & queue = parser.getValue("TEST_PBS_QUEUE"); - int timeout = parser.getValueAsInt("TEST_PBS_TIMEOUT"); - - char * cwd = -#ifdef WIN32 - _getcwd(NULL, 0); -#else - new char [PATH_MAX]; - getcwd(cwd, PATH_MAX); -#endif - string workdir = cwd; - delete [] cwd; - - // Define the job... - Job job; - // ... and its parameters ... - Parametre p; - p[EXECUTABLE] = "test-script.sh"; - p[NAME] = "Test_PBS"; - p[INFILE] = Couple(workdir + "/seta.sh", "seta.sh"); - p[INFILE] += Couple(workdir + "/setb.sh", "setb.sh"); - p[OUTFILE] = Couple(workdir + "/result.txt", "result.txt"); - p[USER] = user; - p[NBPROC] = 1; - p[MAXWALLTIME] = 1; - p[MAXRAMSIZE] = 4; - p[QUEUE] = queue; - job.setParametre(p); - // ... and its environment - Environnement e; - e["MYENVVAR"] = "MYVALUE"; - job.setEnvironnement(e); - cout << job << endl; - - // Get the catalog - BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); - - // Create a BatchManager of type ePBS on localhost - FactBatchManager * fbm = c("PBS"); - BatchManager * bm = (*fbm)(host.c_str()); - - // Submit the job to the BatchManager - JobId jobid = bm->submitJob(job); - cout << jobid.__repr__() << endl; - - // Wait for the end of the job - string state = bm->waitForJobEnd(jobid, timeout); - - if (state == FINISHED || state == FAILED) { - cout << "Job " << jobid.__repr__() << " is done" << endl; - } else { - cerr << "Timeout while executing job" << endl; - return 1; - } - - } catch (GenericException e) { - cerr << "Error: " << e << endl; - return 1; - } catch (ParserException e) { - cerr << "Parser error: " << e.what() << endl; - return 1; - } - - // test the result file - try { - SimpleParser resultParser; - resultParser.parse("result.txt"); - cout << "Result:" << endl << resultParser; - const string & envvar = resultParser.getValue("MYENVVAR"); - int result = resultParser.getValueAsInt("c"); - if (envvar == "MYVALUE" && result == 12) { - cout << "OK, Expected result found." << endl; - return 0; - } else { - cerr << "Error, result is not the expected one (MYENVVAR = MYVALUE, c = 12)." << endl; - return 1; - } - } catch (ParserException e) { - cerr << "Parser error on result file: " << e.what() << endl; - return 1; - } -} diff --git a/src/PBS/Test/Test_ePBS.cxx b/src/PBS/Test/Test_ePBS.cxx deleted file mode 100644 index c016089..0000000 --- a/src/PBS/Test/Test_ePBS.cxx +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Test_ePBS.cxx : - * - * Author : Renaud BARATE - EDF R&D - * Date : April 2009 - * - */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -using namespace std; -using namespace Batch; - -void print_usage() -{ - cout << "usage: Test_ePBS PROTOCOL" << endl; - cout << " PROTOCOL \"SSH\" or \"RSH\"" << endl; -} - -int main(int argc, char** argv) -{ - // Parse argument - if (argc != 2) { - print_usage(); - return 1; - } - CommunicationProtocolType protocol; - if (strcmp(argv[1], "SSH") == 0) - protocol = SSH; - else if (strcmp(argv[1], "RSH") == 0) - protocol = RSH; - else { - print_usage(); - return 1; - } - - cout << "*******************************************************************************************" << endl; - cout << "This program tests the batch submission based on PBS emulation. Passwordless authentication" << endl; - cout << "must be used for this test to pass. For SSH, this can be configured with ssh-agent for" << endl; - cout << "instance. For RSH, this can be configured with the .rhosts file." << endl; - cout << "*******************************************************************************************" << endl; - - // eventually remove any previous result - remove("result.txt"); - - try { - // Parse the test configuration file - SimpleParser parser; - parser.parseTestConfigFile(); - const string & homedir = parser.getValue("TEST_EPBS_HOMEDIR"); - const string & host = parser.getValue("TEST_EPBS_HOST"); - const string & user = parser.getValue("TEST_EPBS_USER"); - const string & queue = parser.getValue("TEST_EPBS_QUEUE"); - int timeout = parser.getValueAsInt("TEST_EPBS_TIMEOUT"); - - // Define the job... - Job job; - // ... and its parameters ... - Parametre p; - p[EXECUTABLE] = "./test-script.sh"; - p[NAME] = string("Test_ePBS_") + argv[1]; - p[WORKDIR] = 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[NBPROC] = 1; - p[MAXWALLTIME] = 1; - p[MAXRAMSIZE] = 128; - p[HOMEDIR] = homedir; - p[QUEUE] = queue; - job.setParametre(p); - // ... and its environment - Environnement e; - e["MYENVVAR"] = "MYVALUE"; - job.setEnvironnement(e); - cout << job << endl; - - // Get the catalog - BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); - - // Create a BatchManager of type ePBS on localhost - FactBatchManager_eClient * fbm = (FactBatchManager_eClient *)(c("ePBS")); - BatchManager_eClient * bm = (*fbm)(host.c_str(), user.c_str(), protocol, "nompi", 8); - - // Submit the job to the BatchManager - JobId jobid = bm->submitJob(job); - cout << jobid.__repr__() << endl; - - // Wait for the end of the job - string state = bm->waitForJobEnd(jobid, timeout); - - if (state == FINISHED || state == FAILED) { - cout << "Job " << jobid.__repr__() << " is done" << endl; - bm->importOutputFiles(job, "resultdir/seconddirname"); - } else { - cerr << "Timeout while executing job" << endl; - return 1; - } - - } catch (GenericException e) { - cerr << "Error: " << e << endl; - return 1; - } catch (ParserException e) { - cerr << "Parser error: " << e.what() << endl; - return 1; - } - - // test the result file - try { - SimpleParser resultParser; - resultParser.parse("resultdir/seconddirname/result.txt"); - cout << "Result:" << endl << resultParser; - const string & envvar = resultParser.getValue("MYENVVAR"); - int result = resultParser.getValueAsInt("c"); - if (envvar == "MYVALUE" && result == 12) { - cout << "OK, Expected result found." << endl; - return 0; - } else { - cerr << "Error, result is not the expected one (MYENVVAR = MYVALUE, c = 12)." << endl; - return 1; - } - } catch (ParserException e) { - cerr << "Parser error on result file: " << e.what() << endl; - return 1; - } -} diff --git a/src/PBS/Test/seta.sh b/src/PBS/Test/seta.sh deleted file mode 100644 index 42d1e38..0000000 --- a/src/PBS/Test/seta.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -a=4 diff --git a/src/PBS/Test/setb.sh b/src/PBS/Test/setb.sh deleted file mode 100644 index 8969060..0000000 --- a/src/PBS/Test/setb.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -b=3 diff --git a/src/PBS/Test/test-script.sh b/src/PBS/Test/test-script.sh deleted file mode 100755 index ae952c8..0000000 --- a/src/PBS/Test/test-script.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -source seta.sh -source setb.sh - -c=`expr $a "*" $b` - -echo "MYENVVAR = $MYENVVAR" > result.txt -echo "c = $c" >> result.txt diff --git a/src/Python/CMakeLists.txt b/src/Python/CMakeLists.txt index f9a8a3a..8e901b9 100644 --- a/src/Python/CMakeLists.txt +++ b/src/Python/CMakeLists.txt @@ -28,14 +28,15 @@ 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}) -SWIG_LINK_LIBRARIES(libBatch_Swig Batch ${PYTHON_LIBRARIES}) +SWIG_ADD_MODULE(libbatch python ${SWIG_SRC_FILE}) +SWIG_LINK_LIBRARIES(libbatch 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 +SET(PYTHON_VERSION "{PYTHON_VERSION_MAJOR}.{PYTHON_VERSION_MINOR}") +INSTALL(TARGETS ${SWIG_MODULE_libbatch_REAL_NAME} DESTINATION lib/python${PYTHON_VERSION}/site-packages) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libbatch.py DESTINATION lib/python${PYTHON_VERSION}/site-packages) -SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES libBatch_Swig.py) +SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES libbatch.py) IF (TEST_ENABLED) add_subdirectory(Test) diff --git a/src/Python/Test/CMakeLists.txt b/src/Python/Test/CMakeLists.txt index fe3d614..0119438 100644 --- a/src/Python/Test/CMakeLists.txt +++ b/src/Python/Test/CMakeLists.txt @@ -24,9 +24,7 @@ IF (BUILD_LOCAL_SUBMISSION AND HAS_SH) # Configure the config file for the test script 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) + # Just copy the test script to the binary dir CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Test_Python_Local_SH.py ${CMAKE_CURRENT_BINARY_DIR}/Test_Python_Local_SH.py COPYONLY) diff --git a/src/Python/Test/Test_Python_Local_SH.py b/src/Python/Test/Test_Python_Local_SH.py index a6dae7d..3a1e742 100644 --- a/src/Python/Test/Test_Python_Local_SH.py +++ b/src/Python/Test/Test_Python_Local_SH.py @@ -25,8 +25,8 @@ import os import sys import time -# Import libBatch library -from libBatch_Swig import * +# Import libbatch library +from libbatch import * def work(): print "*******************************************************************************************" @@ -35,31 +35,32 @@ def work(): print "*******************************************************************************************" # eventually remove any previous result - if (os.path.exists('result.txt')): - os.remove('result.txt') + if (os.path.exists("resultdir/seconddirname/result.txt")): + os.remove("resultdir/seconddirname/result.txt") # Define the job... job = Job() # ... and its parameters ... p = {} - p[EXECUTABLE] = './copied-' + config.EXEC_TEST_NAME - p[ARGUMENTS] = ["copied-seta.sh", "copied-setb.sh", "orig-result.txt"]; + p[EXECUTABLE] = config.TEST_SOURCE_DIR + "/test_script.py"; + p[ARGUMENTS] = ["copied_seta.py", "copied_setb.py", "orig_result.txt"]; p[NAME] = 'Test_Python_Local_SH' - p[WORKDIR] = config.TEST_LOCAL_SH_WORK_DIR - p[INFILE] = [('seta.sh', 'copied-seta.sh'), ('setb.sh', 'copied-setb.sh'), - (config.EXEC_TEST_FULL_PATH, 'copied-' + config.EXEC_TEST_NAME)] - p[OUTFILE] = [('result.txt', 'orig-result.txt')] + p[WORKDIR] = config.TEST_LOCAL_SH_WORKDIR + p[INFILE] = [(config.TEST_SOURCE_DIR + '/seta.py', 'copied_seta.py'), + (config.TEST_SOURCE_DIR + '/setb.py', 'copied_setb.py')] + p[OUTFILE] = [('result.txt', 'orig_result.txt')] job.setParametre(p) # ... and its environment e = {} + e["MYENVVAR"] = "MYVALUE"; job.setEnvironnement(e) print job # Get the catalog c = BatchManagerCatalog.getInstance() - # Create a BatchManager of type Local_SSH on localhost - bm = c('SH')('localhost') + # Create a BatchManager of type Local_SH on localhost + bm = c('LOCAL')('localhost', '', SH) # Submit the job to the BatchManager jobid = bm.submitJob(job) @@ -71,22 +72,31 @@ def work(): # Wait for the end of the job state = bm.waitForJobEnd(jobid, config.TEST_LOCAL_SH_TIMEOUT); + + if state == FINISHED: + print "Job", jobid, "is done" + bm.importOutputFiles(job, "resultdir/seconddirname") + elif state == FAILED: + print "Job", jobid, " finished in error" + bm.importOutputFiles(job, "resultdir/seconddirname") + return 1 + else: + print "Timeout while executing job" + return 1 + if state != FINISHED and state != FAILED: print "Error: Job not finished after timeout" return 1; - print "Job", jobid, "is done" - # 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 + res = {} + execfile('resultdir/seconddirname/result.txt', res) + if (res["c"] == 12 and res["MYENVVAR"] == "MYVALUE"): + print "OK, Expected result found." + return 0 else: - return 1 + print "result found : %s, expected : %s" % (res, 'res["c"] == 12 and res["MYENVVAR"] == "MYVALUE"') + return 1 if __name__ == "__main__": retcode = work() diff --git a/src/Python/Test/config.py.in b/src/Python/Test/config.py.in index 64c7927..af5d3b4 100644 --- a/src/Python/Test/config.py.in +++ b/src/Python/Test/config.py.in @@ -24,8 +24,6 @@ import sys import os sys.path.append('${CMAKE_CURRENT_BINARY_DIR}/..') -EXEC_TEST_FULL_PATH = "${EXEC_TEST_FULL_PATH}" -EXEC_TEST_NAME = "${EXEC_TEST_NAME}" - configfile = os.environ["${TEST_CONFIG_FILE_ENV_VAR}"] execfile(configfile) +TEST_SOURCE_DIR = "${CMAKE_SOURCE_DIR}/src/Core/Test" diff --git a/src/Python/Test/seta.sh b/src/Python/Test/seta.sh deleted file mode 100644 index 42d1e38..0000000 --- a/src/Python/Test/seta.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -a=4 diff --git a/src/Python/Test/setb.sh b/src/Python/Test/setb.sh deleted file mode 100644 index 8969060..0000000 --- a/src/Python/Test/setb.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -b=3 diff --git a/src/Python/libBatch_Swig.i b/src/Python/libBatch_Swig.i index ff36cfd..37445c1 100644 --- a/src/Python/libBatch_Swig.i +++ b/src/Python/libBatch_Swig.i @@ -41,7 +41,7 @@ /* Le nom du module Python tel qu'il est importe */ -%module libBatch_Swig +%module libbatch /* generate docstrings with types */ %feature("autodoc", "1"); @@ -56,19 +56,17 @@ %include libBatch_Swig_exception.i %{ -#include "Batch_Defines.hxx" -#include "Batch_Constants.hxx" -#include "Batch_Job.hxx" -#include "Batch_JobId.hxx" -#include "Batch_JobInfo.hxx" - -#include "Batch_CommunicationProtocol.hxx" - -#include "Batch_BatchManager.hxx" -#include "Batch_BatchManager_eClient.hxx" -#include "Batch_BatchManagerCatalog.hxx" -#include "Batch_FactBatchManager.hxx" -#include "Batch_FactBatchManager_eClient.hxx" +#include "Defines.hxx" +#include "Constants.hxx" +#include "Job.hxx" +#include "JobId.hxx" +#include "JobInfo.hxx" + +#include "CommunicationProtocol.hxx" + +#include "BatchManager.hxx" +#include "BatchManagerCatalog.hxx" +#include "FactBatchManager.hxx" %} /* Les classes exportees en Python */ @@ -76,20 +74,18 @@ %ignore operator<<(std::ostream & os, const Job & job); %ignore operator<<(std::ostream & os, const JobInfo & ji); -%include Batch_Defines.hxx -%include Batch_Job.hxx -%include Batch_JobId.hxx -%include Batch_JobInfo.hxx +%include Defines.hxx +%include Job.hxx +%include JobId.hxx +%include JobInfo.hxx -%include Batch_CommunicationProtocol.hxx +%include CommunicationProtocol.hxx -%include Batch_BatchManager.hxx -%include Batch_BatchManager_eClient.hxx -%include Batch_BatchManagerCatalog.hxx -%include Batch_FactBatchManager.hxx -%include Batch_FactBatchManager_eClient.hxx +%include BatchManager.hxx +%include BatchManagerCatalog.hxx +%include FactBatchManager.hxx -%include Batch_Constants.hxx +%include Constants.hxx /* Les methodes alterJob (surchargees et mal gerees en Python) sont diff --git a/src/Python/libBatch_Swig_typemap.i b/src/Python/libBatch_Swig_typemap.i index 27a2ca0..5c9e513 100644 --- a/src/Python/libBatch_Swig_typemap.i +++ b/src/Python/libBatch_Swig_typemap.i @@ -32,11 +32,11 @@ #include #include #include -#include "Batch_ParameterTypeMap.hxx" -#include "Batch_Parametre.hxx" -#include "Batch_JobId.hxx" -#include "Batch_FactBatchManager.hxx" -#include "Batch_RunTimeException.hxx" +#include "ParameterTypeMap.hxx" +#include "Parametre.hxx" +#include "JobId.hxx" +#include "FactBatchManager.hxx" +#include "RunTimeException.hxx" %} # // supprime toutes les definitions par defaut => sert au debug @@ -277,12 +277,3 @@ static bool initEnvironment(Batch::Environnement & newEnv, PyObject * input) bool res = initEnvironment($1, $input); if (!res) return NULL; } - -// Dynamic cast to FactBatchManager_eClient if necessary -%typemap(out) Batch::FactBatchManager * -{ - if(dynamic_cast($1)) - $result=SWIG_NewPointerObj((void*)$1,$descriptor(Batch::FactBatchManager_eClient *),$owner); - else - $result=SWIG_NewPointerObj((void*)$1,$descriptor(Batch::FactBatchManager *),$owner); -} diff --git a/src/SGE/Batch_BatchManager_eSGE.cxx b/src/SGE/BatchManager_SGE.cxx similarity index 60% rename from src/SGE/Batch_BatchManager_eSGE.cxx rename to src/SGE/BatchManager_SGE.cxx index e576631..ac4bea7 100644 --- a/src/SGE/Batch_BatchManager_eSGE.cxx +++ b/src/SGE/BatchManager_SGE.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * BatchManager_eSGE.cxx : emulation of SGE client + * BatchManager_SGE.cxx : emulation of SGE client * * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr @@ -35,7 +35,6 @@ #include #include #include -#include #include #include @@ -46,33 +45,35 @@ #include #endif -#include "Batch_Constants.hxx" -#include "Batch_BatchManager_eSGE.hxx" -#include "Batch_JobInfo_eSGE.hxx" +#include +#include +#include + +#include "BatchManager_SGE.hxx" +#include "JobInfo_SGE.hxx" +#include "Log.hxx" using namespace std; namespace Batch { - BatchManager_eSGE::BatchManager_eSGE(const FactBatchManager * parent, const char * host, + BatchManager_SGE::BatchManager_SGE(const FactBatchManager * parent, const char * host, const char * username, CommunicationProtocolType protocolType, const char * mpiImpl) - : BatchManager(parent, host), - BatchManager_eClient(parent, host, username, protocolType, mpiImpl) + : BatchManager(parent, host, username, protocolType, mpiImpl) { // Nothing to do } // Destructeur - BatchManager_eSGE::~BatchManager_eSGE() + BatchManager_SGE::~BatchManager_SGE() { // Nothing to do } // Methode pour le controle des jobs : soumet un job au gestionnaire - const JobId BatchManager_eSGE::submitJob(const Job & job) + const JobId BatchManager_SGE::submitJob(const Job & job) { - int status; Parametre params = job.getParametre(); const std::string workDir = params[WORKDIR]; const string fileToExecute = params[EXECUTABLE]; @@ -86,51 +87,30 @@ namespace Batch { // build batch script for job buildBatchScript(job); - // define name of log file (local) - string logFile = generateTemporaryFileName("SGE-submitlog"); - // define command to submit batch string subCommand = string("bash -l -c \\\"cd ") + workDir + "; qsub " + fileNameToExecute + "_Batch.sh\\\""; string command = _protocol.getExecCommand(subCommand, _hostname, _username); - command += " > "; - command += logFile; command += " 2>&1"; - cerr << command.c_str() << endl; - status = system(command.c_str()); - if(status) - { - ifstream error_message(logFile.c_str()); - std::string mess; - std::string temp; - while(std::getline(error_message, temp)) - mess += temp; - error_message.close(); - throw EmulationException("Error of connection on remote host, error was: " + mess); - } - - // read id of submitted job in log file - char line[128]; - FILE *fp = fopen(logFile.c_str(),"r"); - fgets( line, 128, fp); - fclose(fp); + LOG(command); + + // submit job + string output; + int status = Utils::getCommandOutput(command, output); + LOG(output); + if (status != 0) throw RunTimeException("Can't submit job, error was: " + output); + // find id of submitted job in output string strjob; - istringstream iss(line); + istringstream iss(output); iss >> strjob >> strjob >> strjob; JobId id(this, strjob); return id; } - // Ce manager permet de faire de la reprise - const Batch::JobId - BatchManager_eSGE::addJob(const Batch::Job & job, const std::string reference) - { - return JobId(this, reference); - } // Methode pour le controle des jobs : retire un job du gestionnaire - void BatchManager_eSGE::deleteJob(const JobId & jobid) + void BatchManager_SGE::deleteJob(const JobId & jobid) { int status; int ref; @@ -140,80 +120,46 @@ namespace Batch { // define command to delete batch string subCommand = string("bash -l -c \\\"qdel ") + iss.str() + string("\\\""); string command = _protocol.getExecCommand(subCommand, _hostname, _username); - cerr << command.c_str() << endl; + LOG(command); 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"); - } + throw RunTimeException("Error of connection on remote host"); - // 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); + LOG("jobId = " << ref << "killed"); } // Methode pour le controle des jobs : renvoie l'etat du job - JobInfo BatchManager_eSGE::queryJob(const JobId & jobid) + JobInfo BatchManager_SGE::queryJob(const JobId & jobid) { int id; istringstream iss(jobid.getReference()); iss >> id; - // define name of log file (local) - string logFile = generateTemporaryFileName(string("SGE-querylog-id") + jobid.getReference()); - // define command to query batch string subCommand = string("bash -l -c \\\"qstat | grep ") + iss.str() + string("\\\""); string command = _protocol.getExecCommand(subCommand, _hostname, _username); - command += " > "; - command += logFile; - cerr << command.c_str() << endl; - int status = system(command.c_str()); + LOG(command); + + string output; + int status = Utils::getCommandOutput(command, output); if (status && status != 256) - throw EmulationException("Error of connection on remote host"); + throw RunTimeException("Error of connection on remote host"); - JobInfo_eSGE ji = JobInfo_eSGE(id,logFile); + JobInfo_SGE ji = JobInfo_SGE(id, output); return ji; } // Methode pour le controle des jobs : teste si un job est present en machine - bool BatchManager_eSGE::isRunning(const JobId & jobid) + bool BatchManager_SGE::isRunning(const JobId & jobid) { - throw EmulationException("Not yet implemented"); + throw NotYetImplementedException("BatchManager_SGE::isRunning"); } - void BatchManager_eSGE::buildBatchScript(const Job & job) + void BatchManager_SGE::buildBatchScript(const Job & job) { #ifndef WIN32 //TODO porting on Win32 platform - std::cerr << "BuildBatchScript" << std::endl; + LOG("BuildBatchScript"); Parametre params = job.getParametre(); // Job Parameters @@ -228,11 +174,11 @@ namespace Batch { if (params.find(WORKDIR) != params.end()) workDir = params[WORKDIR].str(); else - throw EmulationException("params[WORKDIR] is not defined ! Please defined it, cannot submit this job"); + throw RunTimeException("params[WORKDIR] is not defined ! Please defined it, cannot submit this job"); if (params.find(EXECUTABLE) != params.end()) fileToExecute = params[EXECUTABLE].str(); else - throw EmulationException("params[EXECUTABLE] is not defined ! Please defined it, cannot submit this job"); + throw RunTimeException("params[EXECUTABLE] is not defined ! Please defined it, cannot submit this job"); // Optional parameters if (params.find(NBPROC) != params.end()) @@ -251,7 +197,7 @@ namespace Batch { // Create batch submit file ofstream tempOutputFile; - std::string TmpFileName = createAndOpenTemporaryFile("SGE-script", tempOutputFile); + std::string TmpFileName = Utils::createAndOpenTemporaryFile("SGE-script", tempOutputFile); tempOutputFile << "#! /bin/sh -f" << endl; if (queue != "") @@ -273,19 +219,19 @@ namespace Batch { tempOutputFile.flush(); tempOutputFile.close(); - BATCH_CHMOD(TmpFileName.c_str(), 0x1ED); - cerr << "Batch script file generated is: " << TmpFileName.c_str() << endl; + Utils::chmod(TmpFileName.c_str(), 0x1ED); + LOG("Batch script file generated is: " << TmpFileName.c_str()); int status = _protocol.copyFile(TmpFileName, "", "", workDir + "/" + rootNameToExecute + "_Batch.sh", _hostname, _username); if (status) - throw EmulationException("Error of connection on remote host"); + throw RunTimeException("Error of connection on remote host"); #endif //WIN32 } - std::string BatchManager_eSGE::getWallTime(const long edt) + std::string BatchManager_SGE::getWallTime(const long edt) { long h, m; h = edt / 60; diff --git a/src/SGE/Batch_BatchManager_eSGE.hxx b/src/SGE/BatchManager_SGE.hxx similarity index 71% rename from src/SGE/Batch_BatchManager_eSGE.hxx rename to src/SGE/BatchManager_SGE.hxx index 3d95501..acdb75d 100644 --- a/src/SGE/Batch_BatchManager_eSGE.hxx +++ b/src/SGE/BatchManager_SGE.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * BatchManager_eSGE.hxx : emulation of SGE client + * BatchManager_SGE.hxx : emulation of SGE client * * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr @@ -32,22 +32,22 @@ #ifndef _BATCHMANAGER_ESGE_H_ #define _BATCHMANAGER_ESGE_H_ -#include "Batch_Defines.hxx" -#include "Batch_JobId.hxx" -#include "Batch_JobInfo.hxx" -#include "Batch_FactBatchManager.hxx" -#include "Batch_BatchManager_eClient.hxx" +#include "Defines.hxx" +#include "JobId.hxx" +#include "JobInfo.hxx" +#include "FactBatchManager.hxx" +#include "BatchManager.hxx" namespace Batch { - class BATCH_EXPORT BatchManager_eSGE : public BatchManager_eClient + class BATCH_EXPORT BatchManager_SGE : public BatchManager { public: // Constructeur et destructeur - BatchManager_eSGE(const FactBatchManager * parent, const char * host="localhost", + BatchManager_SGE(const FactBatchManager * parent, const char * host="localhost", const char * username="", CommunicationProtocolType protocolType = SSH, const char * mpiImpl="nompi"); // connexion a la machine host - virtual ~BatchManager_eSGE(); + virtual ~BatchManager_SGE(); // Recupere le nom du serveur par defaut // static string BatchManager_LSF::getDefaultServer(); @@ -55,19 +55,12 @@ namespace Batch { // Methodes pour le controle des jobs virtual const JobId submitJob(const Job & job); // soumet un job au gestionnaire virtual void deleteJob(const JobId & jobid); // retire un job du gestionnaire - virtual void holdJob(const JobId & jobid); // suspend un job en file d'attente - virtual void releaseJob(const JobId & jobid); // relache un job suspendu - virtual void alterJob(const JobId & jobid, const Parametre & param, const Environnement & env); // modifie un job en file d'attente - virtual void alterJob(const JobId & jobid, const Parametre & param); // modifie un job en file d'attente - virtual void alterJob(const JobId & jobid, const Environnement & env); // modifie un job en file d'attente virtual JobInfo queryJob(const JobId & jobid); // renvoie l'etat du job virtual bool isRunning(const JobId & jobid); // teste si un job est present en machine virtual void setParametre(const JobId & jobid, const Parametre & param) { return alterJob(jobid, param); } // modifie un job en file d'attente virtual void setEnvironnement(const JobId & jobid, const Environnement & env) { return alterJob(jobid, env); } // modifie un job en file d'attente - virtual const Batch::JobId addJob(const Batch::Job & job, const std::string reference); // ajoute un nouveau job sans le soumettre - protected: void buildBatchScript(const Job & job); std::string getWallTime(const long edt); diff --git a/src/SGE/Batch_FactBatchManager_eSGE.cxx b/src/SGE/Batch_FactBatchManager_eSGE.cxx deleted file mode 100644 index 19b575e..0000000 --- a/src/SGE/Batch_FactBatchManager_eSGE.cxx +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * FactBatchManager_eSGE.cxx : - * - * Auteur : Bernard SECHER - CEA DEN - * Date : Avril 2008 - * Projet : PAL Salome - * - */ - -#include "Batch_BatchManager_eSGE.hxx" -#include "Batch_FactBatchManager_eSGE.hxx" - -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 * username, - CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node) const - { - // MESSAGE("Building new BatchManager_SGE on host '" << hostname << "'"); - return new BatchManager_eSGE(this, hostname, username, protocolType, mpiImpl); - } - - -} diff --git a/src/SGE/Batch_FactBatchManager_eSGE.hxx b/src/SGE/Batch_FactBatchManager_eSGE.hxx deleted file mode 100644 index 84983b6..0000000 --- a/src/SGE/Batch_FactBatchManager_eSGE.hxx +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * FactBatchManager_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 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 * username, - CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node = 1) const; - - protected: - - private: - - }; - -} - -#endif diff --git a/src/SGE/CMakeLists.txt b/src/SGE/CMakeLists.txt index af32b39..68b706c 100644 --- a/src/SGE/CMakeLists.txt +++ b/src/SGE/CMakeLists.txt @@ -20,9 +20,9 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -SET(CLASS_LIST SGE/Batch_BatchManager_eSGE - SGE/Batch_FactBatchManager_eSGE - SGE/Batch_JobInfo_eSGE +SET(CLASS_LIST SGE/BatchManager_SGE + SGE/FactBatchManager_SGE + SGE/JobInfo_SGE ) APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST}) diff --git a/src/SGE/FactBatchManager_SGE.cxx b/src/SGE/FactBatchManager_SGE.cxx new file mode 100644 index 0000000..00e4ea8 --- /dev/null +++ b/src/SGE/FactBatchManager_SGE.cxx @@ -0,0 +1,59 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +/* + * FactBatchManager_SGE.cxx : + * + * Auteur : Bernard SECHER - CEA DEN + * Date : Avril 2008 + * Projet : PAL Salome + * + */ + +#include "BatchManager_SGE.hxx" +#include "FactBatchManager_SGE.hxx" + +namespace Batch { + + static FactBatchManager_SGE sFBM_SGE; + + // Constructeur + FactBatchManager_SGE::FactBatchManager_SGE() : FactBatchManager("SGE") + { + // Nothing to do + } + + // Destructeur + FactBatchManager_SGE::~FactBatchManager_SGE() + { + // Nothing to do + } + + BatchManager * FactBatchManager_SGE::operator() (const char * hostname, + const char * username, + CommunicationProtocolType protocolType, + const char * mpiImpl) const + { + // MESSAGE("Building new BatchManager_SGE on host '" << hostname << "'"); + return new BatchManager_SGE(this, hostname, username, protocolType, mpiImpl); + } + +} diff --git a/src/LSF/Batch_Job_LSF.hxx b/src/SGE/FactBatchManager_SGE.hxx similarity index 61% rename from src/LSF/Batch_Job_LSF.hxx rename to src/SGE/FactBatchManager_SGE.hxx index ebaacdc..1500e4f 100644 --- a/src/LSF/Batch_Job_LSF.hxx +++ b/src/SGE/FactBatchManager_SGE.hxx @@ -20,44 +20,36 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Job_LSF.hxx : + * FactBatchManager_SGE.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 + * Auteur : Bernard SECHER : CEA DEN + * Date : Avril 2008 + * Projet : PAL Salome * */ -#ifndef _JOB_LSF_H_ -#define _JOB_LSF_H_ +#ifndef _FACTBATCHMANAGER_SGE_H_ +#define _FACTBATCHMANAGER_SGE_H_ -extern "C" { +#include "Defines.hxx" -#include -#include -} -#include -#include "Batch_Job.hxx" +#include "BatchManager.hxx" +#include "FactBatchManager.hxx" namespace Batch { - - class Job_LSF + + class BATCH_EXPORT FactBatchManager_SGE : public FactBatchManager { public: // Constructeur et destructeur - Job_LSF(const Job & job); - virtual ~Job_LSF(); - - // Accesseurs - struct submit * getSubmitStruct(); + FactBatchManager_SGE(); + virtual ~FactBatchManager_SGE(); - protected: - struct submit * _p_submit; // structure pour soumettre les jobs + virtual BatchManager * operator() (const char * hostname, + const char * username, + CommunicationProtocolType protocolType, + const char * mpiImpl) const; - private: - struct submit * ParametreToSubmitStruct(const Parametre & P); - char * string2char(const std::string &); }; } diff --git a/src/SGE/Batch_JobInfo_eSGE.cxx b/src/SGE/JobInfo_SGE.cxx similarity index 81% rename from src/SGE/Batch_JobInfo_eSGE.cxx rename to src/SGE/JobInfo_SGE.cxx index 7760544..db8e1a1 100644 --- a/src/SGE/Batch_JobInfo_eSGE.cxx +++ b/src/SGE/JobInfo_SGE.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * JobInfo_eSGE.cxx : emulation of SGE client + * JobInfo_SGE.cxx : emulation of SGE client * * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr @@ -31,15 +31,15 @@ #include #include -#include #include -#include "Batch_Constants.hxx" -#include "Batch_Parametre.hxx" -#include "Batch_Environnement.hxx" -#include "Batch_RunTimeException.hxx" -#include "Batch_APIInternalFailureException.hxx" -#include "Batch_JobInfo_eSGE.hxx" +#include "Constants.hxx" +#include "Parametre.hxx" +#include "Environnement.hxx" +#include "RunTimeException.hxx" +#include "APIInternalFailureException.hxx" +#include "JobInfo_SGE.hxx" +#include "Log.hxx" using namespace std; @@ -48,16 +48,16 @@ namespace Batch { // Constructeurs - JobInfo_eSGE::JobInfo_eSGE(int id, string logFile) : JobInfo() + JobInfo_SGE::JobInfo_SGE(int id, const std::string & output) : JobInfo() { - // On remplit les membres _param et _env + // On remplit les membres _param et _nv ostringstream oss; oss << id; _param[ID] = oss.str(); // read of log file char line[128]; - ifstream fp(logFile.c_str(),ios::in); + istringstream fp(output); string status; string sline; @@ -89,7 +89,7 @@ namespace Batch { } else if (status == "h") { // Hold _param[STATE] = PAUSED; } else { - cerr << "Unknown job state code: " << status << endl; + LOG("Unknown job state code: " << status); } } else { // TODO: Check this. I suppose that unknown jobs are finished ones. @@ -98,20 +98,20 @@ namespace Batch { } // Teste si un job est present en machine - bool JobInfo_eSGE::isRunning() const + bool JobInfo_SGE::isRunning() const { return _running; } // Destructeur - JobInfo_eSGE::~JobInfo_eSGE() + JobInfo_SGE::~JobInfo_SGE() { // Nothing to do } // Convertit une date HH:MM:SS en secondes - long JobInfo_eSGE::HMStoLong(const string & s) + long JobInfo_SGE::HMStoLong(const string & s) { long hour, min, sec; @@ -120,10 +120,10 @@ namespace Batch { } // Methode pour l'interfacage avec Python (SWIG) : affichage en Python - string JobInfo_eSGE::__str__() const + string JobInfo_SGE::__str__() const { ostringstream sst; - sst << " -#include -#include -#include - -#include -#include -#include - -#ifdef MSVC -#include -#else -#include -#endif - -#include "Batch_Constants.hxx" -#include "Batch_BatchManager_eSSH.hxx" -#include "Batch_JobInfo_eSSH.hxx" - -using namespace std; - -namespace Batch { - - BatchManager_eSSH::BatchManager_eSSH(const FactBatchManager * parent, const char * host, - const char * username, - CommunicationProtocolType protocolType, const char * mpiImpl) - : BatchManager(parent, host), - BatchManager_eClient(parent, host, username, protocolType, mpiImpl), - BatchManager_Local(parent, host, protocolType) - { - // Nothing to do - } - - // Destructeur - BatchManager_eSSH::~BatchManager_eSSH() - { - // Nothing to do - } - - // Methode pour le controle des jobs : soumet un job au gestionnaire - const JobId BatchManager_eSSH::submitJob(const Job & job) - { - // export input files on cluster - std::cerr << "BatchManager_eSSH::submitJob exportInputFiles" << std::endl; - Parametre param = job.getParametre(); - - // Input files copy - exportInputFiles(job); - - // Launch job - // Patch until Local Manager is patched - std::string executable = param[EXECUTABLE].str(); - std::string::size_type p1 = executable.find_last_of("/"); - std::string fileNameToExecute = "./" + executable.substr(p1+1); - Parametre new_param(param); - new_param[INFILE].eraseAll(); - new_param[OUTFILE].eraseAll(); - new_param[EXECUTABLE] = fileNameToExecute; - new_param[EXECUTIONHOST] = _hostname; - Job * j = new Job(new_param); - - - std::cerr << "BatchManager_eSSH::submitJob Local submitJob" << std::endl; - JobId id = BatchManager_Local::submitJob(*j); - delete j; - return id; - } - - // Methode pour le controle des jobs : retire un job du gestionnaire - void BatchManager_eSSH::deleteJob(const JobId & jobid) - { - BatchManager_Local::deleteJob(jobid); - } - - // Methode pour le controle des jobs : renvoie l'etat du job - JobInfo BatchManager_eSSH::queryJob(const JobId & jobid) - { - return BatchManager_Local::queryJob(jobid); - } - - // Methode pour le controle des jobs : suspend un job en file d'attente - void BatchManager_eSSH::holdJob(const JobId & jobid) - { - BatchManager_Local::holdJob(jobid); - } - - // Methode pour le controle des jobs : relache un job suspendu - void BatchManager_eSSH::releaseJob(const JobId & jobid) - { - BatchManager_Local::releaseJob(jobid); - } - - // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager_eSSH::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env) - { - BatchManager_Local::alterJob(jobid, param, env); - } - - // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager_eSSH::alterJob(const JobId & jobid, const Parametre & param) - { - BatchManager_Local::alterJob(jobid, param); - } - - // Methode pour le controle des jobs : modifie un job en file d'attente - void BatchManager_eSSH::alterJob(const JobId & jobid, const Environnement & env) - { - BatchManager_Local::alterJob(jobid, env); - } - - void BatchManager_eSSH::buildBatchScript(const Job & job) - { - Parametre params = job.getParametre(); - Environnement env = job.getEnvironnement(); - const long nbproc = params[NBPROC]; - const long edt = params[MAXWALLTIME]; - const long mem = params[MAXRAMSIZE]; - const string workDir = params[WORKDIR]; - const std::string dirForTmpFiles = params[TMPDIR]; - const string fileToExecute = params[EXECUTABLE]; - const string home = params[HOMEDIR]; - const std::string queue = params[QUEUE]; - std::string rootNameToExecute; - std::string fileNameToExecute; - std::string filelogtemp; - if( fileToExecute.size() > 0 ){ - string::size_type p1 = fileToExecute.find_last_of("/"); - string::size_type p2 = fileToExecute.find_last_of("."); - rootNameToExecute = fileToExecute.substr(p1+1,p2-p1-1); - -#ifdef MSVC - char fname[_MAX_FNAME]; - char ext[_MAX_EXT]; - _splitpath_s(fileToExecute.c_str(), NULL, 0, NULL, 0, fname, _MAX_FNAME, ext, _MAX_EXT); - string execBaseName = string(fname) + ext; -#else - char* basec=strdup(fileToExecute.c_str()); - string execBaseName = string(basename(basec)); - free(basec); -#endif - - fileNameToExecute = "~/" + dirForTmpFiles + "/" + execBaseName; - - int idx = dirForTmpFiles.find("Batch/"); - filelogtemp = dirForTmpFiles.substr(idx+6, dirForTmpFiles.length()); - } - else{ - rootNameToExecute = "command"; - } - - ofstream tempOutputFile; - std::string TmpFileName = createAndOpenTemporaryFile("SSH-script", tempOutputFile); - - tempOutputFile << "#! /bin/sh -f" << endl; - if (queue != "") - tempOutputFile << "#BSUB -q " << queue << endl; - if( edt > 0 ) - tempOutputFile << "#SSH -l walltime=" << edt*60 << endl ; - if( mem > 0 ) - tempOutputFile << "#SSH -l mem=" << mem << "mb" << endl ; - if( fileToExecute.size() > 0 ){ - tempOutputFile << "#SSH -o " << home << "/" << dirForTmpFiles << "/output.log." << filelogtemp << endl ; - tempOutputFile << "#SSH -e " << home << "/" << dirForTmpFiles << "/error.log." << filelogtemp << endl ; - } - else{ - tempOutputFile << "#SSH -o " << dirForTmpFiles << "/" << env["LOGFILE"] << ".output.log" << endl ; - tempOutputFile << "#SSH -e " << dirForTmpFiles << "/" << env["LOGFILE"] << ".error.log" << endl ; - } - if( workDir.size() > 0 ) - tempOutputFile << "cd " << workDir << endl ; - if( fileToExecute.size() > 0 ){ - tempOutputFile << _mpiImpl->boot("${SSH_NODEFILE}",nbproc); - tempOutputFile << _mpiImpl->run("${SSH_NODEFILE}",nbproc,fileNameToExecute); - tempOutputFile << _mpiImpl->halt(); - } - else{ - tempOutputFile << "source " << env["SOURCEFILE"] << endl ; - tempOutputFile << env["COMMAND"]; - } - - tempOutputFile.flush(); - tempOutputFile.close(); -#ifdef WIN32 - _chmod( -#else - chmod( -#endif - TmpFileName.c_str(), 0x1ED); - cerr << TmpFileName.c_str() << endl; - - int status = Batch::BatchManager_eClient::_protocol.copyFile(TmpFileName, "", "", - dirForTmpFiles + "/" + rootNameToExecute + "_Batch.sh", - _hostname, _username); - if (status) - throw EmulationException("Error of connection on remote host"); - - remove(TmpFileName.c_str()); - } - -} diff --git a/src/SSH/Batch_BatchManager_eSSH.hxx b/src/SSH/Batch_BatchManager_eSSH.hxx deleted file mode 100644 index 29592bf..0000000 --- a/src/SSH/Batch_BatchManager_eSSH.hxx +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * BatchManager_eSSH.hxx : emulation of SSH client - * - * Auteur : André RIBES - EDF R&D - * Date : Octobre 2009 - */ - -#ifndef _BATCHMANAGER_ESSH_H_ -#define _BATCHMANAGER_ESSH_H_ - -#include "Batch_Defines.hxx" -#include "Batch_JobId.hxx" -#include "Batch_JobInfo.hxx" -#include "Batch_FactBatchManager.hxx" -#include "Batch_BatchManager_eClient.hxx" -#include "Batch_BatchManager_Local.hxx" - -namespace Batch { - - class BATCH_EXPORT BatchManager_eSSH : - virtual public BatchManager_eClient, - virtual public BatchManager_Local - { - public: - // Constructeur et destructeur - BatchManager_eSSH(const FactBatchManager * parent, const char * host="localhost", - const char * username="", - CommunicationProtocolType protocolType = SSH, const char * mpiImpl="nompi"); // connexion a la machine host - virtual ~BatchManager_eSSH(); - - // Recupere le nom du serveur par defaut - // static string BatchManager_LSF::getDefaultServer(); - - // Methodes pour le controle des jobs - virtual const JobId submitJob(const Job & job); // soumet un job au gestionnaire - virtual void deleteJob(const JobId & jobid); // retire un job du gestionnaire - virtual JobInfo queryJob(const JobId & jobid); // renvoie l'etat du job - - // Non implanté... - virtual void holdJob(const JobId & jobid); // suspend un job en file d'attente - virtual void releaseJob(const JobId & jobid); // relache un job suspendu - virtual void alterJob(const JobId & jobid, const Parametre & param, const Environnement & env); // modifie un job en file d'attente - virtual void alterJob(const JobId & jobid, const Parametre & param); // modifie un job en file d'attente - virtual void alterJob(const JobId & jobid, const Environnement & env); // modifie un job en file d'attente - - - protected: - void buildBatchScript(const Job & job); - - private: - -#ifdef SWIG - public: - // Recupere le l'identifiant d'un job deja soumis au BatchManager - //virtual const JobId getJobIdByReference(const string & ref) { return BatchManager::getJobIdByReference(ref); } - virtual const JobId getJobIdByReference(const char * ref) { return BatchManager::getJobIdByReference(ref); } -#endif - }; -} - -#endif diff --git a/src/SSH/Batch_FactBatchManager_eSSH.cxx b/src/SSH/Batch_FactBatchManager_eSSH.cxx deleted file mode 100644 index e016473..0000000 --- a/src/SSH/Batch_FactBatchManager_eSSH.cxx +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * FactBatchManager_eSSH.cxx : - * - * Auteur : André RIBES : EDF R&D - * Date : Octobre 2009 - */ - -#include -#include "Batch_BatchManager_eSSH.hxx" -#include "Batch_FactBatchManager_eSSH.hxx" - -// Automatic register in the catalogue... -static Batch::FactBatchManager_eSSH sFBM_eSSH; - -Batch::FactBatchManager_eSSH::FactBatchManager_eSSH() : FactBatchManager_eClient("eSSH") {} - -Batch::FactBatchManager_eSSH::~FactBatchManager_eSSH() {} - -Batch::BatchManager * -Batch::FactBatchManager_eSSH::operator() (const char * hostname) const -{ - return new Batch::BatchManager_eSSH(this, hostname); -} - -Batch::BatchManager_eClient * -Batch::FactBatchManager_eSSH::operator() (const char * hostname, - const char * username, - CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node) const -{ - //protocolType and mpiImpl are ignored. - std::cerr << "[Batch::FactBatchManager_eSSH] creating new Batch::BatchManager_eSSH with hostname = " << hostname << std::endl; - - return new Batch::BatchManager_eSSH(this, hostname, username); -} diff --git a/src/SSH/Batch_FactBatchManager_eSSH.hxx b/src/SSH/Batch_FactBatchManager_eSSH.hxx deleted file mode 100644 index 5f17dd4..0000000 --- a/src/SSH/Batch_FactBatchManager_eSSH.hxx +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * FactBatchManager_eSSH.hxx : - * - * Auteur : André RIBES : EDF R&D - * Date : Octobre 2009 - */ - -#ifndef _FACTBATCHMANAGER_eSSH_H_ -#define _FACTBATCHMANAGER_eSSH_H_ - -#include "Batch_Defines.hxx" - -#include -#include -#include "Batch_BatchManager_eClient.hxx" -#include "Batch_FactBatchManager_eClient.hxx" - -namespace Batch { - - class BatchManager_eSSH; - - class BATCH_EXPORT FactBatchManager_eSSH : public FactBatchManager_eClient - { - public: - FactBatchManager_eSSH(); - virtual ~FactBatchManager_eSSH(); - - virtual BatchManager * operator() (const char * hostname) const; // From FactBacthManager - virtual BatchManager_eClient * operator() (const char * hostname, - const char * username, - CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node = 1) const; // From FactBatchManager_eClient - }; -} - -#endif diff --git a/src/SSH/Batch_JobInfo_eSSH.cxx b/src/SSH/Batch_JobInfo_eSSH.cxx deleted file mode 100644 index afc0538..0000000 --- a/src/SSH/Batch_JobInfo_eSSH.cxx +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * JobInfo_eSSH.cxx : emulation of SSH client - * - * Auteur : André RIBES - EDF R&D - * Date : Octobre 2009 - */ - -#include -#include -#include -#include - -#include "Batch_Constants.hxx" -#include "Batch_Parametre.hxx" -#include "Batch_Environnement.hxx" -#include "Batch_RunTimeException.hxx" -#include "Batch_APIInternalFailureException.hxx" -#include "Batch_JobInfo_eSSH.hxx" - -using namespace std; - -namespace Batch { - - // Constructeurs - JobInfo_eSSH::JobInfo_eSSH(int id, string status) : JobInfo() - { - // On remplit les membres _param et _env - ostringstream oss; - oss << id; - _param[ID] = oss.str(); - _param[STATE] = status; - } - - // Destructeur - JobInfo_eSSH::~JobInfo_eSSH() - { - // Nothing to do - } - - // Methode pour l'interfacage avec Python (SWIG) : affichage en Python - string JobInfo_eSSH::__str__() const - { - ostringstream sst; - sst << " #include -#include -#include -#include +#include +#include +#include +#include -#include "Batch_BatchManager_eSlurm.hxx" -#include "Batch_JobInfo_eSlurm.hxx" +#include "BatchManager_Slurm.hxx" +#include "JobInfo_Slurm.hxx" using namespace std; namespace Batch { - BatchManager_eSlurm::BatchManager_eSlurm(const FactBatchManager * parent, + BatchManager_Slurm::BatchManager_Slurm(const FactBatchManager * parent, const char * host, const char * username, CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node) - : BatchManager(parent, host), - BatchManager_eClient(parent, host, username, protocolType, mpiImpl), - _nb_proc_per_node(nb_proc_per_node) + const char * mpiImpl) + : BatchManager(parent, host, username, protocolType, mpiImpl) { } - BatchManager_eSlurm::~BatchManager_eSlurm() + BatchManager_Slurm::~BatchManager_Slurm() { } // Method to submit a job to the batch manager - const JobId BatchManager_eSlurm::submitJob(const Job & job) + const JobId BatchManager_Slurm::submitJob(const Job & job) { Parametre params = job.getParametre(); const string workDir = params[WORKDIR]; @@ -72,19 +70,19 @@ namespace Batch { string subCommand = string("cd ") + workDir + "; sbatch " + cmdFile; string command = _protocol.getExecCommand(subCommand, _hostname, _username); command += " 2>&1"; - cout << command.c_str() << endl; + LOG(command); // submit job string output; int status = Utils::getCommandOutput(command, output); - cout << output; - if (status != 0) throw EmulationException("Can't submit job, error was: " + output); + LOG(output); + if (status != 0) throw RunTimeException("Can't submit job, error was: " + output); // find id of submitted job in output string search = "Submitted batch job "; string::size_type pos = output.find(search); if (pos == string::npos) - throw EmulationException("Error in the submission of the job on the remote host"); + throw RunTimeException("Error in the submission of the job on the remote host"); pos += search.size(); string::size_type endl_pos = output.find('\n', pos); string::size_type count = (endl_pos == string::npos)? string::npos : endl_pos - pos; @@ -98,7 +96,7 @@ namespace Batch { * Create Slurm command file and copy it on the server. * Return the name of the remote file. */ - string BatchManager_eSlurm::buildCommandFile(const Job & job) + string BatchManager_Slurm::buildCommandFile(const Job & job) { Parametre params = job.getParametre(); @@ -111,11 +109,11 @@ namespace Batch { if (params.find(WORKDIR) != params.end()) workDir = params[WORKDIR].str(); else - throw EmulationException("params[WORKDIR] is not defined. Please define it, cannot submit this job."); + throw RunTimeException("params[WORKDIR] is not defined. Please define it, cannot submit this job."); if (params.find(EXECUTABLE) != params.end()) fileToExecute = params[EXECUTABLE].str(); else - throw EmulationException("params[EXECUTABLE] is not defined. Please define it, cannot submit this job."); + throw RunTimeException("params[EXECUTABLE] is not defined. Please define it, cannot submit this job."); string::size_type p1 = fileToExecute.find_last_of("/"); string::size_type p2 = fileToExecute.find_last_of("."); @@ -124,7 +122,7 @@ namespace Batch { // Create batch submit file ofstream tempOutputFile; - string tmpFileName = createAndOpenTemporaryFile("slurm-script", tempOutputFile); + string tmpFileName = Utils::createAndOpenTemporaryFile("slurm-script", tempOutputFile); tempOutputFile << "#!/bin/bash" << endl; tempOutputFile << "#SBATCH --output=" << workDir << "/logs/output.log." << rootNameToExecute << endl; @@ -166,7 +164,16 @@ namespace Batch { // Launch the executable tempOutputFile << "cd " << workDir << endl; - tempOutputFile << "./" + fileNameToExecute << endl; + tempOutputFile << "./" + fileNameToExecute; + if (params.find(ARGUMENTS) != params.end()) { + Versatile V = params[ARGUMENTS]; + for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++) { + StringType argt = * static_cast(*it); + string arg = argt; + tempOutputFile << " " << arg; + } + } + tempOutputFile << endl; // Remove the node file tempOutputFile << "rm $LIBBATCH_NODEFILE" << endl; @@ -174,76 +181,46 @@ namespace Batch { tempOutputFile.flush(); tempOutputFile.close(); - cerr << "Batch script file generated is: " << tmpFileName << endl; + LOG("Batch script file generated is: " << tmpFileName); string remoteFileName = rootNameToExecute + "_slurm.cmd"; int status = _protocol.copyFile(tmpFileName, "", "", workDir + "/" + remoteFileName, _hostname, _username); if (status) - throw EmulationException("Cannot copy command file on host " + _hostname); + throw RunTimeException("Cannot copy command file on host " + _hostname); return remoteFileName; } - void BatchManager_eSlurm::deleteJob(const JobId & jobid) + void BatchManager_Slurm::deleteJob(const JobId & jobid) { // define command to delete job string subCommand = "scancel " + jobid.getReference(); string command = _protocol.getExecCommand(subCommand, _hostname, _username); - cerr << command.c_str() << endl; + LOG(command); int status = system(command.c_str()); if (status) - throw EmulationException("Can't delete job " + jobid.getReference()); - - cerr << "job " << jobid.getReference() << " killed" << endl; - } - - void BatchManager_eSlurm::holdJob(const JobId & jobid) - { - throw NotYetImplementedException("BatchManager_eSlurm::holdJob"); - } + throw RunTimeException("Can't delete job " + jobid.getReference()); - void BatchManager_eSlurm::releaseJob(const JobId & jobid) - { - throw NotYetImplementedException("BatchManager_eSlurm::releaseJob"); - } - - void BatchManager_eSlurm::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env) - { - throw NotYetImplementedException("BatchManager_eSlurm::alterJob"); + LOG("job " << jobid.getReference() << " killed"); } - void BatchManager_eSlurm::alterJob(const JobId & jobid, const Parametre & param) - { - throw NotYetImplementedException("BatchManager_eSlurm::alterJob"); - } - - void BatchManager_eSlurm::alterJob(const JobId & jobid, const Environnement & env) - { - throw NotYetImplementedException("BatchManager_eSlurm::alterJob"); - } - - JobInfo BatchManager_eSlurm::queryJob(const JobId & jobid) + JobInfo BatchManager_Slurm::queryJob(const JobId & jobid) { // define command to query batch string subCommand = "squeue -o %t -j " + jobid.getReference(); string command = _protocol.getExecCommand(subCommand, _hostname, _username); - cerr << command.c_str() << endl; + LOG(command); string output; Utils::getCommandOutput(command, output); // We don't test the return code here because with jobs finished since a long time Slurm // returns an error and a message like "slurm_load_jobs error: Invalid job id specified". // So we consider that the job is finished when we get an error. - JobInfo_eSlurm jobinfo = JobInfo_eSlurm(jobid.getReference(), output); + JobInfo_Slurm jobinfo = JobInfo_Slurm(jobid.getReference(), output); return jobinfo; } - const JobId BatchManager_eSlurm::addJob(const Job & job, const string reference) - { - return JobId(this, reference); - } - } diff --git a/src/Slurm/Batch_BatchManager_eSlurm.hxx b/src/Slurm/BatchManager_Slurm.hxx similarity index 63% rename from src/Slurm/Batch_BatchManager_eSlurm.hxx rename to src/Slurm/BatchManager_Slurm.hxx index 839ff1e..fd40a7f 100644 --- a/src/Slurm/Batch_BatchManager_eSlurm.hxx +++ b/src/Slurm/BatchManager_Slurm.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_BatchManager_eSlurm.hxx : + * BatchManager_Slurm.hxx : * * Created on: 12 may 2011 * Author : Renaud BARATE - EDF R&D @@ -31,43 +31,34 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace Batch { - class BATCH_EXPORT BatchManager_eSlurm : public BatchManager_eClient + class BATCH_EXPORT BatchManager_Slurm : public BatchManager { public: - BatchManager_eSlurm(const FactBatchManager * parent, + BatchManager_Slurm(const FactBatchManager * parent, const char * host = "localhost", const char * username = "", CommunicationProtocolType protocolType = SSH, - const char * mpiImpl = "nompi", - int nb_proc_per_node = 1); - virtual ~BatchManager_eSlurm(); + const char * mpiImpl = "nompi"); + virtual ~BatchManager_Slurm(); // Methods to control jobs virtual const JobId submitJob(const Job & job); virtual void deleteJob(const JobId & jobid); - virtual void holdJob(const JobId & jobid); - virtual void releaseJob(const JobId & jobid); - 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); virtual JobInfo queryJob(const JobId & jobid); - virtual const JobId addJob(const Job & job, const std::string reference); protected: std::string buildCommandFile(const Job & job); - int _nb_proc_per_node; - }; } diff --git a/src/Slurm/Batch_FactBatchManager_eSlurm.cxx b/src/Slurm/Batch_FactBatchManager_eSlurm.cxx deleted file mode 100644 index 36a217a..0000000 --- a/src/Slurm/Batch_FactBatchManager_eSlurm.cxx +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Batch_FactBatchManager_eSlurm.cxx : - * - * Created on: 12 may 2011 - * Author : Renaud BARATE - EDF R&D - */ - -#include - -#include "Batch_BatchManager_eSlurm.hxx" -#include "Batch_FactBatchManager_eSlurm.hxx" - -namespace Batch { - - static FactBatchManager_eSlurm sFBM_eSlurm; - - FactBatchManager_eSlurm::FactBatchManager_eSlurm() : FactBatchManager_eClient("eSLURM") - { - } - - FactBatchManager_eSlurm::~FactBatchManager_eSlurm() - { - } - - BatchManager * FactBatchManager_eSlurm::operator() (const char * hostname) const - { - // MESSAGE("Building new BatchManager_eSlurm on host '" << hostname << "'"); - return new BatchManager_eSlurm(this, hostname); - } - - BatchManager_eClient * FactBatchManager_eSlurm::operator() (const char * hostname, - const char * username, - CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node) const - { - // MESSAGE("Building new BatchManager_eSlurm on host '" << hostname << "'"); - return new BatchManager_eSlurm(this, hostname, username, protocolType, mpiImpl, nb_proc_per_node); - } - -} diff --git a/src/Slurm/Batch_FactBatchManager_eSlurm.hxx b/src/Slurm/Batch_FactBatchManager_eSlurm.hxx deleted file mode 100644 index 969763e..0000000 --- a/src/Slurm/Batch_FactBatchManager_eSlurm.hxx +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Batch_FactBatchManager_eSlurm.hxx : - * - * Created on: 12 may 2011 - * Author : Renaud BARATE - EDF R&D - */ - -#ifndef _FACTBATCHMANAGER_ESLURM_H_ -#define _FACTBATCHMANAGER_ESLURM_H_ - -#include -#include -#include -#include - -namespace Batch { - - class BATCH_EXPORT FactBatchManager_eSlurm : public FactBatchManager_eClient - { - public: - - FactBatchManager_eSlurm(); - virtual ~FactBatchManager_eSlurm(); - - virtual BatchManager * operator() (const char * hostname) const; - virtual BatchManager_eClient * operator() (const char * hostname, - const char * username, - CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node = 1) const; - - }; - -} - -#endif diff --git a/src/Slurm/CMakeLists.txt b/src/Slurm/CMakeLists.txt index 5a1c432..e08f31d 100644 --- a/src/Slurm/CMakeLists.txt +++ b/src/Slurm/CMakeLists.txt @@ -20,13 +20,13 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -SET(CLASS_LIST Slurm/Batch_BatchManager_eSlurm - Slurm/Batch_FactBatchManager_eSlurm - Slurm/Batch_JobInfo_eSlurm +SET(CLASS_LIST Slurm/BatchManager_Slurm + Slurm/FactBatchManager_Slurm + Slurm/JobInfo_Slurm ) APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST}) -IF (TEST_ENABLED) - add_subdirectory(Test) -ENDIF (TEST_ENABLED) +IF (TEST_ENABLED AND HAS_SSH) + ADD_TEST(SLURM_SSH ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager SLURM SSH) +ENDIF (TEST_ENABLED AND HAS_SSH) diff --git a/src/Core/Batch_FactBatchManager_eClient.hxx b/src/Slurm/FactBatchManager_Slurm.cxx similarity index 59% rename from src/Core/Batch_FactBatchManager_eClient.hxx rename to src/Slurm/FactBatchManager_Slurm.cxx index e475929..c4814eb 100644 --- a/src/Core/Batch_FactBatchManager_eClient.hxx +++ b/src/Slurm/FactBatchManager_Slurm.cxx @@ -20,45 +20,35 @@ // 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 + * FactBatchManager_Slurm.cxx : * + * Created on: 12 may 2011 + * Author : Renaud BARATE - EDF R&D */ -#ifndef _FACTBATCHMANAGER_ECLIENT_H_ -#define _FACTBATCHMANAGER_ECLIENT_H_ - -#include +#include -#include "Batch_FactBatchManager.hxx" -#include "Batch_BatchManager_eClient.hxx" -#include "Batch_CommunicationProtocol.hxx" +#include "BatchManager_Slurm.hxx" +#include "FactBatchManager_Slurm.hxx" namespace Batch { - class BATCH_EXPORT FactBatchManager_eClient : public FactBatchManager + static FactBatchManager_Slurm sFBM_Slurm; + + FactBatchManager_Slurm::FactBatchManager_Slurm() : FactBatchManager("SLURM") + { + } + + FactBatchManager_Slurm::~FactBatchManager_Slurm() { - public: - // Constructeur et destructeur - FactBatchManager_eClient(const std::string & type); - virtual ~FactBatchManager_eClient(); + } - virtual Batch::BatchManager_eClient * operator() (const char * hostname, + BatchManager * FactBatchManager_Slurm::operator() (const char * hostname, const char * username, CommunicationProtocolType protocolType, - const char * mpi = "nompi", - int nb_proc_per_node = 1) const = 0; - - protected: - - private: - - }; + const char * mpiImpl) const + { + return new BatchManager_Slurm(this, hostname, username, protocolType, mpiImpl); + } } - -#endif diff --git a/src/Core/Batch_ConnexionFailureException.hxx b/src/Slurm/FactBatchManager_Slurm.hxx similarity index 61% rename from src/Core/Batch_ConnexionFailureException.hxx rename to src/Slurm/FactBatchManager_Slurm.hxx index d36dd33..c37838c 100644 --- a/src/Core/Batch_ConnexionFailureException.hxx +++ b/src/Slurm/FactBatchManager_Slurm.hxx @@ -20,34 +20,35 @@ // 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 + * FactBatchManager_Slurm.hxx : * + * Created on: 12 may 2011 + * Author : Renaud BARATE - EDF R&D */ -#ifndef _CONNEXIONFAILUREEXCEPTION_H_ -#define _CONNEXIONFAILUREEXCEPTION_H_ - -#include "Batch_Defines.hxx" - +#ifndef _FACTBATCHMANAGER_ESLURM_H_ +#define _FACTBATCHMANAGER_ESLURM_H_ -#include "Batch_GenericException.hxx" +#include +#include +#include namespace Batch { - class BATCH_EXPORT ConnexionFailureException : public GenericException + class BATCH_EXPORT FactBatchManager_Slurm : public FactBatchManager { public: - // Constructeur - ConnexionFailureException(std::string ch = "undefined") : GenericException("ConnexionFailureException", ch) {} + + FactBatchManager_Slurm(); + virtual ~FactBatchManager_Slurm(); + + virtual BatchManager * operator() (const char * hostname, + const char * username, + CommunicationProtocolType protocolType, + const char * mpiImpl) const; }; } #endif - diff --git a/src/Slurm/Batch_JobInfo_eSlurm.cxx b/src/Slurm/JobInfo_Slurm.cxx similarity index 90% rename from src/Slurm/Batch_JobInfo_eSlurm.cxx rename to src/Slurm/JobInfo_Slurm.cxx index 3b2d711..6e8aac5 100644 --- a/src/Slurm/Batch_JobInfo_eSlurm.cxx +++ b/src/Slurm/JobInfo_Slurm.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_JobInfo_eSlurm.cxx : + * JobInfo_Slurm.cxx : * * Created on: 12 may 2011 * Author : Renaud BARATE - EDF R&D @@ -28,16 +28,16 @@ #include -#include -#include +#include +#include -#include "Batch_JobInfo_eSlurm.hxx" +#include "JobInfo_Slurm.hxx" using namespace std; namespace Batch { - JobInfo_eSlurm::JobInfo_eSlurm(const std::string & id, const std::string & queryOutput) + JobInfo_Slurm::JobInfo_Slurm(const std::string & id, const std::string & queryOutput) : JobInfo() { _param[ID] = id; @@ -78,7 +78,7 @@ namespace Batch { } } - JobInfo_eSlurm::~JobInfo_eSlurm() + JobInfo_Slurm::~JobInfo_Slurm() { } diff --git a/src/Slurm/Batch_JobInfo_eSlurm.hxx b/src/Slurm/JobInfo_Slurm.hxx similarity index 85% rename from src/Slurm/Batch_JobInfo_eSlurm.hxx rename to src/Slurm/JobInfo_Slurm.hxx index d9c4cc8..cb03982 100644 --- a/src/Slurm/Batch_JobInfo_eSlurm.hxx +++ b/src/Slurm/JobInfo_Slurm.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_JobInfo_eSlurm.hxx : + * JobInfo_Slurm.hxx : * * Created on: 12 may 2011 * Author : Renaud BARATE - EDF R&D @@ -31,16 +31,16 @@ #include -#include +#include namespace Batch { - class JobInfo_eSlurm : public JobInfo + class JobInfo_Slurm : public JobInfo { public: - JobInfo_eSlurm(const std::string & id, const std::string & queryOutput); - virtual ~JobInfo_eSlurm(); + JobInfo_Slurm(const std::string & id, const std::string & queryOutput); + virtual ~JobInfo_Slurm(); }; diff --git a/src/Slurm/Test/CMakeLists.txt b/src/Slurm/Test/CMakeLists.txt deleted file mode 100644 index 3163654..0000000 --- a/src/Slurm/Test/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# 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_SOURCE_DIR}/src/Core/Test) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -# Build the test programs and add the tests -add_executable(Test_eSlurm Test_eSlurm.cxx) -target_link_libraries(Test_eSlurm Batch SimpleParser) - -IF (HAS_SSH) - ADD_TEST(eSlurm_SSH Test_eSlurm SSH) -ENDIF (HAS_SSH) - -#IF (HAS_RSH) -# ADD_TEST(eSlurm_RSH Test_eSlurm RSH) -#ENDIF (HAS_RSH) diff --git a/src/Slurm/Test/Test_eSlurm.cxx b/src/Slurm/Test/Test_eSlurm.cxx deleted file mode 100644 index 38b5d15..0000000 --- a/src/Slurm/Test/Test_eSlurm.cxx +++ /dev/null @@ -1,163 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Test_eSlurm.cxx : - * - * Author : Renaud BARATE - EDF R&D - * Date : May 2011 - * - */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include - -using namespace std; -using namespace Batch; - -void print_usage() -{ - cout << "usage: Test_eSlurm PROTOCOL" << endl; - cout << " PROTOCOL \"SSH\" or \"RSH\"" << endl; -} - -int main(int argc, char** argv) -{ - // Parse argument - if (argc != 2) { - print_usage(); - return 1; - } - CommunicationProtocolType protocol; - if (strcmp(argv[1], "SSH") == 0) - protocol = SSH; - else if (strcmp(argv[1], "RSH") == 0) - protocol = RSH; - else { - print_usage(); - return 1; - } - - cout << "*******************************************************************************************" << endl; - cout << "This program tests the batch submission based on Slurm emulation. Passwordless" << endl; - cout << "authentication must be used for this test to pass. For SSH, this can be configured with" << endl; - cout << "ssh-agent for instance. For RSH, this can be configured with the .rhosts file." << endl; - cout << "*******************************************************************************************" << endl; - - // eventually remove any previous result - remove("result.txt"); - - try { - // Parse the test configuration file - SimpleParser parser; - parser.parseTestConfigFile(); - const string & homedir = parser.getValue("TEST_ESLURM_HOMEDIR"); - const string & host = parser.getValue("TEST_ESLURM_HOST"); - const string & user = parser.getValue("TEST_ESLURM_USER"); - int timeout = parser.getValueAsInt("TEST_ESLURM_TIMEOUT"); - - // Define the job... - Job job; - // ... and its parameters ... - Parametre p; - p[EXECUTABLE] = "./test-script.sh"; - p[NAME] = string("Test eSLURM ") + argv[1]; - p[WORKDIR] = 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[NBPROC] = 1; - p[MAXWALLTIME] = 1; - p[MAXRAMSIZE] = 50; - p[HOMEDIR] = homedir; - p[EXCLUSIVE] = true; - job.setParametre(p); - // ... and its environment - Environnement e; - e["MYENVVAR"] = "MYVALUE"; - job.setEnvironnement(e); - cout << job << endl; - - // Get the catalog - BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); - - // Create a BatchManager of type ePBS on localhost - FactBatchManager_eClient * fbm = (FactBatchManager_eClient *)(c("eSLURM")); - BatchManager_eClient * bm = (*fbm)(host.c_str(), user.c_str(), protocol); - - // Submit the job to the BatchManager - JobId jobid = bm->submitJob(job); - cout << jobid.__repr__() << endl; - - // Wait for the end of the job - string state = bm->waitForJobEnd(jobid, timeout); - - if (state == FINISHED) { - cout << "Job " << jobid.__repr__() << " is done" << endl; - bm->importOutputFiles(job, "resultdir/seconddirname"); - } else if (state == FAILED) { - cerr << "Job " << jobid.__repr__() << " finished in error" << endl; - bm->importOutputFiles(job, "resultdir/seconddirname"); - return 1; - } else { - cerr << "Timeout while executing job" << endl; - return 1; - } - - } catch (GenericException e) { - cerr << "Error: " << e << endl; - return 1; - } catch (ParserException e) { - cerr << "Parser error: " << e.what() << endl; - return 1; - } - - // test the result file - try { - SimpleParser resultParser; - resultParser.parse("resultdir/seconddirname/result.txt"); - cout << "Result:" << endl << resultParser; - const string & envvar = resultParser.getValue("MYENVVAR"); - int result = resultParser.getValueAsInt("c"); - if (envvar == "MYVALUE" && result == 12) { - cout << "OK, Expected result found." << endl; - return 0; - } else { - cerr << "Error, result is not the expected one (MYENVVAR = MYVALUE, c = 12)." << endl; - return 1; - } - } catch (ParserException e) { - cerr << "Parser error on result file: " << e.what() << endl; - return 1; - } -} diff --git a/src/Slurm/Test/seta.sh b/src/Slurm/Test/seta.sh deleted file mode 100644 index 42d1e38..0000000 --- a/src/Slurm/Test/seta.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -a=4 diff --git a/src/Slurm/Test/setb.sh b/src/Slurm/Test/setb.sh deleted file mode 100644 index 8969060..0000000 --- a/src/Slurm/Test/setb.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -b=3 diff --git a/src/Slurm/Test/test-script.sh b/src/Slurm/Test/test-script.sh deleted file mode 100755 index 1d56247..0000000 --- a/src/Slurm/Test/test-script.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -. ./seta.sh -. ./setb.sh - -c=`expr $a "*" $b` - -echo "MYENVVAR = $MYENVVAR" > result.txt -echo "c = $c" >> result.txt diff --git a/src/Vishnu/Batch_BatchManager_eVishnu.cxx b/src/Vishnu/BatchManager_Vishnu.cxx similarity index 72% rename from src/Vishnu/Batch_BatchManager_eVishnu.cxx rename to src/Vishnu/BatchManager_Vishnu.cxx index 9c39013..4b7fe00 100644 --- a/src/Vishnu/Batch_BatchManager_eVishnu.cxx +++ b/src/Vishnu/BatchManager_Vishnu.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_BatchManager_eVishnu.cxx : + * BatchManager_Vishnu.cxx : * * Created on: 24 june 2011 * Author : Renaud BARATE - EDF R&D @@ -35,36 +35,33 @@ #include #include -#include -#include -#include +#include +#include -#include "Batch_BatchManager_eVishnu.hxx" -#include "Batch_JobInfo_eVishnu.hxx" +#include "BatchManager_Vishnu.hxx" +#include "JobInfo_Vishnu.hxx" +#include "Log.hxx" using namespace std; namespace Batch { - BatchManager_eVishnu::BatchManager_eVishnu(const FactBatchManager * parent, + BatchManager_Vishnu::BatchManager_Vishnu(const FactBatchManager * parent, const char * host, const char * username, CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node) - : BatchManager(parent, host), - // Force SH protocol for Vishnu - BatchManager_eClient(parent, host, username, SH, mpiImpl), - _nb_proc_per_node(nb_proc_per_node) + const char * mpiImpl) + : // Force SH protocol for Vishnu + BatchManager(parent, host, username, SH, mpiImpl) { } - BatchManager_eVishnu::~BatchManager_eVishnu() + BatchManager_Vishnu::~BatchManager_Vishnu() { } // Method to submit a job to the batch manager - const JobId BatchManager_eVishnu::submitJob(const Job & job) + const JobId BatchManager_Vishnu::submitJob(const Job & job) { // export input files on cluster exportInputFiles(job); @@ -87,32 +84,32 @@ namespace Batch { subCommand += "vishnu_close"; string command = _protocol.getExecCommand(subCommand, _hostname, _username); command += " 2>&1"; - cerr << command.c_str() << endl; + LOG(command); // submit job string output; int status = Utils::getCommandOutput(command, output); - cout << output; - if (status != 0) throw EmulationException("Can't submit job, error was: " + output); + LOG(output); + if (status != 0) throw RunTimeException("Can't submit job, error was: " + output); // find id of submitted job in output string search = "Job Id : "; string::size_type pos = output.find(search); if (pos == string::npos) - throw EmulationException("Error in the submission of the job on the remote host"); + throw RunTimeException("Error in the submission of the job on the remote host"); pos += search.size(); string::size_type endl_pos = output.find('\n', pos); string::size_type count = (endl_pos == string::npos)? string::npos : endl_pos - pos; string jobref = output.substr(pos, count); if (jobref.size() == 0) - throw EmulationException("Error in the submission of the job on the remote host"); + throw RunTimeException("Error in the submission of the job on the remote host"); JobId id(this, jobref); return id; } - void BatchManager_eVishnu::exportInputFiles(const Job& job) + void BatchManager_Vishnu::exportInputFiles(const Job& job) { Parametre params = job.getParametre(); string subCommand = string("export OMNIORB_CONFIG=$VISHNU_CONFIG_FILE; "); @@ -156,19 +153,19 @@ namespace Batch { // Execute command string command = _protocol.getExecCommand(subCommand, _hostname, _username); command += " 2>&1"; - cerr << command.c_str() << endl; + LOG(command); string output; int status = Utils::getCommandOutput(command, output); - cout << output; + LOG(output); if (status != 0) - throw EmulationException("Can't copy input files, error was: " + output); + throw RunTimeException("Can't copy input files, error was: " + output); } /** * Create Vishnu command file and copy it on the server. * Return the name of the remote file. */ - string BatchManager_eVishnu::buildCommandFile(const Job & job) + string BatchManager_Vishnu::buildCommandFile(const Job & job) { Parametre params = job.getParametre(); @@ -181,11 +178,11 @@ namespace Batch { if (params.find(WORKDIR) != params.end()) workDir = params[WORKDIR].str(); else - throw EmulationException("params[WORKDIR] is not defined. Please define it, cannot submit this job."); + throw RunTimeException("params[WORKDIR] is not defined. Please define it, cannot submit this job."); if (params.find(EXECUTABLE) != params.end()) fileToExecute = params[EXECUTABLE].str(); else - throw EmulationException("params[EXECUTABLE] is not defined. Please define it, cannot submit this job."); + throw RunTimeException("params[EXECUTABLE] is not defined. Please define it, cannot submit this job."); string::size_type p1 = fileToExecute.find_last_of("/"); string::size_type p2 = fileToExecute.find_last_of("."); @@ -194,11 +191,11 @@ namespace Batch { // Create batch submit file ofstream tempOutputFile; - string tmpFileName = createAndOpenTemporaryFile("vishnu-script", tempOutputFile); + string tmpFileName = Utils::createAndOpenTemporaryFile("vishnu-script", tempOutputFile); tempOutputFile << "#!/bin/sh" << endl; tempOutputFile << "#% vishnu_output=" << workDir << "/logs/output.log." << rootNameToExecute << endl; - tempOutputFile << "#% vishnu_error=" << workDir << "/logs/error.log." << rootNameToExecute << endl; + tempOutputFile << "#% vishnu_rror=" << workDir << "/logs/error.log." << rootNameToExecute << endl; if (params.find(NAME) != params.end()) tempOutputFile << "#% vishnu_job_name=\"" << params[NAME] << "\"" << endl; @@ -227,16 +224,25 @@ namespace Batch { // Launch the executable tempOutputFile << "cd " << workDir << endl; - tempOutputFile << "./" + fileNameToExecute << endl; + tempOutputFile << "./" + fileNameToExecute; + if (params.find(ARGUMENTS) != params.end()) { + Versatile V = params[ARGUMENTS]; + for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++) { + StringType argt = * static_cast(*it); + string arg = argt; + tempOutputFile << " " << arg; + } + } + tempOutputFile << endl; tempOutputFile.flush(); tempOutputFile.close(); - cerr << "Batch script file generated is: " << tmpFileName << endl; + LOG("Batch script file generated is: " << tmpFileName); return tmpFileName; } - void BatchManager_eVishnu::deleteJob(const JobId & jobid) + void BatchManager_Vishnu::deleteJob(const JobId & jobid) { // define command to delete job string subCommand = string("export OMNIORB_CONFIG=$VISHNU_CONFIG_FILE; "); @@ -244,41 +250,16 @@ namespace Batch { subCommand += "vishnu_cancel_job " + _hostname + " " + jobid.getReference() + " && "; subCommand += "vishnu_close"; string command = _protocol.getExecCommand(subCommand, _hostname, _username); - cerr << command.c_str() << endl; + LOG(command); int status = system(command.c_str()); if (status) - throw EmulationException("Can't delete job " + jobid.getReference()); - - cerr << "job " << jobid.getReference() << " killed" << endl; - } - - void BatchManager_eVishnu::holdJob(const JobId & jobid) - { - throw NotYetImplementedException("BatchManager_eVishnu::holdJob"); - } + throw RunTimeException("Can't delete job " + jobid.getReference()); - void BatchManager_eVishnu::releaseJob(const JobId & jobid) - { - throw NotYetImplementedException("BatchManager_eVishnu::releaseJob"); - } - - void BatchManager_eVishnu::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env) - { - throw NotYetImplementedException("BatchManager_eVishnu::alterJob"); + LOG("job " << jobid.getReference() << " killed"); } - void BatchManager_eVishnu::alterJob(const JobId & jobid, const Parametre & param) - { - throw NotYetImplementedException("BatchManager_eVishnu::alterJob"); - } - - void BatchManager_eVishnu::alterJob(const JobId & jobid, const Environnement & env) - { - throw NotYetImplementedException("BatchManager_eVishnu::alterJob"); - } - - JobInfo BatchManager_eVishnu::queryJob(const JobId & jobid) + JobInfo BatchManager_Vishnu::queryJob(const JobId & jobid) { // define command to query batch string subCommand = string("export OMNIORB_CONFIG=$VISHNU_CONFIG_FILE; "); @@ -286,22 +267,17 @@ namespace Batch { subCommand += "vishnu_get_job_info " + _hostname + " " + jobid.getReference() + " && "; subCommand += "vishnu_close"; string command = _protocol.getExecCommand(subCommand, _hostname, _username); - cerr << command.c_str() << endl; + LOG(command); string output; int status = Utils::getCommandOutput(command, output); if (status != 0) - throw EmulationException("Can't query job " + jobid.getReference()); - JobInfo_eVishnu jobinfo = JobInfo_eVishnu(jobid.getReference(), output); + throw RunTimeException("Can't query job " + jobid.getReference()); + JobInfo_Vishnu jobinfo = JobInfo_Vishnu(jobid.getReference(), output); return jobinfo; } - const JobId BatchManager_eVishnu::addJob(const Job & job, const string reference) - { - return JobId(this, reference); - } - - void BatchManager_eVishnu::importOutputFiles(const Job & job, const std::string directory) + void BatchManager_Vishnu::importOutputFiles(const Job & job, const std::string directory) { // Create local result directory char * buf = getcwd(NULL, 0); @@ -310,7 +286,7 @@ namespace Batch { string absdir = (Utils::isAbsolutePath(directory))? directory : cwd + "/" + directory; int status = CommunicationProtocol::getInstance(SH).makeDirectory(absdir, "", ""); if (status != 0) { - throw EmulationException("Can't create result directory"); + throw RunTimeException("Can't create result directory"); } string subCommand = string("export OMNIORB_CONFIG=$VISHNU_CONFIG_FILE; "); @@ -342,12 +318,12 @@ namespace Batch { // Execute command string command = _protocol.getExecCommand(subCommand, _hostname, _username); command += " 2>&1"; - cerr << command.c_str() << endl; + LOG(command); string output; status = Utils::getCommandOutput(command, output); - cout << output; + LOG(output); if (status != 0) - throw EmulationException("Can't import output files, error was: " + output); + throw RunTimeException("Can't import output files, error was: " + output); } } diff --git a/src/Vishnu/Batch_BatchManager_eVishnu.hxx b/src/Vishnu/BatchManager_Vishnu.hxx similarity index 65% rename from src/Vishnu/Batch_BatchManager_eVishnu.hxx rename to src/Vishnu/BatchManager_Vishnu.hxx index 094547a..c558ec1 100644 --- a/src/Vishnu/Batch_BatchManager_eVishnu.hxx +++ b/src/Vishnu/BatchManager_Vishnu.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_BatchManager_eVishnu.hxx : + * BatchManager_Vishnu.hxx : * * Created on: 24 june 2011 * Author : Renaud BARATE - EDF R&D @@ -31,36 +31,29 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace Batch { - class BATCH_EXPORT BatchManager_eVishnu : public BatchManager_eClient + class BATCH_EXPORT BatchManager_Vishnu : public BatchManager { public: - BatchManager_eVishnu(const FactBatchManager * parent, + BatchManager_Vishnu(const FactBatchManager * parent, const char * host = "localhost", const char * username = "", CommunicationProtocolType protocolType = SSH, - const char * mpiImpl = "nompi", - int nb_proc_per_node = 1); - virtual ~BatchManager_eVishnu(); + const char * mpiImpl = "nompi"); + virtual ~BatchManager_Vishnu(); // Methods to control jobs virtual const JobId submitJob(const Job & job); virtual void deleteJob(const JobId & jobid); - virtual void holdJob(const JobId & jobid); - virtual void releaseJob(const JobId & jobid); - 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); virtual JobInfo queryJob(const JobId & jobid); - virtual const JobId addJob(const Job & job, const std::string reference); virtual void importOutputFiles(const Job & job, const std::string directory); protected: @@ -68,8 +61,6 @@ namespace Batch { std::string buildCommandFile(const Job & job); void exportInputFiles(const Job & job); - int _nb_proc_per_node; - }; } diff --git a/src/Vishnu/Batch_FactBatchManager_eVishnu.cxx b/src/Vishnu/Batch_FactBatchManager_eVishnu.cxx deleted file mode 100644 index 3f4fc4f..0000000 --- a/src/Vishnu/Batch_FactBatchManager_eVishnu.cxx +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Batch_FactBatchManager_eVishnu.cxx : - * - * Created on: 24 june 2011 - * Author : Renaud BARATE - EDF R&D - */ - -#include - -#include "Batch_BatchManager_eVishnu.hxx" -#include "Batch_FactBatchManager_eVishnu.hxx" - -namespace Batch { - - static FactBatchManager_eVishnu sFBM_eVishnu; - - FactBatchManager_eVishnu::FactBatchManager_eVishnu() : FactBatchManager_eClient("eVISHNU") - { - } - - FactBatchManager_eVishnu::~FactBatchManager_eVishnu() - { - } - - BatchManager * FactBatchManager_eVishnu::operator() (const char * hostname) const - { - // MESSAGE("Building new BatchManager_eVishnu on host '" << hostname << "'"); - return new BatchManager_eVishnu(this, hostname); - } - - BatchManager_eClient * FactBatchManager_eVishnu::operator() (const char * hostname, - const char * username, - CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node) const - { - // MESSAGE("Building new BatchManager_eVishnu on host '" << hostname << "'"); - return new BatchManager_eVishnu(this, hostname, username, protocolType, mpiImpl, nb_proc_per_node); - } - -} diff --git a/src/Vishnu/CMakeLists.txt b/src/Vishnu/CMakeLists.txt index 31ab7a2..a1fec35 100644 --- a/src/Vishnu/CMakeLists.txt +++ b/src/Vishnu/CMakeLists.txt @@ -20,13 +20,13 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -SET(CLASS_LIST Vishnu/Batch_BatchManager_eVishnu - Vishnu/Batch_FactBatchManager_eVishnu - Vishnu/Batch_JobInfo_eVishnu +SET(CLASS_LIST Vishnu/BatchManager_Vishnu + Vishnu/FactBatchManager_Vishnu + Vishnu/JobInfo_Vishnu ) APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST}) IF (TEST_ENABLED) - add_subdirectory(Test) + ADD_TEST(VISHNU ${CMAKE_BINARY_DIR}/src/Core/Test/Test_BatchManager VISHNU SH) ENDIF (TEST_ENABLED) diff --git a/src/Vishnu/Batch_FactBatchManager_eVishnu.hxx b/src/Vishnu/FactBatchManager_Vishnu.cxx similarity index 55% rename from src/Vishnu/Batch_FactBatchManager_eVishnu.hxx rename to src/Vishnu/FactBatchManager_Vishnu.cxx index 5bfaaeb..53361b3 100644 --- a/src/Vishnu/Batch_FactBatchManager_eVishnu.hxx +++ b/src/Vishnu/FactBatchManager_Vishnu.cxx @@ -20,38 +20,36 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_FactBatchManager_eVishnu.hxx : + * FactBatchManager_Vishnu.cxx : * * Created on: 24 june 2011 * Author : Renaud BARATE - EDF R&D */ -#ifndef _FACTBATCHMANAGER_EVISHNU_H_ -#define _FACTBATCHMANAGER_EVISHNU_H_ +#include -#include -#include -#include -#include +#include "BatchManager_Vishnu.hxx" +#include "FactBatchManager_Vishnu.hxx" namespace Batch { - class BATCH_EXPORT FactBatchManager_eVishnu : public FactBatchManager_eClient - { - public: + static FactBatchManager_Vishnu sFBM_Vishnu; - FactBatchManager_eVishnu(); - virtual ~FactBatchManager_eVishnu(); + FactBatchManager_Vishnu::FactBatchManager_Vishnu() : FactBatchManager("VISHNU") + { + } - virtual BatchManager * operator() (const char * hostname) const; - virtual BatchManager_eClient * operator() (const char * hostname, - const char * username, - CommunicationProtocolType protocolType, - const char * mpiImpl, - int nb_proc_per_node = 1) const; + FactBatchManager_Vishnu::~FactBatchManager_Vishnu() + { + } - }; + BatchManager * FactBatchManager_Vishnu::operator() (const char * hostname, + const char * username, + CommunicationProtocolType protocolType, + const char * mpiImpl) const + { + // MESSAGE("Building new BatchManager_Vishnu on host '" << hostname << "'"); + return new BatchManager_Vishnu(this, hostname, username, protocolType, mpiImpl); + } } - -#endif diff --git a/src/Core/Batch_Utils.hxx b/src/Vishnu/FactBatchManager_Vishnu.hxx similarity index 60% rename from src/Core/Batch_Utils.hxx rename to src/Vishnu/FactBatchManager_Vishnu.hxx index c14273b..bc04ec2 100644 --- a/src/Core/Batch_Utils.hxx +++ b/src/Vishnu/FactBatchManager_Vishnu.hxx @@ -20,41 +20,36 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_Utils.hxx + * FactBatchManager_Vishnu.hxx : * - * Created on: 30 jan. 2012 + * Created on: 24 june 2011 * Author : Renaud BARATE - EDF R&D */ -#ifndef BATCH_UTILS_HXX_ -#define BATCH_UTILS_HXX_ +#ifndef _FACTBATCHMANAGER_EVISHNU_H_ +#define _FACTBATCHMANAGER_EVISHNU_H_ -#include +#include +#include +#include +#include namespace Batch { -class Utils { -public: + class BATCH_EXPORT FactBatchManager_Vishnu : public FactBatchManager + { + public: - /** - * Call a command with the system shell and stores its output in parameter "output". - * Returns the return code of the command. - */ - static int getCommandOutput(const std::string & command, std::string & output); + FactBatchManager_Vishnu(); + virtual ~FactBatchManager_Vishnu(); - /** - * Test if the path in parameter is an absolute path (does not test the existence of - * a file or directory at this path). - */ - static bool isAbsolutePath(const std::string & path); + virtual BatchManager * operator() (const char * hostname, + const char * username, + CommunicationProtocolType protocolType, + const char * mpiImpl) const; -private: - - // No instanciation possible as this class provides only static methods - Utils() { } - -}; + }; } -#endif /* BATCH_UTILS_HXX_ */ +#endif diff --git a/src/Vishnu/Batch_JobInfo_eVishnu.cxx b/src/Vishnu/JobInfo_Vishnu.cxx similarity index 91% rename from src/Vishnu/Batch_JobInfo_eVishnu.cxx rename to src/Vishnu/JobInfo_Vishnu.cxx index d4b89d4..68a32b6 100644 --- a/src/Vishnu/Batch_JobInfo_eVishnu.cxx +++ b/src/Vishnu/JobInfo_Vishnu.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_JobInfo_eVishnu.cxx : + * JobInfo_Vishnu.cxx : * * Created on: 24 june 2011 * Author : Renaud BARATE - EDF R&D @@ -29,16 +29,16 @@ #include #include -#include -#include +#include +#include -#include "Batch_JobInfo_eVishnu.hxx" +#include "JobInfo_Vishnu.hxx" using namespace std; namespace Batch { - JobInfo_eVishnu::JobInfo_eVishnu(const string & id, const string & queryOutput) + JobInfo_Vishnu::JobInfo_Vishnu(const string & id, const string & queryOutput) : JobInfo() { _param[ID] = id; @@ -91,7 +91,7 @@ namespace Batch { } } - JobInfo_eVishnu::~JobInfo_eVishnu() + JobInfo_Vishnu::~JobInfo_Vishnu() { } diff --git a/src/Vishnu/Batch_JobInfo_eVishnu.hxx b/src/Vishnu/JobInfo_Vishnu.hxx similarity index 84% rename from src/Vishnu/Batch_JobInfo_eVishnu.hxx rename to src/Vishnu/JobInfo_Vishnu.hxx index 5341495..db124e3 100644 --- a/src/Vishnu/Batch_JobInfo_eVishnu.hxx +++ b/src/Vishnu/JobInfo_Vishnu.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Batch_JobInfo_eVishnu.hxx : + * JobInfo_Vishnu.hxx : * * Created on: 24 june 2011 * Author : Renaud BARATE - EDF R&D @@ -31,16 +31,16 @@ #include -#include +#include namespace Batch { - class JobInfo_eVishnu : public JobInfo + class JobInfo_Vishnu : public JobInfo { public: - JobInfo_eVishnu(const std::string & id, const std::string & queryOutput); - virtual ~JobInfo_eVishnu(); + JobInfo_Vishnu(const std::string & id, const std::string & queryOutput); + virtual ~JobInfo_Vishnu(); }; diff --git a/src/Vishnu/Test/CMakeLists.txt b/src/Vishnu/Test/CMakeLists.txt deleted file mode 100644 index 84d88d0..0000000 --- a/src/Vishnu/Test/CMakeLists.txt +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# 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_SOURCE_DIR}/src/Core/Test) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -# Build the test programs and add the tests -add_executable(Test_eVishnu Test_eVishnu.cxx) -target_link_libraries(Test_eVishnu Batch SimpleParser) - -IF (HAS_SSH) - ADD_TEST(eVishnu_SSH Test_eVishnu SSH) -ENDIF (HAS_SSH) - -#IF (HAS_RSH) -# ADD_TEST(eVishnu_RSH Test_eVishnu RSH) -#ENDIF (HAS_RSH) diff --git a/src/Vishnu/Test/Test_eVishnu.cxx b/src/Vishnu/Test/Test_eVishnu.cxx deleted file mode 100644 index f6c48e1..0000000 --- a/src/Vishnu/Test/Test_eVishnu.cxx +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* - * Test_eVishnu.cxx : - * - * Author : Renaud BARATE - EDF R&D - * Date : June 2011 - * - */ - -#include -#include -#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 Vishnu commands." << endl; - cout << "*******************************************************************************************" << endl; - - // eventually remove any previous result - remove("result.txt"); - - try { - // Parse the test configuration file - SimpleParser parser; - parser.parseTestConfigFile(); - const string & homedir = parser.getValue("TEST_EVISHNU_HOMEDIR"); - const string & host = parser.getValue("TEST_EVISHNU_HOST"); - const string & user = parser.getValue("TEST_EVISHNU_USER"); - int timeout = parser.getValueAsInt("TEST_EVISHNU_TIMEOUT"); - - // Define the job... - Job job; - // ... and its parameters ... - Parametre p; - p[EXECUTABLE] = "./test-script.sh"; - p[NAME] = "Test_eVISHNU"; - p[WORKDIR] = homedir + "/tmp/Batch"; - p[INFILE] = Couple("seta.sh", "seta.sh"); - p[INFILE] += Couple("setb.sh", "setb.sh"); - p[OUTFILE] = Couple("result.txt", "result.txt"); - p[NBPROC] = 1; - p[MAXWALLTIME] = 1; - p[MAXRAMSIZE] = 50; - job.setParametre(p); - // ... and its environment - Environnement e; - e["MYENVVAR"] = "MYVALUE"; - job.setEnvironnement(e); - cout << job << endl; - - // Get the catalog - BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); - - // Create a BatchManager of type ePBS on localhost - FactBatchManager_eClient * fbm = (FactBatchManager_eClient *)(c("eVISHNU")); - BatchManager_eClient * bm = (*fbm)(host.c_str(), user.c_str(), SH); - - // Submit the job to the BatchManager - JobId jobid = bm->submitJob(job); - cout << jobid.__repr__() << endl; - - // Wait for the end of the job - string state = bm->waitForJobEnd(jobid, timeout); - - if (state == FINISHED) { - cout << "Job " << jobid.__repr__() << " is done" << endl; - bm->importOutputFiles(job, "resultdir/seconddirname"); - } else if (state == FAILED) { - cerr << "Job " << jobid.__repr__() << " finished in error" << endl; - bm->importOutputFiles(job, "resultdir/seconddirname"); - return 1; - } else { - cerr << "Timeout while executing job" << endl; - return 1; - } - - } catch (GenericException e) { - cerr << "Error: " << e << endl; - return 1; - } catch (ParserException e) { - cerr << "Parser error: " << e.what() << endl; - return 1; - } - - // test the result file - try { - SimpleParser resultParser; - resultParser.parse("resultdir/seconddirname/result.txt"); - cout << "Result:" << endl << resultParser; - const string & envvar = resultParser.getValue("MYENVVAR"); - int result = resultParser.getValueAsInt("c"); - if (envvar == "MYVALUE" && result == 12) { - cout << "OK, Expected result found." << endl; - return 0; - } else { - cerr << "Error, result is not the expected one (MYENVVAR = MYVALUE, c = 12)." << endl; - return 1; - } - } catch (ParserException e) { - cerr << "Parser error on result file: " << e.what() << endl; - return 1; - } -} diff --git a/src/Vishnu/Test/seta.sh b/src/Vishnu/Test/seta.sh deleted file mode 100644 index 42d1e38..0000000 --- a/src/Vishnu/Test/seta.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -a=4 diff --git a/src/Vishnu/Test/setb.sh b/src/Vishnu/Test/setb.sh deleted file mode 100644 index 8969060..0000000 --- a/src/Vishnu/Test/setb.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -b=3 diff --git a/src/Vishnu/Test/test-script.sh b/src/Vishnu/Test/test-script.sh deleted file mode 100755 index 1d56247..0000000 --- a/src/Vishnu/Test/test-script.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -. ./seta.sh -. ./setb.sh - -c=`expr $a "*" $b` - -echo "MYENVVAR = $MYENVVAR" > result.txt -echo "c = $c" >> result.txt -- 2.39.2