From bb01f43573762db450b4a4dd0f0207376949a32f Mon Sep 17 00:00:00 2001 From: ribes Date: Wed, 13 Apr 2011 17:24:34 +0000 Subject: [PATCH] Save and load Jobs with specific parameters --- src/Launcher/Launcher_Job.cxx | 10 ++++++ src/Launcher/SALOME_Launcher.cxx | 55 ++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/src/Launcher/Launcher_Job.cxx b/src/Launcher/Launcher_Job.cxx index 19daa34c1..d2023ae12 100644 --- a/src/Launcher/Launcher_Job.cxx +++ b/src/Launcher/Launcher_Job.cxx @@ -574,6 +574,16 @@ 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())); + // Specific parameters part + xmlNodePtr specific_parameters_node = xmlNewChild(node, NULL, xmlCharStrdup("specific_parameters"), NULL); + std::map specific_parameters = getSpecificParameters(); + for(std::map::iterator it = specific_parameters.begin(); it != specific_parameters.end(); it++) + { + xmlNodePtr specific_parameter_node = xmlNewChild(specific_parameters_node, NULL, xmlCharStrdup("specific_parameter"), NULL); + xmlNewChild(specific_parameter_node, NULL, xmlCharStrdup("name"), xmlCharStrdup((it->first).c_str())); + xmlNewChild(specific_parameter_node, NULL, xmlCharStrdup("value"), xmlCharStrdup((it->second).c_str())); + } + // Run part xmlNodePtr run_node = xmlNewChild(job_node, NULL, xmlCharStrdup("run_part"), NULL); xmlNewChild(run_node, NULL, xmlCharStrdup("job_state"), xmlCharStrdup(getState().c_str())); diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index ec1993e65..be953f901 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -677,6 +677,61 @@ SALOME_Launcher::loadJobs(const char* jobs_file) xmlFree(maximum_duration); xmlFree(queue); + xmlNodePtr specific_node = xmlNextElementSibling(queue_node); + if (specific_node == NULL) + { + INFOS("A bad job is found, specific_parameters part is not found"); + delete new_job; + break; + } + xmlNodePtr parameter_node = xmlFirstElementChild(specific_node); + while (parameter_node != NULL) + { + if (!xmlStrcmp(parameter_node->name, xmlCharStrdup("specific_parameter"))) + { + xmlNodePtr name_node = xmlFirstElementChild(parameter_node); + xmlNodePtr value_node = xmlNextElementSibling(name_node); + if (name_node == NULL || + value_node == NULL) + { + INFOS("A bad job is found, specific_parameter parts are not found"); + delete new_job; + break; + } + if (xmlStrcmp(name_node->name, xmlCharStrdup("name")) || + xmlStrcmp(value_node->name, xmlCharStrdup("value"))) + { + INFOS("A bad job is found, specific_parameter bad parts are found"); + delete new_job; + break; + } + + xmlChar* name = xmlNodeGetContent(name_node); + xmlChar* value = xmlNodeGetContent(value_node); + try + { + new_job->addSpecificParameter(std::string((const char*)name), std::string((const char*)value)); + xmlFree(name); + xmlFree(value); + } + catch(const LauncherException &ex) + { + INFOS("Exception receice for a specific parameter, cannot add the job" << ex.msg.c_str()); + delete new_job; + xmlFree(name); + xmlFree(value); + break; + } + } + else + { + INFOS("A bad job is found, specific_parameters part is bad, a node that is not a specific parameter is found"); + delete new_job; + break; + } + parameter_node = xmlNextElementSibling(parameter_node); + } + xmlNodePtr res_name_node = xmlFirstElementChild(res_node); xmlNodePtr res_hostname_node = xmlNextElementSibling(res_name_node); xmlNodePtr res_os_node = xmlNextElementSibling(res_hostname_node); -- 2.39.2