Add some tests if user does not enter a correct value.
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<std::string, std::string> &
+Launcher::Job::getSpecificParameters()
+{
+ return _specific_parameters;
+}
+
+void
+Launcher::Job::checkSpecificParameters()
+{
+}
#include <string>
#include <list>
+#include <map>
#include <iostream>
#include <sstream>
#include <algorithm>
std::string updateJobState();
+ void addSpecificParameter(const std::string & name,
+ const std::string & value);
+ const std::map<std::string, std::string> & getSpecificParameters();
+ virtual void checkSpecificParameters();
+
// Checks
void checkMaximumDuration(const std::string & maximum_duration);
void checkResourceRequiredParams(const resourceParams & resource_required_params);
std::string _result_directory;
std::list<std::string> _in_files;
std::list<std::string> _out_files;
+ std::map<std::string, std::string> _specific_parameters;
std::string _maximum_duration;
long _maximum_duration_in_second;
resourceParams _resource_required_params;
// Author: André RIBES - EDF R&D
//
#include "Launcher_Job_YACSFile.hxx"
+#include <sstream>
-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() {}
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<std::string, std::string>::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);
+ }
}
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;
};
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: ");
// 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();
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
{
THROW_SALOME_CORBA_EXCEPTION(ex.msg.c_str(),SALOME::INTERNAL_ERROR);
}
- for(int i=0;i<job_parameters.specific_parameters.length();i++){
- std::string option = CORBA::string_dup(job_parameters.specific_parameters[i].name);
- if(option.find("EnableDumpYACS") != std::string::npos){
- int dumpState = atoi(job_parameters.specific_parameters[i].value);
- (dynamic_cast<Launcher::Job_YACSFile *>(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