]> SALOME platform Git repositories - modules/jobmanager.git/commitdiff
Salome HOME
expected_during_time to maximum_during_time
authorribes <ribes>
Tue, 10 Nov 2009 10:12:59 +0000 (10:12 +0000)
committerribes <ribes>
Tue, 10 Nov 2009 10:12:59 +0000 (10:12 +0000)
src/engine/BL_Job.cxx
src/engine/BL_Job.hxx
src/engine/BL_JobsManager.cxx
src/engine/BL_JobsManager.hxx
src/engine/BL_SALOMEServices.cxx
src/engine/BL_SALOMEServices.hxx
src/genericgui/BL_CreateJobWizard.cxx
src/genericgui/BL_CreateJobWizard.hxx
src/genericgui/BL_JobTab.cxx
src/genericgui/BL_JobTab.hxx
src/genericgui/BL_JobsManager_QT.cxx

index 85bbb659b8dfa1fc1caf07dfac8151bc57545114..3d9244563461a761dff9ab4c64c35a352fffddde 100644 (file)
@@ -25,8 +25,9 @@ BL::Job::Job()
   _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 = "";
@@ -42,8 +43,9 @@ BL::Job::Job(const std::string & name)
   _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 = "";
@@ -104,11 +106,23 @@ BL::Job::getCommand()
   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;
 }
index 6a78e1ce86c318be31478d3b3e6526a0c19e9739..2525a963d7f9c6004d4b7645ce177e75d1d1913a 100644 (file)
@@ -46,11 +46,13 @@ namespace BL{
 
       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;
       };
@@ -90,6 +92,7 @@ namespace BL{
       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;
index 985d280a0578ebaa0f8e7dee40accb0fead77126..eabee2e47caf38359acc898c2bd9ad54084e50c7 100644 (file)
@@ -45,9 +45,9 @@ BL::JobsManager::setObserver(BL::Observer * observer)
 }
 
 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;
 
@@ -60,11 +60,35 @@ BL::JobsManager::addNewJob(const std::string & name)
     _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)
 {
@@ -111,7 +135,6 @@ BL::JobsManager::job_already_exist(const std::string & name)
     return false;
   else
     return true;
-
 }
 
 void
index 675a5ab8547b5c47b041f0e2d814259d104825d8..a4b137c3b88108e09abbbd9006073ca36e0341d4 100644 (file)
@@ -40,7 +40,8 @@ namespace BL{
 
       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);
index 8f6a9d0703f251b7fa079530da78b0a3e210e65e..78f827b43961dd43dfcb5a113315f035059ef622 100644 (file)
@@ -84,85 +84,109 @@ BL::SALOMEServices::getMachineList()
 }
 
 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;
@@ -172,18 +196,14 @@ std::string
 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;
@@ -194,16 +214,13 @@ BL::SALOMEServices::get_results_job(BL::Job * job)
 {
   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)
   {
index f5e597d673863c10783b3c552b87016d6c1c5dd2..ef8ac9551bac12a481c75022bd0df59a4dd8416d 100644 (file)
@@ -43,14 +43,12 @@ namespace BL{
 
       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;
index 99ae4eea8c84648ed285646ef9645574639d96ff..42538212088395e2009096797ea1f912d0387bfb 100644 (file)
@@ -29,8 +29,9 @@ BL::CreateJobWizard::CreateJobWizard(BL::JobsManager_QT * jobs_manager, BL::SALO
   job_name = "";
   yacs_file = "";
   command = "";
+  env_file = "";
   batch_directory = "";
-  expected_during_time = "";
+  maximum_during_time = "";
   expected_memory = "";
   nb_proc = 1;
 
@@ -83,6 +84,8 @@ BL::CreateJobWizard::end(int result)
     // 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();
@@ -98,7 +101,7 @@ BL::CreateJobWizard::end(int result)
       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();
@@ -291,10 +294,15 @@ BL::CreateJobWizard::CommandMainPage::CommandMainPage(QWidget * parent)
   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);
@@ -340,7 +348,7 @@ BL::BatchParametersPage::BatchParametersPage(QWidget * parent)
   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);
index ede4b4be6b27966a027982fc8f030d2f1b6a8ebe..a241e9c82654e9ce0e1384f9c842ffad3620111a 100644 (file)
@@ -59,9 +59,10 @@ namespace BL{
       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;
 
index 5f139cc7f0bf71e0cae8dc84b94dbaaed103b2bb..d08d6df4300c0b3ef45c26696ee272f3d5d9cc20 100644 (file)
@@ -84,8 +84,8 @@ BL::JobTab::createJobSummaryTab()
   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:");
@@ -98,7 +98,7 @@ BL::JobTab::createJobSummaryTab()
   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();
@@ -189,7 +189,7 @@ BL::JobTab::job_selected(const QModelIndex & index)
     _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());
 
@@ -248,7 +248,7 @@ BL::JobTab::reset(QString job_name)
   _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:");
index 2f68cc0c343d66cacea8a5f4fca7b0a2f523bb8c..7f1031ec68eb210c2ce8bb6ddb93feb6c9e3c2f2 100644 (file)
@@ -63,7 +63,7 @@ namespace BL
       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;
 
index 04cc1b52caed3d1c78f6e25f998ba04ec93e4e6e..3bc5f4e0c5326a41a649f89e68d8dd392553e033 100644 (file)
@@ -155,7 +155,7 @@ BL::JobsManager_QT::create_job_wizard()
 
     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
@@ -163,7 +163,7 @@ BL::JobsManager_QT::create_job_wizard()
        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);
@@ -179,9 +179,10 @@ BL::JobsManager_QT::create_job_wizard()
        // 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);
@@ -192,6 +193,7 @@ BL::JobsManager_QT::create_job_wizard()
        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);
@@ -233,7 +235,24 @@ BL::JobsManager_QT::event(QEvent * e)
           << 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")
     {