-// Copyright (C) 2007-2019 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
using namespace std;
//=============================================================================
-/*!
+/*!
* Constructor
* \param orb
* Define a CORBA single thread policy for the server, which avoid to deal
}
//=============================================================================
-/*!
+/*!
* destructor
*/
//=============================================================================
//=============================================================================
/*!
- * Add a job into the launcher - check resource and choose one
- */
+ * Add a job into the launcher - check resource and choose one
+ */
//=============================================================================
-void
+void
Launcher_cpp::createJob(Launcher::Job * new_job)
{
LAUNCHER_MESSAGE("Creating a new job");
//=============================================================================
/*!
- * Launch a job
- */
+ * Launch a job
+ */
//=============================================================================
-void
+void
Launcher_cpp::launchJob(int job_id)
{
LAUNCHER_MESSAGE("Launch a job");
//=============================================================================
/*!
* Get job state
- */
+ */
//=============================================================================
std::string
Launcher_cpp::getJobState(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
- */
+ */
//=============================================================================
void
Launcher_cpp::getJobResults(int job_id, std::string directory)
Launcher::Job * job = findJob(job_id);
std::string resource_name = job->getResourceDefinition().Name;
- try
+ try
{
if (directory != "")
_batchmap[job_id]->importOutputFiles(*(job->getBatchJob()), directory);
//=============================================================================
/*!
* Get Job dump state - the result directory could be changed
- */
+ */
//=============================================================================
bool
Launcher_cpp::getJobDumpState(int job_id, std::string directory)
Launcher::Job * job = findJob(job_id);
std::string resource_name = job->getResourceDefinition().Name;
- try
+ try
{
if (directory != "")
rtn = _batchmap[job_id]->importDumpStateFile(*(job->getBatchJob()), directory);
//=============================================================================
/*!
* Remove the job - into the Launcher and its batch manager
- */
+ */
//=============================================================================
void
Launcher_cpp::removeJob(int job_id)
//=============================================================================
/*!
* stop the job
- */
+ */
//=============================================================================
void
Launcher_cpp::stopJob(int job_id)
}
//=============================================================================
-/*!
+/*!
* create a launcher job based on a file
* \param xmlExecuteFile : to define the execution on the batch cluster
*/
//=============================================================================
-long
-Launcher_cpp::createJobWithFile(const std::string xmlExecuteFile,
+long
+Launcher_cpp::createJobWithFile(const std::string xmlExecuteFile,
const std::string clusterName)
{
LAUNCHER_MESSAGE("Begin of Launcher_cpp::createJobWithFile");
// Creating a new job
std::unique_ptr<Launcher::Job_Command> new_job(new Launcher::Job_Command);
- std::string cmdFile = Kernel_Utils::GetTmpFileName();
+ std::string cmdFile = Kernel_Utils::GetTmpFileName();
#ifndef WIN32
cmdFile += ".sh";
#else
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;
//=============================================================================
/*!
* Factory to instantiate the good batch manager for chosen cluster.
- */
+ */
//=============================================================================
Batch::BatchManager *
Launcher_cpp::FactoryBatchManager(ParserResourcesType& params)
//----------------------------------------------------------
#else
-void
+void
Launcher_cpp::createJob(Launcher::Job * new_job)
{
LAUNCHER_INFOS("Launcher compiled without LIBBATCH - cannot create a job !!!");
"(libBatch was not present at compilation time)");
}
-void
+void
Launcher_cpp::launchJob(int job_id)
{
LAUNCHER_INFOS("Launcher compiled without LIBBATCH - cannot launch a job !!!");
"(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)
{
return 0;
}
-long
+long
Launcher_cpp::createJobWithFile( const std::string xmlExecuteFile, std::string clusterName)
{
throw LauncherException("Method Launcher_cpp::createJobWithFile is not available "
return 0;
}
+JobParameters_cpp
+Launcher_cpp::getJobParameters(int job_id)
+{
+ throw LauncherException("Method Launcher_cpp::getJobParamaters is not available "
+ "(libBatch was not present at compilation time)");
+}
+
#endif
-ParserLauncherType
+ParserLauncherType
Launcher_cpp::ParseXmlFile(std::string xmlExecuteFile)
{
ParserLauncherType job_params;
}
#endif
-void
+void
Launcher_cpp::addJobDirectlyToMap(Launcher::Job * new_job)
{
// Step 0: Calculated job_id