From 7191d89a2e6a64c0b909f856cb9111c59700f6ab Mon Sep 17 00:00:00 2001 From: secher Date: Tue, 3 Jun 2008 13:25:52 +0000 Subject: [PATCH] improvement of API launcher --- idl/SALOME_ContainerManager.idl | 6 ++-- src/Launcher/Launcher.cxx | 54 +++++++++++++++++++++++++++----- src/Launcher/Launcher.hxx | 9 ++++-- src/Launcher/SALOME_Launcher.cxx | 20 ++++++------ src/Launcher/SALOME_Launcher.hxx | 6 ++-- 5 files changed, 69 insertions(+), 26 deletions(-) diff --git a/idl/SALOME_ContainerManager.idl b/idl/SALOME_ContainerManager.idl index 7faca1ae6..9acf9a708 100644 --- a/idl/SALOME_ContainerManager.idl +++ b/idl/SALOME_ContainerManager.idl @@ -96,9 +96,9 @@ struct BatchParameters in FilesList filesToImport, in BatchParameters batch_params, in MachineParameters params ) raises (SALOME::SALOME_Exception); - string querySalomeJob( in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception); - void deleteSalomeJob( in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception); - void getResultSalomeJob( in string directory, in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception); + string queryJob( in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception); + void deleteJob( in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception); + void getResultsJob( in string directory, in long jobId, in MachineParameters params ) raises (SALOME::SALOME_Exception); void Shutdown(); diff --git a/src/Launcher/Launcher.cxx b/src/Launcher/Launcher.cxx index 302541e32..9fd6ed016 100644 --- a/src/Launcher/Launcher.cxx +++ b/src/Launcher/Launcher.cxx @@ -73,6 +73,9 @@ long Launcher_cpp::submitJob( const std::string xmlExecuteFile, long jobId; vector aMachineList; + if(!_ResManager) + throw LauncherException("You must set Resources Manager to Launcher!!"); + // verify if cluster is in resources catalog machineParams params; params.hostname = clusterName; @@ -178,6 +181,9 @@ long Launcher_cpp::submitSalomeJob( const string fileToExecute , long jobId; vector aMachineList; + if(!_ResManager) + throw LauncherException("You must set Resources Manager to Launcher!!"); + // check batch params if ( !check(batch_params) ) throw LauncherException("Batch parameters are bad (see informations above)"); @@ -254,9 +260,12 @@ long Launcher_cpp::submitSalomeJob( const string fileToExecute , * \param params : Constraints for the choice of the batch cluster */ //============================================================================= -string Launcher_cpp::querySalomeJob( long id, - const machineParams& params) throw(LauncherException) +string Launcher_cpp::queryJob( long id, + const machineParams& params) throw(LauncherException) { + if(!_ResManager) + throw LauncherException("You must set Resources Manager to Launcher!!"); + // find a cluster matching params structure vector aCompoList ; vector aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ; @@ -277,6 +286,14 @@ string Launcher_cpp::querySalomeJob( long id, return par[STATE]; } +string Launcher_cpp::queryJob( long id, + const std::string clusterName) +{ + machineParams params; + params.hostname = clusterName; + return queryJob(id,params); +} + //============================================================================= /*! CORBA Method: * Delete a batch job on a cluster @@ -284,9 +301,12 @@ string Launcher_cpp::querySalomeJob( long id, * \param params : Constraints for the choice of the batch cluster */ //============================================================================= -void Launcher_cpp::deleteSalomeJob( const long id, - const machineParams& params) throw(LauncherException) +void Launcher_cpp::deleteJob( const long id, + const machineParams& params) throw(LauncherException) { + if(!_ResManager) + throw LauncherException("You must set Resources Manager to Launcher!!"); + // find a cluster matching params structure vector aCompoList ; vector aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ; @@ -305,6 +325,14 @@ void Launcher_cpp::deleteSalomeJob( const long id, jobId.deleteJob(); } +void Launcher_cpp::deleteJob( long id, + const std::string clusterName) +{ + machineParams params; + params.hostname = clusterName; + deleteJob(id,params); +} + //============================================================================= /*! CORBA Method: * Get result files of job on a cluster @@ -312,10 +340,13 @@ void Launcher_cpp::deleteSalomeJob( const long id, * \param params : Constraints for the choice of the batch cluster */ //============================================================================= -void Launcher_cpp::getResultSalomeJob( const string directory, - const long id, - const machineParams& params) throw(LauncherException) +void Launcher_cpp::getResultsJob( const string directory, + const long id, + const machineParams& params) throw(LauncherException) { + if(!_ResManager) + throw LauncherException("You must set Resources Manager to Launcher!!"); + vector aCompoList ; vector aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ; ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]); @@ -331,6 +362,15 @@ void Launcher_cpp::getResultSalomeJob( const string directory, _batchmap[clustername]->importOutputFiles( *job, directory ); } +void Launcher_cpp::getResultsJob( const std::string directory, + long id, + const std::string clusterName) +{ + machineParams params; + params.hostname = clusterName; + getResultsJob(directory,id,params); +} + //============================================================================= /*! * Factory to instanciate the good batch manager for choosen cluster. diff --git a/src/Launcher/Launcher.hxx b/src/Launcher/Launcher.hxx index 66f954e5f..2cbb1336b 100644 --- a/src/Launcher/Launcher.hxx +++ b/src/Launcher/Launcher.hxx @@ -57,9 +57,12 @@ public: const batchParams& batch_params, const machineParams& params) throw(LauncherException); - std::string querySalomeJob( const long jobId, const machineParams& params) throw(LauncherException); - void deleteSalomeJob( const long jobId, const machineParams& params) throw(LauncherException); - void getResultSalomeJob( const std::string directory, const long jobId, const machineParams& params ) throw(LauncherException); + std::string queryJob( const long jobId, const machineParams& params) throw(LauncherException); + std::string queryJob( const long jobId, const std::string clusterName); + void deleteJob( const long jobId, const machineParams& params) throw(LauncherException); + void deleteJob( const long jobId, const std::string clusterName); + void getResultsJob( const std::string directory, const long jobId, const machineParams& params ) throw(LauncherException); + void getResultsJob( const std::string directory, const long jobId, const std::string clusterName ); void SetResourcesManager( ResourcesManager_cpp* rm ) { _ResManager = rm; } diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index 5178c9ac4..67f770e95 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -179,8 +179,8 @@ CORBA::Long SALOME_Launcher::submitSalomeJob( const char * fileToExecute , * \param params : Constraints for the choice of the batch cluster */ //============================================================================= -char* SALOME_Launcher::querySalomeJob( const CORBA::Long jobId, - const Engines::MachineParameters& params) +char* SALOME_Launcher::queryJob( const CORBA::Long jobId, + const Engines::MachineParameters& params) { string status; machineParams p; @@ -192,7 +192,7 @@ char* SALOME_Launcher::querySalomeJob( const CORBA::Long jobId, p.mem_mb = params.mem_mb; try{ - status = _l.querySalomeJob(jobId,p); + status = _l.queryJob(jobId,p); } catch(const LauncherException &ex){ INFOS("Caught exception."); @@ -208,8 +208,8 @@ char* SALOME_Launcher::querySalomeJob( const CORBA::Long jobId, * \param params : Constraints for the choice of the batch cluster */ //============================================================================= -void SALOME_Launcher::deleteSalomeJob( const CORBA::Long jobId, - const Engines::MachineParameters& params) +void SALOME_Launcher::deleteJob( const CORBA::Long jobId, + const Engines::MachineParameters& params) { machineParams p; p.hostname = params.hostname; @@ -220,7 +220,7 @@ void SALOME_Launcher::deleteSalomeJob( const CORBA::Long jobId, p.mem_mb = params.mem_mb; try{ - _l.deleteSalomeJob(jobId,p); + _l.deleteJob(jobId,p); } catch(const LauncherException &ex){ INFOS("Caught exception."); @@ -235,9 +235,9 @@ void SALOME_Launcher::deleteSalomeJob( const CORBA::Long jobId, * \param params : Constraints for the choice of the batch cluster */ //============================================================================= -void SALOME_Launcher::getResultSalomeJob( const char *directory, - const CORBA::Long jobId, - const Engines::MachineParameters& params) +void SALOME_Launcher::getResultsJob( const char *directory, + const CORBA::Long jobId, + const Engines::MachineParameters& params) { machineParams p; p.hostname = params.hostname; @@ -248,7 +248,7 @@ void SALOME_Launcher::getResultSalomeJob( const char *directory, p.mem_mb = params.mem_mb; try{ - _l.getResultSalomeJob( directory, jobId, p ); + _l.getResultsJob( directory, jobId, p ); } catch(const LauncherException &ex){ INFOS("Caught exception."); diff --git a/src/Launcher/SALOME_Launcher.hxx b/src/Launcher/SALOME_Launcher.hxx index 7f17b3a6f..33755495a 100644 --- a/src/Launcher/SALOME_Launcher.hxx +++ b/src/Launcher/SALOME_Launcher.hxx @@ -61,9 +61,9 @@ public: const Engines::BatchParameters& batch_params, const Engines::MachineParameters& params); - char* querySalomeJob( const CORBA::Long jobId, const Engines::MachineParameters& params); - void deleteSalomeJob( const CORBA::Long jobId, const Engines::MachineParameters& params); - void getResultSalomeJob( const char * directory, const CORBA::Long jobId, const Engines::MachineParameters& params ); + char* queryJob( const CORBA::Long jobId, const Engines::MachineParameters& params); + void deleteJob( const CORBA::Long jobId, const Engines::MachineParameters& params); + void getResultsJob( const char * directory, const CORBA::Long jobId, const Engines::MachineParameters& params ); void Shutdown(); -- 2.39.2