From f16fcdec7134b56f8f7f83247b31904bcebd4f1e Mon Sep 17 00:00:00 2001 From: ribes Date: Fri, 13 Nov 2009 15:05:28 +0000 Subject: [PATCH] Test with new ePBS - Command and YACS File ok --- src/Launcher/Launcher.cxx | 23 +++++++++-------- src/Launcher/Launcher_Job.cxx | 8 +++--- src/Launcher/Launcher_Job_Command.cxx | 34 ++++++++++++++++++++++++-- src/Launcher/Launcher_Job_YACSFile.cxx | 8 ------ 4 files changed, 48 insertions(+), 25 deletions(-) diff --git a/src/Launcher/Launcher.cxx b/src/Launcher/Launcher.cxx index 56082175e..405a5d910 100644 --- a/src/Launcher/Launcher.cxx +++ b/src/Launcher/Launcher.cxx @@ -511,17 +511,10 @@ Batch::BatchManager_eClient *Launcher_cpp::FactoryBatchManager(ParserResourcesTy case prun: mpi = "prun"; break; - case nompi: - std::cerr << "No MPI detected - switch to single machine case" << std::endl; - if (protocol == Batch::SSH) - params.Batch = ssh_batch; - else - throw LauncherException("you must specified an mpi implementation for batch manager or a ssh computer"); - break; default: - throw LauncherException("unknown mpi implementation"); - break; - } + mpi = "nompi"; + } + #if defined(_DEBUG_) || defined(_DEBUG) cerr << "Instanciation of batch manager" << endl; #endif @@ -558,8 +551,8 @@ Batch::BatchManager_eClient *Launcher_cpp::FactoryBatchManager(ParserResourcesTy } return (*fact)(hostname.c_str(), protocol, mpi.c_str()); #else -M@M@ throw LauncherException("Method Launcher_cpp::FactoryBatchManager is not available " - "(libBatch was not present at compilation time)"); + throw LauncherException("Method Launcher_cpp::FactoryBatchManager is not available " + "(libBatch was not present at compilation time)"); #endif } @@ -1059,6 +1052,12 @@ Launcher_cpp::createJob(Launcher::Job * new_job) delete new_job; throw ex; } + catch(const Batch::EmulationException &ex) + { + LAUNCHER_INFOS("Error during creation of the batch manager of the resource, mess: " << ex.message); + delete new_job; + throw LauncherException(ex.message); + } } // Final step - add job to the jobs map diff --git a/src/Launcher/Launcher_Job.cxx b/src/Launcher/Launcher_Job.cxx index 0f3b5a874..d45b8be51 100644 --- a/src/Launcher/Launcher_Job.cxx +++ b/src/Launcher/Launcher_Job.cxx @@ -283,15 +283,17 @@ Launcher::Job::updateJobState() LAUNCHER_MESSAGE("State received is: " << par[STATE].str()); // Patch until new LIBBATCH version - // eSSH Client - if (par[STATE].str() == "Running") + // eSSH Client and ePBS Client + if (par[STATE].str() == "Running" or par[STATE].str() == "E" or par[STATE].str() == "R") _state = "RUNNING"; else if (par[STATE].str() == "Stopped") _state = "PAUSED"; - else if (par[STATE].str() == "Done") + else if (par[STATE].str() == "Done" or par[STATE].str() == "U") _state = "FINISHED"; else if (par[STATE].str() == "Dead") _state = "ERROR"; + else if (par[STATE].str() == "Q") + _state = "QUEUED"; } #endif return _state; diff --git a/src/Launcher/Launcher_Job_Command.cxx b/src/Launcher/Launcher_Job_Command.cxx index d288f1df4..13e5634b0 100644 --- a/src/Launcher/Launcher_Job_Command.cxx +++ b/src/Launcher/Launcher_Job_Command.cxx @@ -58,6 +58,32 @@ Launcher::Job_Command::update_job() #ifdef WITH_LIBBATCH Batch::Parametre params = common_job_params(); + // Files + // local file -> If file is not an absolute path, we apply _local_directory + // remote file -> get only file name from _in_files + + // Copy command file + std::string local_file; + if (_command.substr(0, 1) == std::string("/")) + local_file = _command; + else + local_file = _local_directory + "/" + _command; + size_t found = _command.find_last_of("/"); + std::string remote_file = _work_directory + "/" + _command.substr(found+1); + params[INFILE] += Batch::Couple(local_file, remote_file); + + // Copy env file + if (_env_file != "") + { + if (_env_file.substr(0, 1) == std::string("/")) + local_file = _env_file; + else + local_file = _local_directory + "/" + _env_file; + found = _env_file.find_last_of("/"); + remote_file = _work_directory + "/" + _env_file.substr(found+1); + params[INFILE] += Batch::Couple(local_file, remote_file); + } + // log std::string log_file = "command.log"; std::string log_local_file = _result_directory + "/" + log_file; @@ -80,6 +106,7 @@ Launcher::Job_Command::buildCommandScript(Batch::Parametre params) std::string::size_type p1 = _command.find_last_of("/"); std::string::size_type p2 = _command.find_last_of("."); std::string command_name = _command.substr(p1+1,p2-p1-1); + std::string command_file_name = _command.substr(p1+1); time_t rawtime; time(&rawtime); @@ -102,8 +129,11 @@ Launcher::Job_Command::buildCommandScript(Batch::Parametre params) launch_script_stream << "#! /bin/sh -f" << std::endl; launch_script_stream << "cd " << work_directory << std::endl; if (_env_file != "") - launch_script_stream << "source " << _env_file << std::endl; - launch_script_stream << _command << " > command.log 2>&1" << std::endl; + { + std::string::size_type last = _env_file.find_last_of("/"); + launch_script_stream << "source " << _env_file.substr(last+1) << std::endl; + } + launch_script_stream << "./" << command_file_name << " > command.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 be097b125..b685cb2a0 100644 --- a/src/Launcher/Launcher_Job_YACSFile.cxx +++ b/src/Launcher/Launcher_Job_YACSFile.cxx @@ -75,13 +75,6 @@ Launcher::Job_YACSFile::update_job() std::string remote_file = _work_directory + "/" + _yacs_file.substr(found+1); params[INFILE] += Batch::Couple(local_file, remote_file); - // logs - // local file -> If result_directory is not defined, we use HOME environnement - std::string log_directory = "logs"; - std::string log_local_file = _result_directory + "/" + log_directory; - std::string log_remote_file = _work_directory + "/" + log_directory; - params[OUTFILE] += Batch::Couple(log_local_file, log_remote_file); - params[EXECUTABLE] = buildSalomeCouplingScript(params); // Add in files -> yacs_file and launch_script @@ -121,7 +114,6 @@ Launcher::Job_YACSFile::buildSalomeCouplingScript(Batch::Parametre params) // Begin of script launch_script_stream << "#! /bin/sh -f" << std::endl; launch_script_stream << "cd " << work_directory << std::endl; - launch_script_stream << "mkdir logs" << std::endl; launch_script_stream << "export SALOME_TMP_DIR=" << work_directory << "/logs" << std::endl; // -- Generates Catalog Resources -- 2.39.2