-// 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
// 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
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<int, Batch::BatchManager *>::const_iterator it = _batchmap.find(job_id);
if(it == _batchmap.end())
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)
{
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<int, Launcher::Job *>::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
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<int, Launcher::Job *>::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
//=============================================================================
/*!
- * Factory to instanciate the good batch manager for choosen cluster.
+ * Factory to instantiate the good batch manager for chosen cluster.
*/
//=============================================================================
Batch::BatchManager *
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;
"(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)
{
"(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)
{
{
int job_id = job->getNumber();
- // Select a ressource for the job
+ // Select a resource for the job
std::vector<std::string> ResourceList;
resourceParams params = job->getResourceRequiredParams();
// Consider only resources that can launch batch jobs
{
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());
}
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());
}