From: Ovidiu Mircescu Date: Wed, 25 Oct 2017 09:44:22 +0000 (+0200) Subject: Add a remove working directory feature to the Launcher. X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7b04f482a8c770542a7adb339e40fd8f7346881d;p=modules%2Fyacs.git Add a remove working directory feature to the Launcher. --- diff --git a/idl/SALOME_Launcher.idl b/idl/SALOME_Launcher.idl index fe3738a5d..bebe60d43 100644 --- a/idl/SALOME_Launcher.idl +++ b/idl/SALOME_Launcher.idl @@ -243,6 +243,12 @@ interface SalomeLauncher */ boolean getJobDumpState(in long job_id, in string directory) raises (SALOME::SALOME_Exception); + //! Remove the working directory on the remote file system. + /*! + \param job_id Job id returned by createJob(). + */ + void clearJobWorkingDir(in long job_id) raises (SALOME::SALOME_Exception); + //! Retrieve one sigle file from the working directory. /*! Use this method if you don't want to copy all the results of the job, for instance if you want to obtain a file which contains the computing diff --git a/src/Launcher/Launcher.cxx b/src/Launcher/Launcher.cxx index bd3f5d4b0..8814a5723 100644 --- a/src/Launcher/Launcher.cxx +++ b/src/Launcher/Launcher.cxx @@ -249,6 +249,37 @@ Launcher_cpp::getJobResults(int job_id, std::string directory) LAUNCHER_MESSAGE("getJobResult ended"); } +//============================================================================= +/*! + * Clear the remote working directory + */ +//============================================================================= +void +Launcher_cpp::clearJobWorkingDir(int job_id) +{ + LAUNCHER_MESSAGE("Clear the remote working directory"); + + // Check if job exist + std::map::const_iterator it_job = _launcher_job_map.find(job_id); + if (it_job == _launcher_job_map.end()) + { + LAUNCHER_INFOS("Cannot find the job, is it created ? job number: " << job_id); + throw LauncherException("Cannot find the job, is it created ?"); + } + + Launcher::Job * job = it_job->second; + try + { + _batchmap[job_id]->clearWorkingDir(*(job->getBatchJob())); + } + catch(const Batch::GenericException &ex) + { + LAUNCHER_INFOS("getJobResult is maybe incomplete, exception: " << ex.message); + throw LauncherException(ex.message.c_str()); + } + LAUNCHER_MESSAGE("getJobResult ended"); +} + //============================================================================= /*! * Get Job dump state - the result directory could be changed diff --git a/src/Launcher/Launcher.hxx b/src/Launcher/Launcher.hxx index b7c662137..728694edd 100644 --- a/src/Launcher/Launcher.hxx +++ b/src/Launcher/Launcher.hxx @@ -68,6 +68,7 @@ public: const char * getJobState(int job_id); const char * getAssignedHostnames(int job_id); // Get names or ids of hosts assigned to the job void getJobResults(int job_id, std::string directory); + void clearJobWorkingDir(int job_id); bool getJobDumpState(int job_id, std::string directory); bool getJobWorkFile(int job_id, std::string work_file, std::string directory); void stopJob(int job_id); diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index d37cb04e5..33a961d04 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -286,6 +286,20 @@ SALOME_Launcher::getJobResults(CORBA::Long job_id, const char * directory) } } +void +SALOME_Launcher::clearJobWorkingDir(CORBA::Long job_id) +{ + try + { + _l.clearJobWorkingDir(job_id); + } + catch(const LauncherException &ex) + { + INFOS(ex.msg.c_str()); + THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM); + } +} + CORBA::Boolean SALOME_Launcher::getJobDumpState(CORBA::Long job_id, const char * directory) { diff --git a/src/Launcher/SALOME_Launcher.hxx b/src/Launcher/SALOME_Launcher.hxx index cf4f5795d..a04a5d48e 100644 --- a/src/Launcher/SALOME_Launcher.hxx +++ b/src/Launcher/SALOME_Launcher.hxx @@ -51,6 +51,7 @@ public: char * getJobState (CORBA::Long job_id); char * getAssignedHostnames (CORBA::Long job_id); // Get names or ids of hosts assigned to the job void getJobResults(CORBA::Long job_id, const char * directory); + void clearJobWorkingDir(CORBA::Long job_id); CORBA::Boolean getJobDumpState(CORBA::Long job_id, const char * directory); CORBA::Boolean getJobWorkFile(CORBA::Long job_id, const char * work_file, const char * directory); void stopJob (CORBA::Long job_id);