X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FLauncher%2FLauncher.cxx;h=b6737b1774036b9321836312d5db5c52eb080856;hb=4d57f98cebfdeb55bfcc1a73b698bfe7a36abb4e;hp=0d905d8d7a46d2717247b6d8db3686845e16466e;hpb=53dbc52658003957cb4483086acac6af3906088a;p=modules%2Fkernel.git diff --git a/src/Launcher/Launcher.cxx b/src/Launcher/Launcher.cxx index 0d905d8d7..b6737b177 100644 --- a/src/Launcher/Launcher.cxx +++ b/src/Launcher/Launcher.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 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 @@ -6,7 +6,7 @@ // 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. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -133,7 +133,7 @@ Launcher_cpp::launchJob(int job_id) throw LauncherException("Bad state of the job: " + job->getState()); } - // Third step search batch manager for the job into the map -> instanciate one if does not exist + // Third step search batch manager for the job into the map -> instantiate one if does not exist #ifdef WITH_LIBBATCH std::map::const_iterator it = _batchmap.find(job_id); if(it == _batchmap.end()) @@ -146,6 +146,7 @@ Launcher_cpp::launchJob(int job_id) Batch::JobId batch_manager_job_id = _batchmap[job_id]->submitJob(*(job->getBatchJob())); job->setBatchManagerJobId(batch_manager_job_id); job->setState("QUEUED"); + job->setReference(batch_manager_job_id.getReference()); } catch(const Batch::GenericException &ex) { @@ -248,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 @@ -285,6 +317,45 @@ Launcher_cpp::getJobDumpState(int job_id, std::string directory) return rtn; } +//============================================================================= +/*! + * Get one file from the working directory - the result directory can be changed + */ +//============================================================================= +bool +Launcher_cpp::getJobWorkFile(int job_id, + std::string work_file, + std::string directory) +{ + bool rtn; + LAUNCHER_MESSAGE("Get working file " << work_file); + + // 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; + std::string resource_name = job->getResourceDefinition().Name; + try + { + if (directory != "") + rtn = _batchmap[job_id]->importWorkFile(*(job->getBatchJob()), work_file, directory); + else + rtn = _batchmap[job_id]->importWorkFile(*(job->getBatchJob()), work_file, job->getResultDirectory()); + } + catch(const Batch::GenericException &ex) + { + LAUNCHER_INFOS("getJobWorkFile is maybe incomplete, exception: " << ex.message); + throw LauncherException(ex.message.c_str()); + } + LAUNCHER_MESSAGE("getJobWorkFile ended"); + return rtn; +} + //============================================================================= /*! * Remove the job - into the Launcher and its batch manager @@ -386,7 +457,7 @@ Launcher_cpp::createJobWithFile(const std::string xmlExecuteFile, //============================================================================= /*! - * Factory to instanciate the good batch manager for choosen cluster. + * Factory to instantiate the good batch manager for chosen cluster. */ //============================================================================= Batch::BatchManager * @@ -484,7 +555,7 @@ Launcher_cpp::FactoryBatchManager(ParserResourcesType& params) LAUNCHER_MESSAGE("Cannot find batch manager factory for " << bmType << ". Check your version of libBatch."); throw LauncherException("Cannot find batch manager factory"); } - LAUNCHER_MESSAGE("Instanciation of batch manager of type: " << bmType); + LAUNCHER_MESSAGE("Instantiation of batch manager of type: " << bmType); Batch::BatchManager * batch_client = (*fact)(hostname.c_str(), params.UserName.c_str(), protocol, mpi.c_str()); return batch_client; @@ -536,6 +607,14 @@ Launcher_cpp::getJobResults(int job_id, std::string directory) "(libBatch was not present at compilation time)"); } +void +Launcher_cpp::clearJobWorkingDir(int job_id) +{ + LAUNCHER_INFOS("Launcher compiled without LIBBATCH - cannot clear directory!!!"); + throw LauncherException("Method Launcher_cpp::clearJobWorkingDir is not available " + "(libBatch was not present at compilation time)"); +} + bool Launcher_cpp::getJobDumpState(int job_id, std::string directory) { @@ -544,6 +623,14 @@ Launcher_cpp::getJobDumpState(int job_id, std::string directory) "(libBatch was not present at compilation time)"); } +bool +Launcher_cpp::getJobWorkFile(int job_id, std::string work_file, std::string directory) +{ + LAUNCHER_INFOS("Launcher compiled without LIBBATCH - cannot get job dump state!!!"); + throw LauncherException("Method Launcher_cpp::getJobWorkFile is not available " + "(libBatch was not present at compilation time)"); +} + void Launcher_cpp::removeJob(int job_id) { @@ -617,7 +704,7 @@ Launcher_cpp::createBatchManagerForJob(Launcher::Job * job) { int job_id = job->getNumber(); - // Select a ressource for the job + // Select a resource for the job std::vector ResourceList; resourceParams params = job->getResourceRequiredParams(); // Consider only resources that can launch batch jobs @@ -740,7 +827,7 @@ Launcher_cpp::loadJobs(const char* jobs_file) { if (job_state == "CREATED") { - // In this case, we ignore run_part informations + // In this case, we ignore run_part information createJob(new_job); new_jobs_id_list.push_back(new_job->getNumber()); } @@ -766,7 +853,7 @@ Launcher_cpp::loadJobs(const char* jobs_file) job_state == "FAILED" || job_state == "ERROR") { - // Step 2: We add run_part informations + // Step 2: We add run_part information addJobDirectlyToMap(new_job); new_jobs_id_list.push_back(new_job->getNumber()); }