From 0495a4d133b055224e8a66522f49af037e89f2de Mon Sep 17 00:00:00 2001 From: Ovidiu Mircescu Date: Wed, 27 Nov 2019 10:14:19 +0100 Subject: [PATCH] Add exportInputFiles to SALOME_Launcher --- idl/SALOME_Launcher.idl | 3 +++ src/Launcher/Launcher.cxx | 35 ++++++++++++++++++++++++++++++++ src/Launcher/Launcher.hxx | 1 + src/Launcher/SALOME_Launcher.cxx | 14 +++++++++++++ src/Launcher/SALOME_Launcher.hxx | 1 + src/Launcher_SWIG/Launcher.i | 1 + 6 files changed, 55 insertions(+) diff --git a/idl/SALOME_Launcher.idl b/idl/SALOME_Launcher.idl index 9fdefb727..c312771cd 100644 --- a/idl/SALOME_Launcher.idl +++ b/idl/SALOME_Launcher.idl @@ -227,6 +227,9 @@ interface SalomeLauncher //! Get names or ids of hosts assigned to the job string getAssignedHostnames (in long job_id) raises (SALOME::SALOME_Exception); + //! Copy all the in_files of the job to the work_directory. + void exportInputFiles(in long job_id) raises (SALOME::SALOME_Exception); + //! Copy the result files from the work directory of the job //! to a local directory. /*! The list of result files is given by the JobParameters::out_files parameter. diff --git a/src/Launcher/Launcher.cxx b/src/Launcher/Launcher.cxx index 7a178d139..5e25fbb2c 100644 --- a/src/Launcher/Launcher.cxx +++ b/src/Launcher/Launcher.cxx @@ -255,6 +255,33 @@ Launcher_cpp::getAssignedHostnames(int job_id) return assigned_hostnames; } +void +Launcher_cpp::exportInputFiles(int job_id) +{ + LAUNCHER_MESSAGE("Copy in files"); + // Check if job exists + Launcher::Job * job = findJob(job_id); + + // Check job state (cannot launch a job already launched...) + if (job->getState() != "CREATED") + { + LAUNCHER_INFOS("Bad state of the job: " << job->getState()); + throw LauncherException("Bad state of the job: " + job->getState()); + } + + Batch::BatchManager * bm = getBatchManager(job); + + try { + bm->exportInputFiles(*(job->getBatchJob())); + } + catch(const Batch::GenericException &ex) + { + LAUNCHER_INFOS("Failed to copy in files: " << ex.message); + throw LauncherException(ex.message.c_str()); + } + LAUNCHER_MESSAGE("Files copied"); +} + //============================================================================= /*! * Get Job result - the result directory could be changed @@ -689,6 +716,14 @@ Launcher_cpp::getAssignedHostnames(int job_id) "(libBatch was not present at compilation time)"); } +void +Launcher_cpp::exportInputFiles(int job_id) +{ + LAUNCHER_INFOS("Launcher compiled without LIBBATCH - cannot copy the files!!!"); + throw LauncherException("Method Launcher_cpp::exportInputFiles is not available " + "(libBatch was not present at compilation time)"); +} + void Launcher_cpp::getJobResults(int job_id, std::string directory) { diff --git a/src/Launcher/Launcher.hxx b/src/Launcher/Launcher.hxx index 66bd84008..ea45e689d 100644 --- a/src/Launcher/Launcher.hxx +++ b/src/Launcher/Launcher.hxx @@ -80,6 +80,7 @@ public: void launchJob(int job_id); std::string getJobState(int job_id); std::string getAssignedHostnames(int job_id); // Get names or ids of hosts assigned to the job + void exportInputFiles(int job_id); void getJobResults(int job_id, std::string directory); void clearJobWorkingDir(int job_id); bool getJobDumpState(int job_id, std::string directory); diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index 41d0b850c..c436cd0e2 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -158,6 +158,20 @@ SALOME_Launcher::getAssignedHostnames(CORBA::Long job_id) return CORBA::string_dup(result.c_str()); } +void +SALOME_Launcher::exportInputFiles(CORBA::Long job_id) +{ + try + { + _l.exportInputFiles(job_id); + } + catch(const LauncherException &ex) + { + INFOS(ex.msg.c_str()); + THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::BAD_PARAM); + } +} + void SALOME_Launcher::getJobResults(CORBA::Long job_id, const char * directory) { diff --git a/src/Launcher/SALOME_Launcher.hxx b/src/Launcher/SALOME_Launcher.hxx index 49b0fdeac..de79bc053 100644 --- a/src/Launcher/SALOME_Launcher.hxx +++ b/src/Launcher/SALOME_Launcher.hxx @@ -50,6 +50,7 @@ public: void launchJob (CORBA::Long job_id); char * getJobState (CORBA::Long job_id); char * getAssignedHostnames (CORBA::Long job_id); // Get names or ids of hosts assigned to the job + void exportInputFiles(CORBA::Long job_id); 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); diff --git a/src/Launcher_SWIG/Launcher.i b/src/Launcher_SWIG/Launcher.i index 1e1b89ae0..1d8d8f70e 100644 --- a/src/Launcher_SWIG/Launcher.i +++ b/src/Launcher_SWIG/Launcher.i @@ -214,6 +214,7 @@ public: void launchJob(int job_id); std::string getJobState(int job_id); std::string getAssignedHostnames(int job_id); // Get names or ids of hosts assigned to the job + void exportInputFiles(int job_id); void getJobResults(int job_id, std::string directory); void clearJobWorkingDir(int job_id); bool getJobDumpState(int job_id, std::string directory); -- 2.39.2