From: barate Date: Thu, 24 Sep 2009 15:49:55 +0000 (+0000) Subject: Changed libBatch optional usage from empty implementation classes to #ifdef. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FBR_V51_RB;p=modules%2Fkernel.git Changed libBatch optional usage from empty implementation classes to #ifdef. --- diff --git a/configure.ac b/configure.ac index b335018d3..d09c4b0a4 100644 --- a/configure.ac +++ b/configure.ac @@ -364,7 +364,7 @@ echo -------------------------------------------------------------- echo CHECK_LIBBATCH -AM_CONDITIONAL(WITH_BATCH, [test x"$libbatch_ok" = xyes]) +AM_CONDITIONAL(WITH_LIBBATCH, [test x"$libbatch_ok" = xyes]) echo echo ============================================================ diff --git a/src/Launcher/BatchTest.cxx b/src/Launcher/BatchTest.cxx index bf0e88e64..23ff34abe 100644 --- a/src/Launcher/BatchTest.cxx +++ b/src/Launcher/BatchTest.cxx @@ -20,9 +20,13 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "BatchTest.hxx" +#include "Launcher.hxx" +#ifdef WITH_LIBBATCH #include #include +#endif + #include "utilities.h" #include @@ -33,6 +37,7 @@ #endif BatchTest::BatchTest(const Engines::MachineDefinition& batch_descr) { +#ifdef WITH_LIBBATCH _batch_descr = batch_descr; // Getting date @@ -54,6 +59,7 @@ BatchTest::BatchTest(const Engines::MachineDefinition& batch_descr) _test_filename += _date + "_test_cluster_file_"; _test_filename += _batch_descr.alias.in(); _base_filename = _date + "_test_cluster_file_" + _batch_descr.alias.in(); +#endif } BatchTest::~BatchTest() {} @@ -438,6 +444,7 @@ BatchTest::test_jobsubmit_simple() std::string BatchTest::test_jobsubmit_mpi() { +#ifdef WITH_LIBBATCH int status; std::string home; std::string command; @@ -629,6 +636,10 @@ BatchTest::test_jobsubmit_mpi() } result = "OK"; return result; +#else + throw LauncherException("Method BatchTest::test_jobsubmit_mpi is not available " + "(libBatch was not present at compilation time)"); +#endif } std::string diff --git a/src/Launcher/DummyBatchTest.cxx b/src/Launcher/DummyBatchTest.cxx deleted file mode 100644 index 6e995a204..000000000 --- a/src/Launcher/DummyBatchTest.cxx +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// This implementation is an empty shell compiled only when libBatch is absent. -// It will just throw exceptions when it is called. - -#include "BatchTest.hxx" -#include "Launcher.hxx" - -BatchTest::BatchTest(const Engines::MachineDefinition& batch_descr) -{ -} - -BatchTest::~BatchTest() -{ -} - -bool BatchTest::test() -{ - throw LauncherException("Method BatchTest::test() is not available " - "(libBatch was not found at compilation time)."); -} diff --git a/src/Launcher/DummyLauncher.cxx b/src/Launcher/DummyLauncher.cxx deleted file mode 100644 index fb9222b59..000000000 --- a/src/Launcher/DummyLauncher.cxx +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// This implementation is an empty shell compiled only when libBatch is absent. -// It will just throw exceptions when it is called. - -#include "Launcher.hxx" - -using namespace std; - -Launcher_cpp::Launcher_cpp() -{ -} - -Launcher_cpp::~Launcher_cpp() -{ -} - -long Launcher_cpp::submitJob(const string xmlExecuteFile, - const string clusterName) throw (LauncherException) -{ - throw LauncherException("Method Launcher_cpp::submitJob is not available " - "(libBatch was not found at compilation time)."); -} - -long Launcher_cpp::submitSalomeJob(const string fileToExecute, - const vector& filesToExport, - const vector& filesToImport, - const batchParams& batch_params, - const machineParams& params) throw (LauncherException) -{ - throw LauncherException("Method Launcher_cpp::submitSalomeJob is not available " - "(libBatch was not found at compilation time)."); -} - -string Launcher_cpp::queryJob(long id, - const machineParams& params) throw (LauncherException) -{ - throw LauncherException("Method Launcher_cpp::queryJob is not available " - "(libBatch was not found at compilation time)."); -} - -string Launcher_cpp::queryJob(long id, - const string clusterName) throw (LauncherException) -{ - throw LauncherException("Method Launcher_cpp::queryJob is not available " - "(libBatch was not found at compilation time)."); -} - -void Launcher_cpp::deleteJob(const long id, - const machineParams& params) throw (LauncherException) -{ - throw LauncherException("Method Launcher_cpp::deleteJob is not available " - "(libBatch was not found at compilation time)."); -} - -void Launcher_cpp::deleteJob(long id, - const string clusterName) throw (LauncherException) -{ - throw LauncherException("Method Launcher_cpp::deleteJob is not available " - "(libBatch was not found at compilation time)."); -} - -void Launcher_cpp::getResultsJob(const string directory, - const long id, - const machineParams& params) throw (LauncherException) -{ - throw LauncherException("Method Launcher_cpp::getResultsJob is not available " - "(libBatch was not found at compilation time)."); -} - -void Launcher_cpp::getResultsJob(const string directory, - long id, - const string clusterName) throw (LauncherException) -{ - throw LauncherException("Method Launcher_cpp::getResultsJob is not available " - "(libBatch was not found at compilation time)."); -} diff --git a/src/Launcher/Launcher.cxx b/src/Launcher/Launcher.cxx index 9e14cc361..b0f2601e9 100644 --- a/src/Launcher/Launcher.cxx +++ b/src/Launcher/Launcher.cxx @@ -20,11 +20,14 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#ifdef WITH_LIBBATCH #include #include #include #include #include +#endif + #include "SALOME_Launcher_Handler.hxx" #include "Launcher.hxx" #include @@ -61,12 +64,15 @@ Launcher_cpp::~Launcher_cpp() #if defined(_DEBUG_) || defined(_DEBUG) cerr << "Launcher_cpp destructor" << endl; #endif + +#ifdef WITH_LIBBATCH std::map < string, Batch::BatchManager_eClient * >::const_iterator it1; for(it1=_batchmap.begin();it1!=_batchmap.end();it1++) delete it1->second; std::map < std::pair , Batch::Job* >::const_iterator it2; for(it2=_jobmap.begin();it2!=_jobmap.end();it2++) delete it2->second; +#endif } //============================================================================= @@ -79,6 +85,7 @@ Launcher_cpp::~Launcher_cpp() long Launcher_cpp::submitJob( const std::string xmlExecuteFile, const std::string clusterName) throw(LauncherException) { +#ifdef WITH_LIBBATCH #if defined(_DEBUG_) || defined(_DEBUG) cout << "BEGIN OF Launcher_cpp::submitJob" << endl; #endif @@ -174,6 +181,10 @@ long Launcher_cpp::submitJob( const std::string xmlExecuteFile, } return jobId; +#else + throw LauncherException("Method Launcher_cpp::submitJob is not available " + "(libBatch was not present at compilation time)"); +#endif } //============================================================================= @@ -191,6 +202,7 @@ long Launcher_cpp::submitSalomeJob( const string fileToExecute , const batchParams& batch_params, const machineParams& params) throw(LauncherException) { +#ifdef WITH_LIBBATCH #if defined(_DEBUG_) || defined(_DEBUG) cerr << "BEGIN OF Launcher_cpp::submitSalomeJob" << endl; #endif @@ -279,6 +291,10 @@ long Launcher_cpp::submitSalomeJob( const string fileToExecute , } return jobId; +#else + throw LauncherException("Method Launcher_cpp::submitSalomeJob is not available " + "(libBatch was not present at compilation time)"); +#endif } //============================================================================= @@ -291,6 +307,7 @@ long Launcher_cpp::submitSalomeJob( const string fileToExecute , string Launcher_cpp::queryJob( long id, const machineParams& params) throw(LauncherException) { +#ifdef WITH_LIBBATCH if(!_ResManager) throw LauncherException("You must set Resources Manager to Launcher!!"); @@ -318,6 +335,10 @@ string Launcher_cpp::queryJob( long id, } return par[STATE]; +#else + throw LauncherException("Method Launcher_cpp::queryJob is not available " + "(libBatch was not present at compilation time)"); +#endif } string Launcher_cpp::queryJob( long id, @@ -338,6 +359,7 @@ string Launcher_cpp::queryJob( long id, void Launcher_cpp::deleteJob( const long id, const machineParams& params) throw(LauncherException) { +#ifdef WITH_LIBBATCH if(!_ResManager) throw LauncherException("You must set Resources Manager to Launcher!!"); @@ -356,6 +378,10 @@ void Launcher_cpp::deleteJob( const long id, Batch::JobId jobId( _batchmap[clustername], oss.str() ); jobId.deleteJob(); +#else + throw LauncherException("Method Launcher_cpp::deleteJob is not available " + "(libBatch was not present at compilation time)"); +#endif } void Launcher_cpp::deleteJob( long id, @@ -377,6 +403,7 @@ void Launcher_cpp::getResultsJob( const string directory, const long id, const machineParams& params) throw(LauncherException) { +#ifdef WITH_LIBBATCH if(!_ResManager) throw LauncherException("You must set Resources Manager to Launcher!!"); @@ -392,6 +419,10 @@ void Launcher_cpp::getResultsJob( const string directory, Batch::Job* job = _jobmap[ pair(clustername,id) ]; _batchmap[clustername]->importOutputFiles( *job, directory ); +#else + throw LauncherException("Method Launcher_cpp::getResultsJob is not available " + "(libBatch was not present at compilation time)"); +#endif } void Launcher_cpp::getResultsJob( const std::string directory, @@ -411,7 +442,7 @@ void Launcher_cpp::getResultsJob( const std::string directory, Batch::BatchManager_eClient *Launcher_cpp::FactoryBatchManager( const ParserResourcesType& params ) throw(LauncherException) { - +#ifdef WITH_LIBBATCH std::string hostname, mpi; Batch::CommunicationProtocolType protocol; Batch::FactBatchManager_eClient* fact; @@ -483,10 +514,15 @@ Batch::BatchManager_eClient *Launcher_cpp::FactoryBatchManager( const ParserReso throw LauncherException("no batchmanager for that cluster"); } return (*fact)(hostname.c_str(), protocol, mpi.c_str()); +#else + throw LauncherException("Method Launcher_cpp::FactoryBatchManager is not available " + "(libBatch was not present at compilation time)"); +#endif } string Launcher_cpp::buildSalomeCouplingScript(const string fileToExecute, const string dirForTmpFiles, const ParserResourcesType& params) { +#ifdef WITH_LIBBATCH #ifndef WIN32 //TODO: need for porting on Windows int idx = dirForTmpFiles.find("Batch/"); std::string filelogtemp = dirForTmpFiles.substr(idx+6, dirForTmpFiles.length()); @@ -605,10 +641,15 @@ string Launcher_cpp::buildSalomeCouplingScript(const string fileToExecute, const return ""; #endif +#else + throw LauncherException("Method Launcher_cpp::buildSalomeCouplingScript is not available " + "(libBatch was not present at compilation time)"); +#endif } MpiImpl *Launcher_cpp::FactoryMpiImpl(MpiImplType mpi) throw(LauncherException) { +#ifdef WITH_LIBBATCH switch(mpi){ case lam: return new MpiImpl_LAM(); @@ -629,11 +670,15 @@ MpiImpl *Launcher_cpp::FactoryMpiImpl(MpiImplType mpi) throw(LauncherException) oss << mpi << " : not yet implemented"; throw LauncherException(oss.str().c_str()); } - +#else + throw LauncherException("Method Launcher_cpp::FactoryMpiImpl is not available " + "(libBatch was not present at compilation time)"); +#endif } string Launcher_cpp::getTmpDirForBatchFiles() { +#ifdef WITH_LIBBATCH string ret; string thedate; @@ -652,6 +697,10 @@ string Launcher_cpp::getTmpDirForBatchFiles() ret = string("Batch/"); ret += thedate; return ret; +#else + throw LauncherException("Method Launcher_cpp::getTmpDirForBatchFiles is not available " + "(libBatch was not present at compilation time)"); +#endif } string Launcher_cpp::getRemoteFile( std::string remoteDir, std::string localFile ) diff --git a/src/Launcher/Makefile.am b/src/Launcher/Makefile.am index 235bda841..fc49e1121 100644 --- a/src/Launcher/Makefile.am +++ b/src/Launcher/Makefile.am @@ -64,6 +64,10 @@ COMMON_CPPFLAGS=\ -I$(top_builddir)/idl \ @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ +if WITH_LIBBATCH + COMMON_CPPFLAGS += -DWITH_LIBBATCH +endif + # This local variable defines the list of dependant libraries common to all target in this package. COMMON_LIBS =\ ../Registry/libRegistry.la \ @@ -91,16 +95,10 @@ if WITHONLYLAUNCHER else lib_LTLIBRARIES = libLauncher.la libSalomeLauncher.la endif - libSalomeLauncher_la_SOURCES=\ + BatchTest.cxx \ SALOME_Launcher.cxx -if WITH_BATCH - libSalomeLauncher_la_SOURCES += BatchTest.cxx -else - libSalomeLauncher_la_SOURCES += DummyBatchTest.cxx -endif - libSalomeLauncher_la_CPPFLAGS =\ $(COMMON_CPPFLAGS) @@ -113,13 +111,8 @@ libSalomeLauncher_la_LIBADD =\ libLauncher_la_SOURCES=\ SALOME_Launcher_Parser.cxx \ - SALOME_Launcher_Handler.cxx - -if WITH_BATCH - libLauncher_la_SOURCES += Launcher.cxx -else - libLauncher_la_SOURCES += DummyLauncher.cxx -endif + SALOME_Launcher_Handler.cxx \ + Launcher.cxx libLauncher_la_CPPFLAGS =\ -I$(srcdir)/../ResourcesManager \ @@ -127,6 +120,10 @@ libLauncher_la_CPPFLAGS =\ @MPI_INCLUDES@ \ @LIBXML_INCLUDES@ +if WITH_LIBBATCH + libLauncher_la_CPPFLAGS += -DWITH_LIBBATCH +endif + libLauncher_la_LDFLAGS =\ -no-undefined -version-info=0:0:0 \ @LDEXPDYNFLAGS@