1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
25 * Auteur : Ivan DUTKA-MALEN - EDF R&D
26 * Date : Septembre 2003
31 #ifndef _BATCHMANAGER_H_
32 #define _BATCHMANAGER_H_
34 #include "Defines.hxx"
40 #include "JobInfo.hxx"
41 #include "InvalidArgumentException.hxx"
42 #include "CommunicationProtocol.hxx"
43 #include "MpiImpl.hxx"
50 class FactBatchManager;
52 class BATCH_EXPORT BatchManager
55 // Constructeur et destructeur
56 BatchManager(const Batch::FactBatchManager * parent, const char * host = "localhost",
57 const char * username = "",
58 CommunicationProtocolType protocolType = SSH, const char * mpiImpl = "nompi");
59 virtual ~BatchManager();
60 virtual std::string __repr__() const;
62 // Recupere le l'identifiant d'un job deja soumis au BatchManager
63 //virtual const JobId getJobIdByReference(const std::string & ref);
64 virtual const Batch::JobId getJobIdByReference(const char * ref);
66 // Methodes pour le controle des jobs : doivent etre implementees dans les classes filles
67 virtual const Batch::JobId submitJob(const Batch::Job & job); // soumet un job au gestionnaire
68 virtual void deleteJob(const Batch::JobId & jobid); // retire un job du gestionnaire
69 virtual void holdJob(const Batch::JobId & jobid); // suspend un job en file d'attente
70 virtual void releaseJob(const Batch::JobId & jobid); // relache un job suspendu
71 virtual void alterJob(const Batch::JobId & jobid, const Batch::Parametre & param, const Batch::Environnement & env); // modifie un job en file d'attente
72 virtual void alterJob(const Batch::JobId & jobid, const Batch::Parametre & param); // modifie un job en file d'attente
73 virtual void alterJob(const Batch::JobId & jobid, const Batch::Environnement & env); // modifie un job en file d'attente
74 virtual Batch::JobInfo queryJob(const Batch::JobId & jobid); // renvoie l'etat du job
75 virtual const Batch::JobId addJob(const Batch::Job & job, const std::string & reference); // ajoute un nouveau job sans le soumettre
76 virtual std::string waitForJobEnd(const Batch::JobId & jobid, long timeout = -1,
77 long initSleepTime = 1, long maxSleepTime = 600);
78 virtual void importOutputFiles( const Job & job, const std::string directory );
79 bool importDumpStateFile( const Job & job, const std::string directory );
80 // copier le fichier work_file à partir du working_directory vers directory
81 virtual bool importWorkFile( const Job & job, const std::string& work_file, const std::string& directory );
82 virtual void clearWorkingDir( const Job & job );
84 // Get the underlying communication protocol
85 const CommunicationProtocol & getProtocol() const;
88 std::string _hostname; // serveur ou tourne le BatchManager
89 // std::map< const std::string, const Batch::JobId * > jobid_map; // table des jobs deja soumis
90 std::map< std::string, const Batch::JobId * > jobid_map; // table des jobs deja soumis
91 const std::string & _type;
92 const CommunicationProtocol & _protocol; // protocol to access _hostname
93 const std::string _username; // username to access _hostname
94 MpiImpl *_mpiImpl; // Mpi implementation to launch executable in batch script
96 MpiImpl* FactoryMpiImpl(std::string mpiImpl);
97 virtual void exportInputFiles(const Job & job);
99 // Preprocessing done on the frontal using "PREPROCESS" parameter as a script.
100 // May throw exceptions in case of failure.
101 virtual void preprocess(const Batch::Job & job);
103 // Submit to batch manager, but we suppose input files are already copied
104 // and preprocess finished without error
105 virtual const Batch::JobId runJob(const Batch::Job & job);