_name = "";
_yacs_file = "";
_command = "";
+ _env_file = "";
_batch_params.batch_directory = "";
- _batch_params.expected_during_time = "";
+ _batch_params.maximum_during_time = "";
_batch_params.expected_memory = "";
_batch_params.nb_proc = 0;
_files_params.result_directory = "";
_name = name;
_yacs_file = "";
_command = "";
+ _env_file = "";
_batch_params.batch_directory = "";
- _batch_params.expected_during_time = "";
+ _batch_params.maximum_during_time = "";
_batch_params.expected_memory = "";
_batch_params.nb_proc = 0;
_files_params.result_directory = "";
return _command;
}
+void
+BL::Job::setEnvFile(std::string & env_file)
+{
+ _env_file = env_file;
+}
+
+std::string &
+BL::Job::getEnvFile()
+{
+ return _env_file;
+}
+
void
BL::Job::setBatchParameters(BL::Job::BatchParam & param)
{
_batch_params.batch_directory = param.batch_directory;
- _batch_params.expected_during_time = param.expected_during_time;
+ _batch_params.maximum_during_time = param.maximum_during_time;
_batch_params.expected_memory = param.expected_memory;
_batch_params.nb_proc = param.nb_proc;
}
void setCommand(std::string & command);
std::string & getCommand();
+ void setEnvFile(std::string & env_file);
+ std::string & getEnvFile();
struct BatchParam
{
std::string batch_directory;
- std::string expected_during_time;
+ std::string maximum_during_time;
std::string expected_memory;
int nb_proc;
};
BL::Job::JobType _type;
std::string _yacs_file;
std::string _command;
+ std::string _env_file;
BL::Job::BatchParam _batch_params;
BL::Job::FilesParam _files_params;
}
BL::Job *
-BL::JobsManager::addNewJob(const std::string & name)
+BL::JobsManager::createJob(const std::string & name)
{
- DEBTRACE("addNewJob BL::JobsManager");
+ DEBTRACE("createJob BL::JobsManager");
BL::Job * new_job = NULL;
_jobs[name] = new_job;
}
else
- DEBTRACE("addNewJob Error !!!! Job already exist: " << name);
+ DEBTRACE("createJob Error !!!! Job already exist: " << name);
return new_job;
}
+void
+BL::JobsManager::addJobToLauncher(const std::string & name)
+{
+ DEBTRACE("addJobToLauncher BL::JobsManager");
+
+ _jobs_it = _jobs.find(name);
+ if (_jobs_it == _jobs.end())
+ {
+ // TODO: SHOULD SEND an exeception...
+ DEBMSG("[addJobToLauncher] failed, job was not found");
+ }
+
+ std::string result = "";
+ result = _salome_services->create_job(_jobs_it->second);
+ if (_observer)
+ if (result != "")
+ {
+ _observer->sendEvent("create_job", "Error", name, result);
+ _jobs_it->second->setState(BL::Job::ERROR);
+ }
+ else
+ _observer->sendEvent("create_job", "Ok", name, "");
+}
+
void
BL::JobsManager::removeJob(const std::string & name)
{
return false;
else
return true;
-
}
void
void setObserver(BL::Observer * observer);
- BL::Job * addNewJob(const std::string & name);
+ BL::Job * createJob(const std::string & name);
+ void addJobToLauncher(const std::string & name);
void removeJob(const std::string & name);
BL::Job * getJob(const std::string & name);
}
std::string
-BL::SALOMEServices::start_job(BL::Job * job)
-{
- return start_yacs_job(job);
-}
-
-std::string
-BL::SALOMEServices::start_yacs_job(BL::Job * job)
+BL::SALOMEServices::create_job(BL::Job * job)
{
+ DEBTRACE("Begin of create_job");
std::string ret = "";
- // Prepare Arguments
- const char * fileToExecute = job->getYACSFile().c_str();
+ Engines::JobParameters_var job_parameters = new Engines::JobParameters;
+
+ // Job type
+ if (job->getType() == BL::Job::COMMAND)
+ {
+ job_parameters->job_type = CORBA::string_dup("command");
+ job_parameters->command = CORBA::string_dup(job->getCommand().c_str());
+ job_parameters->env_file = CORBA::string_dup(job->getEnvFile().c_str());
+ }
+ else if (job->getType() == BL::Job::YACS_SCHEMA)
+ {
+ job_parameters->job_type = CORBA::string_dup("yacs_file");
+ job_parameters->yacs_file = CORBA::string_dup(job->getYACSFile().c_str());
+ }
+ // Files
BL::Job::FilesParam files = job->getFilesParameters();
- Engines::FilesList_var filesToExport = new Engines::FilesList;
- filesToExport->length(files.input_files_list.size());
std::list<std::string>::iterator it;
- int i = 0;
- for (it=files.input_files_list.begin() ; it != files.input_files_list.end(); it++)
+ int i,j = 0;
+
+ job_parameters->in_files.length(files.input_files_list.size());
+ for (it = files.input_files_list.begin() ; it != files.input_files_list.end(); it++)
{
- filesToExport[i] = CORBA::string_dup((*it).c_str());
+ job_parameters->in_files[i] = CORBA::string_dup((*it).c_str());
i++;
}
- Engines::FilesList_var filesToImport = new Engines::FilesList;
- filesToImport->length(files.output_files_list.size());
- i = 0;
- for (it=files.output_files_list.begin() ; it != files.output_files_list.end(); it++)
+
+ job_parameters->out_files.length(files.output_files_list.size());
+ for (it = files.output_files_list.begin() ; it != files.output_files_list.end(); it++)
{
- filesToImport[i] = CORBA::string_dup((*it).c_str());
- i++;
+ job_parameters->out_files[j] = CORBA::string_dup((*it).c_str());
+ j++;
}
+ job_parameters->local_directory = CORBA::string_dup("");
+ job_parameters->result_directory = CORBA::string_dup(files.result_directory.c_str());
BL::Job::BatchParam cpp_batch_params = job->getBatchParameters();
- Engines::BatchParameters_var batch_params = new Engines::BatchParameters;
- batch_params->batch_directory = CORBA::string_dup(cpp_batch_params.batch_directory.c_str());
- batch_params->expected_during_time = CORBA::string_dup(cpp_batch_params.expected_during_time.c_str());
- batch_params->mem = CORBA::string_dup(cpp_batch_params.expected_memory.c_str());
- batch_params->nb_proc = cpp_batch_params.nb_proc;
-
- Engines::MachineParameters_var machine = new Engines::MachineParameters;
- machine->hostname = CORBA::string_dup(job->getMachine().c_str());
-
- // Start Job !
+ job_parameters->work_directory = CORBA::string_dup(cpp_batch_params.batch_directory.c_str());
+
+ // Resource
+ job_parameters->maximum_during_time = CORBA::string_dup(cpp_batch_params.maximum_during_time.c_str());
+ job_parameters->resource_required.hostname = CORBA::string_dup(job->getMachine().c_str());
+ job_parameters->resource_required.nb_node = cpp_batch_params.nb_proc;
+
+ // Memory
+ CORBA::Long memory;
+ std::string ram = cpp_batch_params.expected_memory.substr(0,cpp_batch_params.expected_memory.size()-2);
+ std::istringstream iss(ram);
+ iss >> memory;
+ std::string unity = cpp_batch_params.expected_memory.substr(cpp_batch_params.expected_memory.size()-2, 2);
+ if((unity.find("gb") != std::string::npos))
+ memory = memory * 1024;
+ job_parameters->resource_required.mem_mb = memory;
+
+ // Create Job
try
{
- int job_id = _salome_launcher->submitSalomeJob(fileToExecute, filesToExport,
- filesToImport, batch_params, machine);
+ int job_id = _salome_launcher->createJob(job_parameters);
job->setSalomeLauncherId(job_id);
}
catch (const SALOME::SALOME_Exception & ex)
{
- DEBTRACE("SALOME Exception in submitSalomeJob !");
+ DEBTRACE("SALOME Exception in createJob !");
ret = ex.details.text.in();
}
return ret;
}
std::string
-BL::SALOMEServices::refresh_job(BL::Job * job)
+BL::SALOMEServices::start_job(BL::Job * job)
{
std::string ret = "";
+ // Launch Job !
+ try
+ {
+ _salome_launcher->launchJob(job->getSalomeLauncherId());
+ }
+ catch (const SALOME::SALOME_Exception & ex)
+ {
+ DEBTRACE("SALOME Exception in launchJob !");
+ ret = ex.details.text.in();
+ }
+ return ret;
+}
- Engines::MachineParameters_var machine = new Engines::MachineParameters;
- machine->hostname = CORBA::string_dup(job->getMachine().c_str());
+std::string
+BL::SALOMEServices::refresh_job(BL::Job * job)
+{
+ std::string ret = "";
// Refresh Job !
try
{
- CORBA::String_var result = _salome_launcher->queryJob(job->getSalomeLauncherId(), machine);
- std::string res = result.in();
- if (res == "Running")
- return "RUNNING";
- else if (res == "Done")
- return "FINISHED";
- else
- return result.in();
+ CORBA::String_var result = _salome_launcher->getJobState(job->getSalomeLauncherId());
+ ret = result.in();
}
catch (const SALOME::SALOME_Exception & ex)
{
- DEBTRACE("SALOME Exception in refresh_job !");
+ DEBTRACE("SALOME Exception in getJobState !");
ret = ex.details.text.in();
}
return ret;
BL::SALOMEServices::delete_job(BL::Job * job)
{
std::string ret = "";
-
- Engines::MachineParameters_var machine = new Engines::MachineParameters;
- machine->hostname = CORBA::string_dup(job->getMachine().c_str());
-
// Delete Job !
try
{
- _salome_launcher->deleteJob(job->getSalomeLauncherId(), machine);
+ _salome_launcher->removeJob(job->getSalomeLauncherId());
}
catch (const SALOME::SALOME_Exception & ex)
{
- DEBTRACE("SALOME Exception in refresh_job !");
+ DEBTRACE("SALOME Exception in removeJob !");
ret = ex.details.text.in();
}
return ret;
{
std::string ret = "";
- Engines::MachineParameters_var machine = new Engines::MachineParameters;
- machine->hostname = CORBA::string_dup(job->getMachine().c_str());
-
BL::Job::FilesParam files = job->getFilesParameters();
CORBA::String_var directory = CORBA::string_dup(files.result_directory.c_str());
// get job results !
try
{
- _salome_launcher->getResultsJob(directory, job->getSalomeLauncherId(), machine);
+ _salome_launcher->getJobResults(job->getSalomeLauncherId(), directory);
}
catch (const SALOME::SALOME_Exception & ex)
{
std::list<std::string> getMachineList();
+ std::string create_job(BL::Job * job);
std::string start_job(BL::Job * job);
std::string refresh_job(BL::Job * job);
std::string delete_job(BL::Job * job);
std::string get_results_job(BL::Job * job);
- protected:
- std::string start_yacs_job(BL::Job * job);
-
private:
CORBA::ORB_var _orb;
SALOME_NamingService * _salome_naming_service;
job_name = "";
yacs_file = "";
command = "";
+ env_file = "";
batch_directory = "";
- expected_during_time = "";
+ maximum_during_time = "";
expected_memory = "";
nb_proc = 1;
// Command Panel
QString f_command = field("command").toString();
command = f_command.toStdString();
+ QString f_env_file = field("env_file").toString();
+ env_file = f_env_file.toStdString();
// Batch Panel
QString f_batch_directory = field("batch_directory").toString();
time_min = "0" + field("during_time_min").toString();
else
time_min = field("during_time_min").toString();
- expected_during_time = time_hour.toStdString() + ":" + time_min.toStdString() + ":00";
+ maximum_during_time = time_hour.toStdString() + ":" + time_min.toStdString() + ":00";
QString mem = field("mem_value").toString();
int mem_type_i = field("mem_type").toInt();
QLabel * label_command = new QLabel("Command: ");
QLineEdit * line_command = new QLineEdit(this);
registerField("command", line_command);
+ QLabel * label_env_file = new QLabel("Environnement file: ");
+ QLineEdit * line_env_file = new QLineEdit(this);
+ registerField("env_file", line_env_file);
QGridLayout *layout = new QGridLayout;
layout->addWidget(label_command, 0, 0);
layout->addWidget(line_command, 0, 1);
+ layout->addWidget(label_env_file, 1, 0);
+ layout->addWidget(line_env_file, 1, 1);
QVBoxLayout * main_layout = new QVBoxLayout;
main_layout->addWidget(label);
registerField("batch_directory", line_directory);
// exected during time
- QLabel * label_during_time = new QLabel("Expected during time: ");
+ QLabel * label_during_time = new QLabel("Maximum during time: ");
QSpinBox * spin_during_time_hour = new QSpinBox(this);
QLabel * label_during_time_hour = new QLabel("Hours");
spin_during_time_hour->setMinimum(0);
std::string yacs_file;
std::string command;
+ std::string env_file;
std::string batch_directory;
- std::string expected_during_time;
+ std::string maximum_during_time;
std::string expected_memory;
int nb_proc;
QLabel * job_rd_label = new QLabel("Result directory:");
_job_rd_label_value = new QLabel("");
- QLabel * job_edt_label = new QLabel("Expected during time:");
- _job_edt_label_value = new QLabel("");
+ QLabel * job_mdt_label = new QLabel("Maximum during time:");
+ _job_mdt_label_value = new QLabel("");
QLabel * job_em_label = new QLabel("Expected memory:");
_job_em_label_value = new QLabel("");
QLabel * job_nop_label = new QLabel("Number of processors:");
run_values_form->insertRow(2, job_bd_label, _job_bd_label_value);
run_values_form->insertRow(3, job_rd_label, _job_rd_label_value);
QFormLayout * other_run_values_form = new QFormLayout;
- other_run_values_form->insertRow(0, job_edt_label, _job_edt_label_value);
+ other_run_values_form->insertRow(0, job_mdt_label, _job_mdt_label_value);
other_run_values_form->insertRow(1, job_em_label, _job_em_label_value);
other_run_values_form->insertRow(2, job_nop_label, _job_nop_label_value);
QHBoxLayout * box_layout = new QHBoxLayout();
_job_bd_label_value->setText(QString(batch_params.batch_directory.c_str()));
_job_rd_label_value->setText(QString(files_params.result_directory.c_str()));
- _job_edt_label_value->setText(QString(batch_params.expected_during_time.c_str()));
+ _job_mdt_label_value->setText(QString(batch_params.maximum_during_time.c_str()));
_job_em_label_value->setText(QString(batch_params.expected_memory.c_str()));
_job_nop_label_value->setText(QVariant(batch_params.nb_proc).toString());
_job_nof_label_value->setText("");
_job_bd_label_value->setText("");
_job_rd_label_value->setText("");
- _job_edt_label_value->setText("");
+ _job_mdt_label_value->setText("");
_job_em_label_value->setText("");
_job_nop_label_value->setText("");
_job_command_label->setText("Schema or Command:");
QLabel * _job_nof_label_value;
QLabel * _job_bd_label_value;
QLabel * _job_rd_label_value;
- QLabel * _job_edt_label_value;
+ QLabel * _job_mdt_label_value;
QLabel * _job_em_label_value;
QLabel * _job_nop_label_value;
if (wizard.job_name != "")
{
- BL::Job * new_job = addNewJob(wizard.job_name);
+ BL::Job * new_job = createJob(wizard.job_name);
if (wizard.yacs_file != "")
{
// YACS schema job
new_job->setYACSFile(wizard.yacs_file);
BL::Job::BatchParam param;
param.batch_directory = wizard.batch_directory;
- param.expected_during_time = wizard.expected_during_time;
+ param.maximum_during_time = wizard.maximum_during_time;
param.expected_memory = wizard.expected_memory;
param.nb_proc = wizard.nb_proc;
new_job->setBatchParameters(param);
// Command Job
new_job->setType(BL::Job::COMMAND);
new_job->setCommand(wizard.command);
+ new_job->setEnvFile(wizard.env_file);
BL::Job::BatchParam param;
param.batch_directory = wizard.batch_directory;
- param.expected_during_time = wizard.expected_during_time;
+ param.maximum_during_time = wizard.maximum_during_time;
param.expected_memory = wizard.expected_memory;
param.nb_proc = wizard.nb_proc;
new_job->setBatchParameters(param);
new_job->setFilesParameters(files_params);
new_job->setMachine(wizard.machine_choosed);
}
+ addJobToLauncher(wizard.job_name);
emit new_job_added(QString::fromStdString(wizard.job_name));
if (wizard.start_job)
start_job(wizard.job_name);
<< event->event_name << " "
<< event->job_name << " "
<< event->data);
- if (event->action == "start_job")
+
+ if (event->action == "create_job")
+ {
+ if (event->event_name == "Ok")
+ {
+ QString str((event->job_name).c_str());
+ write_normal_text("Job " + str + " created\n");
+ }
+ else
+ {
+ QString str((event->job_name).c_str());
+ write_error_text("Error in creating job: " + str + "\n");
+ write_error_text("*** ");
+ write_error_text((event->data).c_str());
+ write_error_text(" ***\n");
+ }
+ }
+ else if (event->action == "start_job")
{
if (event->event_name == "Ok")
{