From: barate Date: Wed, 28 Aug 2013 15:50:30 +0000 (+0000) Subject: Add job parameter 'exclusive' to let the user choose to share nodes or not (EDF issue... X-Git-Tag: begin_agr_portmanager_branch_131004~37 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=aa5403d08e580cb0172f8fa7bd40fdd38f90fb23;p=modules%2Fkernel.git Add job parameter 'exclusive' to let the user choose to share nodes or not (EDF issue #2700) --- diff --git a/idl/SALOME_Launcher.idl b/idl/SALOME_Launcher.idl index fb90010bc..8e8a014ed 100644 --- a/idl/SALOME_Launcher.idl +++ b/idl/SALOME_Launcher.idl @@ -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 diff --git a/src/Launcher/Launcher_Job.cxx b/src/Launcher/Launcher_Job.cxx index 5e1fc7ae2..60e0dcba6 100644 --- a/src/Launcher/Launcher_Job.cxx +++ b/src/Launcher/Launcher_Job.cxx @@ -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::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())); diff --git a/src/Launcher/Launcher_Job.hxx b/src/Launcher/Launcher_Job.hxx index f1f973254..39c999f1d 100644 --- a/src/Launcher/Launcher_Job.hxx +++ b/src/Launcher/Launcher_Job.hxx @@ -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; diff --git a/src/Launcher/Launcher_Job_Command.cxx b/src/Launcher/Launcher_Job_Command.cxx index 072db83ee..b623ff9f0 100644 --- a/src/Launcher/Launcher_Job_Command.cxx +++ b/src/Launcher/Launcher_Job_Command.cxx @@ -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 } diff --git a/src/Launcher/Launcher_Job_SALOME.cxx b/src/Launcher/Launcher_Job_SALOME.cxx index 7720767f6..52a7624af 100644 --- a/src/Launcher/Launcher_Job_SALOME.cxx +++ b/src/Launcher/Launcher_Job_SALOME.cxx @@ -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 } diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index 07e802c45..a0eb7e5f6 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -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));