]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Add job parameter 'exclusive' to let the user choose to share nodes or not (EDF issue...
authorbarate <barate>
Wed, 28 Aug 2013 15:50:30 +0000 (15:50 +0000)
committerbarate <barate>
Wed, 28 Aug 2013 15:50:30 +0000 (15:50 +0000)
idl/SALOME_Launcher.idl
src/Launcher/Launcher_Job.cxx
src/Launcher/Launcher_Job.hxx
src/Launcher/Launcher_Job_Command.cxx
src/Launcher/Launcher_Job_SALOME.cxx
src/Launcher/SALOME_Launcher.cxx

index fb90010bc62cc621b0de6378d3bec0b87befaf76..8e8a014ed8bc4630277ffbb927db0836c34f0b8d 100644 (file)
@@ -72,6 +72,9 @@ struct JobParameters
     Name of the batch queue choosed - optional
   */
   string queue;
+  
+  //! Specifies if the job must run in exclusive mode (without sharing nodes with other jobs)
+  boolean exclusive;
 
   /*!
     Specific parameters for each type of job - optional
index 5e1fc7ae2508bb1376d4757a1c305fee216913c9..60e0dcba6637838b781c6a7278514b022325e781 100644 (file)
@@ -52,6 +52,7 @@ Launcher::Job::Job()
   _resource_required_params.mem_mb = -1;
   _queue = "";
   _job_type = "";
+  _exclusive = false;
 
   // Parameters for COORM
   _launcher_file = "";
@@ -306,6 +307,23 @@ Launcher::Job::setQueue(const std::string & queue)
   _queue = queue;
 }
 
+void
+Launcher::Job::setExclusive(bool exclusive)
+{
+  _exclusive = exclusive;
+}
+
+void
+Launcher::Job::setExclusiveStr(const std::string & exclusiveStr)
+{
+  if (exclusiveStr == "true")
+    _exclusive = true;
+  else if (exclusiveStr == "false")
+    _exclusive = false;
+  else
+    throw LauncherException(std::string("Invalid boolean value for exclusive: ") + exclusiveStr);
+}
+
 std::string 
 Launcher::Job::getWorkDirectory()
 {
@@ -366,6 +384,18 @@ Launcher::Job::getQueue()
   return _queue;
 }
 
+bool
+Launcher::Job::getExclusive()
+{
+  return _exclusive;
+}
+
+std::string
+Launcher::Job::getExclusiveStr() const
+{
+  return _exclusive ? "true" : "false";
+}
+
 void 
 Launcher::Job::checkMaximumDuration(const std::string & maximum_duration)
 {
@@ -575,6 +605,10 @@ Launcher::Job::common_job_params()
   if (_queue != "")
     params[Batch::QUEUE] = _queue;
 
+  // Exclusive
+  if (getExclusive())
+    params[Batch::EXCLUSIVE] = true;
+
   // Specific parameters
   std::map<std::string, std::string>::iterator it = _specific_parameters.find("LoalLevelerJobType");
   if (it != _specific_parameters.end())
@@ -648,6 +682,7 @@ Launcher::Job::addToXmlDocument(xmlNodePtr root_node)
 
   xmlNewChild(node, NULL, xmlCharStrdup("maximum_duration"), xmlCharStrdup(getMaximumDuration().c_str()));
   xmlNewChild(node, NULL, xmlCharStrdup("queue"),            xmlCharStrdup(getQueue().c_str()));
+  xmlNewChild(node, NULL, xmlCharStrdup("exclusive"),        xmlCharStrdup(getExclusiveStr().c_str()));
 
   // For COORM
   xmlNewChild(node, NULL, xmlCharStrdup("launcher_args"), xmlCharStrdup(getLauncherArgs().c_str()));
index f1f9732540fd418171aa55efc1feb19e53bae0e9..39c999f1d5eb620ec2ea6b6570cb03fc1c2456b3 100644 (file)
@@ -78,7 +78,8 @@ namespace Launcher
       void setResourceRequiredParams(const resourceParams & resource_required_params);
       void setQueue(const std::string & queue);
       void setEnvFile(const std::string & env_file);
-
+      void setExclusive(bool exclusive);
+      void setExclusiveStr(const std::string & exclusiveStr);
          // For COORM
          void setLauncherFile(const std::string & launcher_file);
          void setLauncherArgs(const std::string & launcher_args);
@@ -95,6 +96,8 @@ namespace Launcher
       std::string getQueue();
       std::string getEnvFile();
       std::string getJobType();
+      bool getExclusive();
+      std::string getExclusiveStr() const;
 
          // For COORM
          std::string getLauncherFile();
@@ -151,6 +154,7 @@ namespace Launcher
       long _maximum_duration_in_second;
       resourceParams _resource_required_params;
       std::string _queue;
+      bool _exclusive;
 
          // Parameters for COORM
          std::string _launcher_file;
index 072db83eed7f92425e747d0ce9a5c36043e11023..b623ff9f0864a438391bf9d7fb0225abf84df462 100644 (file)
@@ -41,7 +41,6 @@ Launcher::Job_Command::update_job()
 #ifdef WITH_LIBBATCH
   Batch::Parametre params = common_job_params();
   params[Batch::EXECUTABLE] = buildCommandScript(params, _launch_date);
-  params[Batch::EXCLUSIVE] = false;
   _batch_job->setParametre(params);
 #endif
 }
index 7720767f6d52b58a5be83d4ac1d7113a41e2dc46..52a7624afff780bae2de4d0d09597d2b56f81861 100644 (file)
@@ -53,7 +53,6 @@ Launcher::Job_SALOME::update_job()
 #ifdef WITH_LIBBATCH
   Batch::Parametre params = common_job_params();
   params[Batch::EXECUTABLE] = buildSalomeScript(params);
-  params[Batch::EXCLUSIVE] = true;
   _batch_job->setParametre(params);
 #endif
 }
index 07e802c4548982f2bff881a0b50e90ab70992adc..a0eb7e5f6f3d1c0d74dc3d29cb7e6c0575497e45 100644 (file)
@@ -157,6 +157,9 @@ SALOME_Launcher::createJob(const Engines::JobParameters & job_parameters)
   std::string queue = job_parameters.queue.in();
   new_job->setQueue(queue);
 
+  // Exclusive
+  new_job->setExclusive(job_parameters.exclusive);
+
   // Resources requirements
   try
   {
@@ -492,6 +495,7 @@ SALOME_Launcher::getJobParameters(CORBA::Long job_id)
 
   job_parameters->maximum_duration = CORBA::string_dup(job->getMaximumDuration().c_str());
   job_parameters->queue            = CORBA::string_dup(job->getQueue().c_str());
+  job_parameters->exclusive        = job->getExclusive();
 
   resourceParams resource_params = job->getResourceRequiredParams();
   job_parameters->resource_required.name             = CORBA::string_dup(resource_params.name.c_str());
@@ -709,10 +713,12 @@ SALOME_Launcher::loadJobs(const char* jobs_file)
         xmlNodePtr res_node = xmlNextElementSibling(files_node);
         xmlNodePtr maximum_duration_node = xmlNextElementSibling(res_node);
         xmlNodePtr queue_node = xmlNextElementSibling(maximum_duration_node);
-        xmlNodePtr launcher_args_node = xmlNextElementSibling(queue_node);
+        xmlNodePtr exclusive_node = xmlNextElementSibling(queue_node);
+        xmlNodePtr launcher_args_node = xmlNextElementSibling(exclusive_node);
         if (res_node              == NULL ||
             maximum_duration_node == NULL ||
             queue_node            == NULL ||
+            exclusive_node        == NULL ||
                        // For COORM
             launcher_args_node    == NULL
            )
@@ -724,6 +730,7 @@ SALOME_Launcher::loadJobs(const char* jobs_file)
         if (xmlStrcmp(res_node->name,              xmlCharStrdup("resource_params"))  ||
             xmlStrcmp(maximum_duration_node->name, xmlCharStrdup("maximum_duration")) ||
             xmlStrcmp(queue_node->name,            xmlCharStrdup("queue")) ||
+            xmlStrcmp(exclusive_node->name,        xmlCharStrdup("exclusive")) ||
                        // For COORM
             xmlStrcmp(launcher_args_node->name,    xmlCharStrdup("launcher_args"))
            )
@@ -749,6 +756,20 @@ SALOME_Launcher::loadJobs(const char* jobs_file)
         xmlFree(maximum_duration);
         xmlFree(queue);
 
+        xmlChar* exclusive = xmlNodeGetContent(exclusive_node);
+        try
+        {
+          new_job->setExclusiveStr(std::string((const char *)exclusive));
+        }
+        catch(const LauncherException &ex)
+        {
+          INFOS("Exception received for exclusive, cannot add the job. " << ex.msg.c_str());
+          delete new_job;
+          xmlFree(exclusive);
+          break;
+        }
+        xmlFree(exclusive);
+
                // For COORM
         xmlChar* launcher_args           = xmlNodeGetContent(launcher_args_node);
         new_job->setLauncherArgs(std::string((const char *)launcher_args));