From e68bce0dfa995dde33693fa9263f847347340c98 Mon Sep 17 00:00:00 2001 From: ribes Date: Wed, 18 Nov 2009 10:26:51 +0000 Subject: [PATCH] - maximum_during_time tp maximum_duration - Bugs in Command_Job --- idl/SALOME_ContainerManager.idl | 2 +- src/Launcher/Launcher_Job.cxx | 37 +++++++++++++------------- src/Launcher/Launcher_Job.hxx | 13 ++++----- src/Launcher/Launcher_Job_Command.cxx | 13 +++------ src/Launcher/Launcher_Job_YACSFile.cxx | 11 ++++---- src/Launcher/SALOME_Launcher.cxx | 4 +-- 6 files changed, 37 insertions(+), 43 deletions(-) diff --git a/idl/SALOME_ContainerManager.idl b/idl/SALOME_ContainerManager.idl index 7fb7004d5..38872f70f 100644 --- a/idl/SALOME_ContainerManager.idl +++ b/idl/SALOME_ContainerManager.idl @@ -149,7 +149,7 @@ struct JobParameters /*! Time for the batch (has to be like this : hh:mm) - Could be empty, in this case, default value of the selected resource will be used. */ - string maximum_during_time; + string maximum_duration; // Memory is expressed in megabytes -> mem_mb // Number of Processors -> nb_node diff --git a/src/Launcher/Launcher_Job.cxx b/src/Launcher/Launcher_Job.cxx index df4372f98..ae96a88f5 100644 --- a/src/Launcher/Launcher_Job.cxx +++ b/src/Launcher/Launcher_Job.cxx @@ -25,12 +25,13 @@ Launcher::Job::Job() { _number = -1; _state = "CREATED"; + _launch_date = getLaunchDate(); _work_directory = ""; _local_directory = ""; _result_directory = ""; - _maximum_during_time = ""; - _maximum_during_time_in_second = -1; + _maximum_duration = ""; + _maximum_duration_in_second = -1; _machine_required_params.hostname = ""; _machine_required_params.OS = ""; _machine_required_params.nb_node = -1; @@ -150,11 +151,11 @@ Launcher::Job::add_out_file(const std::string & file) } void -Launcher::Job::setMaximumDuringTime(const std::string & maximum_during_time) +Launcher::Job::setMaximumDuration(const std::string & maximum_duration) { - checkMaximumDuringTime(maximum_during_time); - _maximum_during_time_in_second = convertMaximumDuringTime(maximum_during_time); - _maximum_during_time = maximum_during_time; + checkMaximumDuration(maximum_duration); + _maximum_duration_in_second = convertMaximumDuration(maximum_duration); + _maximum_duration = maximum_duration; } void @@ -201,9 +202,9 @@ Launcher::Job::get_out_files() } std::string -Launcher::Job::getMaximumDuringTime() +Launcher::Job::getMaximumDuration() { - return _maximum_during_time; + return _maximum_duration; } machineParams @@ -219,10 +220,10 @@ Launcher::Job::getQueue() } void -Launcher::Job::checkMaximumDuringTime(const std::string & maximum_during_time) +Launcher::Job::checkMaximumDuration(const std::string & maximum_duration) { std::string result(""); - std::string edt_value = maximum_during_time; + std::string edt_value = maximum_duration; if (edt_value != "") { std::string begin_edt_value = edt_value.substr(0, 2); std::string mid_edt_value = edt_value.substr(2, 1); @@ -231,20 +232,20 @@ Launcher::Job::checkMaximumDuringTime(const std::string & maximum_during_time) long value; std::istringstream iss(begin_edt_value); if (!(iss >> value)) { - result = "[Launcher::Job::checkExpectedDuringTime] Error on definition ! : " + edt_value; + result = "[Launcher::Job::checkExpectedDuration] Error on definition ! : " + edt_value; } else if (value < 0) { - result = "[Launcher::Job::checkExpectedDuringTime] Error on definition time is negative ! : " + value; + result = "[Launcher::Job::checkExpectedDuration] Error on definition time is negative ! : " + value; } std::istringstream iss_2(end_edt_value); if (!(iss_2 >> value)) { - result = "[Launcher::Job::checkExpectedDuringTime] Error on definition ! : " + edt_value; + result = "[Launcher::Job::checkExpectedDuration] Error on definition ! : " + edt_value; } else if (value < 0) { - result = "[Launcher::Job::checkExpectedDuringTime] Error on definition time is negative ! : " + value; + result = "[Launcher::Job::checkExpectedDuration] Error on definition time is negative ! : " + value; } if (mid_edt_value != ":") { - result = "[Launcher::Job::checkExpectedDuringTime] Error on definition ! :" + edt_value; + result = "[Launcher::Job::checkExpectedDuration] Error on definition ! :" + edt_value; } } if (result != "") @@ -263,7 +264,7 @@ Launcher::Job::checkMachineRequiredParams(const machineParams & machine_required } long -Launcher::Job::convertMaximumDuringTime(const std::string & edt) +Launcher::Job::convertMaximumDuration(const std::string & edt) { long hh, mm, ret; @@ -416,8 +417,8 @@ Launcher::Job::common_job_params() } // Time - if (_maximum_during_time_in_second != -1) - params[MAXWALLTIME] = _maximum_during_time_in_second; + if (_maximum_duration_in_second != -1) + params[MAXWALLTIME] = _maximum_duration_in_second; // Queue if (_queue != "") diff --git a/src/Launcher/Launcher_Job.hxx b/src/Launcher/Launcher_Job.hxx index 1c719e0ca..5c74b1a21 100644 --- a/src/Launcher/Launcher_Job.hxx +++ b/src/Launcher/Launcher_Job.hxx @@ -66,7 +66,7 @@ namespace Launcher void setResultDirectory(const std::string & result_directory); void add_in_file(const std::string & file); void add_out_file(const std::string & file); - void setMaximumDuringTime(const std::string & maximum_during_time); + void setMaximumDuration(const std::string & maximum_duration); void setMachineRequiredParams(const machineParams & machine_required_params); void setQueue(const std::string & queue); @@ -75,18 +75,18 @@ namespace Launcher std::string getResultDirectory(); const std::list & get_in_files(); const std::list & get_out_files(); - std::string getMaximumDuringTime(); + std::string getMaximumDuration(); machineParams getMachineRequiredParams(); std::string getQueue(); std::string updateJobState(); // Checks - void checkMaximumDuringTime(const std::string & maximum_during_time); + void checkMaximumDuration(const std::string & maximum_duration); void checkMachineRequiredParams(const machineParams & machine_required_params); // Helps - long convertMaximumDuringTime(const std::string & maximum_during_time); + long convertMaximumDuration(const std::string & maximum_duration); std::string getLaunchDate(); // Abstract class @@ -96,6 +96,7 @@ namespace Launcher int _number; std::string _state; + std::string _launch_date; ParserResourcesType _machine_definition; @@ -104,8 +105,8 @@ namespace Launcher std::string _result_directory; std::list _in_files; std::list _out_files; - std::string _maximum_during_time; - long _maximum_during_time_in_second; + std::string _maximum_duration; + long _maximum_duration_in_second; machineParams _machine_required_params; std::string _queue; diff --git a/src/Launcher/Launcher_Job_Command.cxx b/src/Launcher/Launcher_Job_Command.cxx index 464581720..aa8d92811 100644 --- a/src/Launcher/Launcher_Job_Command.cxx +++ b/src/Launcher/Launcher_Job_Command.cxx @@ -84,14 +84,7 @@ Launcher::Job_Command::update_job() params[INFILE] += Batch::Couple(local_file, remote_file); } - // log - std::string launch_date = getLaunchDate(); - std::string log_file = "command_" + launch_date + ".log"; - std::string log_local_file = _result_directory + "/" + log_file; - std::string log_remote_file = _work_directory + "/" + log_file; - params[OUTFILE] += Batch::Couple(log_local_file, log_remote_file); - - params[EXECUTABLE] = buildCommandScript(params, launch_date); + params[EXECUTABLE] = buildCommandScript(params, _launch_date); _batch_job->setParametre(params); #endif } @@ -120,9 +113,9 @@ Launcher::Job_Command::buildCommandScript(Batch::Parametre params, std::string l if (_env_file != "") { std::string::size_type last = _env_file.find_last_of("/"); - launch_script_stream << "source " << _env_file.substr(last+1) << std::endl; + launch_script_stream << "source ./" << _env_file.substr(last+1) << std::endl; } - launch_script_stream << "./" << command_file_name << " > command_" << launch_date << ".log 2>&1" << std::endl; + launch_script_stream << "./" << command_file_name << " > " << work_directory <<"/logs/command_" << launch_date << ".log 2>&1" << std::endl; // Return launch_script_stream.flush(); diff --git a/src/Launcher/Launcher_Job_YACSFile.cxx b/src/Launcher/Launcher_Job_YACSFile.cxx index 511e5c306..3150c0342 100644 --- a/src/Launcher/Launcher_Job_YACSFile.cxx +++ b/src/Launcher/Launcher_Job_YACSFile.cxx @@ -91,10 +91,9 @@ Launcher::Job_YACSFile::buildSalomeCouplingScript(Batch::Parametre params) std::string::size_type p1 = _yacs_file.find_last_of("/"); std::string::size_type p2 = _yacs_file.find_last_of("."); std::string yacs_file_name = _yacs_file.substr(p1+1,p2-p1-1); - std::string launch_date = getLaunchDate(); - std::string launch_date_port_file = launch_date; - std::string launch_script = "/tmp/runSalome_" + yacs_file_name + "_" + launch_date + ".sh"; + std::string launch_date_port_file = _launch_date; + std::string launch_script = "/tmp/runSalome_" + yacs_file_name + "_" + _launch_date + ".sh"; std::ofstream launch_script_stream; launch_script_stream.open(launch_script.c_str(), std::ofstream::out); @@ -107,7 +106,7 @@ Launcher::Job_YACSFile::buildSalomeCouplingScript(Batch::Parametre params) std::string machine_protocol = "ssh"; if (_machine_definition.Protocol == rsh) machine_protocol = "rsh"; - launch_script_stream << "CATALOG_FILE=" << work_directory << "/CatalogResources_" << launch_date << ".xml" << std::endl; + launch_script_stream << "CATALOG_FILE=" << work_directory << "/CatalogResources_" << _launch_date << ".xml" << std::endl; launch_script_stream << "export USER_CATALOG_RESOURCES_FILE=" << "$CATALOG_FILE" << std::endl; launch_script_stream << "echo '' > $CATALOG_FILE" << std::endl; @@ -123,7 +122,7 @@ Launcher::Job_YACSFile::buildSalomeCouplingScript(Batch::Parametre params) launch_script_stream << "echo '' >> $CATALOG_FILE" << std::endl; // Launch SALOME with an appli - launch_script_stream << _machine_definition.AppliPath << "/runAppli --terminal --ns-port-log=" << launch_date_port_file << " > logs/salome_" << launch_date << ".log 2>&1" << std::endl; + launch_script_stream << _machine_definition.AppliPath << "/runAppli --terminal --ns-port-log=" << launch_date_port_file << " > logs/salome_" << _launch_date << ".log 2>&1" << std::endl; launch_script_stream << "current=0\n" << "stop=20\n" << "while ! test -f " << _machine_definition.AppliPath << "/" << launch_date_port_file << "\n" @@ -136,7 +135,7 @@ Launcher::Job_YACSFile::buildSalomeCouplingScript(Batch::Parametre params) << " fi\n" << "done\n" << "appli_port=`cat " << _machine_definition.AppliPath << "/" << launch_date_port_file << "`\n"; - launch_script_stream << _machine_definition.AppliPath << "/runSession -p $appli_port driver " << yacs_file_name << ".xml > logs/yacs_" << launch_date << ".log 2>&1" << std::endl; + launch_script_stream << _machine_definition.AppliPath << "/runSession -p $appli_port driver " << yacs_file_name << ".xml > logs/yacs_" << _launch_date << ".log 2>&1" << std::endl; launch_script_stream << _machine_definition.AppliPath << "/runSession -p $appli_port shutdownSalome.py" << std::endl; // Return diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index 761ef3912..3b5a30bf6 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -251,8 +251,8 @@ SALOME_Launcher::createJob(const Engines::JobParameters & job_parameters) // Expected During Time try { - std::string maximum_during_time = job_parameters.maximum_during_time.in(); - new_job->setMaximumDuringTime(maximum_during_time); + std::string maximum_duration = job_parameters.maximum_duration.in(); + new_job->setMaximumDuration(maximum_duration); } catch(const LauncherException &ex){ INFOS(ex.msg.c_str()); -- 2.39.2