1 // Copyright (C) 2007-2012 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.
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 "Batch_Defines.hxx"
38 #include "Batch_Job.hxx"
39 #include "Batch_JobId.hxx"
40 #include "Batch_JobInfo.hxx"
41 #include "Batch_InvalidArgumentException.hxx"
42 #include "Batch_CommunicationProtocol.hxx"
43 #include "Batch_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 : virtuelles pures
67 virtual const Batch::JobId submitJob(const Batch::Job & job) = 0; // soumet un job au gestionnaire
68 virtual void deleteJob(const Batch::JobId & jobid) = 0; // retire un job du gestionnaire
69 virtual void holdJob(const Batch::JobId & jobid) = 0; // suspend un job en file d'attente
70 virtual void releaseJob(const Batch::JobId & jobid) = 0; // relache un job suspendu
71 virtual void alterJob(const Batch::JobId & jobid, const Batch::Parametre & param, const Batch::Environnement & env) = 0; // modifie un job en file d'attente
72 virtual void alterJob(const Batch::JobId & jobid, const Batch::Parametre & param) = 0; // modifie un job en file d'attente
73 virtual void alterJob(const Batch::JobId & jobid, const Batch::Environnement & env) = 0; // modifie un job en file d'attente
74 virtual Batch::JobInfo queryJob(const Batch::JobId & jobid) = 0; // renvoie l'etat du job
75 virtual const Batch::JobId addJob(const Batch::Job & job, const std::string reference) = 0; // 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 );
81 // Get the underlying communication protocol
82 const CommunicationProtocol & getProtocol() const;
85 std::string _hostname; // serveur ou tourne le BatchManager
86 // std::map< const std::string, const Batch::JobId * > jobid_map; // table des jobs deja soumis
87 std::map< std::string, const Batch::JobId * > jobid_map; // table des jobs deja soumis
88 const Batch::FactBatchManager * _parent;
89 const CommunicationProtocol & _protocol; // protocol to access _hostname
90 const std::string _username; // username to access _hostname
91 MpiImpl *_mpiImpl; // Mpi implementation to launch executable in batch script
93 MpiImpl* FactoryMpiImpl(std::string mpiImpl);
94 void exportInputFiles(const Job & job);