Salome HOME
in session_attached mode synchronize local NS with content of salome.[cm,rm,esm,dsm]
[modules/kernel.git] / src / Launcher / Launcher.cxx
index 0ef3ebc381ac0ee0dc8c3b501785799f701ae29c..f673496f8de112525501b4829d4d390dc360027a 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2020  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021  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
@@ -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
@@ -515,9 +542,9 @@ Launcher_cpp::createJobWithFile(const std::string xmlExecuteFile,
   new_job->setWorkDirectory(job_params.MachinesList[clusterName].WorkDirectory);
   new_job->setEnvFile(job_params.MachinesList[clusterName].EnvFile);
 
-  for(int i=0; i < job_params.InputFile.size(); i++)
+  for(size_t i=0; i < job_params.InputFile.size(); i++)
     new_job->add_in_file(job_params.InputFile[i]);
-  for(int i=0; i < job_params.OutputFile.size();i++)
+  for(size_t i=0; i < job_params.OutputFile.size();i++)
     new_job->add_out_file(job_params.OutputFile[i]);
 
   resourceParams p;
@@ -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)
 {