From: ribes Date: Wed, 13 Apr 2011 16:18:26 +0000 (+0000) Subject: Refactoring code EnableDumpYACS X-Git-Tag: V6_3_0a1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=edb905a00a4bde7ab817e0cb7d634047dec142dc;p=modules%2Fkernel.git Refactoring code EnableDumpYACS Add some tests if user does not enter a correct value. --- diff --git a/src/Launcher/Launcher_Job.cxx b/src/Launcher/Launcher_Job.cxx index 7e8c42fa0..19daa34c1 100644 --- a/src/Launcher/Launcher_Job.cxx +++ b/src/Launcher/Launcher_Job.cxx @@ -585,3 +585,22 @@ Launcher::Job::addToXmlDocument(xmlNodePtr root_node) xmlNewChild(run_node, NULL, xmlCharStrdup("job_reference"), xmlCharStrdup(job_id.getReference().c_str())); #endif } + +void +Launcher::Job::addSpecificParameter(const std::string & name, + const std::string & value) +{ + std::cerr << "Adding " << name << " " << value << std::endl; + _specific_parameters[name] = value; +} + +const std::map & +Launcher::Job::getSpecificParameters() +{ + return _specific_parameters; +} + +void +Launcher::Job::checkSpecificParameters() +{ +} diff --git a/src/Launcher/Launcher_Job.hxx b/src/Launcher/Launcher_Job.hxx index be0284932..eeba823a7 100644 --- a/src/Launcher/Launcher_Job.hxx +++ b/src/Launcher/Launcher_Job.hxx @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -92,6 +93,11 @@ namespace Launcher std::string updateJobState(); + void addSpecificParameter(const std::string & name, + const std::string & value); + const std::map & getSpecificParameters(); + virtual void checkSpecificParameters(); + // Checks void checkMaximumDuration(const std::string & maximum_duration); void checkResourceRequiredParams(const resourceParams & resource_required_params); @@ -127,6 +133,7 @@ namespace Launcher std::string _result_directory; std::list _in_files; std::list _out_files; + std::map _specific_parameters; std::string _maximum_duration; long _maximum_duration_in_second; resourceParams _resource_required_params; diff --git a/src/Launcher/Launcher_Job_YACSFile.cxx b/src/Launcher/Launcher_Job_YACSFile.cxx index 31bd4fe14..7f04d7d17 100644 --- a/src/Launcher/Launcher_Job_YACSFile.cxx +++ b/src/Launcher/Launcher_Job_YACSFile.cxx @@ -20,9 +20,14 @@ // Author: André RIBES - EDF R&D // #include "Launcher_Job_YACSFile.hxx" +#include -Launcher::Job_YACSFile::Job_YACSFile() {_job_type = "yacs_file"; _dumpState=0;} +Launcher::Job_YACSFile::Job_YACSFile() +{ + _job_type = "yacs_file"; + _dumpState = -1; +} Launcher::Job_YACSFile::~Job_YACSFile() {} @@ -36,13 +41,22 @@ void Launcher::Job_YACSFile::addJobTypeSpecificScript(std::ofstream & launch_script_stream) { launch_script_stream << _resource_definition.AppliPath << "/runSession -p $appli_port driver " << _job_file_name_complete; - if(_dumpState > 0) + if (_dumpState > 0) launch_script_stream << " --dump=" << _dumpState; launch_script_stream << " > logs/yacs_" << _launch_date << ".log 2>&1" << std::endl; } void -Launcher::Job_YACSFile::setDumpState(const int dumpState) +Launcher::Job_YACSFile::checkSpecificParameters() { - _dumpState = dumpState; + // Specific parameters + std::map::iterator it = _specific_parameters.find("EnableDumpYACS"); + if (it != _specific_parameters.end()) + { + // Decode info + std::string user_value = it->second; + std::istringstream iss(user_value); + if (!(iss >> _dumpState)) + throw LauncherException("Specific parameter EnableDumpYACS is not correctly defined: it should be an integer. Value given is " + user_value); + } } diff --git a/src/Launcher/Launcher_Job_YACSFile.hxx b/src/Launcher/Launcher_Job_YACSFile.hxx index e6226afcf..f283eac5b 100644 --- a/src/Launcher/Launcher_Job_YACSFile.hxx +++ b/src/Launcher/Launcher_Job_YACSFile.hxx @@ -34,7 +34,8 @@ namespace Launcher virtual void setJobFile(const std::string & job_file); virtual void addJobTypeSpecificScript(std::ofstream & launch_script_stream); - virtual void setDumpState(const int dumpState); + virtual void checkSpecificParameters(); + protected: int _dumpState; }; diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index 379f681b7..d16ebcdc0 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -88,7 +88,7 @@ CORBA::Long SALOME_Launcher::createJob(const Engines::JobParameters & job_parameters) { std::string job_type = job_parameters.job_type.in(); - + if (job_type != "command" && job_type != "yacs_file" && job_type != "python_salome") { std::string message("SALOME_Launcher::createJob: bad job type: "); @@ -107,7 +107,7 @@ SALOME_Launcher::createJob(const Engines::JobParameters & job_parameters) // Name new_job->setJobName(job_parameters.job_name.in()); - + // Directories std::string work_directory = job_parameters.work_directory.in(); std::string local_directory = job_parameters.local_directory.in(); @@ -135,7 +135,7 @@ SALOME_Launcher::createJob(const Engines::JobParameters & job_parameters) new_job->add_in_file(job_parameters.in_files[i].in()); for (CORBA::ULong i = 0; i < job_parameters.out_files.length(); i++) new_job->add_out_file(job_parameters.out_files[i].in()); - + // Expected During Time try { @@ -170,12 +170,18 @@ SALOME_Launcher::createJob(const Engines::JobParameters & job_parameters) THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR); } - for(int i=0;i(new_job))->setDumpState(dumpState); - } + // Adding specific parameters to the job + for (CORBA::ULong i = 0; i < job_parameters.specific_parameters.length(); i++) + new_job->addSpecificParameter(job_parameters.specific_parameters[i].name.in(), + job_parameters.specific_parameters[i].value.in()); + try + { + new_job->checkSpecificParameters(); + } + catch(const LauncherException &ex) + { + INFOS(ex.msg.c_str()); + THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR); } try