-// Copyright (C) 2009-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2009-2013 CEA/DEN, EDF R&D, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include "Launcher.hxx"
#ifdef WITH_LIBBATCH
-#include <Batch/Batch_Constants.hxx>
+#include <libbatch/Constants.hxx>
#endif
Launcher::Job::Job()
_queue = "";
_job_type = "";
+ // Parameters for COORM
+ _launcher_file = "";
+ _launcher_args = "";
+
#ifdef WITH_LIBBATCH
_batch_job = new Batch::Job();
#endif
{
_batch_job_id.deleteJob();
}
- catch (const Batch::EmulationException &ex)
+ catch (const Batch::GenericException &ex)
{
LAUNCHER_INFOS("WARNING: exception when stopping the job: " << ex.message);
}
{
_batch_job_id.deleteJob();
}
- catch (const Batch::EmulationException &ex)
+ catch (const Batch::GenericException &ex)
{
LAUNCHER_INFOS("WARNING: exception when removing the job: " << ex.message);
}
return _state;
}
+// Get names or ids of hosts assigned to the job
+std::string
+Launcher::Job::getAssignedHostnames()
+{
+ return _assigned_hostnames;
+}
+
void
Launcher::Job::setNumber(const int & number)
{
_maximum_duration = maximum_duration;
}
+// For COORM
+void
+Launcher::Job::setLauncherFile(const std::string & launcher_file)
+{
+ _launcher_file = launcher_file;
+}
+void
+Launcher::Job::setLauncherArgs(const std::string & launcher_args)
+{
+ _launcher_args = launcher_args;
+}
+
void
Launcher::Job::setResourceRequiredParams(const resourceParams & resource_required_params)
{
return _maximum_duration;
}
+// For COORM
+std::string
+Launcher::Job::getLauncherFile()
+{
+ return _launcher_file;
+}
+std::string
+Launcher::Job::getLauncherArgs()
+{
+ return _launcher_args;
+}
+
resourceParams
Launcher::Job::getResourceRequiredParams()
{
Batch::JobInfo job_info = _batch_job_id.queryJob();
Batch::Parametre par = job_info.getParametre();
_state = par[Batch::STATE].str();
+ _assigned_hostnames = (par.find(Batch::ASSIGNEDHOSTNAMES) == par.end())?
+ "" : par[Batch::ASSIGNEDHOSTNAMES].str();
LAUNCHER_MESSAGE("State received is: " << par[Batch::STATE].str());
}
#endif
Batch::Parametre params;
params[Batch::NAME] = getJobName();
- params[Batch::USER] = _resource_definition.UserName;
params[Batch::NBPROC] = _resource_required_params.nb_proc;
+ params[Batch::NBPROCPERNODE] = _resource_required_params.nb_proc_per_node;
// Memory in megabytes
if (_resource_required_params.mem_mb > 0)
// We define a default directory based on user time
if (_work_directory == "")
{
- std::string thedate;
- Batch::Date date = Batch::Date(time(0));
- thedate = date.str();
- int lend = thedate.size() ;
- int i = 0 ;
- while ( i < lend ) {
- if ( thedate[i] == '/' || thedate[i] == '-' || thedate[i] == ':' ) {
- thedate[i] = '_' ;
- }
- i++ ;
- }
- _work_directory = std::string("$HOME/Batch/");
- _work_directory += thedate;
+ const size_t BUFSIZE = 32;
+ char date[BUFSIZE];
+ time_t curtime = time(NULL);
+ strftime(date, BUFSIZE, "%Y_%m_%d__%H_%M_%S", localtime(&curtime));
+ _work_directory = std::string("$HOME/Batch/workdir_");
+ _work_directory += date;
}
params[Batch::WORKDIR] = _work_directory;
- params[Batch::TMPDIR] = _work_directory; // To Compatibility -- remove ??? TODO
+
+ // Parameters for COORM
+ params[Batch::LAUNCHER_FILE] = _launcher_file;
+ params[Batch::LAUNCHER_ARGS] = _launcher_args;
// If result_directory is not defined, we use HOME environnement
if (_result_directory == "")
xmlNewChild(node, NULL, xmlCharStrdup("local_directory"), xmlCharStrdup(getLocalDirectory().c_str()));
xmlNewChild(node, NULL, xmlCharStrdup("result_directory"), xmlCharStrdup(getResultDirectory().c_str()));
+ // Parameters for COORM
+ xmlNewChild(node, NULL, xmlCharStrdup("launcher_file"), xmlCharStrdup(getLauncherFile().c_str()));
+
// Files
xmlNodePtr files_node = xmlNewChild(node, NULL, xmlCharStrdup("files"), NULL);
std::list<std::string> in_files = get_in_files();
xmlNewChild(node, NULL, xmlCharStrdup("maximum_duration"), xmlCharStrdup(getMaximumDuration().c_str()));
xmlNewChild(node, NULL, xmlCharStrdup("queue"), xmlCharStrdup(getQueue().c_str()));
+ // For COORM
+ xmlNewChild(node, NULL, xmlCharStrdup("launcher_args"), xmlCharStrdup(getLauncherArgs().c_str()));
+
// Specific parameters part
xmlNodePtr specific_parameters_node = xmlNewChild(node, NULL, xmlCharStrdup("specific_parameters"), NULL);
std::map<std::string, std::string> specific_parameters = getSpecificParameters();