From: barate Date: Fri, 6 Mar 2009 10:31:17 +0000 (+0000) Subject: Removed dependency on Basics from Batch. Fixed --with-onlylauncher mode. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fd31223b3334d1d87280055cd7e704ff065bae5b;p=modules%2Fkernel.git Removed dependency on Basics from Batch. Fixed --with-onlylauncher mode. --- diff --git a/configure.ac b/configure.ac index 844d28f58..fa01feeaa 100644 --- a/configure.ac +++ b/configure.ac @@ -88,8 +88,9 @@ AM_CONDITIONAL(CORBA_GEN, test x$corba_gen = xtrue) # ---- option to build only launcher, resources manager and batch classes AC_ARG_WITH(onlylauncher, - --with-onlylauncher, - [],[with_onlylauncher="no"]) + [AC_HELP_STRING([--with-onlylauncher],[Build only launcher, resources manager and batch classes [default=no]])], + [], + [with_onlylauncher="no"]) AM_CONDITIONAL(WITHONLYLAUNCHER, test x$with_onlylauncher = xyes) # ---------------------------------------------------------------------------- diff --git a/src/Batch/Batch_BatchManagerCatalog.cxx b/src/Batch/Batch_BatchManagerCatalog.cxx index e2d341ec6..c9e5ea7ed 100644 --- a/src/Batch/Batch_BatchManagerCatalog.cxx +++ b/src/Batch/Batch_BatchManagerCatalog.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * BatchManagerCatalog.cxx : + * BatchManagerCatalog.cxx : * * Auteur : Ivan DUTKA-MALEN - EDF R&D * Date : Septembre 2004 @@ -39,7 +39,7 @@ namespace Batch { pthread_mutex_t BatchManagerCatalog::_mutex = PTHREAD_MUTEX_INITIALIZER; std::map * BatchManagerCatalog::_p_catalog = 0; - BatchManagerCatalog BatchManagerCatalog::theCatalog; +// BatchManagerCatalog BatchManagerCatalog::theCatalog; // Constructeur BatchManagerCatalog::BatchManagerCatalog() @@ -50,7 +50,12 @@ namespace Batch { // Destructeur BatchManagerCatalog::~BatchManagerCatalog() { - delete BatchManagerCatalog::_p_catalog; + // Note (RB, 6mar09) : this deletion can cause big memory problems as the pointer + // may have been destroyed before this call to delete, and delete can be called + // several times. So it's better to remove it for now, even if there is a (small) + // memory leak. + // TODO: Replace that by a clean singleton implementation +// delete BatchManagerCatalog::_p_catalog; } // Functor diff --git a/src/Batch/Batch_BatchManager_eClient.cxx b/src/Batch/Batch_BatchManager_eClient.cxx index ebdd30895..5ff48dd1f 100644 --- a/src/Batch/Batch_BatchManager_eClient.cxx +++ b/src/Batch/Batch_BatchManager_eClient.cxx @@ -25,12 +25,13 @@ * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr * Date : Thu Apr 24 10:17:22 2008 -* Projet : PAL Salome +* Projet : PAL Salome * */ #include "Batch_BatchManager_eClient.hxx" -#include "Basics_DirUtils.hxx" +#include "Batch_RunTimeException.hxx" +#include "Batch_NotYetImplementedException.hxx" #include #include @@ -179,10 +180,10 @@ namespace Batch { command += directory; cerr << command.c_str() << endl; status = system(command.c_str()); - if(status) + if(status) { // Try to get what we can (logs files) - // throw BatchException("Error of connection on remote host"); + // throw BatchException("Error of connection on remote host"); std::string mess("Copy command failed ! status is :"); ostringstream status_str; status_str << status; @@ -216,31 +217,36 @@ namespace Batch { } } - string BatchManager_eClient::BuildTemporaryFileName() const - { - //build more complex file name to support multiple salome session - string aFileName = Kernel_Utils::GetTmpFileName(); -#ifndef WIN32 - aFileName += ".sh"; -#else - aFileName += ".bat"; -#endif - return aFileName; - } - - void BatchManager_eClient::RmTmpFile(std::string & TemporaryFileName) + /** + * This method creates a temporary file and opens an output stream to write into this file. + * The file is created with the pattern "/tmp/batch_XXXXXX" where the X's are replaced by random + * characters. The caller is responsible for closing and deleting the file when it is no more used. + * \param outputStream an output stream that will be opened for writing in the temporary file. If + * the stream is already open, it will be closed first. + * \return the name of the created file. + */ + string BatchManager_eClient::createAndOpenTemporaryFile(ofstream & outputStream) const { + string fileName; #ifdef WIN32 - string command = "del /F "; + throw NotYetImplementedException("Temporary file creation in Batch library has not been ported to Windows yet"); #else - string command = "rm "; + char * tmpFileName = strdup("/tmp/batch_XXXXXX"); + int fd = mkstemp(tmpFileName); + if (fd == -1) + { + throw RunTimeException("Can't create temporary file"); + } + + if (outputStream.is_open()) + outputStream.close(); + outputStream.open(tmpFileName); + close(fd); // Close the file descriptor so that the file is not opened twice + + fileName = tmpFileName; + delete[] tmpFileName; #endif - command += TemporaryFileName; - char *temp = strdup(command.c_str()); - int lgthTemp = strlen(temp); - temp[lgthTemp - 3] = '*'; - temp[lgthTemp - 2] = '\0'; - system(temp); - free(temp); + return fileName; } + } diff --git a/src/Batch/Batch_BatchManager_eClient.hxx b/src/Batch/Batch_BatchManager_eClient.hxx index 172ca4abd..c8f401386 100644 --- a/src/Batch/Batch_BatchManager_eClient.hxx +++ b/src/Batch/Batch_BatchManager_eClient.hxx @@ -25,7 +25,7 @@ * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr * Date : Thu Apr 24 10:17:22 2008 - * Projet : PAL Salome + * Projet : PAL Salome * */ @@ -47,7 +47,7 @@ namespace Batch { { public: const std::string msg; - + EmulationException(const std::string m) : msg(m) {} }; @@ -64,8 +64,7 @@ namespace Batch { std::string _username; // username to access _hostname MpiImpl *_mpiImpl; // Mpi implementation to launch executable in batch script - std::string BuildTemporaryFileName() const; - void RmTmpFile(std::string & TemporaryFileName); + std::string createAndOpenTemporaryFile(std::ofstream & outputStream) const; MpiImpl* FactoryMpiImpl(std::string mpiImpl) throw(EmulationException); void exportInputFiles(const Job & job) throw(EmulationException); diff --git a/src/Batch/Batch_BatchManager_eLSF.cxx b/src/Batch/Batch_BatchManager_eLSF.cxx index 009d4c6a4..e48690c47 100644 --- a/src/Batch/Batch_BatchManager_eLSF.cxx +++ b/src/Batch/Batch_BatchManager_eLSF.cxx @@ -25,7 +25,7 @@ * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr * Date : Thu Apr 24 10:17:22 2008 - * Projet : PAL Salome + * Projet : PAL Salome * */ @@ -120,7 +120,7 @@ namespace Batch { FILE *fp = fopen(logFile.c_str(),"r"); fgets( line, 128, fp); fclose(fp); - + string sline(line); int p10 = sline.find("<"); int p20 = sline.find(">"); @@ -137,7 +137,7 @@ namespace Batch { int ref; istringstream iss(jobid.getReference()); iss >> ref; - + // define command to submit batch string command; command = _protocol; @@ -159,7 +159,7 @@ namespace Batch { 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) { @@ -244,7 +244,7 @@ namespace Batch { throw EmulationException("Not yet implemented"); } - void BatchManager_eLSF::buildBatchScript(const Job & job) throw(EmulationException) + void BatchManager_eLSF::buildBatchScript(const Job & job) { #ifndef WIN32 //TODO: need for porting on Windows int status; @@ -276,9 +276,8 @@ namespace Batch { rootNameToExecute = "command"; } - std::string TmpFileName = BuildTemporaryFileName(); ofstream tempOutputFile; - tempOutputFile.open(TmpFileName.c_str(), ofstream::out ); + std::string TmpFileName = createAndOpenTemporaryFile(tempOutputFile); tempOutputFile << "#! /bin/sh -f" << endl ; if (queue != "") @@ -307,7 +306,7 @@ namespace Batch { tempOutputFile << "source " << env["SOURCEFILE"] << endl ; tempOutputFile << env["COMMAND"]; } - + tempOutputFile.flush(); tempOutputFile.close(); #ifdef WIN32 @@ -340,11 +339,11 @@ namespace Batch { cerr << command.c_str() << endl; status = system(command.c_str()); if(status) - throw EmulationException("Error of connection on remote host"); + throw EmulationException("Error of connection on remote host"); - RmTmpFile(TmpFileName); + remove(TmpFileName.c_str()); #endif - + } std::string BatchManager_eLSF::getWallTime(const long edt) diff --git a/src/Batch/Batch_BatchManager_eLSF.hxx b/src/Batch/Batch_BatchManager_eLSF.hxx index 599d90c68..d09db3d9b 100644 --- a/src/Batch/Batch_BatchManager_eLSF.hxx +++ b/src/Batch/Batch_BatchManager_eLSF.hxx @@ -25,7 +25,7 @@ * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr * Date : Thu Apr 24 10:17:22 2008 - * Projet : PAL Salome + * Projet : PAL Salome * */ @@ -77,7 +77,7 @@ namespace Batch { protected: - void buildBatchScript(const Job & job) throw(EmulationException); + void buildBatchScript(const Job & job); std::string getWallTime(const long edt); private: diff --git a/src/Batch/Batch_BatchManager_ePBS.cxx b/src/Batch/Batch_BatchManager_ePBS.cxx index 177319c32..68d1cab07 100644 --- a/src/Batch/Batch_BatchManager_ePBS.cxx +++ b/src/Batch/Batch_BatchManager_ePBS.cxx @@ -25,7 +25,7 @@ * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr * Date : Thu Apr 24 10:17:22 2008 - * Projet : PAL Salome + * Projet : PAL Salome * */ @@ -115,7 +115,7 @@ namespace Batch { FILE *fp = fopen(logFile.c_str(),"r"); fgets( line, 128, fp); fclose(fp); - + string sline(line); int pos = sline.find("."); string strjob; @@ -135,7 +135,7 @@ namespace Batch { int ref; istringstream iss(jobid.getReference()); iss >> ref; - + // define command to submit batch string command; command = _protocol; @@ -157,7 +157,7 @@ namespace Batch { 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) { @@ -238,7 +238,7 @@ namespace Batch { throw EmulationException("Not yet implemented"); } - void BatchManager_ePBS::buildBatchScript(const Job & job) throw(EmulationException) + void BatchManager_ePBS::buildBatchScript(const Job & job) { #ifndef WIN32 //TODO: need for porting on Windows int status; @@ -270,9 +270,8 @@ namespace Batch { rootNameToExecute = "command"; } - std::string TmpFileName = BuildTemporaryFileName(); ofstream tempOutputFile; - tempOutputFile.open(TmpFileName.c_str(), ofstream::out ); + std::string TmpFileName = createAndOpenTemporaryFile(tempOutputFile); tempOutputFile << "#! /bin/sh -f" << endl; if (queue != "") @@ -300,7 +299,7 @@ namespace Batch { tempOutputFile << "source " << env["SOURCEFILE"] << endl ; tempOutputFile << env["COMMAND"]; } - + tempOutputFile.flush(); tempOutputFile.close(); #ifdef WIN32 @@ -333,10 +332,10 @@ namespace Batch { cerr << command.c_str() << endl; status = system(command.c_str()); if(status) - throw EmulationException("Error of connection on remote host"); + throw EmulationException("Error of connection on remote host"); - RmTmpFile(TmpFileName); -#endif + remove(TmpFileName.c_str()); +#endif } } diff --git a/src/Batch/Batch_BatchManager_ePBS.hxx b/src/Batch/Batch_BatchManager_ePBS.hxx index 9effa53cf..661b36829 100644 --- a/src/Batch/Batch_BatchManager_ePBS.hxx +++ b/src/Batch/Batch_BatchManager_ePBS.hxx @@ -25,7 +25,7 @@ * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr * Date : Thu Apr 24 10:17:22 2008 - * Projet : PAL Salome + * Projet : PAL Salome * */ @@ -77,7 +77,7 @@ namespace Batch { protected: - void buildBatchScript(const Job & job) throw(EmulationException); + void buildBatchScript(const Job & job); private: diff --git a/src/Batch/Batch_BatchManager_eSGE.cxx b/src/Batch/Batch_BatchManager_eSGE.cxx index 56130df01..cb4f9604d 100644 --- a/src/Batch/Batch_BatchManager_eSGE.cxx +++ b/src/Batch/Batch_BatchManager_eSGE.cxx @@ -25,7 +25,7 @@ * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr * Date : Thu Apr 24 10:17:22 2008 - * Projet : PAL Salome + * Projet : PAL Salome * */ @@ -113,7 +113,7 @@ namespace Batch { FILE *fp = fopen(logFile.c_str(),"r"); fgets( line, 128, fp); fclose(fp); - + string strjob; istringstream iss(line); iss >> strjob >> strjob >> strjob; @@ -129,7 +129,7 @@ namespace Batch { int ref; istringstream iss(jobid.getReference()); iss >> ref; - + // define command to submit batch string command; command = _protocol; @@ -151,7 +151,7 @@ namespace Batch { 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) { @@ -232,7 +232,7 @@ namespace Batch { throw EmulationException("Not yet implemented"); } - void BatchManager_eSGE::buildBatchScript(const Job & job) throw(EmulationException) + void BatchManager_eSGE::buildBatchScript(const Job & job) { #ifndef WIN32 //TODO porting on Win32 platform @@ -263,9 +263,8 @@ namespace Batch { rootNameToExecute = "command"; } - std::string TmpFileName = BuildTemporaryFileName(); ofstream tempOutputFile; - tempOutputFile.open(TmpFileName.c_str(), ofstream::out ); + std::string TmpFileName = createAndOpenTemporaryFile(tempOutputFile); tempOutputFile << "#! /bin/sh -f" << endl; if (queue != "") @@ -294,7 +293,7 @@ namespace Batch { tempOutputFile << "source " << env["SOURCEFILE"] << endl ; tempOutputFile << env["COMMAND"]; } - + tempOutputFile.flush(); tempOutputFile.close(); chmod(TmpFileName.c_str(), 0x1ED); @@ -322,10 +321,10 @@ namespace Batch { cerr << command.c_str() << endl; status = system(command.c_str()); if(status) - throw EmulationException("Error of connection on remote host"); + throw EmulationException("Error of connection on remote host"); - RmTmpFile(TmpFileName); -#endif //WIN32 + remove(TmpFileName.c_str()); +#endif //WIN32 } std::string BatchManager_eSGE::getWallTime(const long edt) diff --git a/src/Batch/Batch_BatchManager_eSGE.hxx b/src/Batch/Batch_BatchManager_eSGE.hxx index c2a0fecca..4f7ca9685 100644 --- a/src/Batch/Batch_BatchManager_eSGE.hxx +++ b/src/Batch/Batch_BatchManager_eSGE.hxx @@ -25,7 +25,7 @@ * Auteur : Bernard SECHER - CEA DEN * Mail : mailto:bernard.secher@cea.fr * Date : Thu Apr 24 10:17:22 2008 - * Projet : PAL Salome + * Projet : PAL Salome * */ @@ -76,7 +76,7 @@ namespace Batch { protected: - void buildBatchScript(const Job & job) throw(EmulationException); + void buildBatchScript(const Job & job); std::string getWallTime(const long edt); private: diff --git a/src/Batch/Makefile.am b/src/Batch/Makefile.am index e0bc1b719..8d115a68f 100644 --- a/src/Batch/Makefile.am +++ b/src/Batch/Makefile.am @@ -119,21 +119,12 @@ LIB_SRC = \ MpiImpl.cxx -LIB_CPPFLAGS = \ - ${PYTHON_INCLUDES} +LIB_CPPFLAGS = ${PYTHON_INCLUDES} if !WITHONLYLAUNCHER - LIB_CPPFLAGS += \ - -I$(srcdir)/../Basics \ - -I$(top_builddir)/salome_adm/unix + LIB_CPPFLAGS += -I$(top_builddir)/salome_adm/unix endif -LIB_LIBADD = -if !WITHONLYLAUNCHER - LIB_LIBADD += \ - ../Basics/libSALOMEBasics.la -endif - -LIB_LIBADD += $(PYTHON_LIBS) +LIB_LIBADD = $(PYTHON_LIBS) # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/Launcher/Makefile.am b/src/Launcher/Makefile.am index ab797d703..97e08d2a0 100644 --- a/src/Launcher/Makefile.am +++ b/src/Launcher/Makefile.am @@ -123,7 +123,7 @@ libLauncher_la_LDFLAGS =\ libLauncher_la_LIBADD =\ ../Batch/libSalomeBatch.la \ - ../ResourcesManager/libSalomeResourcesManager.la \ + ../ResourcesManager/libResourcesManager.la \ @MPI_LIBS@ \ @LIBXML_LIBS@ diff --git a/src/ResourcesManager/Makefile.am b/src/ResourcesManager/Makefile.am index f24d8355d..469acb657 100755 --- a/src/ResourcesManager/Makefile.am +++ b/src/ResourcesManager/Makefile.am @@ -101,5 +101,4 @@ libResourcesManager_la_CPPFLAGS =\ libResourcesManager_la_LDFLAGS = -no-undefined -version-info=0:0:0 libResourcesManager_la_LIBADD =\ - ../Utils/libOpUtil.la \ @LIBXML_LIBS@