1 // Copyright (C) 2005 OPEN CASCADE, CEA, EDF R&D, LEG
2 // PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 * BatchManager_Local.hxx :
22 * Auteur : Ivan DUTKA-MALEN - EDF R&D
23 * Mail : mailto:ivan.dutka-malen@der.edf.fr
24 * Date : Thu Nov 6 10:17:22 2003
29 #ifndef _BATCHMANAGER_LOCAL_H_
30 #define _BATCHMANAGER_LOCAL_H_
38 #include "Batch_Job.hxx"
39 #include "Batch_JobId.hxx"
40 #include "Batch_JobInfo.hxx"
41 #include "Batch_JobInfo_Local.hxx"
42 #include "Batch_Job_Local.hxx"
43 #include "Batch_InvalidArgumentException.hxx"
44 #include "Batch_ConnexionFailureException.hxx"
45 #include "Batch_APIInternalFailureException.hxx"
46 #include "Batch_NotYetImplementedException.hxx"
47 #include "Batch_BatchManager.hxx"
51 class FactBatchManager;
53 class BatchManager_Local : public BatchManager
56 friend class ThreadAdapter;
59 ThreadAdapter(BatchManager_Local & bm, const Job_Local & job);
60 static void * run(void * arg);
61 BatchManager_Local & getBatchManager() const { return _bm; };
64 BatchManager_Local & _bm;
68 void pere(pid_t child);
94 queue<Commande, deque<Commande> > command_queue;
105 // Constructeur et destructeur
106 BatchManager_Local(const FactBatchManager * parent, const char * host="localhost") throw(InvalidArgumentException,ConnexionFailureException); // connexion a la machine host
107 virtual ~BatchManager_Local();
109 // Recupere le nom du serveur par defaut
110 // static string BatchManager_Local::getDefaultServer();
112 // Methodes pour le controle des jobs
113 virtual const JobId submitJob(const Job & job); // soumet un job au gestionnaire
114 virtual void deleteJob(const JobId & jobid); // retire un job du gestionnaire
115 virtual void holdJob(const JobId & jobid); // suspend un job en file d'attente
116 virtual void releaseJob(const JobId & jobid); // relache un job suspendu
117 virtual void alterJob(const JobId & jobid, const Parametre & param, const Environnement & env); // modifie un job en file d'attente
118 virtual void alterJob(const JobId & jobid, const Parametre & param); // modifie un job en file d'attente
119 virtual void alterJob(const JobId & jobid, const Environnement & env); // modifie un job en file d'attente
120 virtual JobInfo queryJob(const JobId & jobid); // renvoie l'etat du job
121 virtual bool isRunning(const JobId & jobid); // teste si un job est present en machine
123 virtual void setParametre(const JobId & jobid, const Parametre & param) { return alterJob(jobid, param); } // modifie un job en file d'attente
124 virtual void setEnvironnement(const JobId & jobid, const Environnement & env) { return alterJob(jobid, env); } // modifie un job en file d'attente
128 int _connect; // Local connect id
129 pthread_mutex_t _threads_mutex;
130 map<Id, Child > _threads;
132 // Methode abstraite qui renvoie la commande de copie du fichier source en destination
133 virtual string copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const = 0;
135 // Methode abstraite qui renvoie la commande a executer
136 virtual string exec_command(Parametre & param) const = 0;
138 // Methode abstraite qui renvoie la commande d'effacement du fichier
139 virtual string remove_command(const string & host_destination, const string & destination) const = 0;
142 virtual pthread_t submit(const Job_Local & job);
143 virtual void cancel(pthread_t thread_id);
144 static void kill_child_on_exit(void * p_pid);
145 static void delete_on_exit(void * arg);
146 Id nextId(); // Retourne un identifiant unique pour un thread (clef de la map)
147 Id getIdByThread_id(pthread_t thread_id);
148 Id registerThread_id(pthread_t thread_id);
149 pthread_mutex_t _thread_id_id_association_mutex;
150 pthread_cond_t _thread_id_id_association_cond;
151 map<pthread_t, Id> _thread_id_id_association;
155 // Recupere le l'identifiant d'un job deja soumis au BatchManager
156 //virtual const JobId getJobIdByReference(const string & ref) { return BatchManager::getJobIdByReference(ref); }
157 virtual const JobId getJobIdByReference(const char * ref) { return BatchManager::getJobIdByReference(ref); }