static const string STARTDATE;
static const string STATE;
static const string TEXT;
- static const string TMPDIR;
static const string USEDCPUTIME;
static const string USEDDISKSIZE;
static const string USEDRAMSIZE;
static const string USEDWALLTIME;
static const string USER;
+ static const string WORKDIR;
protected:
// map interne servant a controler le type
l'utilisateur de la raison qui maintient un job dans un etat suspendu ou
qui l'empeche de s'executer.
-@item TMPDIR : type STRING
-
-Un chemin d'acces absolu a un repertoire qui sera cree au demarrage du
-job et qui isolera le job des autres travaux en cours d'execution sur la
-meme machine.
-
@item USEDCPUTIME : type LONG
Le temps de calcul (@i{CPU time}) en secondes reellement consomme par le job.
sur la machine d'execution. Ce parametre est utile lorsque l'utilisateur
possede des comptes differents sur les machines sur lequel il soumet et calcule.
+@item WORKDIR : type STRING
+
+Un chemin d'acces a un repertoire sur la machine d'execution qui sera cree au
+demarrage du job et qui isolera le job des autres travaux en cours d'execution
+sur la meme machine.
+
@end itemize
#include <libgen.h>
#endif
-#include "Batch_Constants.hxx"
+#include <Batch_Constants.hxx>
+#include <Batch_NotYetImplementedException.hxx>
+#include <Batch_Utils.hxx>
+
#include "Batch_BatchManager_eCCC.hxx"
#include "Batch_JobInfo_eCCC.hxx"
BatchManager_eCCC::BatchManager_eCCC(const FactBatchManager * parent, const char * host,
const char * username,
CommunicationProtocolType protocolType, const char * mpiImpl)
- : BatchManager(parent, host),
- BatchManager_eClient(parent, host, username, protocolType, mpiImpl)
+ : BatchManager(parent, host, username, protocolType, mpiImpl)
{
// Nothing to do
}
// Methode pour le controle des jobs : soumet un job au gestionnaire
const JobId BatchManager_eCCC::submitJob(const Job & job)
{
- int status;
Parametre params = job.getParametre();
const std::string workDir = params[WORKDIR];
const string fileToExecute = params[EXECUTABLE];
buildBatchScript(job);
cerr << "Script envoye" << endl;
- // define name of log file (local)
- string logFile = generateTemporaryFileName("CCC-submitlog");
-
// define command to submit batch
string subCommand = string("bash -l -c \\\"cd ") + workDir + "; ccc_msub " + fileNameToExecute + "_Batch.sh\\\"";
string command = _protocol.getExecCommand(subCommand, _hostname, _username);
- command += " > ";
- command += logFile;
command += " 2>&1";
cerr << command.c_str() << endl;
- status = system(command.c_str());
- if(status)
- {
- ifstream error_message(logFile.c_str());
- std::string mess;
- std::string temp;
- while(std::getline(error_message, temp))
- mess += temp;
- error_message.close();
- throw EmulationException("Error of connection on remote host, error was: " + mess);
- }
- // read id of submitted job in log file
- ifstream idfile(logFile.c_str());
+ // submit job
+ string output;
+ int status = Utils::getCommandOutput(command, output);
+ cout << output;
+ if (status != 0) throw RunTimeException("Can't submit job, error was: " + output);
+
+ // find id of submitted job in output
+ istringstream idfile(output);
string sidj;
idfile >> sidj;
idfile >> sidj;
idfile >> sidj;
idfile >> sidj;
- idfile.close();
if (sidj.size() == 0)
- throw EmulationException("Error in the submission of the job on the remote host");
+ throw RunTimeException("Error in the submission of the job on the remote host");
JobId id(this, sidj);
return id;
cerr << command.c_str() << endl;
status = system(command.c_str());
if (status)
- throw EmulationException("Error of connection on remote host");
+ throw RunTimeException("Error of connection on remote host");
cerr << "jobId = " << ref << "killed" << endl;
}
// Methode pour le controle des jobs : suspend un job en file d'attente
void BatchManager_eCCC::holdJob(const JobId & jobid)
{
- throw EmulationException("Not yet implemented");
+ throw NotYetImplementedException("BatchManager_eCCC::holdJob");
}
// Methode pour le controle des jobs : relache un job suspendu
void BatchManager_eCCC::releaseJob(const JobId & jobid)
{
- throw EmulationException("Not yet implemented");
+ throw NotYetImplementedException("BatchManager_eCCC::releaseJob");
}
// Methode pour le controle des jobs : modifie un job en file d'attente
void BatchManager_eCCC::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env)
{
- throw EmulationException("Not yet implemented");
+ throw NotYetImplementedException("BatchManager_eCCC::alterJob");
}
// Methode pour le controle des jobs : modifie un job en file d'attente
istringstream iss(jobid.getReference());
iss >> id;
- // define name of log file (local)
- string logFile = generateTemporaryFileName(string("CCC-querylog-id") + jobid.getReference());
-
// define command to query batch
string subCommand = string("bash -l -c \\\"bjobs ") + iss.str() + string("\\\"");
string command = _protocol.getExecCommand(subCommand, _hostname, _username);
- command += " > ";
- command += logFile;
cerr << command.c_str() << endl;
- int status = system(command.c_str());
+
+ string output;
+ int status = Utils::getCommandOutput(command, output);
if (status)
- throw EmulationException("Error of connection on remote host");
+ throw RunTimeException("Error of connection on remote host");
- JobInfo_eCCC ji = JobInfo_eCCC(id,logFile);
+ JobInfo_eCCC ji = JobInfo_eCCC(id, output);
return ji;
}
// Methode pour le controle des jobs : teste si un job est present en machine
bool BatchManager_eCCC::isRunning(const JobId & jobid)
{
- throw EmulationException("Not yet implemented");
+ throw NotYetImplementedException("BatchManager_eCCC::isRunning");
}
void BatchManager_eCCC::buildBatchScript(const Job & job)
if (params.find(WORKDIR) != params.end())
workDir = params[WORKDIR].str();
else
- throw EmulationException("params[WORKDIR] is not defined ! Please defined it, cannot submit this job");
+ throw RunTimeException("params[WORKDIR] is not defined ! Please defined it, cannot submit this job");
if (params.find(EXECUTABLE) != params.end())
fileToExecute = params[EXECUTABLE].str();
else
- throw EmulationException("params[EXECUTABLE] is not defined ! Please defined it, cannot submit this job");
+ throw RunTimeException("params[EXECUTABLE] is not defined ! Please defined it, cannot submit this job");
// Optional parameters
if (params.find(NBPROC) != params.end())
// Create batch submit file
ofstream tempOutputFile;
- std::string TmpFileName = createAndOpenTemporaryFile("LSF-script", tempOutputFile);
+ std::string TmpFileName = Utils::createAndOpenTemporaryFile("LSF-script", tempOutputFile);
tempOutputFile << "#!/bin/bash" << endl ;
if (queue != "")
workDir + "/" + rootNameToExecute + "_Batch.sh",
_hostname, _username);
if (status)
- throw EmulationException("Error of connection on remote host");
+ throw RunTimeException("Error of connection on remote host");
#endif
std::string BatchManager_eCCC::getHomeDir(std::string tmpdir)
{
std::string home;
- std::string filelogtemp = generateTemporaryFileName("gethomedir");
string subCommand = string("echo ");
subCommand += tmpdir;
- string command = _protocol.getExecCommand(subCommand, _hostname, _username) + " > " + filelogtemp;
+ string command = _protocol.getExecCommand(subCommand, _hostname, _username);
cerr << command.c_str() << endl;
- int status = system(command.c_str());
+
+ string output;
+ int status = Utils::getCommandOutput(command, output);
+
if (status)
- throw EmulationException("Error of launching home command on remote host");
+ throw RunTimeException("Error of launching home command on remote host");
- std::ifstream file_home(filelogtemp.c_str());
+ std::istringstream file_home(output);
std::getline(file_home, home);
- file_home.close();
return home;
}
#include "Batch_JobId.hxx"
#include "Batch_JobInfo.hxx"
#include "Batch_FactBatchManager.hxx"
-#include "Batch_BatchManager_eClient.hxx"
+#include "Batch_BatchManager.hxx"
namespace Batch {
- class BATCH_EXPORT BatchManager_eCCC : public BatchManager_eClient
+ class BATCH_EXPORT BatchManager_eCCC : public BatchManager
{
public:
// Constructeur et destructeur
static FactBatchManager_eCCC sFBM_eCCC;
// Constructeur
- FactBatchManager_eCCC::FactBatchManager_eCCC() : FactBatchManager_eClient("eCCC")
+ FactBatchManager_eCCC::FactBatchManager_eCCC() : FactBatchManager("CCC")
{
// Nothing to do
}
// Nothing to do
}
- // Functor
- BatchManager * FactBatchManager_eCCC::operator() (const char * hostname) const
- {
- // MESSAGE("Building new BatchManager_CCC on host '" << hostname << "'");
- return new BatchManager_eCCC(this, hostname);
- }
-
- BatchManager_eClient * FactBatchManager_eCCC::operator() (const char * hostname,
- const char * username,
- CommunicationProtocolType protocolType,
- const char * mpiImpl,
- int nb_proc_per_node) const
+ BatchManager * FactBatchManager_eCCC::operator() (const char * hostname,
+ const char * username,
+ CommunicationProtocolType protocolType,
+ const char * mpiImpl,
+ int nb_proc_per_node) const
{
// MESSAGE("Building new BatchManager_CCC on host '" << hostname << "'");
return new BatchManager_eCCC(this, hostname, username, protocolType, mpiImpl);
#define _FACTBATCHMANAGER_eCCC_H_
#include "Batch_Defines.hxx"
-#include "Batch_BatchManager_eClient.hxx"
-#include "Batch_FactBatchManager_eClient.hxx"
+#include "Batch_BatchManager.hxx"
+#include "Batch_FactBatchManager.hxx"
namespace Batch {
- class BATCH_EXPORT FactBatchManager_eCCC : public FactBatchManager_eClient
+ class BATCH_EXPORT FactBatchManager_eCCC : public FactBatchManager
{
public:
// Constructeur et destructeur
FactBatchManager_eCCC();
virtual ~FactBatchManager_eCCC();
- virtual BatchManager * operator() (const char * hostname) const;
- virtual BatchManager_eClient * operator() (const char * hostname,
- const char * username,
- CommunicationProtocolType protocolType,
- const char * mpiImpl,
- int nb_proc_per_node = 1) const;
-
- protected:
-
- private:
-
+ virtual BatchManager * operator() (const char * hostname,
+ const char * username,
+ CommunicationProtocolType protocolType,
+ const char * mpiImpl,
+ int nb_proc_per_node = 1) const;
};
}
#include <cstdio>
#include <iostream>
-#include <fstream>
#include <sstream>
#include "Batch_Constants.hxx"
#include "Batch_Parametre.hxx"
#include "Batch_Environnement.hxx"
-#include "Batch_RunTimeException.hxx"
-#include "Batch_APIInternalFailureException.hxx"
#include "Batch_JobInfo_eCCC.hxx"
using namespace std;
// Constructeurs
- JobInfo_eCCC::JobInfo_eCCC(int id, string logFile) : JobInfo()
+ JobInfo_eCCC::JobInfo_eCCC(int id, string output) : JobInfo()
{
// On remplit les membres _param et _env
ostringstream oss;
// read status of job in log file
char line[128];
- ifstream fp(logFile.c_str(),ios::in);
+ istringstream fp(output);
fp.getline(line,80,'\n');
string sjobid, username, status;
public:
// Constructeurs et destructeur
JobInfo_eCCC() : _running(false) {};
- JobInfo_eCCC(int id,std::string logFile);
+ JobInfo_eCCC(int id,std::string output);
virtual ~JobInfo_eCCC();
// Constructeur par recopie
add_subdirectory (LSF)
add_subdirectory (PBS)
add_subdirectory (SGE)
-add_subdirectory (SSH)
+#add_subdirectory (SSH)
add_subdirectory (LoadLeveler)
add_subdirectory (Slurm)
#include "Batch_InvalidArgumentException.hxx"
#include "Batch_FactBatchManager.hxx"
#include "Batch_BatchManager.hxx"
+#include "Batch_Utils.hxx"
#ifdef WIN32
#define sleep(seconds) Sleep((seconds)*1000)
namespace Batch {
- // Constructeur
-// BatchManager::BatchManager(string host) throw(InvalidArgumentException) : _hostname(host), jobid_map()
-// {
-// // On verifie que le hostname est correct
-// if (!gethostbyname(_hostname.c_str())) { // hostname unknown from network
-// string msg = "hostname \"";
-// msg += _hostname;
-// msg += "\" unknown from the network";
-// throw InvalidArgumentException(msg.c_str());
-// }
-// }
- BatchManager::BatchManager(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException) : _hostname(host), jobid_map(), _parent(parent)
+ BatchManager::BatchManager(const Batch::FactBatchManager * parent, const char* host,
+ const char * username,
+ CommunicationProtocolType protocolType, const char* mpiImpl)
+ : _hostname(host), jobid_map(), _parent(parent),
+ _protocol(CommunicationProtocol::getInstance(protocolType)),
+ _username(username), _mpiImpl(FactoryMpiImpl(mpiImpl))
{
- /*
-#ifdef WIN32
- WSADATA wsaData;
- WSAStartup(MAKEWORD(2, 2), &wsaData); // Initialize Winsock
-#endif
-
- // On verifie que le hostname est correct
- struct hostent* res = gethostbyname(_hostname.c_str());
-
-#ifdef WIN32
- WSACleanup(); // Finalize Winsock
-#endif
-
- if (!res) { // hostname unknown from network
- string msg = "hostname \"";
- msg += _hostname;
- msg += "\" unknown from the network";
- throw InvalidArgumentException(msg.c_str());
- }
- */
}
+
// Destructeur
BatchManager::~BatchManager()
{
- // Nothing to do
+ delete _mpiImpl;
}
string BatchManager::__repr__() const
return state;
}
+
+ void BatchManager::exportInputFiles(const Job& job)
+ {
+ int status;
+ Parametre params = job.getParametre();
+ const Versatile & V = params[INFILE];
+ Versatile::const_iterator Vit;
+
+ // Create remote directories
+ string logdir = string(params[WORKDIR]) + "/logs";
+ status = _protocol.makeDirectory(logdir, _hostname, _username);
+ if (status) {
+ std::ostringstream oss;
+ oss << "Cannot create directory " << logdir << " on host " << _hostname;
+ oss << ". Return status is " << status;
+ throw RunTimeException(oss.str());
+ }
+
+ // Copy the file to execute into the remote working directory
+ string executeFile = params[EXECUTABLE];
+ if (executeFile.size() != 0) {
+ status = _protocol.copyFile(executeFile, "", "",
+ params[WORKDIR], _hostname, _username);
+ if (status) {
+ std::ostringstream oss;
+ oss << "Cannot copy file " << executeFile << " on host " << _hostname;
+ oss << ". Return status is " << status;
+ throw RunTimeException(oss.str());
+ }
+
+#ifdef WIN32
+ // On Windows, we make the remote file executable afterward because
+ // pscp does not preserve access permissions on files
+
+ string remoteExec = string(params[EXECUTABLE]);
+ remoteExec = remoteExec.substr(remoteExec.rfind("\\") + 1, remoteExec.length());
+ remoteExec = string(params[WORKDIR]) + "/" + executable;
+
+ string subCommand = string("chmod u+x ") + remoteExec;
+ string command = _protocol.getExecCommand(subCommand, _hostname, _username);
+ cerr << command.c_str() << endl;
+ status = system(command.c_str());
+ if (status) {
+ std::ostringstream oss;
+ oss << "Cannot change permissions of file " << remoteExec << " on host " << _hostname;
+ oss << ". Return status is " << status;
+ throw RunTimeException(oss.str());
+ }
+#endif
+ }
+
+ // Copy input files into the remote working directory
+ for (Vit=V.begin() ; Vit!=V.end() ; Vit++) {
+ CoupleType cpt = *static_cast< CoupleType * >(*Vit);
+ Couple inputFile = cpt;
+ status = _protocol.copyFile(inputFile.getLocal(), "", "",
+ inputFile.getRemote(), _hostname, _username);
+ if (status) {
+ std::ostringstream oss;
+ oss << "Cannot copy file " << inputFile.getLocal() << " on host " << _hostname;
+ oss << ". Return status is " << status;
+ throw RunTimeException(oss.str());
+ }
+ }
+
+ }
+
+ void BatchManager::importOutputFiles( const Job & job, const string directory )
+ {
+ Parametre params = job.getParametre();
+ const Versatile & V = params[OUTFILE];
+ Versatile::const_iterator Vit;
+
+ // Create local result directory
+ int status = CommunicationProtocol::getInstance(SH).makeDirectory(directory, "", "");
+ if (status) {
+ string mess("Directory creation failed. Status is :");
+ ostringstream status_str;
+ status_str << status;
+ mess += status_str.str();
+ cerr << mess << endl;
+ }
+
+ for(Vit=V.begin(); Vit!=V.end(); Vit++) {
+ CoupleType cpt = *static_cast< CoupleType * >(*Vit);
+ Couple outputFile = cpt;
+ string localPath = outputFile.getLocal();
+ if (!Utils::isAbsolutePath(localPath)) {
+ localPath = directory + "/" + localPath;
+ }
+ status = _protocol.copyFile(outputFile.getRemote(), _hostname, _username,
+ localPath, "", "");
+ if (status) {
+ // Try to get what we can (logs files)
+ // throw BatchException("Error of connection on remote host");
+ std::string mess("Copy command failed ! status is :");
+ ostringstream status_str;
+ status_str << status;
+ mess += status_str.str();
+ cerr << mess << endl;
+ }
+ }
+
+ // Copy logs
+ status = _protocol.copyFile(string(params[WORKDIR]) + string("/logs"), _hostname, _username,
+ directory, "", "");
+ if (status) {
+ std::string mess("Copy logs directory failed ! status is :");
+ ostringstream status_str;
+ status_str << status;
+ mess += status_str.str();
+ cerr << mess << endl;
+ }
+
+ }
+
+ bool BatchManager::importDumpStateFile( const Job & job, const string directory )
+ {
+ Parametre params = job.getParametre();
+
+ // Create local result directory
+ int status = CommunicationProtocol::getInstance(SH).makeDirectory(directory, "", "");
+ if (status) {
+ string mess("Directory creation failed. Status is :");
+ ostringstream status_str;
+ status_str << status;
+ mess += status_str.str();
+ cerr << mess << endl;
+ }
+
+ bool ret = true;
+ status = _protocol.copyFile(string(params[WORKDIR]) + string("/dumpState*.xml"), _hostname, _username,
+ directory, "", "");
+ if (status) {
+ // Try to get what we can (logs files)
+ // throw BatchException("Error of connection on remote host");
+ std::string mess("Copy command failed ! status is :");
+ ostringstream status_str;
+ status_str << status;
+ mess += status_str.str();
+ cerr << mess << endl;
+ ret = false;
+ }
+ return ret;
+ }
+
+ MpiImpl *BatchManager::FactoryMpiImpl(string mpiImpl)
+ {
+ if(mpiImpl == "lam")
+ return new MpiImpl_LAM();
+ else if(mpiImpl == "mpich1")
+ return new MpiImpl_MPICH1();
+ else if(mpiImpl == "mpich2")
+ return new MpiImpl_MPICH2();
+ else if(mpiImpl == "openmpi")
+ return new MpiImpl_OPENMPI();
+ else if(mpiImpl == "ompi")
+ return new MpiImpl_OMPI();
+ else if(mpiImpl == "slurm")
+ return new MpiImpl_SLURM();
+ else if(mpiImpl == "prun")
+ return new MpiImpl_PRUN();
+ else if(mpiImpl == "nompi")
+ return NULL;
+ else{
+ ostringstream oss;
+ oss << mpiImpl << " : not yet implemented";
+ throw RunTimeException(oss.str().c_str());
+ }
+ }
+
+ const CommunicationProtocol & BatchManager::getProtocol() const
+ {
+ return _protocol;
+ }
+
}
#include "Batch_JobId.hxx"
#include "Batch_JobInfo.hxx"
#include "Batch_InvalidArgumentException.hxx"
+#include "Batch_CommunicationProtocol.hxx"
+#include "Batch_MpiImpl.hxx"
namespace Batch {
{
public:
// Constructeur et destructeur
- //BatchManager(std::string host="localhost") throw(InvalidArgumentException); // connexion a la machine host
- BatchManager(const Batch::FactBatchManager * parent, const char * host="localhost") throw(InvalidArgumentException); // connexion a la machine host
+ BatchManager(const Batch::FactBatchManager * parent, const char * host = "localhost",
+ const char * username = "",
+ CommunicationProtocolType protocolType = SSH, const char * mpiImpl = "nompi");
virtual ~BatchManager();
virtual std::string __repr__() const;
virtual const Batch::JobId addJob(const Batch::Job & job, const std::string reference) = 0; // ajoute un nouveau job sans le soumettre
virtual std::string waitForJobEnd(const Batch::JobId & jobid, long timeout = -1,
long initSleepTime = 1, long maxSleepTime = 600);
+ virtual void importOutputFiles( const Job & job, const std::string directory );
+ bool importDumpStateFile( const Job & job, const std::string directory );
+
+ // Get the underlying communication protocol
+ const CommunicationProtocol & getProtocol() const;
protected:
std::string _hostname; // serveur ou tourne le BatchManager
// std::map< const std::string, const Batch::JobId * > jobid_map; // table des jobs deja soumis
std::map< std::string, const Batch::JobId * > jobid_map; // table des jobs deja soumis
const Batch::FactBatchManager * _parent;
+ const CommunicationProtocol & _protocol; // protocol to access _hostname
+ const std::string _username; // username to access _hostname
+ MpiImpl *_mpiImpl; // Mpi implementation to launch executable in batch script
+
+ MpiImpl* FactoryMpiImpl(std::string mpiImpl);
+ void exportInputFiles(const Job & job);
private:
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
-* BatchManager_eLSF.cxx : emulation of LSF client
-*
-* Auteur : Bernard SECHER - CEA DEN
-* Mail : mailto:bernard.secher@cea.fr
-* Date : Thu Apr 24 10:17:22 2008
-* Projet : PAL Salome
-*
-*/
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <ctime>
-#include <iostream>
-#include <fstream>
-#include <sstream>
-
-#ifdef WIN32
-#include <direct.h>
-#include <io.h>
-#else
-#include <unistd.h>
-#endif
-
-#include <Batch_config.h>
-
-#include "Batch_Constants.hxx"
-#include "Batch_BatchManager_eClient.hxx"
-#include "Batch_RunTimeException.hxx"
-#include "Batch_Utils.hxx"
-
-#ifdef MSVC
-#define EXISTS(path) _access_s(path, 0) == 0
-#else
-#define EXISTS(path) access(path, F_OK) == 0
-#endif
-
-using namespace std;
-
-
-namespace Batch {
-
- BatchManager_eClient::BatchManager_eClient(const Batch::FactBatchManager * parent, const char* host,
- const char * username,
- CommunicationProtocolType protocolType, const char* mpiImpl)
- : BatchManager(parent, host), _protocol(CommunicationProtocol::getInstance(protocolType)),
- _username(username)
- {
- // instanciation of mpi implementation needed to launch executable in batch script
- _mpiImpl = FactoryMpiImpl(mpiImpl);
- }
-
- // Destructeur
- BatchManager_eClient::~BatchManager_eClient()
- {
- if (_mpiImpl)
- delete _mpiImpl;
- }
-
- void BatchManager_eClient::exportInputFiles(const Job& job)
- {
- int status;
- Parametre params = job.getParametre();
- const Versatile & V = params[INFILE];
- Versatile::const_iterator Vit;
-
- status = _protocol.makeDirectory(string(params[TMPDIR]) + "/logs", _hostname, _username);
- if(status) {
- std::ostringstream oss;
- oss << status;
- std::string ex_mess("Error of connection on remote host ! status = ");
- ex_mess += oss.str();
- throw EmulationException(ex_mess.c_str());
- }
-
- // Second step : copy fileToExecute into
- // batch tmp files directory
- string executeFile = params[EXECUTABLE];
- if (executeFile.size() != 0) {
- status = _protocol.copyFile(executeFile, "", "",
- params[TMPDIR], _hostname, _username);
- if(status) {
- std::ostringstream oss;
- oss << status;
- std::string ex_mess("Error of connection on remote host ! status = ");
- ex_mess += oss.str();
- throw EmulationException(ex_mess.c_str());
- }
-
-#ifdef WIN32
- // On Windows, we make the remote file executable afterward because
- // pscp does not preserve access permissions on files
-
- string executable = string(params[EXECUTABLE]);
- executable = executable.substr(executable.rfind("\\") + 1,executable.length());
-
- string subCommand = string("chmod u+x ") + string(params[TMPDIR]) + "/" + executable;
- string command = _protocol.getExecCommand(subCommand, _hostname, _username);
- cerr << command.c_str() << endl;
- status = system(command.c_str());
- if(status) {
- std::ostringstream oss;
- oss << status;
- std::string ex_mess("Error of connection on remote host ! status = ");
- ex_mess += oss.str();
- throw EmulationException(ex_mess.c_str());
- }
-#endif
- }
-
- // Third step : copy filesToExportList into
- // batch tmp files directory
- for(Vit=V.begin(); Vit!=V.end(); Vit++) {
- CoupleType cpt = *static_cast< CoupleType * >(*Vit);
- Couple inputFile = cpt;
- status = _protocol.copyFile(inputFile.getLocal(), "", "",
- inputFile.getRemote(), _hostname, _username);
- if(status) {
- std::ostringstream oss;
- oss << status;
- std::string ex_mess("Error of connection on remote host ! status = ");
- ex_mess += oss.str();
- throw EmulationException(ex_mess.c_str());
- }
- }
-
- }
-
- void BatchManager_eClient::importOutputFiles( const Job & job, const string directory )
- {
- Parametre params = job.getParametre();
- const Versatile & V = params[OUTFILE];
- Versatile::const_iterator Vit;
-
- // Create local result directory
- int status = CommunicationProtocol::getInstance(SH).makeDirectory(directory, "", "");
- if (status) {
- string mess("Directory creation failed. Status is :");
- ostringstream status_str;
- status_str << status;
- mess += status_str.str();
- cerr << mess << endl;
- }
-
- for(Vit=V.begin(); Vit!=V.end(); Vit++) {
- CoupleType cpt = *static_cast< CoupleType * >(*Vit);
- Couple outputFile = cpt;
- string localPath = outputFile.getLocal();
- if (!Utils::isAbsolutePath(localPath)) {
- localPath = directory + "/" + localPath;
- }
- status = _protocol.copyFile(outputFile.getRemote(), _hostname, _username,
- localPath, "", "");
- if (status) {
- // Try to get what we can (logs files)
- // throw BatchException("Error of connection on remote host");
- std::string mess("Copy command failed ! status is :");
- ostringstream status_str;
- status_str << status;
- mess += status_str.str();
- cerr << mess << endl;
- }
- }
-
- // Copy logs
- status = _protocol.copyFile(string(params[TMPDIR]) + string("/logs"), _hostname, _username,
- directory, "", "");
- if (status) {
- std::string mess("Copy logs directory failed ! status is :");
- ostringstream status_str;
- status_str << status;
- mess += status_str.str();
- cerr << mess << endl;
- }
-
- }
-
- bool BatchManager_eClient::importDumpStateFile( const Job & job, const string directory )
- {
- Parametre params = job.getParametre();
-
- // Create local result directory
- int status = CommunicationProtocol::getInstance(SH).makeDirectory(directory, "", "");
- if (status) {
- string mess("Directory creation failed. Status is :");
- ostringstream status_str;
- status_str << status;
- mess += status_str.str();
- cerr << mess << endl;
- }
-
- bool ret = true;
- status = _protocol.copyFile(string(params[TMPDIR]) + string("/dumpState*.xml"), _hostname, _username,
- directory, "", "");
- if (status) {
- // Try to get what we can (logs files)
- // throw BatchException("Error of connection on remote host");
- std::string mess("Copy command failed ! status is :");
- ostringstream status_str;
- status_str << status;
- mess += status_str.str();
- cerr << mess << endl;
- ret = false;
- }
- return ret;
- }
-
- MpiImpl *BatchManager_eClient::FactoryMpiImpl(string mpiImpl)
- {
- if(mpiImpl == "lam")
- return new MpiImpl_LAM();
- else if(mpiImpl == "mpich1")
- return new MpiImpl_MPICH1();
- else if(mpiImpl == "mpich2")
- return new MpiImpl_MPICH2();
- else if(mpiImpl == "openmpi")
- return new MpiImpl_OPENMPI();
- else if(mpiImpl == "ompi")
- return new MpiImpl_OMPI();
- else if(mpiImpl == "slurm")
- return new MpiImpl_SLURM();
- else if(mpiImpl == "prun")
- return new MpiImpl_PRUN();
- else if(mpiImpl == "nompi")
- return NULL;
- else{
- ostringstream oss;
- oss << mpiImpl << " : not yet implemented";
- throw EmulationException(oss.str().c_str());
- }
- }
-
- /**
- * This method generates a temporary file name with the pattern "<tmpdir>/<prefix>-XXXXXX" where
- * <tmpdir> is the directory for temporary files (see BatchManager_eClient::getTmpDir()) and the
- * X's are replaced by random characters. Note that this method is less secure than
- * BatchManager_eClient::createAndOpenTemporaryFile, so use the latter whenever possible.
- * \param prefix the prefix to use for the temporary file.
- * \return a name usable for a temporary file.
- */
- string BatchManager_eClient::generateTemporaryFileName(const string & prefix)
- {
- string fileName = getTmpDir() + "/" + prefix + "-XXXXXX";
- char randstr[7];
-
- do {
- sprintf(randstr, "%06d", rand() % 1000000);
- fileName.replace(fileName.size()-6, 6, randstr);
- } while (EXISTS(fileName.c_str()));
-
- return fileName;
- }
-
- /**
- * This method creates a temporary file and opens an output stream to write into this file.
- * The file is created with the pattern "<tmpdir>/<prefix>-XXXXXX" where <tmpdir> is the directory
- * for temporary files (see BatchManager_eClient::getTmpDir()) and the X's are replaced by random
- * characters. The caller is responsible for closing and deleting the file when it is no more used.
- * \param prefix the prefix to use for the temporary file.
- * \param outputStream an output stream that will be opened for writing in the temporary file. If
- * the stream is already open, it will be closed first.
- * \return the name of the created file.
- */
- string BatchManager_eClient::createAndOpenTemporaryFile(const string & prefix, ofstream & outputStream)
- {
- if (outputStream.is_open())
- outputStream.close();
-
-#ifdef WIN32
-
- string fileName = generateTemporaryFileName(prefix);
- // Open the file as binary to avoid problems with Windows newlines
- outputStream.open(fileName.c_str(), ios_base::binary | ios_base::out);
-
-#else
-
- string fileName = getTmpDir() + "/" + prefix + "-XXXXXX";
- char * buf = new char[fileName.size()+1];
- fileName.copy(buf, fileName.size());
- buf[fileName.size()] = '\0';
-
- int fd = mkstemp(buf);
- if (fd == -1) {
- delete[] buf;
- throw RunTimeException(string("Can't create temporary file ") + fileName);
- }
- fileName = buf;
- delete[] buf;
-
- outputStream.open(fileName.c_str());
- close(fd); // Close the file descriptor so that the file is not opened twice
-
-#endif
-
- if (outputStream.fail())
- throw RunTimeException(string("Can't open temporary file ") + fileName);
-
- return fileName;
- }
-
- /**
- * This method finds the name of the directory to use for temporary files in libBatch. This name
- * is <tempdir>/libBatch-<username>-XXXXXX. <tempdir> is found by looking for environment
- * variables TEMP, TMP, TEMPDIR, TMPDIR, and defaults to "/tmp" if none of them is defined.
- * <username> is found by looking for environment variables USER and USERNAME, and defaults to
- * "unknown". XXXXXX represents random characters. The directory name is generated only once for
- * each BatchManager_eClient instance, and the directory is created at this moment. Subsequent
- * calls will always return the same path and the existence of the directory will not be
- * rechecked.
- * \return the name of the directory to use for temporary files.
- */
- const std::string & BatchManager_eClient::getTmpDir()
- {
- if (tmpDirName.empty()) {
- const char * baseDir = getenv("TEMP");
- if (baseDir == NULL) baseDir = getenv("TMP");
- if (baseDir == NULL) baseDir = getenv("TEMPDIR");
- if (baseDir == NULL) baseDir = getenv("TMPDIR");
- if (baseDir == NULL) baseDir = "/tmp";
-
- const char * userName = getenv("USER");
- if (userName == NULL) userName = getenv("USERNAME");
- if (userName == NULL) userName = "unknown";
-
- string baseName = string(baseDir) + "/libBatch-" + userName + "-XXXXXX";
- srand(time(NULL));
-
-#ifdef WIN32
-
- char randstr[7];
- do {
- sprintf(randstr, "%06d", rand() % 1000000);
- baseName.replace(baseName.size()-6, 6, randstr);
- } while (EXISTS(baseName.c_str()));
- if (_mkdir(baseName.c_str()) != 0)
- throw RunTimeException(string("Can't create temporary directory ") + baseName);
- tmpDirName = baseName;
-
-#else
-
- char * buf = new char[baseName.size() + 1];
- baseName.copy(buf, baseName.size());
- buf[baseName.size()] = '\0';
- if (mkdtemp(buf) == NULL) {
- delete[] buf;
- throw RunTimeException(string("Can't create temporary directory ") + baseName);
- }
- tmpDirName = buf;
- delete[] buf;
-
-#endif
-
- }
-
- return tmpDirName;
- }
-
-}
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
- * BatchManager_eLSF.hxx : emulation of client
- *
- * Auteur : Bernard SECHER - CEA DEN
- * Mail : mailto:bernard.secher@cea.fr
- * Date : Thu Apr 24 10:17:22 2008
- * Projet : PAL Salome
- *
- */
-
-#ifndef _BATCHMANAGER_eClient_H_
-#define _BATCHMANAGER_eClient_H_
-
-#include "Batch_Defines.hxx"
-#include "Batch_MpiImpl.hxx"
-#include "Batch_BatchManager.hxx"
-#include "Batch_EmulationException.hxx"
-#include "Batch_CommunicationProtocol.hxx"
-
-#include <string>
-
-namespace Batch {
-
- class Job;
-
- class BATCH_EXPORT BatchManager_eClient : virtual public BatchManager
- {
- public:
- // Constructeur et destructeur
- BatchManager_eClient(const Batch::FactBatchManager * parent, const char* host="localhost",
- const char * username="",
- CommunicationProtocolType protocolType = SSH, const char* mpiImpl="mpich1");
- virtual ~BatchManager_eClient();
- virtual void importOutputFiles( const Job & job, const std::string directory );
- bool importDumpStateFile( const Job & job, const std::string directory );
-
- protected:
- const CommunicationProtocol & _protocol; // protocol to access _hostname
- const std::string _username; // username to access _hostname
- MpiImpl *_mpiImpl; // Mpi implementation to launch executable in batch script
-
- std::string generateTemporaryFileName(const std::string & prefix);
- std::string createAndOpenTemporaryFile(const std::string & prefix, std::ofstream & outputStream);
- MpiImpl* FactoryMpiImpl(std::string mpiImpl);
- void exportInputFiles(const Job & job);
- const std::string & getTmpDir();
-
- private:
- std::string tmpDirName; // Path to the directory for temporary files
-
- };
-
-}
-
-#endif
def_Constant(ENDTIME);
def_Constant(EUSER);
def_Constant(EXECUTABLE);
- def_Constant(EXECUTIONHOST);
def_Constant(EXITCODE);
def_Constant(HOLD);
def_Constant(ID);
def_Constant(STARTTIME);
def_Constant(STATE);
def_Constant(TEXT);
- def_Constant(TMPDIR);
def_Constant(USEDCPUTIME);
def_Constant(USEDDISKSIZE);
def_Constant(USEDRAMSIZE);
decl_extern_Constant(ENDTIME);
decl_extern_Constant(EUSER);
decl_extern_Constant(EXECUTABLE);
- decl_extern_Constant(EXECUTIONHOST);
decl_extern_Constant(EXITCODE);
decl_extern_Constant(HOLD);
decl_extern_Constant(ID);
decl_extern_Constant(STARTTIME);
decl_extern_Constant(STATE);
decl_extern_Constant(TEXT);
- decl_extern_Constant(TMPDIR);
decl_extern_Constant(USEDCPUTIME);
decl_extern_Constant(USEDDISKSIZE);
decl_extern_Constant(USEDRAMSIZE);
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
- * EmulationException.cxx :
- *
- * Author : Renaud BARATE - EDF R&D
- * Date : April 2009
- *
- */
-
-#include "Batch_EmulationException.hxx"
-using namespace std;
-
-namespace Batch {
-
-}
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
- * EmulationException.hxx :
- *
- * Author : Renaud BARATE - EDF R&D
- * Date : April 2009
- *
- */
-
-#ifndef _EMULATIONEXCEPTION_H_
-#define _EMULATIONEXCEPTION_H_
-
-#include "Batch_Defines.hxx"
-#include "Batch_GenericException.hxx"
-
-namespace Batch {
-
- class BATCH_EXPORT EmulationException : public GenericException
- {
- public:
- // Constructor
- EmulationException(const std::string & ch = "undefined")
- : GenericException("EmulationException", ch) {}
- };
-
-}
-
-#endif
#ifndef _FACTBATCHMANAGER_H_
#define _FACTBATCHMANAGER_H_
-#include "Batch_Defines.hxx"
-
#include <string>
-#include <map>
+
+#include "Batch_Defines.hxx"
+#include "Batch_CommunicationProtocol.hxx"
namespace Batch {
FactBatchManager(const std::string & type);
virtual ~FactBatchManager();
- virtual Batch::BatchManager * operator() (const char * hostname) const = 0;
+ virtual Batch::BatchManager * operator() (const char * hostname,
+ const char * username = "",
+ CommunicationProtocolType protocolType = SSH,
+ const char * mpi = "nompi",
+ int nb_proc_per_node = 1) const = 0;
std::string getType() const;
std::string __repr__() const;
protected:
std::string type;
- private:
-
};
}
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
- * FactBatchManager_eClient.cxx : emulation of client
- *
- * Auteur : Bernard SECHER - CEA DEN
- * Mail : mailto:bernard.secher@cea.fr
- * Date : Thu Apr 24 10:17:22 2008
- * Projet : PAL Salome
- *
- */
-
-#include <string>
-#include <sstream>
-#include "Batch_FactBatchManager_eClient.hxx"
-using namespace std;
-
-namespace Batch {
-
- // Constructeur
- FactBatchManager_eClient::FactBatchManager_eClient(const string & _t) : FactBatchManager(_t)
- {
- }
-
- // Destructeur
- FactBatchManager_eClient::~FactBatchManager_eClient()
- {
- // Nothing to do
- }
-
-}
+++ /dev/null
-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-/*
- * FactBatchManager_eClient.hxx : emulation of client
- *
- * Auteur : Bernard SECHER - CEA DEN
- * Mail : mailto:bernard.secher@cea.fr
- * Date : Thu Apr 24 10:17:22 2008
- * Projet : PAL Salome
- *
- */
-
-#ifndef _FACTBATCHMANAGER_ECLIENT_H_
-#define _FACTBATCHMANAGER_ECLIENT_H_
-
-#include <string>
-
-#include "Batch_FactBatchManager.hxx"
-#include "Batch_BatchManager_eClient.hxx"
-#include "Batch_CommunicationProtocol.hxx"
-
-namespace Batch {
-
- class BATCH_EXPORT FactBatchManager_eClient : public FactBatchManager
- {
- public:
- // Constructeur et destructeur
- FactBatchManager_eClient(const std::string & type);
- virtual ~FactBatchManager_eClient();
-
- virtual Batch::BatchManager_eClient * operator() (const char * hostname,
- const char * username,
- CommunicationProtocolType protocolType,
- const char * mpi = "nompi",
- int nb_proc_per_node = 1) const = 0;
-
- protected:
-
- private:
-
- };
-
-}
-
-#endif
addParameter("ENDTIME", LONG, 1);
addParameter("EUSER", STRING, 1);
addParameter("EXECUTABLE", STRING, 1);
- addParameter("EXECUTIONHOST", STRING, 0);
addParameter("EXITCODE", LONG, 1);
addParameter("HOLD", LONG, 1);
addParameter("ID", STRING, 1);
addParameter("STARTTIME", LONG, 1);
addParameter("STATE", STRING, 1);
addParameter("TEXT", STRING, 1);
- addParameter("TMPDIR", STRING, 1);
addParameter("USEDCPUTIME", LONG, 1);
addParameter("USEDDISKSIZE", LONG, 1);
addParameter("USEDRAMSIZE", LONG, 1);
* Author : Renaud BARATE - EDF R&D
*/
+#include <cstdlib>
#include <cstdio>
+#include <unistd.h>
+#include <iostream>
+#include <fstream>
#include <Batch_config.h>
#include "Batch_Utils.hxx"
+#include "Batch_RunTimeException.hxx"
#ifdef MSVC
#define popen _popen
return path[0] == '/';
}
+string Utils::createAndOpenTemporaryFile(const string & prefix, ofstream & outputStream)
+{
+ if (outputStream.is_open())
+ outputStream.close();
+
+ // Find directory for temporary files
+ const char * tmpDirName = getenv("TEMP");
+ if (tmpDirName == NULL) tmpDirName = getenv("TMP");
+ if (tmpDirName == NULL) tmpDirName = getenv("TEMPDIR");
+ if (tmpDirName == NULL) tmpDirName = getenv("TMPDIR");
+ if (tmpDirName == NULL) tmpDirName = "/tmp";
+
+ string fileName = (string)tmpDirName + "/libbatch-" + prefix + "-XXXXXX";
+
+#ifdef WIN32
+
+ char randstr[7];
+ srand(time(NULL));
+
+ do {
+ sprintf(randstr, "%06d", rand() % 1000000);
+ fileName.replace(fileName.size()-6, 6, randstr);
+ } while (EXISTS(fileName.c_str()));
+
+ // Open the file as binary to avoid problems with Windows newlines
+ outputStream.open(fileName.c_str(), ios_base::binary | ios_base::out);
+
+#else
+
+ char * buf = new char[fileName.size()+1];
+ fileName.copy(buf, fileName.size());
+ buf[fileName.size()] = '\0';
+
+ int fd = mkstemp(buf);
+ if (fd == -1) {
+ delete[] buf;
+ throw RunTimeException(string("Can't create temporary file ") + fileName);
+ }
+ fileName = buf;
+ delete[] buf;
+
+ outputStream.open(fileName.c_str());
+ close(fd); // Close the file descriptor so that the file is not opened twice
+
+#endif
+
+ if (outputStream.fail())
+ throw RunTimeException(string("Can't open temporary file ") + fileName);
+
+ return fileName;
+}
+
}
*/
static bool isAbsolutePath(const std::string & path);
+ /**
+ * Create a temporary file and open an output stream to write into this file.
+ * The file is created with the pattern "<tmpdir>/libbatch-<prefix>-XXXXXX" where <tmpdir> is the
+ * directory for temporary files and the X's are replaced by random characters. The caller is
+ * responsible for closing and deleting the file when it is no more used.
+ * <tmpdir> is found by looking for environment variables TEMP, TMP, TEMPDIR, TMPDIR, and defaults
+ * to "/tmp" if none of them is defined.
+ * \param prefix the prefix to use for the temporary file.
+ * \param outputStream an output stream that will be opened for writing in the temporary file. If
+ * the stream is already open, it will be closed first.
+ * \return the name of the created file.
+ */
+ static std::string createAndOpenTemporaryFile(const std::string & prefix,
+ std::ofstream & outputStream);
+
private:
// No instanciation possible as this class provides only static methods
#
SET(CLASS_LIST Core/Batch_APIInternalFailureException
- Core/Batch_BatchManager_eClient
Core/Batch_BatchManager
Core/Batch_BatchManagerCatalog
Core/Batch_BoolType
Core/Batch_CoupleType
Core/Batch_Date
Core/Batch_DateType
- Core/Batch_EmulationException
Core/Batch_Environnement
- Core/Batch_FactBatchManager_eClient
Core/Batch_FactBatchManager
Core/Batch_GenericException
Core/Batch_GenericType
#include <Batch_Constants.hxx>
#include <Batch_Utils.hxx>
+#include <Batch_NotYetImplementedException.hxx>
#include "Batch_BatchManager_eLSF.hxx"
#include "Batch_JobInfo_eLSF.hxx"
BatchManager_eLSF::BatchManager_eLSF(const FactBatchManager * parent, const char * host,
const char * username,
CommunicationProtocolType protocolType, const char * mpiImpl)
- : BatchManager(parent, host),
- BatchManager_eClient(parent, host, username, protocolType, mpiImpl)
-
+ : BatchManager(parent, host, username, protocolType, mpiImpl)
{
// Nothing to do
}
string output;
int status = Utils::getCommandOutput(command, output);
cout << output;
- if (status != 0) throw EmulationException("Can't submit job, error was: " + output);
+ if (status != 0) throw RunTimeException("Can't submit job, error was: " + output);
// read id of submitted job in output
int p10 = output.find("<");
cerr << command.c_str() << endl;
status = system(command.c_str());
if (status)
- throw EmulationException("Error of connection on remote host");
+ throw RunTimeException("Error of connection on remote host");
cerr << "jobId = " << ref << "killed" << endl;
}
// Methode pour le controle des jobs : suspend un job en file d'attente
void BatchManager_eLSF::holdJob(const JobId & jobid)
{
- throw EmulationException("Not yet implemented");
+ throw NotYetImplementedException("BatchManager_eLSF::holdJob");
}
// Methode pour le controle des jobs : relache un job suspendu
void BatchManager_eLSF::releaseJob(const JobId & jobid)
{
- throw EmulationException("Not yet implemented");
+ throw NotYetImplementedException("BatchManager_eLSF::releaseJob");
}
// Methode pour le controle des jobs : modifie un job en file d'attente
void BatchManager_eLSF::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env)
{
- throw EmulationException("Not yet implemented");
+ throw NotYetImplementedException("BatchManager_eLSF::alterJob");
}
// Methode pour le controle des jobs : modifie un job en file d'attente
string output;
int status = Utils::getCommandOutput(command, output);
- if (status) throw EmulationException("Error of connection on remote host");
+ if (status) throw RunTimeException("Error of connection on remote host");
JobInfo_eLSF ji = JobInfo_eLSF(id, output);
return ji;
// Methode pour le controle des jobs : teste si un job est present en machine
bool BatchManager_eLSF::isRunning(const JobId & jobid)
{
- throw EmulationException("Not yet implemented");
+ throw NotYetImplementedException("BatchManager_eLSF::isRunning");
}
std::string BatchManager_eLSF::buildSubmissionScript(const Job & job)
if (params.find(WORKDIR) != params.end())
workDir = params[WORKDIR].str();
else
- throw EmulationException("params[WORKDIR] is not defined ! Please defined it, cannot submit this job");
+ throw RunTimeException("params[WORKDIR] is not defined ! Please defined it, cannot submit this job");
if (params.find(EXECUTABLE) != params.end())
fileToExecute = params[EXECUTABLE].str();
else
- throw EmulationException("params[EXECUTABLE] is not defined ! Please defined it, cannot submit this job");
+ throw RunTimeException("params[EXECUTABLE] is not defined ! Please defined it, cannot submit this job");
// Optional parameters
if (params.find(NBPROC) != params.end())
// Create batch submit file
ofstream tempOutputFile;
- std::string TmpFileName = createAndOpenTemporaryFile("LSF-script", tempOutputFile);
+ std::string TmpFileName = Utils::createAndOpenTemporaryFile("LSF-script", tempOutputFile);
tempOutputFile << "#! /bin/sh -f" << endl ;
if (params.find(NAME) != params.end())
workDir + "/" + remoteFileName,
_hostname, _username);
if (status)
- throw EmulationException("Error of connection on remote host");
+ throw RunTimeException("Error of connection on remote host");
return remoteFileName;
}
cerr << command.c_str() << endl;
int status = system(command.c_str());
if (status)
- throw EmulationException("Error of launching home command on remote host");
+ throw RunTimeException("Error of launching home command on remote host");
std::ifstream file_home(filelogtemp.c_str());
std::getline(file_home, home);
#include "Batch_JobId.hxx"
#include "Batch_JobInfo.hxx"
#include "Batch_FactBatchManager.hxx"
-#include "Batch_BatchManager_eClient.hxx"
+#include "Batch_BatchManager.hxx"
namespace Batch {
- class BATCH_EXPORT BatchManager_eLSF : public BatchManager_eClient
+ class BATCH_EXPORT BatchManager_eLSF : public BatchManager
{
public:
// Constructeur et destructeur
static FactBatchManager_eLSF sFBM_eLSF;
// Constructeur
- FactBatchManager_eLSF::FactBatchManager_eLSF() : FactBatchManager_eClient("eLSF")
+ FactBatchManager_eLSF::FactBatchManager_eLSF() : FactBatchManager("LSF")
{
// Nothing to do
}
// Nothing to do
}
- // Functor
- BatchManager * FactBatchManager_eLSF::operator() (const char * hostname) const
- {
- // MESSAGE("Building new BatchManager_LSF on host '" << hostname << "'");
- return new BatchManager_eLSF(this, hostname);
- }
-
- BatchManager_eClient * FactBatchManager_eLSF::operator() (const char * hostname,
- const char * username,
- CommunicationProtocolType protocolType,
- const char * mpiImpl,
- int nb_proc_per_node) const
+ BatchManager * FactBatchManager_eLSF::operator() (const char * hostname,
+ const char * username,
+ CommunicationProtocolType protocolType,
+ const char * mpiImpl,
+ int nb_proc_per_node) const
{
// MESSAGE("Building new BatchManager_LSF on host '" << hostname << "'");
return new BatchManager_eLSF(this, hostname, username, protocolType, mpiImpl);
#define _FACTBATCHMANAGER_eLSF_H_
#include "Batch_Defines.hxx"
-#include "Batch_BatchManager_eClient.hxx"
-#include "Batch_FactBatchManager_eClient.hxx"
+#include "Batch_BatchManager.hxx"
+#include "Batch_FactBatchManager.hxx"
namespace Batch {
- class BATCH_EXPORT FactBatchManager_eLSF : public FactBatchManager_eClient
+ class BATCH_EXPORT FactBatchManager_eLSF : public FactBatchManager
{
public:
- // Constructeur et destructeur
+
FactBatchManager_eLSF();
virtual ~FactBatchManager_eLSF();
- virtual BatchManager * operator() (const char * hostname) const;
- virtual BatchManager_eClient * operator() (const char * hostname,
- const char * username,
- CommunicationProtocolType protocolType,
- const char * mpiImpl,
- int nb_proc_per_node = 1) const;
-
- protected:
-
- private:
+ virtual BatchManager * operator() (const char * hostname,
+ const char * username,
+ CommunicationProtocolType protocolType,
+ const char * mpiImpl,
+ int nb_proc_per_node = 1) const;
};
LSF/Batch_JobInfo_eLSF
)
-IF (BUILD_LSF_INTERFACE AND LSF_FOUND)
- SET(CLASS_LIST ${CLASS_LIST}
- LSF/Batch_BatchManager_LSF
- LSF/Batch_FactBatchManager_LSF
- LSF/Batch_Job_LSF
- LSF/Batch_JobInfo_LSF
- )
-ENDIF (BUILD_LSF_INTERFACE AND LSF_FOUND)
+#IF (BUILD_LSF_INTERFACE AND LSF_FOUND)
+# SET(CLASS_LIST ${CLASS_LIST}
+# LSF/Batch_BatchManager_LSF
+# LSF/Batch_FactBatchManager_LSF
+# LSF/Batch_Job_LSF
+# LSF/Batch_JobInfo_LSF
+# )
+#ENDIF (BUILD_LSF_INTERFACE AND LSF_FOUND)
APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST})
#include <Batch_Job.hxx>
#include <Batch_BatchManagerCatalog.hxx>
#include <Batch_FactBatchManager.hxx>
-#include <Batch_FactBatchManager_eClient.hxx>
#include <Batch_BatchManager.hxx>
-#include <Batch_BatchManager_eClient.hxx>
#include <SimpleParser.hxx>
p[INFILE] = Couple("seta.sh", "tmp/Batch/seta.sh");
p[INFILE] += Couple("setb.sh", "tmp/Batch/setb.sh");
p[OUTFILE] = Couple("result.txt", "tmp/Batch/result.txt");
- p[TMPDIR] = "tmp/Batch/";
p[NBPROC] = 1;
p[MAXWALLTIME] = 1;
p[MAXRAMSIZE] = 128;
BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
// Create a BatchManager of type ePBS on localhost
- FactBatchManager_eClient * fbm = (FactBatchManager_eClient *)(c("eLSF"));
- BatchManager_eClient * bm = (*fbm)(host.c_str(), user.c_str(), protocol);
+ FactBatchManager * fbm = c("LSF");
+ BatchManager * bm = (*fbm)(host.c_str(), user.c_str(), protocol);
// Submit the job to the BatchManager
JobId jobid = bm->submitJob(job);
#include <cstdlib>
#include <iostream>
#include <fstream>
+#include <sstream>
#include <Batch_NotYetImplementedException.hxx>
#include <Batch_Constants.hxx>
+#include <Batch_Utils.hxx>
#include "Batch_FactBatchManager_eLL.hxx"
#include "Batch_BatchManager_eLL.hxx"
const char * username,
CommunicationProtocolType protocolType, const char * mpiImpl,
int nb_proc_per_node)
- : BatchManager(parent, host),
- BatchManager_eClient(parent, host, username, protocolType, mpiImpl),
+ : BatchManager(parent, host, username, protocolType, mpiImpl),
_nb_proc_per_node(nb_proc_per_node)
{
// Nothing to do
// Method to submit a job to the batch manager
const JobId BatchManager_eLL::submitJob(const Job & job)
{
- int status;
Parametre params = job.getParametre();
const string workDir = params[WORKDIR];
// build command file to submit the job and copy it on the server
string cmdFile = buildCommandFile(job);
- // define name of log file (local)
- string logFile = generateTemporaryFileName("LL-submitlog");
-
// define command to submit batch
string subCommand = string("cd ") + workDir + "; llsubmit " + cmdFile;
string command = _protocol.getExecCommand(subCommand, _hostname, _username);
- command += " > ";
- command += logFile;
cerr << command.c_str() << endl;
- status = system(command.c_str());
- if (status)
- {
- ifstream error_message(logFile.c_str());
- string mess;
- string temp;
- while(getline(error_message, temp))
- mess += temp;
- error_message.close();
- throw EmulationException("Error of connection on remote host, error was: " + mess);
- }
- // read id of submitted job in log file
+ // submit job
+ string output;
+ int status = Utils::getCommandOutput(command, output);
+ cout << output;
+ if (status != 0) throw RunTimeException("Can't submit job, error was: " + output);
+
+ // find id of submitted job in output
string jobref;
- ifstream idfile(logFile.c_str());
+ istringstream idfile(output);
string line;
while (idfile && line.compare(0, 9, "llsubmit:") != 0)
getline(idfile, line);
- idfile.close();
if (line.compare(0, 9, "llsubmit:") == 0)
{
string::size_type p1 = line.find_first_of("\"");
jobref = line.substr(p1 + 1, p2 - p1 - 1);
}
if (jobref.size() == 0)
- throw EmulationException("Error in the submission of the job on the remote host");
+ throw RunTimeException("Error in the submission of the job on the remote host");
JobId id(this, jobref);
return id;
if (params.find(WORKDIR) != params.end())
workDir = params[WORKDIR].str();
else
- throw EmulationException("params[WORKDIR] is not defined. Please define it, cannot submit this job.");
+ throw RunTimeException("params[WORKDIR] is not defined. Please define it, cannot submit this job.");
if (params.find(EXECUTABLE) != params.end())
fileToExecute = params[EXECUTABLE].str();
else
- throw EmulationException("params[EXECUTABLE] is not defined. Please define it, cannot submit this job.");
+ throw RunTimeException("params[EXECUTABLE] is not defined. Please define it, cannot submit this job.");
string::size_type p1 = fileToExecute.find_last_of("/");
string::size_type p2 = fileToExecute.find_last_of(".");
// Create batch submit file
ofstream tempOutputFile;
- string tmpFileName = createAndOpenTemporaryFile("LL-script", tempOutputFile);
+ string tmpFileName = Utils::createAndOpenTemporaryFile("LL-script", tempOutputFile);
tempOutputFile << "#!/bin/bash" << endl;
tempOutputFile << "# @ output = " << workDir << "/logs/output.log." << rootNameToExecute << endl;
workDir + "/" + remoteFileName,
_hostname, _username);
if (status)
- throw EmulationException("Cannot copy command file on host " + _hostname);
+ throw RunTimeException("Cannot copy command file on host " + _hostname);
return remoteFileName;
}
int status = system(command.c_str());
if (status)
- throw EmulationException("Can't delete job " + jobid.getReference());
+ throw RunTimeException("Can't delete job " + jobid.getReference());
cerr << "job " << jobid.getReference() << " killed" << endl;
}
JobInfo BatchManager_eLL::queryJob(const JobId & jobid)
{
- // define name of log file (local)
- string logFile = generateTemporaryFileName("LL-querylog-" + jobid.getReference());
-
// define command to query batch
string subCommand = "llq -f %st " + jobid.getReference();
string command = _protocol.getExecCommand(subCommand, _hostname, _username);
- command += " > ";
- command += logFile;
cerr << command.c_str() << endl;
- int status = system(command.c_str());
+ string output;
+ int status = Utils::getCommandOutput(command, output);
if (status != 0)
- throw EmulationException("Can't query job " + jobid.getReference());
+ throw RunTimeException("Can't query job " + jobid.getReference());
- JobInfo_eLL jobinfo = JobInfo_eLL(jobid.getReference(), logFile);
+ JobInfo_eLL jobinfo = JobInfo_eLL(jobid.getReference(), output);
return jobinfo;
}
#include "Batch_JobId.hxx"
#include "Batch_JobInfo.hxx"
#include "Batch_FactBatchManager.hxx"
-#include "Batch_BatchManager_eClient.hxx"
+#include "Batch_BatchManager.hxx"
namespace Batch {
- class BATCH_EXPORT BatchManager_eLL : public BatchManager_eClient
+ class BATCH_EXPORT BatchManager_eLL : public BatchManager
{
public:
BatchManager_eLL(const FactBatchManager * parent, const char * host = "localhost",
static FactBatchManager_eLL sFBM_eLL;
- FactBatchManager_eLL::FactBatchManager_eLL() : FactBatchManager_eClient("eLL")
+ FactBatchManager_eLL::FactBatchManager_eLL() : FactBatchManager("LL")
{
// Add specific parameters
ParameterTypeMap::getInstance().addParameter(LL_JOBTYPE, STRING, 1);
// Nothing to do
}
- // Functor
- BatchManager * FactBatchManager_eLL::operator() (const char * hostname) const
- {
- // MESSAGE("Building new BatchManager_eLL on host '" << hostname << "'");
- return new BatchManager_eLL(this, hostname);
- }
-
- BatchManager_eClient * FactBatchManager_eLL::operator() (const char * hostname,
- const char * username,
- CommunicationProtocolType protocolType,
- const char * mpiImpl,
- int nb_proc_per_node) const
+ BatchManager * FactBatchManager_eLL::operator() (const char * hostname,
+ const char * username,
+ CommunicationProtocolType protocolType,
+ const char * mpiImpl,
+ int nb_proc_per_node) const
{
// MESSAGE("Building new BatchManager_eLL on host '" << hostname << "'");
return new BatchManager_eLL(this, hostname, username, protocolType, mpiImpl, nb_proc_per_node);
#include <Batch_Defines.hxx>
#include <Batch_Constants.hxx>
-#include "Batch_BatchManager_eClient.hxx"
-#include "Batch_FactBatchManager_eClient.hxx"
+#include "Batch_BatchManager.hxx"
+#include "Batch_FactBatchManager.hxx"
namespace Batch {
class BatchManager_eLL;
- class BATCH_EXPORT FactBatchManager_eLL : public FactBatchManager_eClient
+ class BATCH_EXPORT FactBatchManager_eLL : public FactBatchManager
{
public:
// Constructeur et destructeur
FactBatchManager_eLL();
virtual ~FactBatchManager_eLL();
- virtual BatchManager * operator() (const char * hostname) const;
- virtual BatchManager_eClient * operator() (const char * hostname,
- const char * username,
- CommunicationProtocolType protocolType,
- const char * mpiImpl,
- int nb_proc_per_node = 1) const;
-
+ virtual BatchManager * operator() (const char * hostname,
+ const char * username,
+ CommunicationProtocolType protocolType,
+ const char * mpiImpl,
+ int nb_proc_per_node = 1) const;
};
}
*/
#include <iostream>
-#include <fstream>
#include <sstream>
#include <Batch_RunTimeException.hxx>
namespace Batch {
- JobInfo_eLL::JobInfo_eLL(const std::string & id, const std::string & logFile)
+ JobInfo_eLL::JobInfo_eLL(const std::string & id, const std::string & output)
: JobInfo()
{
_param[ID] = id;
// read log file
- ifstream log(logFile.c_str());
+ istringstream log(output);
string line;
// status should be on the third line
for (int i=0 ; i<3 ; i++)
getline(log, line);
- log.close();
string status;
istringstream iss(line);
iss >> status;
class JobInfo_eLL : public JobInfo
{
public:
- JobInfo_eLL(const std::string & id, const std::string & logFile);
+ JobInfo_eLL(const std::string & id, const std::string & output);
virtual ~JobInfo_eLL();
};
#include <Batch_Job.hxx>
#include <Batch_BatchManagerCatalog.hxx>
#include <Batch_FactBatchManager.hxx>
-#include <Batch_FactBatchManager_eClient.hxx>
#include <Batch_FactBatchManager_eLL.hxx>
#include <Batch_BatchManager.hxx>
-#include <Batch_BatchManager_eClient.hxx>
#include <SimpleParser.hxx>
p[INFILE] = Couple("seta.sh", "tmp/Batch/seta.sh");
p[INFILE] += Couple("setb.sh", "tmp/Batch/setb.sh");
p[OUTFILE] = Couple("result.txt", "tmp/Batch/result.txt");
- p[TMPDIR] = "tmp/Batch/";
p[NBPROC] = 1;
p[MAXWALLTIME] = 1;
p[MAXRAMSIZE] = 50;
BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
// Create a BatchManager of type ePBS on localhost
- FactBatchManager_eClient * fbm = (FactBatchManager_eClient *)(c("eLL"));
- BatchManager_eClient * bm = (*fbm)(host.c_str(), user.c_str(), protocol);
+ FactBatchManager * fbm = c("LL");
+ BatchManager * bm = (*fbm)(host.c_str(), user.c_str(), protocol);
// Submit the job to the BatchManager
JobId jobid = bm->submitJob(job);
// Constructeur
- BatchManager_Local::BatchManager_Local(const FactBatchManager * parent, const char * host,
- CommunicationProtocolType protocolType)
- : BatchManager(parent, host), _connect(0),
- _protocol(CommunicationProtocol::getInstance(protocolType)),
+ BatchManager_Local::BatchManager_Local(const Batch::FactBatchManager * parent, const char * host,
+ const char * username,
+ CommunicationProtocolType protocolType, const char * mpiImpl,
+ int nb_proc_per_node)
+ : BatchManager(parent, host, username, protocolType, mpiImpl), _connect(0),
_idCounter(0)
{
pthread_mutex_init(&_threads_mutex, NULL);
pthread_cond_destroy(&_threadSyncCondition);
}
- const CommunicationProtocol & BatchManager_Local::getProtocol() const
- {
- return _protocol;
- }
-
// Methode pour le controle des jobs : soumet un job au gestionnaire
const JobId BatchManager_Local::submitJob(const Job & job)
{
+ // export input files in the working directory of the execution host
+ exportInputFiles(job);
+
Job_Local jobLocal = job;
Id id = _idCounter++;
ThreadAdapter * p_ta = new ThreadAdapter(*this, job, id);
if (strlen(drive) > 0) exec_sub_cmd << drive << " && ";
#endif
- exec_sub_cmd << "cd " << param[WORKDIR] << " && " << param[EXECUTABLE];
+ string fileToExecute = param[EXECUTABLE].str();
+ string::size_type p1 = fileToExecute.find_last_of("/");
+ string fileNameToExecute = fileToExecute.substr(p1+1);
+
+ exec_sub_cmd << "cd " << param[WORKDIR] << " && ./" << fileNameToExecute;
if (param.find(ARGUMENTS) != param.end()) {
Versatile V = param[ARGUMENTS];
user = string(it->second);
}
- return _protocol.getExecCommandArgs(exec_sub_cmd.str(), param[EXECUTIONHOST], user);
+ return _protocol.getExecCommandArgs(exec_sub_cmd.str(), _hostname, user);
}
pthread_cleanup_push(BatchManager_Local::setFailedOnCancel, arg);
pthread_cleanup_push(BatchManager_Local::kill_child_on_exit, static_cast<void *> (&child));
-
- // Le code retour cumule (ORed) de tous les appels
- // Nul en cas de reussite de l'ensemble des operations
- int rc = 0;
-
- // Cette table contient la liste des fichiers a detruire a la fin du processus
- std::vector<string> files_to_delete;
-
-
-
- // On copie les fichiers d'entree pour le fils
- const Parametre param = p_ta->_job.getParametre();
- Parametre::const_iterator it;
-
- // On initialise la variable workdir a la valeur du Current Working Directory
- char * cwd =
-#ifdef WIN32
- _getcwd(NULL, 0);
-#else
- new char [PATH_MAX];
- getcwd(cwd, PATH_MAX);
-#endif
- string workdir = cwd;
- delete [] cwd;
-
- if ( (it = param.find(WORKDIR)) != param.end() ) {
- workdir = static_cast<string>( (*it).second );
- }
-
- string executionhost = string(param[EXECUTIONHOST]);
- string user;
- if ( (it = param.find(USER)) != param.end() ) {
- user = string(it->second);
- }
-
- if ( (it = param.find(INFILE)) != param.end() ) {
- Versatile V = (*it).second;
- Versatile::iterator Vit;
-
- for(Vit=V.begin(); Vit!=V.end(); Vit++) {
- CoupleType cpt = *static_cast< CoupleType * >(*Vit);
- Couple cp = cpt;
- string local = cp.getLocal();
- string remote = cp.getRemote();
-
- std::cerr << workdir << std::endl;
- std::cerr << remote << std::endl;
-
- int status = p_ta->getBatchManager().getProtocol().copyFile(local, "", "",
- workdir + "/" + remote,
- executionhost, user);
- if (status) {
- // Echec de la copie
- rc |= 1;
- } else {
- // On enregistre le fichier comme etant a detruire
- files_to_delete.push_back(workdir + "/" + remote);
- }
-
- }
- }
-
-
-
-
// On forke/exec un nouveau process pour pouvoir controler le fils
// (plus finement qu'avec un appel system)
// int rc = system(commande.c_str());
}
#endif
-
- // On copie les fichiers de sortie du fils
- if ( (it = param.find(OUTFILE)) != param.end() ) {
- Versatile V = (*it).second;
- Versatile::iterator Vit;
-
- for(Vit=V.begin(); Vit!=V.end(); Vit++) {
- CoupleType cpt = *static_cast< CoupleType * >(*Vit);
- Couple cp = cpt;
- string local = cp.getLocal();
- string remote = cp.getRemote();
-
- int status = p_ta->getBatchManager().getProtocol().copyFile(workdir + "/" + remote,
- executionhost, user,
- local, "", "");
- if (status) {
- // Echec de la copie
- rc |= 1;
- } else {
- // On enregistre le fichier comme etant a detruire
- files_to_delete.push_back(workdir + "/" + remote);
- }
-
- }
- }
-
- // On efface les fichiers d'entree et de sortie du fils si les copies precedentes ont reussi
- // ou si la creation du fils n'a pu avoir lieu
- if ( (rc == 0) || (child < 0) ) {
- std::vector<string>::const_iterator it;
- for(it=files_to_delete.begin(); it!=files_to_delete.end(); it++) {
- p_ta->getBatchManager().getProtocol().removeFile(*it, executionhost, user);
-/* string remove_cmd = p_ta->getBatchManager().remove_command(user, executionhost, *it);
- UNDER_LOCK( cout << "Removing : " << remove_cmd << endl );
-#ifdef WIN32
- remove_cmd = string("\"") + remove_cmd + string("\"");
-#endif
- system(remove_cmd.c_str());*/
- }
- }
-
pthread_mutex_lock(&p_ta->_bm._threads_mutex);
// Set the job state to FINISHED or FAILED
public:
- // Constructeur et destructeur
- BatchManager_Local(const FactBatchManager * parent,
- const char * host="localhost",
- CommunicationProtocolType protocolType = SSH); // connexion a la machine host
+
+ BatchManager_Local(const Batch::FactBatchManager * parent, const char * host = "localhost",
+ const char * username = "",
+ CommunicationProtocolType protocolType = SSH, const char * mpiImpl = "nompi",
+ int nb_proc_per_node = 1);
virtual ~BatchManager_Local();
// Recupere le nom du serveur par defaut
// static string BatchManager_Local::getDefaultServer();
- // Get the underlying communication protocol
- const CommunicationProtocol & getProtocol() const;
-
// Methodes pour le controle des jobs
virtual const JobId submitJob(const Job & job); // soumet un job au gestionnaire
virtual void deleteJob(const JobId & jobid); // retire un job du gestionnaire
pthread_mutex_t _threads_mutex;
std::map<Id, Child > _threads;
- const CommunicationProtocol & _protocol;
-
// Methode qui renvoie la commande a executer
std::vector<std::string> exec_command(const Parametre & param) const;
namespace Batch {
-#ifdef HAS_SH
- static FactBatchManager_Local sFBM_Local_SH("SH", SH);
-#endif
+ static FactBatchManager_Local sFBM_Local;
-#ifdef HAS_RSH
- static FactBatchManager_Local sFBM_Local_RSH("RSH", RSH);
-#endif
-
-#ifdef HAS_SSH
- static FactBatchManager_Local sFBM_Local_SSH("SSH", SSH);
-#endif
-
- // Constructeur
- FactBatchManager_Local::FactBatchManager_Local(const char * name,
- CommunicationProtocolType protocolType)
- : FactBatchManager(name),
- _protocolType(protocolType)
+ FactBatchManager_Local::FactBatchManager_Local()
+ : FactBatchManager("LOCAL")
{
- // Nothing to do
}
- // Destructeur
FactBatchManager_Local::~FactBatchManager_Local()
{
- // Nothing to do
}
- // Functor
- BatchManager * FactBatchManager_Local::operator() (const char * hostname) const
+ BatchManager * FactBatchManager_Local::operator() (const char * hostname,
+ const char * username,
+ CommunicationProtocolType protocolType,
+ const char * mpi,
+ int nb_proc_per_node) const
{
- // MESSAGE("Building new BatchManager_Local on host '" << hostname << "'");
- return new BatchManager_Local(this, hostname, _protocolType);
+ return new BatchManager_Local(this, hostname, username,
+ protocolType, mpi, nb_proc_per_node);
}
}
class FactBatchManager_Local : public FactBatchManager
{
public:
- // Constructeur et destructeur
- FactBatchManager_Local(const char * name, CommunicationProtocolType protocolType);
- virtual ~FactBatchManager_Local();
-
- virtual BatchManager * operator() (const char * hostname) const;
- protected:
-
- CommunicationProtocolType _protocolType;
+ FactBatchManager_Local();
+ virtual ~FactBatchManager_Local();
- private:
+ virtual BatchManager * operator() (const char * hostname,
+ const char * username = "",
+ CommunicationProtocolType protocolType = SSH,
+ const char * mpi = "nompi",
+ int nb_proc_per_node = 1) const;
};
Job_Local::Job_Local(const Job & job) :
_command(), _param(job.getParametre()), _env(job.getEnvironnement())
{
- // On positionne le nom du EXECUTIONHOST a "localhost" s'il n'est pas precise
- if ( _param.find(EXECUTIONHOST) == _param.end() ) {
- _param[EXECUTIONHOST] = "localhost";
- }
-
// On convertit les objets Parametre et Environnement en liste chainee d'attributs + operateur
addEnvironnement( _env );
addParametre ( _param );
-
}
Job job;
// ... and its parameters ...
Parametre p;
- p[EXECUTABLE] = "source copied-test-script.sh";
+ p[EXECUTABLE] = "test-script.sh";
p[NAME] = "Test_Local_RSH";
p[WORKDIR] = workdir;
- p[INFILE] = Couple("seta.sh", "copied-seta.sh");
- p[INFILE] += Couple("setb.sh", "copied-setb.sh");
- p[INFILE] += Couple("test-script.sh", "copied-test-script.sh");
- p[OUTFILE] = Couple("result.txt", "orig-result.txt");
- p[EXECUTIONHOST] = exechost;
+ p[INFILE] = Couple("seta.sh", workdir + "/copied-seta.sh");
+ p[INFILE] += Couple("setb.sh", workdir + "/copied-setb.sh");
+ p[OUTFILE] = Couple("result.txt", workdir + "/orig-result.txt");
p[USER] = user;
job.setParametre(p);
// ... and its environment
BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
// Create a BatchManager of type Local_RSH on localhost
- FactBatchManager * fbm = c("RSH");
+ FactBatchManager * fbm = c("LOCAL");
if (fbm == NULL) {
cerr << "Can't get RSH batch manager factory" << endl;
return 1;
}
- BatchManager * bm = (*fbm)("localhost");
+ BatchManager * bm = (*fbm)(exechost.c_str(), user.c_str(), RSH);
// Submit the job to the BatchManager
JobId jobid = bm->submitJob(job);
// Wait for the end of the job
string state = bm->waitForJobEnd(jobid, timeout);
- if (state != FINISHED && state != FAILED) {
- cerr << "Error: Job not finished after timeout" << endl;
+ if (state == FINISHED) {
+ cout << "Job " << jobid.__repr__() << " is done" << endl;
+ bm->importOutputFiles(job, "resultdir/seconddirname");
+ } else if (state == FAILED) {
+ cerr << "Job " << jobid.__repr__() << " finished in error" << endl;
+ bm->importOutputFiles(job, "resultdir/seconddirname");
+ return 1;
+ } else {
+ cerr << "Timeout while executing job" << endl;
return 1;
}
- cout << "Job " << jobid.__repr__() << " is done" << endl;
-
} catch (GenericException e) {
cerr << "Error: " << e << endl;
return 1;
// test the result file
string exp = "c = 12";
string res;
- ifstream f("result.txt");
+ ifstream f("resultdir/seconddirname/result.txt");
getline(f, res);
f.close();
Job job;
// ... and its parameters ...
Parametre p;
- p[EXECUTABLE] = string("./copied-") + EXEC_TEST_NAME;
+ p[EXECUTABLE] = EXEC_TEST_NAME;
p[ARGUMENTS] = "copied-seta.sh";
p[ARGUMENTS] += "copied-setb.sh";
p[ARGUMENTS] += "orig-result.txt";
p[NAME] = "Test_Local_SH";
p[WORKDIR] = workdir;
- p[INFILE] = Couple("seta.sh", "copied-seta.sh");
- p[INFILE] += Couple("setb.sh", "copied-setb.sh");
- p[INFILE] += Couple(EXEC_TEST_NAME, string("copied-") + EXEC_TEST_NAME);
- p[OUTFILE] = Couple("result.txt", "orig-result.txt");
+ p[INFILE] = Couple("seta.sh", workdir + "/copied-seta.sh");
+ p[INFILE] += Couple("setb.sh", workdir + "/copied-setb.sh");
+ p[OUTFILE] = Couple("result.txt", workdir + "/orig-result.txt");
job.setParametre(p);
// ... and its environment
Environnement e;
BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
// Create a BatchManager of type Local_SH on localhost
- FactBatchManager * fbm = c("SH");
+ FactBatchManager * fbm = c("LOCAL");
if (fbm == NULL) {
cerr << "Can't get SH batch manager factory" << endl;
return 1;
}
- BatchManager * bm = (*fbm)("localhost");
+ BatchManager * bm = (*fbm)("localhost", "", SH);
// Submit the job to the BatchManager
JobId jobid = bm->submitJob(job);
// Wait for the end of the job
string state = bm->waitForJobEnd(jobid, timeout);
- if (state != FINISHED && state != FAILED) {
- cerr << "Error: Job not finished after timeout" << endl;
+ if (state == FINISHED) {
+ cout << "Job " << jobid.__repr__() << " is done" << endl;
+ bm->importOutputFiles(job, "resultdir/seconddirname");
+ } else if (state == FAILED) {
+ cerr << "Job " << jobid.__repr__() << " finished in error" << endl;
+ bm->importOutputFiles(job, "resultdir/seconddirname");
+ return 1;
+ } else {
+ cerr << "Timeout while executing job" << endl;
return 1;
}
- cout << "Job " << jobid.__repr__() << " is done" << endl;
-
} catch (GenericException e) {
cerr << "Error: " << e << endl;
return 1;
// test the result file
string exp = "c = 12";
string res;
- ifstream f("result.txt");
+ ifstream f("resultdir/seconddirname/result.txt");
getline(f, res);
f.close();
Job job;
// ... and its parameters ...
Parametre p;
- p[EXECUTABLE] = "source copied-test-script.sh";
+ p[EXECUTABLE] = "test-script.sh";
p[NAME] = "Test_Local_SSH";
p[WORKDIR] = workdir;
- p[INFILE] = Couple("seta.sh", "copied-seta.sh");
- p[INFILE] += Couple("setb.sh", "copied-setb.sh");
- p[INFILE] += Couple("test-script.sh", "copied-test-script.sh");
- p[OUTFILE] = Couple("result.txt", "orig-result.txt");
- p[EXECUTIONHOST] = exechost;
+ p[INFILE] = Couple("seta.sh", workdir + "/copied-seta.sh");
+ p[INFILE] += Couple("setb.sh", workdir + "/copied-setb.sh");
+ p[OUTFILE] = Couple("result.txt", workdir + "/orig-result.txt");
p[USER] = user;
job.setParametre(p);
// ... and its environment (SSH_AUTH_SOCK env var is important for ssh agent authentication)
BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
// Create a BatchManager of type Local_SSH on localhost
- FactBatchManager * fbm = c("SSH");
+ FactBatchManager * fbm = c("LOCAL");
if (fbm == NULL) {
cerr << "Can't get SSH batch manager factory" << endl;
return 1;
}
- BatchManager * bm = (*fbm)("localhost");
+ BatchManager * bm = (*fbm)(exechost.c_str(), user.c_str(), SSH);
// Submit the job to the BatchManager
JobId jobid = bm->submitJob(job);
// Wait for the end of the job
string state = bm->waitForJobEnd(jobid, timeout);
- if (state != FINISHED && state != FAILED) {
- cerr << "Error: Job not finished after timeout" << endl;
+ if (state == FINISHED) {
+ cout << "Job " << jobid.__repr__() << " is done" << endl;
+ bm->importOutputFiles(job, "resultdir/seconddirname");
+ } else if (state == FAILED) {
+ cerr << "Job " << jobid.__repr__() << " finished in error" << endl;
+ bm->importOutputFiles(job, "resultdir/seconddirname");
+ return 1;
+ } else {
+ cerr << "Timeout while executing job" << endl;
return 1;
}
- cout << "Job " << jobid.__repr__() << " is done" << endl;
-
} catch (GenericException e) {
cerr << "Error: " << e << endl;
return 1;
// test the result file
string exp = "c = 12";
string res;
- ifstream f("result.txt");
+ ifstream f("resultdir/seconddirname/result.txt");
getline(f, res);
f.close();
#!/bin/sh
-source copied-seta.sh
-source copied-setb.sh
+. ./copied-seta.sh
+. ./copied-setb.sh
c=`expr $a "*" $b`
#include <Batch_Constants.hxx>
#include <Batch_Utils.hxx>
+#include <Batch_NotYetImplementedException.hxx>
#include "Batch_BatchManager_ePBS.hxx"
#include "Batch_JobInfo_ePBS.hxx"
const char * username,
CommunicationProtocolType protocolType, const char * mpiImpl,
int nb_proc_per_node)
- : BatchManager(parent, host),
- BatchManager_eClient(parent, host, username, protocolType, mpiImpl),
+ : BatchManager(parent, host, username, protocolType, mpiImpl),
_nb_proc_per_node(nb_proc_per_node)
{
// Nothing to do
string output;
int status = Utils::getCommandOutput(command, output);
cout << output;
- if (status != 0) throw EmulationException("Can't submit job, error was: " + output);
+ if (status != 0) throw RunTimeException("Can't submit job, error was: " + output);
// normally output contains only id of submitted job, we just need to remove the final \n
string jobref = output.substr(0, output.size() - 1);
cerr << command.c_str() << endl;
status = system(command.c_str());
if (status)
- throw EmulationException("Error of connection on remote host");
+ throw RunTimeException("Error of connection on remote host");
cerr << "jobId = " << ref << "killed" << endl;
}
// Methode pour le controle des jobs : suspend un job en file d'attente
void BatchManager_ePBS::holdJob(const JobId & jobid)
{
- throw EmulationException("Not yet implemented");
+ throw NotYetImplementedException("BatchManager_ePBS::holdJob");
}
// Methode pour le controle des jobs : relache un job suspendu
void BatchManager_ePBS::releaseJob(const JobId & jobid)
{
- throw EmulationException("Not yet implemented");
+ throw NotYetImplementedException("BatchManager_ePBS::releaseJob");
}
// Methode pour le controle des jobs : modifie un job en file d'attente
void BatchManager_ePBS::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env)
{
- throw EmulationException("Not yet implemented");
+ throw NotYetImplementedException("BatchManager_ePBS::alterJob");
}
// Methode pour le controle des jobs : modifie un job en file d'attente
string output;
int status = Utils::getCommandOutput(command, output);
if(status && status != 153 && status != 256*153)
- throw EmulationException("Error of connection on remote host");
+ throw RunTimeException("Error of connection on remote host");
JobInfo_ePBS ji = JobInfo_ePBS(id, output);
return ji;
// Methode pour le controle des jobs : teste si un job est present en machine
bool BatchManager_ePBS::isRunning(const JobId & jobid)
{
- throw EmulationException("Not yet implemented");
+ throw NotYetImplementedException("BatchManager_ePBS::isRunning");
}
std::string BatchManager_ePBS::buildSubmissionScript(const Job & job)
if (params.find(WORKDIR) != params.end())
workDir = params[WORKDIR].str();
else
- throw EmulationException("params[WORKDIR] is not defined ! Please defined it, cannot submit this job");
+ throw RunTimeException("params[WORKDIR] is not defined ! Please defined it, cannot submit this job");
if (params.find(EXECUTABLE) != params.end())
fileToExecute = params[EXECUTABLE].str();
else
- throw EmulationException("params[EXECUTABLE] is not defined ! Please defined it, cannot submit this job");
+ throw RunTimeException("params[EXECUTABLE] is not defined ! Please defined it, cannot submit this job");
// Optional parameters
if (params.find(NBPROC) != params.end())
// Create batch submit file
ofstream tempOutputFile;
- std::string TmpFileName = createAndOpenTemporaryFile("PBS-script", tempOutputFile);
+ std::string TmpFileName = Utils::createAndOpenTemporaryFile("PBS-script", tempOutputFile);
tempOutputFile << "#! /bin/sh -f" << endl;
if (params.find(NAME) != params.end()) {
workDir + "/" + remoteFileName,
_hostname, _username);
if (status)
- throw EmulationException("Error of connection on remote host, cannot copy batch submission file");
+ throw RunTimeException("Error of connection on remote host, cannot copy batch submission file");
return remoteFileName;
}
}
#include "Batch_JobId.hxx"
#include "Batch_JobInfo.hxx"
#include "Batch_FactBatchManager.hxx"
-#include "Batch_BatchManager_eClient.hxx"
+#include "Batch_BatchManager.hxx"
namespace Batch {
- class BATCH_EXPORT BatchManager_ePBS : public BatchManager_eClient
+ class BATCH_EXPORT BatchManager_ePBS : public BatchManager
{
public:
// Constructeur et destructeur
*
*/
-#include <string>
#include "Batch_BatchManager_ePBS.hxx"
#include "Batch_FactBatchManager_ePBS.hxx"
-//#include "utilities.h"
namespace Batch {
static FactBatchManager_ePBS sFBM_ePBS;
// Constructeur
- FactBatchManager_ePBS::FactBatchManager_ePBS() : FactBatchManager_eClient("ePBS")
+ FactBatchManager_ePBS::FactBatchManager_ePBS() : FactBatchManager("PBS")
{
// Nothing to do
}
// Nothing to do
}
- // Functor
- BatchManager * FactBatchManager_ePBS::operator() (const char * hostname) const
+ BatchManager * FactBatchManager_ePBS::operator() (const char * hostname,
+ const char * username,
+ CommunicationProtocolType protocolType,
+ const char * mpiImpl,
+ int nb_proc_per_node) const
{
- // MESSAGE("Building new BatchManager_PBS on host '" << hostname << "'");
- return new BatchManager_ePBS(this, hostname);
- }
-
- BatchManager_eClient * FactBatchManager_ePBS::operator() (const char * hostname,
- const char * username,
- CommunicationProtocolType protocolType,
- const char * mpiImpl,
- int nb_proc_per_node) const
- {
- // MESSAGE("Building new BatchManager_PBS on host '" << hostname << "'");
return new BatchManager_ePBS(this, hostname, username, protocolType, mpiImpl, nb_proc_per_node);
}
-
}
#include "Batch_Defines.hxx"
-#include <string>
-#include <map>
-#include "Batch_BatchManager_eClient.hxx"
-#include "Batch_FactBatchManager_eClient.hxx"
+#include "Batch_BatchManager.hxx"
+#include "Batch_FactBatchManager.hxx"
namespace Batch {
class BatchManager_ePBS;
- class BATCH_EXPORT FactBatchManager_ePBS : public FactBatchManager_eClient
+ class BATCH_EXPORT FactBatchManager_ePBS : public FactBatchManager
{
public:
// Constructeur et destructeur
FactBatchManager_ePBS();
virtual ~FactBatchManager_ePBS();
- virtual BatchManager * operator() (const char * hostname) const;
- virtual BatchManager_eClient * operator() (const char * hostname,
- const char * username,
- CommunicationProtocolType protocolType,
- const char * mpiImpl,
- int nb_proc_per_node = 1) const;
-
- protected:
-
- private:
+ virtual BatchManager * operator() (const char * hostname,
+ const char * username,
+ CommunicationProtocolType protocolType,
+ const char * mpiImpl,
+ int nb_proc_per_node = 1) const;
};
PBS/Batch_JobInfo_ePBS
)
-IF (BUILD_PBS_INTERFACE AND PBS_FOUND)
- SET(CLASS_LIST ${CLASS_LIST}
- PBS/Batch_BatchManager_PBS
- PBS/Batch_FactBatchManager_PBS
- PBS/Batch_Job_PBS
- PBS/Batch_JobInfo_PBS
- )
-ENDIF (BUILD_PBS_INTERFACE AND PBS_FOUND)
+#IF (BUILD_PBS_INTERFACE AND PBS_FOUND)
+# SET(CLASS_LIST ${CLASS_LIST}
+# PBS/Batch_BatchManager_PBS
+# PBS/Batch_FactBatchManager_PBS
+# PBS/Batch_Job_PBS
+# PBS/Batch_JobInfo_PBS
+# )
+#ENDIF (BUILD_PBS_INTERFACE AND PBS_FOUND)
APPEND_CLASSES_TO_SRC_FILES(${CLASS_LIST})
ADD_TEST(ePBS_RSH Test_ePBS RSH)
ENDIF (HAS_RSH)
-IF (BUILD_PBS_INTERFACE AND PBS_FOUND)
- add_executable(Test_PBS Test_PBS.cxx)
- target_link_libraries(Test_PBS Batch SimpleParser)
- ADD_TEST(PBS Test_PBS)
-ENDIF (BUILD_PBS_INTERFACE AND PBS_FOUND)
+#IF (BUILD_PBS_INTERFACE AND PBS_FOUND)
+# add_executable(Test_PBS Test_PBS.cxx)
+# target_link_libraries(Test_PBS Batch SimpleParser)
+# ADD_TEST(PBS Test_PBS)
+#ENDIF (BUILD_PBS_INTERFACE AND PBS_FOUND)
#include <Batch_Job.hxx>
#include <Batch_BatchManagerCatalog.hxx>
#include <Batch_FactBatchManager.hxx>
-#include <Batch_FactBatchManager_eClient.hxx>
#include <Batch_BatchManager.hxx>
-#include <Batch_BatchManager_eClient.hxx>
#include <SimpleParser.hxx>
p[INFILE] = Couple("seta.sh", "tmp/Batch/seta.sh");
p[INFILE] += Couple("setb.sh", "tmp/Batch/setb.sh");
p[OUTFILE] = Couple("result.txt", "tmp/Batch/result.txt");
- p[TMPDIR] = "tmp/Batch/";
p[NBPROC] = 1;
p[MAXWALLTIME] = 1;
p[MAXRAMSIZE] = 128;
BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
// Create a BatchManager of type ePBS on localhost
- FactBatchManager_eClient * fbm = (FactBatchManager_eClient *)(c("ePBS"));
- BatchManager_eClient * bm = (*fbm)(host.c_str(), user.c_str(), protocol, "nompi", 8);
+ FactBatchManager * fbm = c("PBS");
+ BatchManager * bm = (*fbm)(host.c_str(), user.c_str(), protocol, "nompi", 8);
// Submit the job to the BatchManager
JobId jobid = bm->submitJob(job);
job = Job()
# ... and its parameters ...
p = {}
- p[EXECUTABLE] = './copied-' + config.EXEC_TEST_NAME
+ p[EXECUTABLE] = config.EXEC_TEST_FULL_PATH
p[ARGUMENTS] = ["copied-seta.sh", "copied-setb.sh", "orig-result.txt"];
p[NAME] = 'Test_Python_Local_SH'
p[WORKDIR] = config.TEST_LOCAL_SH_WORK_DIR
- p[INFILE] = [('seta.sh', 'copied-seta.sh'), ('setb.sh', 'copied-setb.sh'),
- (config.EXEC_TEST_FULL_PATH, 'copied-' + config.EXEC_TEST_NAME)]
- p[OUTFILE] = [('result.txt', 'orig-result.txt')]
+ p[INFILE] = [('seta.sh', p[WORKDIR] + '/copied-seta.sh'),
+ ('setb.sh', p[WORKDIR] + '/copied-setb.sh')]
+ p[OUTFILE] = [('result.txt', p[WORKDIR] + '/orig-result.txt')]
job.setParametre(p)
# ... and its environment
e = {}
# Get the catalog
c = BatchManagerCatalog.getInstance()
- # Create a BatchManager of type Local_SSH on localhost
- bm = c('SH')('localhost')
+ # Create a BatchManager of type Local_SH on localhost
+ bm = c('LOCAL')('localhost', '', SH)
# Submit the job to the BatchManager
jobid = bm.submitJob(job)
# Wait for the end of the job
state = bm.waitForJobEnd(jobid, config.TEST_LOCAL_SH_TIMEOUT);
+
+ if state == FINISHED:
+ print "Job", jobid, "is done"
+ bm.importOutputFiles(job, "resultdir/seconddirname")
+ elif state == FAILED:
+ print "Job", jobid, " finished in error"
+ bm.importOutputFiles(job, "resultdir/seconddirname")
+ return 1
+ else:
+ print "Timeout while executing job"
+ return 1
+
if state != FINISHED and state != FAILED:
print "Error: Job not finished after timeout"
return 1;
- print "Job", jobid, "is done"
-
# test the result file
exp = "c = 12"
- f = open('result.txt')
+ f = open('resultdir/seconddirname/result.txt')
res = f.read().strip()
print "result found : %s, expected : %s" % (res, exp)
#include "Batch_CommunicationProtocol.hxx"
#include "Batch_BatchManager.hxx"
-#include "Batch_BatchManager_eClient.hxx"
#include "Batch_BatchManagerCatalog.hxx"
#include "Batch_FactBatchManager.hxx"
-#include "Batch_FactBatchManager_eClient.hxx"
%}
/* Les classes exportees en Python */
%include Batch_CommunicationProtocol.hxx
%include Batch_BatchManager.hxx
-%include Batch_BatchManager_eClient.hxx
%include Batch_BatchManagerCatalog.hxx
%include Batch_FactBatchManager.hxx
-%include Batch_FactBatchManager_eClient.hxx
%include Batch_Constants.hxx
bool res = initEnvironment($1, $input);
if (!res) return NULL;
}
-
-// Dynamic cast to FactBatchManager_eClient if necessary
-%typemap(out) Batch::FactBatchManager *
-{
- if(dynamic_cast<Batch::FactBatchManager_eClient *>($1))
- $result=SWIG_NewPointerObj((void*)$1,$descriptor(Batch::FactBatchManager_eClient *),$owner);
- else
- $result=SWIG_NewPointerObj((void*)$1,$descriptor(Batch::FactBatchManager *),$owner);
-}
#include <libgen.h>
#endif
-#include "Batch_Constants.hxx"
+#include <Batch_Constants.hxx>
+#include <Batch_Utils.hxx>
+#include <Batch_NotYetImplementedException.hxx>
+
#include "Batch_BatchManager_eSGE.hxx"
#include "Batch_JobInfo_eSGE.hxx"
BatchManager_eSGE::BatchManager_eSGE(const FactBatchManager * parent, const char * host,
const char * username,
CommunicationProtocolType protocolType, const char * mpiImpl)
- : BatchManager(parent, host),
- BatchManager_eClient(parent, host, username, protocolType, mpiImpl)
+ : BatchManager(parent, host, username, protocolType, mpiImpl)
{
// Nothing to do
}
// Methode pour le controle des jobs : soumet un job au gestionnaire
const JobId BatchManager_eSGE::submitJob(const Job & job)
{
- int status;
Parametre params = job.getParametre();
const std::string workDir = params[WORKDIR];
const string fileToExecute = params[EXECUTABLE];
// build batch script for job
buildBatchScript(job);
- // define name of log file (local)
- string logFile = generateTemporaryFileName("SGE-submitlog");
-
// define command to submit batch
string subCommand = string("bash -l -c \\\"cd ") + workDir + "; qsub " + fileNameToExecute + "_Batch.sh\\\"";
string command = _protocol.getExecCommand(subCommand, _hostname, _username);
- command += " > ";
- command += logFile;
command += " 2>&1";
cerr << command.c_str() << endl;
- status = system(command.c_str());
- if(status)
- {
- ifstream error_message(logFile.c_str());
- std::string mess;
- std::string temp;
- while(std::getline(error_message, temp))
- mess += temp;
- error_message.close();
- throw EmulationException("Error of connection on remote host, error was: " + mess);
- }
-
- // read id of submitted job in log file
- char line[128];
- FILE *fp = fopen(logFile.c_str(),"r");
- fgets( line, 128, fp);
- fclose(fp);
+ // submit job
+ string output;
+ int status = Utils::getCommandOutput(command, output);
+ cout << output;
+ if (status != 0) throw RunTimeException("Can't submit job, error was: " + output);
+
+ // find id of submitted job in output
string strjob;
- istringstream iss(line);
+ istringstream iss(output);
iss >> strjob >> strjob >> strjob;
JobId id(this, strjob);
cerr << command.c_str() << endl;
status = system(command.c_str());
if(status)
- throw EmulationException("Error of connection on remote host");
+ throw RunTimeException("Error of connection on remote host");
cerr << "jobId = " << ref << "killed" << endl;
}
// Methode pour le controle des jobs : suspend un job en file d'attente
void BatchManager_eSGE::holdJob(const JobId & jobid)
{
- throw EmulationException("Not yet implemented");
+ throw NotYetImplementedException("BatchManager_eSGE::holdJob");
}
// Methode pour le controle des jobs : relache un job suspendu
void BatchManager_eSGE::releaseJob(const JobId & jobid)
{
- throw EmulationException("Not yet implemented");
+ throw NotYetImplementedException("BatchManager_eSGE::releaseJob");
}
// Methode pour le controle des jobs : modifie un job en file d'attente
void BatchManager_eSGE::alterJob(const JobId & jobid, const Parametre & param, const Environnement & env)
{
- throw EmulationException("Not yet implemented");
+ throw NotYetImplementedException("BatchManager_eSGE::alterJob");
}
// Methode pour le controle des jobs : modifie un job en file d'attente
istringstream iss(jobid.getReference());
iss >> id;
- // define name of log file (local)
- string logFile = generateTemporaryFileName(string("SGE-querylog-id") + jobid.getReference());
-
// define command to query batch
string subCommand = string("bash -l -c \\\"qstat | grep ") + iss.str() + string("\\\"");
string command = _protocol.getExecCommand(subCommand, _hostname, _username);
- command += " > ";
- command += logFile;
cerr << command.c_str() << endl;
- int status = system(command.c_str());
+
+ string output;
+ int status = Utils::getCommandOutput(command, output);
if (status && status != 256)
- throw EmulationException("Error of connection on remote host");
+ throw RunTimeException("Error of connection on remote host");
- JobInfo_eSGE ji = JobInfo_eSGE(id,logFile);
+ JobInfo_eSGE ji = JobInfo_eSGE(id, output);
return ji;
}
// Methode pour le controle des jobs : teste si un job est present en machine
bool BatchManager_eSGE::isRunning(const JobId & jobid)
{
- throw EmulationException("Not yet implemented");
+ throw NotYetImplementedException("BatchManager_eSGE::isRunning");
}
void BatchManager_eSGE::buildBatchScript(const Job & job)
if (params.find(WORKDIR) != params.end())
workDir = params[WORKDIR].str();
else
- throw EmulationException("params[WORKDIR] is not defined ! Please defined it, cannot submit this job");
+ throw RunTimeException("params[WORKDIR] is not defined ! Please defined it, cannot submit this job");
if (params.find(EXECUTABLE) != params.end())
fileToExecute = params[EXECUTABLE].str();
else
- throw EmulationException("params[EXECUTABLE] is not defined ! Please defined it, cannot submit this job");
+ throw RunTimeException("params[EXECUTABLE] is not defined ! Please defined it, cannot submit this job");
// Optional parameters
if (params.find(NBPROC) != params.end())
// Create batch submit file
ofstream tempOutputFile;
- std::string TmpFileName = createAndOpenTemporaryFile("SGE-script", tempOutputFile);
+ std::string TmpFileName = Utils::createAndOpenTemporaryFile("SGE-script", tempOutputFile);
tempOutputFile << "#! /bin/sh -f" << endl;
if (queue != "")
workDir + "/" + rootNameToExecute + "_Batch.sh",
_hostname, _username);
if (status)
- throw EmulationException("Error of connection on remote host");
+ throw RunTimeException("Error of connection on remote host");
#endif //WIN32
}
#include "Batch_JobId.hxx"
#include "Batch_JobInfo.hxx"
#include "Batch_FactBatchManager.hxx"
-#include "Batch_BatchManager_eClient.hxx"
+#include "Batch_BatchManager.hxx"
namespace Batch {
- class BATCH_EXPORT BatchManager_eSGE : public BatchManager_eClient
+ class BATCH_EXPORT BatchManager_eSGE : public BatchManager
{
public:
// Constructeur et destructeur
static FactBatchManager_eSGE sFBM_eSGE;
// Constructeur
- FactBatchManager_eSGE::FactBatchManager_eSGE() : FactBatchManager_eClient("eSGE")
+ FactBatchManager_eSGE::FactBatchManager_eSGE() : FactBatchManager("SGE")
{
// Nothing to do
}
// Nothing to do
}
- // Functor
- BatchManager * FactBatchManager_eSGE::operator() (const char * hostname) const
- {
- // MESSAGE("Building new BatchManager_SGE on host '" << hostname << "'");
- return new BatchManager_eSGE(this, hostname);
- }
-
- BatchManager_eClient * FactBatchManager_eSGE::operator() (const char * hostname,
- const char * username,
- CommunicationProtocolType protocolType,
- const char * mpiImpl,
- int nb_proc_per_node) const
+ BatchManager * FactBatchManager_eSGE::operator() (const char * hostname,
+ const char * username,
+ CommunicationProtocolType protocolType,
+ const char * mpiImpl,
+ int nb_proc_per_node) const
{
// MESSAGE("Building new BatchManager_SGE on host '" << hostname << "'");
return new BatchManager_eSGE(this, hostname, username, protocolType, mpiImpl);
}
-
}
#include "Batch_Defines.hxx"
-#include "Batch_BatchManager_eClient.hxx"
-#include "Batch_FactBatchManager_eClient.hxx"
+#include "Batch_BatchManager.hxx"
+#include "Batch_FactBatchManager.hxx"
namespace Batch {
- class BATCH_EXPORT FactBatchManager_eSGE : public FactBatchManager_eClient
+ class BATCH_EXPORT FactBatchManager_eSGE : public FactBatchManager
{
public:
// Constructeur et destructeur
FactBatchManager_eSGE();
virtual ~FactBatchManager_eSGE();
- virtual BatchManager * operator() (const char * hostname) const;
- virtual BatchManager_eClient * operator() (const char * hostname,
- const char * username,
- CommunicationProtocolType protocolType,
- const char * mpiImpl,
- int nb_proc_per_node = 1) const;
-
- protected:
-
- private:
+ virtual BatchManager * operator() (const char * hostname,
+ const char * username,
+ CommunicationProtocolType protocolType,
+ const char * mpiImpl,
+ int nb_proc_per_node = 1) const;
};
#include <cstdio>
#include <iostream>
-#include <fstream>
#include <sstream>
#include "Batch_Constants.hxx"
// Constructeurs
- JobInfo_eSGE::JobInfo_eSGE(int id, string logFile) : JobInfo()
+ JobInfo_eSGE::JobInfo_eSGE(int id, const std::string & output) : JobInfo()
{
// On remplit les membres _param et _env
ostringstream oss;
// read of log file
char line[128];
- ifstream fp(logFile.c_str(),ios::in);
+ istringstream fp(output);
string status;
string sline;
public:
// Constructeurs et destructeur
JobInfo_eSGE() : _running(false) {};
- JobInfo_eSGE(int id,std::string logFile);
+ JobInfo_eSGE(int id, const std::string & output);
virtual ~JobInfo_eSGE();
// Constructeur par recopie
CommunicationProtocolType protocolType,
const char * mpiImpl,
int nb_proc_per_node)
- : BatchManager(parent, host),
- BatchManager_eClient(parent, host, username, protocolType, mpiImpl),
- _nb_proc_per_node(nb_proc_per_node)
+ : BatchManager(parent, host, username, protocolType, mpiImpl)
{
}
string output;
int status = Utils::getCommandOutput(command, output);
cout << output;
- if (status != 0) throw EmulationException("Can't submit job, error was: " + output);
+ if (status != 0) throw RunTimeException("Can't submit job, error was: " + output);
// find id of submitted job in output
string search = "Submitted batch job ";
string::size_type pos = output.find(search);
if (pos == string::npos)
- throw EmulationException("Error in the submission of the job on the remote host");
+ throw RunTimeException("Error in the submission of the job on the remote host");
pos += search.size();
string::size_type endl_pos = output.find('\n', pos);
string::size_type count = (endl_pos == string::npos)? string::npos : endl_pos - pos;
if (params.find(WORKDIR) != params.end())
workDir = params[WORKDIR].str();
else
- throw EmulationException("params[WORKDIR] is not defined. Please define it, cannot submit this job.");
+ throw RunTimeException("params[WORKDIR] is not defined. Please define it, cannot submit this job.");
if (params.find(EXECUTABLE) != params.end())
fileToExecute = params[EXECUTABLE].str();
else
- throw EmulationException("params[EXECUTABLE] is not defined. Please define it, cannot submit this job.");
+ throw RunTimeException("params[EXECUTABLE] is not defined. Please define it, cannot submit this job.");
string::size_type p1 = fileToExecute.find_last_of("/");
string::size_type p2 = fileToExecute.find_last_of(".");
// Create batch submit file
ofstream tempOutputFile;
- string tmpFileName = createAndOpenTemporaryFile("slurm-script", tempOutputFile);
+ string tmpFileName = Utils::createAndOpenTemporaryFile("slurm-script", tempOutputFile);
tempOutputFile << "#!/bin/bash" << endl;
tempOutputFile << "#SBATCH --output=" << workDir << "/logs/output.log." << rootNameToExecute << endl;
workDir + "/" + remoteFileName,
_hostname, _username);
if (status)
- throw EmulationException("Cannot copy command file on host " + _hostname);
+ throw RunTimeException("Cannot copy command file on host " + _hostname);
return remoteFileName;
}
int status = system(command.c_str());
if (status)
- throw EmulationException("Can't delete job " + jobid.getReference());
+ throw RunTimeException("Can't delete job " + jobid.getReference());
cerr << "job " << jobid.getReference() << " killed" << endl;
}
#include <Batch_JobId.hxx>
#include <Batch_JobInfo.hxx>
#include <Batch_FactBatchManager.hxx>
-#include <Batch_BatchManager_eClient.hxx>
+#include <Batch_BatchManager.hxx>
namespace Batch {
- class BATCH_EXPORT BatchManager_eSlurm : public BatchManager_eClient
+ class BATCH_EXPORT BatchManager_eSlurm : public BatchManager
{
public:
std::string buildCommandFile(const Job & job);
- int _nb_proc_per_node;
-
};
}
static FactBatchManager_eSlurm sFBM_eSlurm;
- FactBatchManager_eSlurm::FactBatchManager_eSlurm() : FactBatchManager_eClient("eSLURM")
+ FactBatchManager_eSlurm::FactBatchManager_eSlurm() : FactBatchManager("SLURM")
{
}
{
}
- BatchManager * FactBatchManager_eSlurm::operator() (const char * hostname) const
+ BatchManager * FactBatchManager_eSlurm::operator() (const char * hostname,
+ const char * username,
+ CommunicationProtocolType protocolType,
+ const char * mpiImpl,
+ int nb_proc_per_node) const
{
- // MESSAGE("Building new BatchManager_eSlurm on host '" << hostname << "'");
- return new BatchManager_eSlurm(this, hostname);
- }
-
- BatchManager_eClient * FactBatchManager_eSlurm::operator() (const char * hostname,
- const char * username,
- CommunicationProtocolType protocolType,
- const char * mpiImpl,
- int nb_proc_per_node) const
- {
- // MESSAGE("Building new BatchManager_eSlurm on host '" << hostname << "'");
return new BatchManager_eSlurm(this, hostname, username, protocolType, mpiImpl, nb_proc_per_node);
}
#define _FACTBATCHMANAGER_ESLURM_H_
#include <Batch_Defines.hxx>
-#include <Batch_Constants.hxx>
-#include <Batch_BatchManager_eClient.hxx>
-#include <Batch_FactBatchManager_eClient.hxx>
+#include <Batch_BatchManager.hxx>
+#include <Batch_FactBatchManager.hxx>
namespace Batch {
- class BATCH_EXPORT FactBatchManager_eSlurm : public FactBatchManager_eClient
+ class BATCH_EXPORT FactBatchManager_eSlurm : public FactBatchManager
{
public:
FactBatchManager_eSlurm();
virtual ~FactBatchManager_eSlurm();
- virtual BatchManager * operator() (const char * hostname) const;
- virtual BatchManager_eClient * operator() (const char * hostname,
- const char * username,
- CommunicationProtocolType protocolType,
- const char * mpiImpl,
- int nb_proc_per_node = 1) const;
+ virtual BatchManager * operator() (const char * hostname,
+ const char * username,
+ CommunicationProtocolType protocolType,
+ const char * mpiImpl,
+ int nb_proc_per_node = 1) const;
};
#include <Batch_Job.hxx>
#include <Batch_BatchManagerCatalog.hxx>
#include <Batch_FactBatchManager.hxx>
-#include <Batch_FactBatchManager_eClient.hxx>
#include <Batch_BatchManager.hxx>
-#include <Batch_BatchManager_eClient.hxx>
#include <SimpleParser.hxx>
p[INFILE] = Couple("seta.sh", "tmp/Batch/seta.sh");
p[INFILE] += Couple("setb.sh", "tmp/Batch/setb.sh");
p[OUTFILE] = Couple("result.txt", "tmp/Batch/result.txt");
- p[TMPDIR] = "tmp/Batch/";
p[NBPROC] = 1;
p[MAXWALLTIME] = 1;
p[MAXRAMSIZE] = 50;
BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
// Create a BatchManager of type ePBS on localhost
- FactBatchManager_eClient * fbm = (FactBatchManager_eClient *)(c("eSLURM"));
- BatchManager_eClient * bm = (*fbm)(host.c_str(), user.c_str(), protocol);
+ FactBatchManager * fbm = c("SLURM");
+ BatchManager * bm = (*fbm)(host.c_str(), user.c_str(), protocol);
// Submit the job to the BatchManager
JobId jobid = bm->submitJob(job);
CommunicationProtocolType protocolType,
const char * mpiImpl,
int nb_proc_per_node)
- : BatchManager(parent, host),
- // Force SH protocol for Vishnu
- BatchManager_eClient(parent, host, username, SH, mpiImpl),
+ : // Force SH protocol for Vishnu
+ BatchManager(parent, host, username, SH, mpiImpl),
_nb_proc_per_node(nb_proc_per_node)
{
}
string output;
int status = Utils::getCommandOutput(command, output);
cout << output;
- if (status != 0) throw EmulationException("Can't submit job, error was: " + output);
+ if (status != 0) throw RunTimeException("Can't submit job, error was: " + output);
// find id of submitted job in output
string search = "Job Id : ";
string::size_type pos = output.find(search);
if (pos == string::npos)
- throw EmulationException("Error in the submission of the job on the remote host");
+ throw RunTimeException("Error in the submission of the job on the remote host");
pos += search.size();
string::size_type endl_pos = output.find('\n', pos);
string::size_type count = (endl_pos == string::npos)? string::npos : endl_pos - pos;
string jobref = output.substr(pos, count);
if (jobref.size() == 0)
- throw EmulationException("Error in the submission of the job on the remote host");
+ throw RunTimeException("Error in the submission of the job on the remote host");
JobId id(this, jobref);
return id;
int status = Utils::getCommandOutput(command, output);
cout << output;
if (status != 0)
- throw EmulationException("Can't copy input files, error was: " + output);
+ throw RunTimeException("Can't copy input files, error was: " + output);
}
/**
if (params.find(WORKDIR) != params.end())
workDir = params[WORKDIR].str();
else
- throw EmulationException("params[WORKDIR] is not defined. Please define it, cannot submit this job.");
+ throw RunTimeException("params[WORKDIR] is not defined. Please define it, cannot submit this job.");
if (params.find(EXECUTABLE) != params.end())
fileToExecute = params[EXECUTABLE].str();
else
- throw EmulationException("params[EXECUTABLE] is not defined. Please define it, cannot submit this job.");
+ throw RunTimeException("params[EXECUTABLE] is not defined. Please define it, cannot submit this job.");
string::size_type p1 = fileToExecute.find_last_of("/");
string::size_type p2 = fileToExecute.find_last_of(".");
// Create batch submit file
ofstream tempOutputFile;
- string tmpFileName = createAndOpenTemporaryFile("vishnu-script", tempOutputFile);
+ string tmpFileName = Utils::createAndOpenTemporaryFile("vishnu-script", tempOutputFile);
tempOutputFile << "#!/bin/sh" << endl;
tempOutputFile << "#% vishnu_output=" << workDir << "/logs/output.log." << rootNameToExecute << endl;
int status = system(command.c_str());
if (status)
- throw EmulationException("Can't delete job " + jobid.getReference());
+ throw RunTimeException("Can't delete job " + jobid.getReference());
cerr << "job " << jobid.getReference() << " killed" << endl;
}
string output;
int status = Utils::getCommandOutput(command, output);
if (status != 0)
- throw EmulationException("Can't query job " + jobid.getReference());
+ throw RunTimeException("Can't query job " + jobid.getReference());
JobInfo_eVishnu jobinfo = JobInfo_eVishnu(jobid.getReference(), output);
return jobinfo;
}
string absdir = (Utils::isAbsolutePath(directory))? directory : cwd + "/" + directory;
int status = CommunicationProtocol::getInstance(SH).makeDirectory(absdir, "", "");
if (status != 0) {
- throw EmulationException("Can't create result directory");
+ throw RunTimeException("Can't create result directory");
}
string subCommand = string("export OMNIORB_CONFIG=$VISHNU_CONFIG_FILE; ");
status = Utils::getCommandOutput(command, output);
cout << output;
if (status != 0)
- throw EmulationException("Can't import output files, error was: " + output);
+ throw RunTimeException("Can't import output files, error was: " + output);
}
}
#include <Batch_JobId.hxx>
#include <Batch_JobInfo.hxx>
#include <Batch_FactBatchManager.hxx>
-#include <Batch_BatchManager_eClient.hxx>
+#include <Batch_BatchManager.hxx>
namespace Batch {
- class BATCH_EXPORT BatchManager_eVishnu : public BatchManager_eClient
+ class BATCH_EXPORT BatchManager_eVishnu : public BatchManager
{
public:
static FactBatchManager_eVishnu sFBM_eVishnu;
- FactBatchManager_eVishnu::FactBatchManager_eVishnu() : FactBatchManager_eClient("eVISHNU")
+ FactBatchManager_eVishnu::FactBatchManager_eVishnu() : FactBatchManager("VISHNU")
{
}
{
}
- BatchManager * FactBatchManager_eVishnu::operator() (const char * hostname) const
- {
- // MESSAGE("Building new BatchManager_eVishnu on host '" << hostname << "'");
- return new BatchManager_eVishnu(this, hostname);
- }
-
- BatchManager_eClient * FactBatchManager_eVishnu::operator() (const char * hostname,
- const char * username,
- CommunicationProtocolType protocolType,
- const char * mpiImpl,
- int nb_proc_per_node) const
+ BatchManager * FactBatchManager_eVishnu::operator() (const char * hostname,
+ const char * username,
+ CommunicationProtocolType protocolType,
+ const char * mpiImpl,
+ int nb_proc_per_node) const
{
// MESSAGE("Building new BatchManager_eVishnu on host '" << hostname << "'");
return new BatchManager_eVishnu(this, hostname, username, protocolType, mpiImpl, nb_proc_per_node);
#include <Batch_Defines.hxx>
#include <Batch_Constants.hxx>
-#include <Batch_BatchManager_eClient.hxx>
-#include <Batch_FactBatchManager_eClient.hxx>
+#include <Batch_BatchManager.hxx>
+#include <Batch_FactBatchManager.hxx>
namespace Batch {
- class BATCH_EXPORT FactBatchManager_eVishnu : public FactBatchManager_eClient
+ class BATCH_EXPORT FactBatchManager_eVishnu : public FactBatchManager
{
public:
FactBatchManager_eVishnu();
virtual ~FactBatchManager_eVishnu();
- virtual BatchManager * operator() (const char * hostname) const;
- virtual BatchManager_eClient * operator() (const char * hostname,
- const char * username,
- CommunicationProtocolType protocolType,
- const char * mpiImpl,
- int nb_proc_per_node = 1) const;
+ virtual BatchManager * operator() (const char * hostname,
+ const char * username,
+ CommunicationProtocolType protocolType,
+ const char * mpiImpl,
+ int nb_proc_per_node = 1) const;
};
#include <Batch_Job.hxx>
#include <Batch_BatchManagerCatalog.hxx>
#include <Batch_FactBatchManager.hxx>
-#include <Batch_FactBatchManager_eClient.hxx>
#include <Batch_BatchManager.hxx>
-#include <Batch_BatchManager_eClient.hxx>
#include <SimpleParser.hxx>
BatchManagerCatalog& c = BatchManagerCatalog::getInstance();
// Create a BatchManager of type ePBS on localhost
- FactBatchManager_eClient * fbm = (FactBatchManager_eClient *)(c("eVISHNU"));
- BatchManager_eClient * bm = (*fbm)(host.c_str(), user.c_str(), SH);
+ FactBatchManager * fbm = c("VISHNU");
+ BatchManager * bm = (*fbm)(host.c_str(), user.c_str(), SH);
// Submit the job to the BatchManager
JobId jobid = bm->submitJob(job);