#ifndef _APIINTERNALFAILUREEXCEPTION_H_
#define _APIINTERNALFAILUREEXCEPTION_H_
+#include "Batch_Defines.hxx"
#include "Batch_GenericException.hxx"
#include "Batch_GenericException.hxx"
namespace Batch {
- class APIInternalFailureException : public GenericException
+ class BATCH_EXPORT APIInternalFailureException : public GenericException
{
public:
// Constructeur
#include <iostream>
#include <sstream>
#include <string>
-#include <netdb.h>
+#ifdef WIN32
+# include<winsock2.h>
+#else
+# include <netdb.h>
+#endif
+
//#include "MEDMEM_STRING.hxx"
#include "Batch_Job.hxx"
#include "Batch_JobId.hxx"
#ifndef _BATCHMANAGER_H_
#define _BATCHMANAGER_H_
+#include "Batch_Defines.hxx"
+
#include <string>
#include <map>
#include "Batch_Job.hxx"
class JobInfo;
class FactBatchManager;
- class BatchManager
+ class BATCH_EXPORT BatchManager
{
public:
// Constructeur et destructeur
#ifndef _CATALOG_H_
#define _CATALOG_H_
+#include "Batch_Defines.hxx"
+
#include <string>
#include <map>
#include <pthread.h>
class FactBatchManager;
- class BatchManagerCatalog
+ class BATCH_EXPORT BatchManagerCatalog
{
public:
// Constructeur
#ifndef _BATCHMANAGER_LSF_H_
#define _BATCHMANAGER_LSF_H_
+#include "Batch_Defines.hxx"
#include "Batch_Job.hxx"
#include "Batch_Job.hxx"
class JobInfo;
class FactBatchManager;
- class BatchManager_LSF : public BatchManager
+ class BATCH_EXPORT BatchManager_LSF : public BatchManager
{
public:
// Constructeur et destructeur
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
/*
- * BatchManager_Local.cxx :
- *
- * Auteur : Ivan DUTKA-MALEN - EDF R&D
- * Mail : mailto:ivan.dutka-malen@der.edf.fr
- * Date : Thu Nov 6 10:17:22 2003
- * Projet : Salome 2
- *
- */
+* BatchManager_Local.cxx :
+*
+* Auteur : Ivan DUTKA-MALEN - EDF R&D
+* Mail : mailto:ivan.dutka-malen@der.edf.fr
+* Date : Thu Nov 6 10:17:22 2003
+* Projet : Salome 2
+*
+*/
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include <sys/types.h>
-#include <sys/wait.h>
+#ifdef WIN32
+# include <direct.h>
+#else
+# include <sys/wait.h>
+# include <unistd.h>
+#endif
#include <ctime>
-#include <unistd.h>
#include <pthread.h>
#include <signal.h>
#include <errno.h>
#include "Batch_IOMutex.hxx"
#include "Batch_BatchManager_Local.hxx"
+using namespace std;
+
namespace Batch {
// Constructeur
- BatchManager_Local::BatchManager_Local(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager(parent, host), _connect(0), _threads_mutex(), _threads(), _thread_id_id_association_mutex(), _thread_id_id_association_cond(), _thread_id_id_association()
+ BatchManager_Local::BatchManager_Local(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException,ConnexionFailureException) : BatchManager(parent, host), _connect(0), _threads_mutex(), _threads(), _thread_id_id_association_mutex(), _thread_id_id_association_cond()
+#ifndef WIN32 //TODO: porting of following functionality
+ ,_thread_id_id_association()
+#endif
{
pthread_mutex_init(&_threads_mutex, NULL);
pthread_mutex_init(&_thread_id_id_association_mutex, NULL);
cancel(thread_id);
}
-
+
// Methode pour le controle des jobs : suspend un job en file d'attente
void BatchManager_Local::holdJob(const JobId & jobid)
{
if (_threads.find(id) != _threads.end())
_threads[id].command_queue.push(RELEASE);
pthread_mutex_unlock(&_threads_mutex);
- // @@@ --------> SECTION CRITIQUE <-------- @@@
- }
+ // @@@ --------> SECTION CRITIQUE <-------- @@@
+ }
// Methode pour le controle des jobs : modifie un job en file d'attente
pthread_t BatchManager_Local::submit(const Job_Local & job)
{
// L'id du thread a creer
- pthread_t thread_id = 0;
+ pthread_t thread_id =
+#ifdef WIN32
+ {0,0};
+#else
+ 0;
+#endif
// Les attributs du thread a sa creation
pthread_attr_t thread_attr;
// Creation du thread qui va executer la commande systeme qu'on lui passe
int rc = pthread_create(&thread_id,
- &thread_attr,
- &ThreadAdapter::run,
- static_cast<void *>(p_ta));
+ &thread_attr,
+ &ThreadAdapter::run,
+ static_cast<void *>(p_ta));
if (rc) {
}
// @@@ --------> SECTION CRITIQUE <-------- @@@
pthread_mutex_lock(&_thread_id_id_association_mutex);
+#ifndef WIN32 //TODO: porting of following functionality
while (_thread_id_id_association.find(thread_id) == _thread_id_id_association.end())
pthread_cond_wait(&_thread_id_id_association_cond, &_thread_id_id_association_mutex);
id = _thread_id_id_association[thread_id];
_thread_id_id_association.erase(thread_id);
-
+#endif
+
pthread_mutex_unlock(&_thread_id_id_association_mutex);
// @@@ --------> SECTION CRITIQUE <-------- @@@
// @@@ --------> SECTION CRITIQUE <-------- @@@
pthread_mutex_lock(&_thread_id_id_association_mutex);
+#ifndef WIN32 //TODO: porting of following functionality
if (_thread_id_id_association.find(thread_id) == _thread_id_id_association.end()) {
id = _thread_id_id_association[thread_id] = nextId();
pthread_cond_signal(&_thread_id_id_association_cond);
} else {
UNDER_LOCK( cerr << "ERROR : Pthread Inconstency. Two threads own the same thread_id." << endl );
}
+#endif
pthread_mutex_unlock(&_thread_id_id_association_mutex);
// @@@ --------> SECTION CRITIQUE <-------- @@@
// Constructeur de la classe ThreadAdapter
BatchManager_Local::ThreadAdapter::ThreadAdapter(BatchManager_Local & bm, const Job_Local & job) :
- _bm(bm), _job(job)
+ _bm(bm), _job(job)
{
// Nothing to do
}
// Methode d'execution du thread
void * BatchManager_Local::ThreadAdapter::run(void * arg)
{
+#ifndef WIN32 //TODO: porting of following functionality
// On bloque tous les signaux pour ce thread
sigset_t setmask;
sigfillset(&setmask);
pthread_sigmask(SIG_BLOCK, &setmask, NULL);
-
// On autorise la terminaison differee du thread
// (ces valeurs sont les valeurs par defaut mais on les force par precaution)
pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
Parametre::const_iterator it;
// On initialise la variable workdir a la valeur du Current Working Directory
- char * cwd = new char [PATH_MAX];
+ char * cwd =
+#ifdef WIN32
+ _getcwd(NULL, 0);
+#else
+ new char [PATH_MAX];
getcwd(cwd, PATH_MAX);
+#endif
string workdir = cwd;
delete [] cwd;
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();
-
- string copy_cmd = p_ta->getBatchManager().copy_command("", local, executionhost, workdir + "/" + remote);
- UNDER_LOCK( cout << "Copying : " << copy_cmd << endl );
-
- if (system(copy_cmd.c_str()) ) {
- // Echec de la copie
- rc |= 1;
- } else {
- // On enregistre le fichier comme etant a detruire
- files_to_delete.push_back(workdir + "/" + remote);
- }
+ CoupleType cpt = *static_cast< CoupleType * >(*Vit);
+ Couple cp = cpt;
+ string local = cp.getLocal();
+ string remote = cp.getRemote();
+
+ string copy_cmd = p_ta->getBatchManager().copy_command("", local, executionhost, workdir + "/" + remote);
+ UNDER_LOCK( cout << "Copying : " << copy_cmd << endl );
+
+ if (system(copy_cmd.c_str()) ) {
+ // Echec de la copie
+ rc |= 1;
+ } else {
+ // On enregistre le fichier comme etant a detruire
+ files_to_delete.push_back(workdir + "/" + remote);
+ }
}
}
-
+#ifdef WIN32
+ //TODO
+ //Using CreateThread instead fork() POSIX function
+#else
// On forke/exec un nouveau process pour pouvoir controler le fils
// (plus finement qu'avec un appel system)
// int rc = system(commande.c_str());
} else { // fils
p_ta->fils();
}
-
+#endif
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();
-
- string copy_cmd = p_ta->getBatchManager().copy_command(executionhost, workdir + "/" + remote, "", local);
- UNDER_LOCK( cout << "Copying : " << copy_cmd << endl );
-
- if (system(copy_cmd.c_str()) ) {
- // Echec de la copie
- rc |= 1;
- } else {
- // On enregistre le fichier comme etant a detruire
- files_to_delete.push_back(workdir + "/" + remote);
- }
+ CoupleType cpt = *static_cast< CoupleType * >(*Vit);
+ Couple cp = cpt;
+ string local = cp.getLocal();
+ string remote = cp.getRemote();
+
+ string copy_cmd = p_ta->getBatchManager().copy_command(executionhost, workdir + "/" + remote, "", local);
+ UNDER_LOCK( cout << "Copying : " << copy_cmd << endl );
+
+ if (system(copy_cmd.c_str()) ) {
+ // Echec de la copie
+ rc |= 1;
+ } else {
+ // On enregistre le fichier comme etant a detruire
+ files_to_delete.push_back(workdir + "/" + remote);
+ }
}
}
if ( (rc == 0) || (child < 0) ) {
std::vector<string>::const_iterator it;
for(it=files_to_delete.begin(); it!=files_to_delete.end(); it++) {
- string remove_cmd = p_ta->getBatchManager().remove_command(executionhost, *it);
- UNDER_LOCK( cout << "Removing : " << remove_cmd << endl );
- system(remove_cmd.c_str());
+ string remove_cmd = p_ta->getBatchManager().remove_command(executionhost, *it);
+ UNDER_LOCK( cout << "Removing : " << remove_cmd << endl );
+ system(remove_cmd.c_str());
}
}
UNDER_LOCK( cout << "Father is leaving" << endl );
pthread_exit(NULL);
-
+#endif
return NULL;
}
void BatchManager_Local::ThreadAdapter::pere(pid_t child)
{
+#ifndef WIN32 //TODO: porting of following functionality
time_t child_starttime = time(NULL);
// On enregistre le fils dans la table des threads
int child_rc = 0;
pid_t child_wait_rc = waitpid(child, &child_rc, WNOHANG /* | WUNTRACED */);
if (child_wait_rc > 0) {
- if (WIFSTOPPED(child_rc)) {
- // NOTA : pour rentrer dans cette section, il faut que le flag WUNTRACED
- // soit positionne dans l'appel a waitpid ci-dessus. Ce flag est couramment
- // desactive car s'il est possible de detecter l'arret d'un process, il est
- // plus difficile de detecter sa reprise.
-
- // Le fils est simplement stoppe
- // @@@ --------> SECTION CRITIQUE <-------- @@@
- pthread_mutex_lock(&_bm._threads_mutex);
- _bm._threads[id].status = STOPPED;
- _bm._threads[id].param[STATE] = "Stopped";
- pthread_mutex_unlock(&_bm._threads_mutex);
- // @@@ --------> SECTION CRITIQUE <-------- @@@
- UNDER_LOCK( cout << "Father sees his child is STOPPED : " << child_wait_rc << endl );
-
- }
- else {
- // Le fils est termine, on sort de la boucle et du if englobant
- // @@@ --------> SECTION CRITIQUE <-------- @@@
- pthread_mutex_lock(&_bm._threads_mutex);
- _bm._threads[id].status = DONE;
- _bm._threads[id].param[STATE] = "Done";
- pthread_mutex_unlock(&_bm._threads_mutex);
- // @@@ --------> SECTION CRITIQUE <-------- @@@
- UNDER_LOCK( cout << "Father sees his child is DONE : " << child_wait_rc << " (child_rc=" << (WIFEXITED(child_rc) ? WEXITSTATUS(child_rc) : -1) << ")" << endl );
- break;
- }
+ if (WIFSTOPPED(child_rc)) {
+ // NOTA : pour rentrer dans cette section, il faut que le flag WUNTRACED
+ // soit positionne dans l'appel a waitpid ci-dessus. Ce flag est couramment
+ // desactive car s'il est possible de detecter l'arret d'un process, il est
+ // plus difficile de detecter sa reprise.
+
+ // Le fils est simplement stoppe
+ // @@@ --------> SECTION CRITIQUE <-------- @@@
+ pthread_mutex_lock(&_bm._threads_mutex);
+ _bm._threads[id].status = STOPPED;
+ _bm._threads[id].param[STATE] = "Stopped";
+ pthread_mutex_unlock(&_bm._threads_mutex);
+ // @@@ --------> SECTION CRITIQUE <-------- @@@
+ UNDER_LOCK( cout << "Father sees his child is STOPPED : " << child_wait_rc << endl );
+
+ }
+ else {
+ // Le fils est termine, on sort de la boucle et du if englobant
+ // @@@ --------> SECTION CRITIQUE <-------- @@@
+ pthread_mutex_lock(&_bm._threads_mutex);
+ _bm._threads[id].status = DONE;
+ _bm._threads[id].param[STATE] = "Done";
+ pthread_mutex_unlock(&_bm._threads_mutex);
+ // @@@ --------> SECTION CRITIQUE <-------- @@@
+ UNDER_LOCK( cout << "Father sees his child is DONE : " << child_wait_rc << " (child_rc=" << (WIFEXITED(child_rc) ? WEXITSTATUS(child_rc) : -1) << ")" << endl );
+ break;
+ }
}
else if (child_wait_rc == -1) {
- // Le fils a disparu ...
- // @@@ --------> SECTION CRITIQUE <-------- @@@
- pthread_mutex_lock(&_bm._threads_mutex);
- _bm._threads[id].status = DEAD;
- _bm._threads[id].param[STATE] = "Dead";
- pthread_mutex_unlock(&_bm._threads_mutex);
- // @@@ --------> SECTION CRITIQUE <-------- @@@
- UNDER_LOCK( cout << "Father sees his child is DEAD : " << child_wait_rc << " (Reason : " << strerror(errno) << ")" << endl );
- break;
+ // Le fils a disparu ...
+ // @@@ --------> SECTION CRITIQUE <-------- @@@
+ pthread_mutex_lock(&_bm._threads_mutex);
+ _bm._threads[id].status = DEAD;
+ _bm._threads[id].param[STATE] = "Dead";
+ pthread_mutex_unlock(&_bm._threads_mutex);
+ // @@@ --------> SECTION CRITIQUE <-------- @@@
+ UNDER_LOCK( cout << "Father sees his child is DEAD : " << child_wait_rc << " (Reason : " << strerror(errno) << ")" << endl );
+ break;
}
time_t child_currenttime = time(NULL);
time_t child_elapsedtime = child_currenttime - child_starttime;
if (param.find(MAXWALLTIME) != param.end()) {
- int maxwalltime = param[MAXWALLTIME];
- // cout << "child_starttime = " << child_starttime << endl
- // << "child_currenttime = " << child_currenttime << endl
- // << "child_elapsedtime = " << child_elapsedtime << endl
- // << "maxwalltime = " << maxwalltime << endl
- // << "int(maxwalltime * 1.1) = " << int(maxwalltime * 1.1) << endl;
- if (child_elapsedtime > int(maxwalltime * 1.1) ) { // On se donne 10% de marge avant le KILL
- UNDER_LOCK( cout << "Father is sending KILL command to the thread " << id << endl );
- // On introduit une commande dans la queue du thread
- // @@@ --------> SECTION CRITIQUE <-------- @@@
- pthread_mutex_lock(&_bm._threads_mutex);
- if (_bm._threads.find(id) != _bm._threads.end())
- _bm._threads[id].command_queue.push(KILL);
- pthread_mutex_unlock(&_bm._threads_mutex);
- // @@@ --------> SECTION CRITIQUE <-------- @@@
-
-
- } else if (child_elapsedtime > maxwalltime ) {
- UNDER_LOCK( cout << "Father is sending TERM command to the thread " << id << endl );
- // On introduit une commande dans la queue du thread
- // @@@ --------> SECTION CRITIQUE <-------- @@@
- pthread_mutex_lock(&_bm._threads_mutex);
- if (_bm._threads.find(id) != _bm._threads.end())
- _bm._threads[id].command_queue.push(TERM);
- pthread_mutex_unlock(&_bm._threads_mutex);
- // @@@ --------> SECTION CRITIQUE <-------- @@@
- }
+ int maxwalltime = param[MAXWALLTIME];
+ // cout << "child_starttime = " << child_starttime << endl
+ // << "child_currenttime = " << child_currenttime << endl
+ // << "child_elapsedtime = " << child_elapsedtime << endl
+ // << "maxwalltime = " << maxwalltime << endl
+ // << "int(maxwalltime * 1.1) = " << int(maxwalltime * 1.1) << endl;
+ if (child_elapsedtime > int(maxwalltime * 1.1) ) { // On se donne 10% de marge avant le KILL
+ UNDER_LOCK( cout << "Father is sending KILL command to the thread " << id << endl );
+ // On introduit une commande dans la queue du thread
+ // @@@ --------> SECTION CRITIQUE <-------- @@@
+ pthread_mutex_lock(&_bm._threads_mutex);
+ if (_bm._threads.find(id) != _bm._threads.end())
+ _bm._threads[id].command_queue.push(KILL);
+ pthread_mutex_unlock(&_bm._threads_mutex);
+ // @@@ --------> SECTION CRITIQUE <-------- @@@
+
+
+ } else if (child_elapsedtime > maxwalltime ) {
+ UNDER_LOCK( cout << "Father is sending TERM command to the thread " << id << endl );
+ // On introduit une commande dans la queue du thread
+ // @@@ --------> SECTION CRITIQUE <-------- @@@
+ pthread_mutex_lock(&_bm._threads_mutex);
+ if (_bm._threads.find(id) != _bm._threads.end())
+ _bm._threads[id].command_queue.push(TERM);
+ pthread_mutex_unlock(&_bm._threads_mutex);
+ // @@@ --------> SECTION CRITIQUE <-------- @@@
+ }
}
// @@@ --------> SECTION CRITIQUE <-------- @@@
pthread_mutex_lock(&_bm._threads_mutex);
if (_bm._threads.find(id) != _bm._threads.end()) {
- while (_bm._threads[id].command_queue.size() > 0) {
- Commande cmd = _bm._threads[id].command_queue.front();
- _bm._threads[id].command_queue.pop();
-
- switch (cmd) {
- case NOP:
- UNDER_LOCK( cout << "Father does nothing to his child" << endl );
- break;
-
- case HOLD:
- UNDER_LOCK( cout << "Father is sending SIGSTOP signal to his child" << endl );
- kill(child, SIGSTOP);
- break;
-
- case RELEASE:
- UNDER_LOCK( cout << "Father is sending SIGCONT signal to his child" << endl );
- kill(child, SIGCONT);
- break;
-
- case TERM:
- UNDER_LOCK( cout << "Father is sending SIGTERM signal to his child" << endl );
- kill(child, SIGTERM);
- break;
-
- case KILL:
- UNDER_LOCK( cout << "Father is sending SIGKILL signal to his child" << endl );
- kill(child, SIGKILL);
- break;
-
- case ALTER:
- break;
-
- default:
- break;
- }
- }
-
+ while (_bm._threads[id].command_queue.size() > 0) {
+ Commande cmd = _bm._threads[id].command_queue.front();
+ _bm._threads[id].command_queue.pop();
+
+ switch (cmd) {
+ case NOP:
+ UNDER_LOCK( cout << "Father does nothing to his child" << endl );
+ break;
+
+ case HOLD:
+ UNDER_LOCK( cout << "Father is sending SIGSTOP signal to his child" << endl );
+ kill(child, SIGSTOP);
+ break;
+
+ case RELEASE:
+ UNDER_LOCK( cout << "Father is sending SIGCONT signal to his child" << endl );
+ kill(child, SIGCONT);
+ break;
+
+ case TERM:
+ UNDER_LOCK( cout << "Father is sending SIGTERM signal to his child" << endl );
+ kill(child, SIGTERM);
+ break;
+
+ case KILL:
+ UNDER_LOCK( cout << "Father is sending SIGKILL signal to his child" << endl );
+ kill(child, SIGKILL);
+ break;
+
+ case ALTER:
+ break;
+
+ default:
+ break;
+ }
+ }
+
}
pthread_mutex_unlock(&_bm._threads_mutex);
// @@@ --------> SECTION CRITIQUE <-------- @@@
// On fait une petite pause pour ne pas surcharger inutilement le processeur
sleep(1);
-
+
}
+#endif
}
void BatchManager_Local::ThreadAdapter::fils()
{
+#ifndef WIN32 //TODO: porting of following functionality
Parametre param = _job.getParametre();
Parametre::iterator it;
try {
- // On se place dans le repertoire de travail
- if ( (it = param.find(WORKDIR)) != param.end() ) {
- string workdir = static_cast<string>( (*it).second );
- chdir(workdir.c_str());
- }
+ // On se place dans le repertoire de travail
+ if ( (it = param.find(WORKDIR)) != param.end() ) {
+ string workdir = static_cast<string>( (*it).second );
+ chdir(workdir.c_str());
+ }
- // EXECUTABLE is MANDATORY, if missing, we exit with failure notification
- char * execpath = NULL;
- if (param.find(EXECUTABLE) != param.end()) {
- string executable = _bm.exec_command(param);
- execpath = new char [executable.size() + 1];
- strncpy(execpath, executable.c_str(), executable.size() + 1);
- } else exit(1);
+ // EXECUTABLE is MANDATORY, if missing, we exit with failure notification
+ char * execpath = NULL;
+ if (param.find(EXECUTABLE) != param.end()) {
+ string executable = _bm.exec_command(param);
+ execpath = new char [executable.size() + 1];
+ strncpy(execpath, executable.c_str(), executable.size() + 1);
+ } else exit(1);
- string debug_command = execpath;
+ string debug_command = execpath;
- string name = (param.find(NAME) != param.end()) ? param[NAME] : param[EXECUTABLE];
+ string name = (param.find(NAME) != param.end()) ? param[NAME] : param[EXECUTABLE];
- char ** argv = NULL;
- if (param.find(ARGUMENTS) != param.end()) {
- Versatile V = param[ARGUMENTS];
+ char ** argv = NULL;
+ if (param.find(ARGUMENTS) != param.end()) {
+ Versatile V = param[ARGUMENTS];
- argv = new char * [V.size() + 2]; // 1 pour name et 1 pour le NULL terminal
+ argv = new char * [V.size() + 2]; // 1 pour name et 1 pour le NULL terminal
- argv[0] = new char [name.size() + 1];
- strncpy(argv[0], name.c_str(), name.size() + 1);
+ argv[0] = new char [name.size() + 1];
+ strncpy(argv[0], name.c_str(), name.size() + 1);
- debug_command += string(" # ") + argv[0];
+ debug_command += string(" # ") + argv[0];
- int i = 1;
- for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++, i++) {
- StringType argt = * static_cast<StringType *>(*it);
- string arg = argt;
- argv[i] = new char [arg.size() + 1];
- strncpy(argv[i], arg.c_str(), arg.size() + 1);
- debug_command += string(" # ") + argv[i];
+ int i = 1;
+ for(Versatile::const_iterator it=V.begin(); it!=V.end(); it++, i++) {
+ StringType argt = * static_cast<StringType *>(*it);
+ string arg = argt;
+ argv[i] = new char [arg.size() + 1];
+ strncpy(argv[i], arg.c_str(), arg.size() + 1);
+ debug_command += string(" # ") + argv[i];
+ }
+
+ // assert (i == V.size() + 1)
+ argv[i] = NULL;
}
- // assert (i == V.size() + 1)
- argv[i] = NULL;
- }
+ UNDER_LOCK( cout << "*** debug_command = " << debug_command << endl );
- UNDER_LOCK( cout << "*** debug_command = " << debug_command << endl );
+ Environnement env = _job.getEnvironnement();
- Environnement env = _job.getEnvironnement();
+ char ** envp = NULL;
+ if(env.size() > 0) {
+ envp = new char * [env.size() + 1]; // 1 pour le NULL terminal
+ int i = 0;
+ for(Environnement::const_iterator it=env.begin(); it!=env.end(); it++, i++) {
+ const string & key = (*it).first;
+ const string & value = (*it).second;
+ ostringstream oss;
+ oss << key << "=" << value;
+ envp[i] = new char [oss.str().size() + 1];
+ strncpy(envp[i], oss.str().c_str(), oss.str().size() + 1);
+ }
- char ** envp = NULL;
- if(env.size() > 0) {
- envp = new char * [env.size() + 1]; // 1 pour le NULL terminal
- int i = 0;
- for(Environnement::const_iterator it=env.begin(); it!=env.end(); it++, i++) {
- const string & key = (*it).first;
- const string & value = (*it).second;
- ostringstream oss;
- oss << key << "=" << value;
- envp[i] = new char [oss.str().size() + 1];
- strncpy(envp[i], oss.str().c_str(), oss.str().size() + 1);
+ // assert (i == env.size())
+ envp[i] = NULL;
}
- // assert (i == env.size())
- envp[i] = NULL;
- }
+ // On positionne les limites systeme imposees au fils
+ if (param.find(MAXCPUTIME) != param.end()) {
+ int maxcputime = param[MAXCPUTIME];
+ struct rlimit limit;
+ limit.rlim_cur = maxcputime;
+ limit.rlim_max = int(maxcputime * 1.1);
+ setrlimit(RLIMIT_CPU, &limit);
+ }
- // On positionne les limites systeme imposees au fils
- if (param.find(MAXCPUTIME) != param.end()) {
- int maxcputime = param[MAXCPUTIME];
- struct rlimit limit;
- limit.rlim_cur = maxcputime;
- limit.rlim_max = int(maxcputime * 1.1);
- setrlimit(RLIMIT_CPU, &limit);
- }
+ if (param.find(MAXDISKSIZE) != param.end()) {
+ int maxdisksize = param[MAXDISKSIZE];
+ struct rlimit limit;
+ limit.rlim_cur = maxdisksize * 1024;
+ limit.rlim_max = int(maxdisksize * 1.1) * 1024;
+ setrlimit(RLIMIT_FSIZE, &limit);
+ }
- if (param.find(MAXDISKSIZE) != param.end()) {
- int maxdisksize = param[MAXDISKSIZE];
- struct rlimit limit;
- limit.rlim_cur = maxdisksize * 1024;
- limit.rlim_max = int(maxdisksize * 1.1) * 1024;
- setrlimit(RLIMIT_FSIZE, &limit);
- }
+ if (param.find(MAXRAMSIZE) != param.end()) {
+ int maxramsize = param[MAXRAMSIZE];
+ struct rlimit limit;
+ limit.rlim_cur = maxramsize * 1024;
+ limit.rlim_max = int(maxramsize * 1.1) * 1024;
+ setrlimit(RLIMIT_AS, &limit);
+ }
- if (param.find(MAXRAMSIZE) != param.end()) {
- int maxramsize = param[MAXRAMSIZE];
- struct rlimit limit;
- limit.rlim_cur = maxramsize * 1024;
- limit.rlim_max = int(maxramsize * 1.1) * 1024;
- setrlimit(RLIMIT_AS, &limit);
- }
+ // On cree une session pour le fils de facon a ce qu'il ne soit pas
+ // detruit lorsque le shell se termine (le shell ouvre une session et
+ // tue tous les process appartenant a la session en quittant)
+ setsid();
- // On cree une session pour le fils de facon a ce qu'il ne soit pas
- // detruit lorsque le shell se termine (le shell ouvre une session et
- // tue tous les process appartenant a la session en quittant)
- setsid();
+ // On ferme les descripteurs de fichiers standards
+ //close(STDIN_FILENO);
+ //close(STDOUT_FILENO);
+ //close(STDERR_FILENO);
- // On ferme les descripteurs de fichiers standards
- //close(STDIN_FILENO);
- //close(STDOUT_FILENO);
- //close(STDERR_FILENO);
+ // On execute la commande du fils
+ execve(execpath, argv, envp);
- // On execute la commande du fils
- execve(execpath, argv, envp);
+ // No need to deallocate since nothing happens after a successful exec
- // No need to deallocate since nothing happens after a successful exec
+ // Normalement on ne devrait jamais arriver ici
+ ofstream file_err("error.log");
+ UNDER_LOCK( file_err << "Echec de l'appel a execve" << endl );
- // Normalement on ne devrait jamais arriver ici
- ofstream file_err("error.log");
- UNDER_LOCK( file_err << "Echec de l'appel a execve" << endl );
-
} catch (GenericException & e) {
-
+
std::cerr << "Caught exception : " << e.type << " : " << e.message << std::endl;
}
exit(99);
-
+#endif
}
void BatchManager_Local::kill_child_on_exit(void * p_pid)
{
+#ifndef WIN32
+ //TODO: porting of following functionality
pid_t child = * static_cast<pid_t *>(p_pid);
// On tue le fils
// Nota : on pourrait aussi faire a la suite un kill(child, SIGKILL)
// mais cette option n'est pas implementee pour le moment, car il est
// preferable de laisser le process fils se terminer normalement et seul.
-
+#endif
}
void BatchManager_Local::delete_on_exit(void * arg)
#ifndef _BATCHMANAGER_LOCAL_H_
#define _BATCHMANAGER_LOCAL_H_
+#include "Batch_Defines.hxx"
#include <vector>
#include <map>
#include <queue>
-#include <deque>
#include <pthread.h>
#include "Batch_Job.hxx"
#include "Batch_JobId.hxx"
class FactBatchManager;
- class BatchManager_Local : public BatchManager
+ class BATCH_EXPORT BatchManager_Local : public BatchManager
{
private:
friend class ThreadAdapter;
struct Child {
pthread_t thread_id;
- queue<Commande, deque<Commande> > command_queue;
+ std::queue<Commande, std::deque<Commande> > command_queue;
pid_t pid;
int exit_code;
Status status;
protected:
int _connect; // Local connect id
pthread_mutex_t _threads_mutex;
- map<Id, Child > _threads;
+ std::map<Id, Child > _threads;
// Methode abstraite qui renvoie la commande de copie du fichier source en destination
- virtual string copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const = 0;
+ virtual std::string copy_command( const std::string & host_source,
+ const std::string & source,
+ const std::string & host_destination,
+ const std::string & destination) const = 0;
// Methode abstraite qui renvoie la commande a executer
- virtual string exec_command(Parametre & param) const = 0;
+ virtual std::string exec_command(Parametre & param) const = 0;
// Methode abstraite qui renvoie la commande d'effacement du fichier
- virtual string remove_command(const string & host_destination, const string & destination) const = 0;
+ virtual std::string remove_command( const std::string & host_destination,
+ const std::string & destination) const = 0;
private:
virtual pthread_t submit(const Job_Local & job);
Id registerThread_id(pthread_t thread_id);
pthread_mutex_t _thread_id_id_association_mutex;
pthread_cond_t _thread_id_id_association_cond;
- map<pthread_t, Id> _thread_id_id_association;
+#ifndef WIN32 //TODO: porting of following functionality
+ //reason: pthread_t on win32 is a struct of pointer and int members
+ std::map<pthread_t, Id> _thread_id_id_association;
+#endif
#ifdef SWIG
public:
#include <sstream>
#include <cstdlib>
#include <sys/types.h>
+#ifndef WIN32
#include <sys/wait.h>
-#include <ctime>
#include <unistd.h>
+#endif
+#include <ctime>
#include <pthread.h>
#include <signal.h>
#include <errno.h>
#error "RSH undefined. You must set RSH to a valid path to a rsh-like command."
#endif
+using namespace std;
+
namespace Batch {
#ifndef _BATCHMANAGER_LOCAL_RSH_H_
#define _BATCHMANAGER_LOCAL_RSH_H_
+#include "Batch_Defines.hxx"
#include <vector>
#include <map>
class FactBatchManager;
- class BatchManager_Local_RSH : public BatchManager_Local
+ class BATCH_EXPORT BatchManager_Local_RSH : public BatchManager_Local
{
public:
// Constructeur et destructeur
protected:
// Methode abstraite qui renvoie la commande de copie du fichier source en destination
- virtual string copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const;
+ virtual std::string copy_command( const std::string & host_source,
+ const std::string & source,
+ const std::string & host_destination,
+ const std::string & destination) const;
// Methode abstraite qui renvoie la commande a executer
- virtual string exec_command(Parametre & param) const;
+ virtual std::string exec_command(Parametre & param) const;
// Methode qui renvoie la commande d'effacement du fichier
- virtual string remove_command(const string & host_destination, const string & destination) const;
+ virtual std::string remove_command( const std::string & host_destination,
+ const std::string & destination) const;
};
#include <sstream>
#include <cstdlib>
#include <sys/types.h>
+#ifndef WIN32
#include <sys/wait.h>
+#endif
#include <ctime>
#include <unistd.h>
#include <pthread.h>
#error "SH undefined. You must set SH to a valid path to a sh-like command."
#endif
+using namespace std;
+
namespace Batch {
#ifndef _BATCHMANAGER_LOCAL_SH_H_
#define _BATCHMANAGER_LOCAL_SH_H_
+#include "Batch_Defines.hxx"
#include <vector>
#include <map>
class FactBatchManager;
- class BatchManager_Local_SH : public BatchManager_Local
+ class BATCH_EXPORT BatchManager_Local_SH : public BatchManager_Local
{
public:
// Constructeur et destructeur
protected:
// Methode qui renvoie la commande de copie du fichier source en destination
- virtual string copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const;
+ virtual std::string copy_command( const std::string & host_source,
+ const std::string & source,
+ const std::string & host_destination,
+ const std::string & destination) const;
// Methode qui renvoie la commande a executer
- virtual string exec_command(Parametre & param) const;
+ virtual std::string exec_command(Parametre & param) const;
// Methode qui renvoie la commande d'effacement du fichier
- virtual string remove_command(const string & host_destination, const string & destination) const;
+ virtual std::string remove_command( const std::string & host_destination,
+ const std::string & destination) const;
};
#include <sstream>
#include <cstdlib>
#include <sys/types.h>
+#ifndef WIN32
#include <sys/wait.h>
-#include <ctime>
#include <unistd.h>
+#endif
+#include <ctime>
+
#include <pthread.h>
#include <signal.h>
#include <errno.h>
#error "SSH undefined. You must set SSH to a valid path to a ssh-like command."
#endif
+using namespace std;
+
namespace Batch {
#ifndef _BATCHMANAGER_LOCAL_SSH_H_
#define _BATCHMANAGER_LOCAL_SSH_H_
+#include "Batch_Defines.hxx"
#include <vector>
#include <map>
class FactBatchManager;
- class BatchManager_Local_SSH : public BatchManager_Local
+ class BATCH_EXPORT BatchManager_Local_SSH : public BatchManager_Local
{
public:
// Constructeur et destructeur
protected:
// Methode abstraite qui renvoie la commande de copie du fichier source en destination
- virtual string copy_command(const string & host_source, const string & source, const string & host_destination, const string & destination) const;
+ virtual std::string copy_command( const std::string & host_source,
+ const std::string & source,
+ const std::string & host_destination,
+ const std::string & destination) const;
// Methode abstraite qui renvoie la commande a executer
- virtual string exec_command(Parametre & param) const;
+ virtual std::string exec_command(Parametre & param) const;
// Methode qui renvoie la commande d'effacement du fichier
- virtual string remove_command(const string & host_destination, const string & destination) const;
+ virtual std::string remove_command( const std::string & host_destination,
+ const std::string & destination) const;
};
#ifndef _BATCHMANAGER_PBS_H_
#define _BATCHMANAGER_PBS_H_
+#include "Batch_Defines.hxx"
#include "Batch_Job.hxx"
#include "Batch_Job.hxx"
class JobInfo;
class FactBatchManager;
- class BatchManager_PBS : public BatchManager
+ class BATCH_EXPORT BatchManager_PBS : public BatchManager
{
public:
// Constructeur et destructeur
// 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
- *
- */
+* 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 "Batch_BatchManager_eClient.hxx"
+#include "Basics_DirUtils.hxx"
#include <iostream>
#include <fstream>
#include <sstream>
#include <sys/stat.h>
-#include "Batch_BatchManager_eClient.hxx"
+
+using namespace std;
+
namespace Batch {
copy_command = "scp ";
else
throw EmulationException("Unknown protocol : only rsh and ssh are known !");
-
+
// First step : creating batch tmp files directory
command = _protocol;
command += " ";
ex_mess += oss.str();
throw EmulationException(ex_mess.c_str());
}
-
+
// Third step : copy filesToExportList into
// batch tmp files directory
for(Vit=V.begin(); Vit!=V.end(); Vit++) {
command += inputFile.getLocal();
command += " ";
if(_username != ""){
- command += _username;
- command += "@";
+ command += _username;
+ command += "@";
}
command += _hostname;
command += ":";
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());
+ 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());
}
}
Parametre params = job.getParametre();
Versatile V = params[OUTFILE];
Versatile::iterator Vit;
-
+
for(Vit=V.begin(); Vit!=V.end(); Vit++) {
CoupleType cpt = *static_cast< CoupleType * >(*Vit);
Couple outputFile = cpt;
if( _protocol == "rsh" )
- command = "rcp ";
+ command = "rcp ";
else if( _protocol == "ssh" )
- command = "scp ";
+ command = "scp ";
else
- throw EmulationException("Unknown protocol");
+ throw EmulationException("Unknown protocol");
if (_username != ""){
- command += _username;
- command += "@";
+ command += _username;
+ command += "@";
}
command += _hostname;
command += ":";
status = system(command.c_str());
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;
+ // 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;
}
}
string BatchManager_eClient::BuildTemporaryFileName() const
{
//build more complex file name to support multiple salome session
- char *temp = new char[19];
- strcpy(temp, "/tmp/command");
- strcat(temp, "XXXXXX");
-#ifndef WNT
- mkstemp(temp);
+ string aFileName = Kernel_Utils::GetTmpFileName();
+#ifndef WIN32
+ aFileName += ".sh";
#else
- char aPID[80];
- itoa(getpid(), aPID, 10);
- strcat(temp, aPID);
+ aFileName += ".bat";
#endif
-
- string command(temp);
- delete [] temp;
- command += ".sh";
- return command;
+ return aFileName;
}
void BatchManager_eClient::RmTmpFile(std::string & TemporaryFileName)
{
+#ifdef WIN32
+ string command = "del /F ";
+#else
string command = "rm ";
+#endif
command += TemporaryFileName;
char *temp = strdup(command.c_str());
int lgthTemp = strlen(temp);
system(temp);
free(temp);
}
-
}
#ifndef _BATCHMANAGER_eClient_H_
#define _BATCHMANAGER_eClient_H_
+#include "Batch_Defines.hxx"
#include "MpiImpl.hxx"
#include "Batch_BatchManager.hxx"
+#include <string>
+
namespace Batch {
class Job;
- class EmulationException
+ class BATCH_EXPORT EmulationException
{
public:
const std::string msg;
EmulationException(const std::string m) : msg(m) {}
};
- class BatchManager_eClient : public BatchManager
+ class BATCH_EXPORT BatchManager_eClient : public BatchManager
{
public:
// Constructeur et destructeur
std::string BuildTemporaryFileName() const;
void RmTmpFile(std::string & TemporaryFileName);
- MpiImpl* FactoryMpiImpl(string mpiImpl) throw(EmulationException);
+ MpiImpl* FactoryMpiImpl(std::string mpiImpl) throw(EmulationException);
void exportInputFiles(const Job & job) throw(EmulationException);
private:
#include <sstream>
#include <sys/stat.h>
#include "Batch_BatchManager_eLSF.hxx"
+#ifdef WIN32
+# include <time.h>
+# include <io.h>
+#endif
+
+using namespace std;
namespace Batch {
void BatchManager_eLSF::buildBatchScript(const Job & job) throw(EmulationException)
{
+#ifndef WIN32 //TODO: need for porting on Windows
int status;
Parametre params = job.getParametre();
const int nbproc = params[NBPROC];
tempOutputFile << _mpiImpl->halt();
tempOutputFile.flush();
tempOutputFile.close();
- chmod(TmpFileName.c_str(), 0x1ED);
+#ifdef WIN32
+ _chmod(
+#else
+ chmod(
+#endif
+ TmpFileName.c_str(), 0x1ED);
cerr << TmpFileName.c_str() << endl;
string command;
throw EmulationException("Error of connection on remote host");
RmTmpFile(TmpFileName);
+#endif
}
#ifndef _BATCHMANAGER_eLSF_H_
#define _BATCHMANAGER_eLSF_H_
+#include "Batch_Defines.hxx"
#include "Batch_JobId.hxx"
#include "Batch_JobInfo.hxx"
class JobInfo;
class FactBatchManager;
- class BatchManager_eLSF : public BatchManager_eClient
+ class BATCH_EXPORT BatchManager_eLSF : public BatchManager_eClient
{
public:
// Constructeur et destructeur
#include <sstream>
#include <sys/stat.h>
#include "Batch_BatchManager_ePBS.hxx"
+#ifdef WIN32
+# include <time.h>
+# include <io.h>
+#endif
+
+using namespace std;
namespace Batch {
void BatchManager_ePBS::buildBatchScript(const Job & job) throw(EmulationException)
{
+#ifndef WIN32 //TODO: need for porting on Windows
int status;
Parametre params = job.getParametre();
const long nbproc = params[NBPROC];
tempOutputFile << _mpiImpl->halt();
tempOutputFile.flush();
tempOutputFile.close();
- chmod(TmpFileName.c_str(), 0x1ED);
+#ifdef WIN32
+ _chmod(
+#else
+ chmod(
+#endif
+ TmpFileName.c_str(), 0x1ED);
cerr << TmpFileName.c_str() << endl;
string command;
throw EmulationException("Error of connection on remote host");
RmTmpFile(TmpFileName);
-
+#endif
}
}
#ifndef _BATCHMANAGER_eLSF_H_
#define _BATCHMANAGER_eLSF_H_
+#include "Batch_Defines.hxx"
+
#include "Batch_JobId.hxx"
#include "Batch_JobInfo.hxx"
#include "Batch_JobInfo_ePBS.hxx"
class JobInfo;
class FactBatchManager;
- class BatchManager_ePBS : public BatchManager_eClient
+ class BATCH_EXPORT BatchManager_ePBS : public BatchManager_eClient
{
public:
// Constructeur et destructeur
#ifndef _BOOLTYPE_H_
#define _BOOLTYPE_H_
+#include "Batch_Defines.hxx"
+
#include <string>
#include "Batch_GenericType.hxx"
namespace Batch {
- class BoolType : public GenericType
+ class BATCH_EXPORT BoolType : public GenericType
{
public:
// Constructeur
#ifndef _CHARTYPE_H_
#define _CHARTYPE_H_
+#include "Batch_Defines.hxx"
+
#include <string>
#include "Batch_GenericType.hxx"
namespace Batch {
- class CharType : public GenericType
+ class BATCH_EXPORT CharType : public GenericType
{
public:
// Constructeur
#ifndef _CONNEXIONFAILUREEXCEPTION_H_
#define _CONNEXIONFAILUREEXCEPTION_H_
+#include "Batch_Defines.hxx"
+
#include "Batch_GenericException.hxx"
namespace Batch {
- class ConnexionFailureException : public GenericException
+ class BATCH_EXPORT ConnexionFailureException : public GenericException
{
public:
// Constructeur
#ifndef _COUPLE_H_
#define _COUPLE_H_
+#include "Batch_Defines.hxx"
+
#include <string>
namespace Batch {
- class Couple
+ class BATCH_EXPORT Couple
{
public:
// Constructeur standard
#ifndef _COUPLETYPE_H_
#define _COUPLETYPE_H_
+#include "Batch_Defines.hxx"
+
#include <string>
#include "Batch_GenericType.hxx"
#include "Batch_Couple.hxx"
namespace Batch {
- class CoupleType : public GenericType
+ class BATCH_EXPORT CoupleType : public GenericType
{
public:
// Constructeur
#ifndef _DATE_H_
#define _DATE_H_
+#include "Batch_Defines.hxx"
+
#include <string>
namespace Batch {
- class Date
+ class BATCH_EXPORT Date
{
public:
Date(const long l=0);
#ifndef _DATETYPE_H_
#define _DATETYPE_H_
+#include "Batch_Defines.hxx"
+
#include <string>
#include "Batch_GenericType.hxx"
#include "Batch_Date.hxx"
namespace Batch {
- class DateType : public GenericType
+ class BATCH_EXPORT DateType : public GenericType
{
public:
// Constructeur
--- /dev/null
+// Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : Batch_Defines.hxx
+// Author : Alexander A. BORODIN
+// Module : SALOME
+
+#ifndef _BATCH_Defines_HXX_
+#define _BATCH_Defines_HXX_
+
+#ifdef WIN32
+# ifdef BATCH_EXPORTS
+# define BATCH_EXPORT __declspec( dllexport )
+# else
+# define BATCH_EXPORT __declspec( dllimport )
+# endif
+# define RM "rm"
+# define RCP "rpc"
+# define RSH "rsh"
+#else
+# define BATCH_EXPORT
+#endif
+
+#endif
#ifndef _ENVIRONNEMENT_H_
#define _ENVIRONNEMENT_H_
+#include "Batch_Defines.hxx"
+
#include <string>
#include <map>
FactBatchManager::FactBatchManager(const string & _t) : type(_t)
{
BatchManagerCatalog::addFactBatchManager(type.c_str(), this);
+ /*
+ #ifndef WIN32
+ Win32 limitation: it's impossible to create new thread of LocalTraceCollector
+ during initialization of static objects of DLL
+ Be careful with static objects of types inherited from FactBatchManager class
+ */
ostringstream msg;
msg << "FactBatchManager of type '" << type << "' inserted into catalog";
MESSAGE(msg.str().c_str());
+ //#endif
}
// Destructeur
#ifndef _FACTBATCHMANAGER_H_
#define _FACTBATCHMANAGER_H_
+#include "Batch_Defines.hxx"
+
#include <string>
#include <map>
class BatchManager;
- class FactBatchManager
+ class BATCH_EXPORT FactBatchManager
{
public:
// Constructeur et destructeur
#ifndef _FACTBATCHMANAGER_LSF_H_
#define _FACTBATCHMANAGER_LSF_H_
-using namespace std;
-#include <string>
-#include <map>
#include "Batch_FactBatchManager.hxx"
namespace Batch {
#ifndef _FACTBATCHMANAGER_LOCAL_H_
#define _FACTBATCHMANAGER_LOCAL_H_
-using namespace std;
-#include <string>
-#include <map>
#include "Batch_FactBatchManager.hxx"
namespace Batch {
//#include "utilities.h"
namespace Batch {
+
+ static FactBatchManager_Local_RSH* instanceOfFBM_eLSF()
+ {
+ static FactBatchManager_Local_RSH* sFBM_Local_RSH = 0;
+ if ( !sFBM_Local_RSH )
+ sFBM_Local_RSH = new FactBatchManager_Local_RSH();
- static FactBatchManager_Local_RSH sFBM_Local_RSH;
+ return sFBM_Local_RSH;
+ }
// Constructeur
FactBatchManager_Local_RSH::FactBatchManager_Local_RSH() : FactBatchManager("RSH")
#ifndef _FACTBATCHMANAGER_LOCAL_RSH_H_
#define _FACTBATCHMANAGER_LOCAL_RSH_H_
-using namespace std;
-#include <string>
-#include <map>
#include "Batch_FactBatchManager.hxx"
namespace Batch {
#ifndef _FACTBATCHMANAGER_LOCAL_SH_H_
#define _FACTBATCHMANAGER_LOCAL_SH_H_
-using namespace std;
-#include <string>
-#include <map>
#include "Batch_FactBatchManager.hxx"
namespace Batch {
#ifndef _FACTBATCHMANAGER_LOCAL_SSH_H_
#define _FACTBATCHMANAGER_LOCAL_SSH_H_
-using namespace std;
-#include <string>
-#include <map>
#include "Batch_FactBatchManager.hxx"
namespace Batch {
namespace Batch {
- static FactBatchManager_eLSF sFBM_eLSF;
+static FactBatchManager_eLSF* instanceOfFBM_eLSF()
+{
+ static FactBatchManager_eLSF* sFBM_eLSF = 0;
+ if ( !sFBM_eLSF )
+ sFBM_eLSF = new FactBatchManager_eLSF();
+
+ return sFBM_eLSF;
+}
+
// Constructeur
FactBatchManager_eLSF::FactBatchManager_eLSF() : FactBatchManager_eClient("eLSF")
#ifndef _FACTBATCHMANAGER_eLSF_H_
#define _FACTBATCHMANAGER_eLSF_H_
-using namespace std;
+#include "Batch_Defines.hxx"
+
#include <string>
#include <map>
#include "Batch_BatchManager_eClient.hxx"
class BatchManager_eLSF;
- class FactBatchManager_eLSF : public FactBatchManager_eClient
+ class BATCH_EXPORT FactBatchManager_eLSF : public FactBatchManager_eClient
{
public:
// Constructeur et destructeur
namespace Batch {
- static FactBatchManager_ePBS sFBM_ePBS;
+ static FactBatchManager_ePBS* instanceOfFBM_eLSF()
+ {
+ static FactBatchManager_ePBS* sFBM_ePBS = 0;
+ if ( !sFBM_ePBS )
+ sFBM_ePBS = new FactBatchManager_ePBS();
+
+ return sFBM_ePBS;
+ }
// Constructeur
FactBatchManager_ePBS::FactBatchManager_ePBS() : FactBatchManager_eClient("ePBS")
#ifndef _FACTBATCHMANAGER_ePBS_H_
#define _FACTBATCHMANAGER_ePBS_H_
-using namespace std;
+#include "Batch_Defines.hxx"
+
#include <string>
#include <map>
#include "Batch_BatchManager_eClient.hxx"
class BatchManager_ePBS;
- class FactBatchManager_ePBS : public FactBatchManager_eClient
+ class BATCH_EXPORT FactBatchManager_ePBS : public FactBatchManager_eClient
{
public:
// Constructeur et destructeur
#ifndef _GENERICEXCEPTION_H_
#define _GENERICEXCEPTION_H_
+#include "Batch_Defines.hxx"
+
#include <string>
namespace Batch {
- class GenericException
+ class BATCH_EXPORT GenericException
{
public:
const std::string type; // la nature de l'exception
#ifndef _GENERICTYPE_H_
#define _GENERICTYPE_H_
+#include "Batch_Defines.hxx"
+
#include <iostream>
#include <string>
namespace Batch {
- class GenericType
+ class BATCH_EXPORT GenericType
{
public:
// Constructeur et destructeur
#ifndef _INTTYPE_H_
#define _INTTYPE_H_
+#include "Batch_Defines.hxx"
+
#include <string>
#include "Batch_GenericType.hxx"
namespace Batch {
- class IntType : public GenericType
+ class BATCH_EXPORT IntType : public GenericType
{
public:
// Constructeur
#define _INVALIDARGUMENTEXCEPTION_H_
+#include "Batch_Defines.hxx"
+
#include "Batch_GenericException.hxx"
#include "Batch_GenericException.hxx"
namespace Batch {
- class InvalidArgumentException : public GenericException
+ class BATCH_EXPORT InvalidArgumentException : public GenericException
{
public:
// Constructeur
#ifndef _INVALIDKEYEXCEPTION_H_
#define _INVALIDKEYEXCEPTION_H_
+#include "Batch_Defines.hxx"
+
#include "Batch_GenericException.hxx"
#include "Batch_GenericException.hxx"
namespace Batch {
- class InvalidKeyException : public GenericException
+ class BATCH_EXPORT InvalidKeyException : public GenericException
{
public:
// Constructeur
#ifndef _JOB_H_
#define _JOB_H_
+#include "Batch_Defines.hxx"
+
#include "Batch_Parametre.hxx"
#include "Batch_Environnement.hxx"
namespace Batch {
- class Job
+ class BATCH_EXPORT Job
{
public:
// Constructeurs et destructeur
#define _JOBID_H_
+#include "Batch_Defines.hxx"
+
#include "Batch_JobInfo.hxx"
#include "Batch_BatchManager.hxx"
class BatchManager;
- class JobId
+ class BATCH_EXPORT JobId
{
friend class BatchManager;
//#include "MEDMEM_STRING.hxx"
#include "Batch_JobInfo.hxx"
+using namespace std;
+
namespace Batch {
// Destructeur
#ifndef _JOBINFO_H_
#define _JOBINFO_H_
-using namespace std;
+#include "Batch_Defines.hxx"
+
#include <iostream>
#include <string>
#include "Batch_Parametre.hxx"
namespace Batch {
- class JobInfo
+ class BATCH_EXPORT JobInfo
{
public:
// Constructeur standard et destructeur
JobInfo(const JobInfo & jinfo) : _param(jinfo._param), _env(jinfo._env) {};
// Operateur pour l'affichage sur un stream
- friend ostream & operator <<(ostream & os, const JobInfo & ji);
+ friend std::ostream & operator <<(std::ostream & os, const JobInfo & ji);
// Accesseurs
// _CS_gbo Ajout explicite du namespace pour les besoins de swig (mauvaise gestion
// Methodes pour l'interfacage avec Python (SWIG)
// TODO : supprimer ces methodes et transferer leur definitions dans SWIG
- string __str__() const; // SWIG : affichage en Python
- string __repr__() const { return __str__(); }; // SWIG : affichage en Python
+ std::string __str__() const; // SWIG : affichage en Python
+ std::string __repr__() const { return __str__(); }; // SWIG : affichage en Python
protected:
Parametre _param; // parametres du job
#include "Batch_APIInternalFailureException.hxx"
#include "Batch_JobInfo_eLSF.hxx"
+using namespace std;
+
namespace Batch {
#ifndef _JOBINFO_LSF_H_
#define _JOBINFO_LSF_H_
-#include <string>
#include "Batch_RunTimeException.hxx"
#include "Batch_JobInfo.hxx"
+#include <string>
+
namespace Batch {
class JobInfo_eLSF : public JobInfo
// Methodes pour l'interfacage avec Python (SWIG)
// TODO : supprimer ces methodes et transferer leur definitions dans SWIG
- string __str__() const; // SWIG : affichage en Python
- string __repr__() const { return __str__(); }; // SWIG : affichage en Python
+ std::string __str__() const; // SWIG : affichage en Python
+ std::string __repr__() const { return __str__(); }; // SWIG : affichage en Python
protected:
bool _running; // etat du job en machine
private:
// Convertit une date HH:MM:SS en secondes
- long HMStoLong(const string &);
+ long HMStoLong(const std::string &);
};
#include "Batch_APIInternalFailureException.hxx"
#include "Batch_JobInfo_ePBS.hxx"
+using namespace std;
+
namespace Batch {
// Methodes pour l'interfacage avec Python (SWIG)
// TODO : supprimer ces methodes et transferer leur definitions dans SWIG
- string __str__() const; // SWIG : affichage en Python
- string __repr__() const { return __str__(); }; // SWIG : affichage en Python
+ std::string __str__() const; // SWIG : affichage en Python
+ std::string __repr__() const { return __str__(); }; // SWIG : affichage en Python
protected:
bool _running; // etat du job en machine
private:
// Convertit une date HH:MM:SS en secondes
- long HMStoLong(const string &);
+ long HMStoLong(const std::string &);
};
#include <stdio.h>
#include <stdlib.h>
+#ifndef WIN32
#include <unistd.h>
+#endif
#include "Batch_Job_Local.hxx"
+using namespace std;
+
namespace Batch {
// Constructeur
#ifndef _LISTISFULLEXCEPTION_H_
#define _LISTISFULLEXCEPTION_H_
+#include "Batch_Defines.hxx"
+
#include "Batch_GenericException.hxx"
namespace Batch {
- class ListIsFullException : public GenericException
+ class BATCH_EXPORT ListIsFullException : public GenericException
{
public:
// Constructeur
#ifndef _LONGTYPE_H_
#define _LONGTYPE_H_
+#include "Batch_Defines.hxx"
+
#include <string>
#include "Batch_GenericType.hxx"
namespace Batch {
- class LongType : public GenericType
+ class BATCH_EXPORT LongType : public GenericType
{
public:
// Constructeur
#ifndef _MAPKEY_H_
#define _MAPKEY_H_
+#include "Batch_Defines.hxx"
+
#include <string>
// une classe privee pour les differents types
// ces types ne peuvent pas etre redefinis
- class MapKey : public std::string
+ class BATCH_EXPORT MapKey : public std::string
{
private:
friend class Parametre; // seule la classe Parametre peut creer des MapKey
#ifndef _NOTYETIMPLEMENTEDEXCEPTION_H_
#define _NOTYETIMPLEMENTEDEXCEPTION_H_
-
+#include "Batch_Defines.hxx"
#include "Batch_GenericException.hxx"
-using namespace std;
+
+#include <string>
namespace Batch {
- class NotYetImplementedException : public GenericException
+ class BATCH_EXPORT NotYetImplementedException : public GenericException
{
public:
// Constructeur
- NotYetImplementedException(string ch = "undefined") : GenericException("NotYetImplementedException", ch) {}
+ NotYetImplementedException(std::string ch = "undefined") : GenericException("NotYetImplementedException", ch) {}
};
}
*
*/
-#include <map>
#include "Batch_Versatile.hxx"
#include "Batch_InvalidKeyException.hxx"
#include "Batch_Parametre.hxx"
+using namespace std;
+
// Definition des membres constants statiques
// Definition des noms globaux pour les clefs en tant que references
// TODO : supprimer les declarations statiques des clefs de la map
#ifndef _PARAMETRE_H_
#define _PARAMETRE_H_
-using namespace std;
+#include "Batch_Defines.hxx"
+
#include <map>
#include <string>
#include "Batch_InvalidKeyException.hxx"
#include "Batch_Versatile.hxx"
-
// Ces macros permettent de simplifier l'ajout de nouvelles
// clefs dans la map Parametre
// TODO : remplacer ce mecanisme statique par la lecture
// TODO : d'une descrption dans un fichier exterieur (genre XML)
-#define def_extern_MapKey(mk) extern const string & mk;
-#define def_static_MapKey(mk) const string Batch::Parametre::mk(#mk); \
- const string & mk = Batch::Parametre::mk;
+#define def_extern_MapKey(mk) extern BATCH_EXPORT const std::string & mk;
+#define def_static_MapKey(mk) const std::string Batch::Parametre::mk(#mk); \
+ const std::string & mk = Batch::Parametre::mk;
namespace Batch {
- class Parametre : public map< string, Versatile >
+ class BATCH_EXPORT Parametre : public std::map< std::string, Versatile >
{
public:
// Constructeur standard
Parametre(const Parametre & PM);
// Operateur de recherche dans la map
- Versatile & operator [] (const string &);
- const Versatile & operator [] (const string &) const;
+ Versatile & operator [] (const std::string &);
+ const Versatile & operator [] (const std::string &) const;
// Operateur d'affectation
Parametre & operator =(const Parametre & PM);
// Declarations statique des clefs de la map
// TODO : supprimer les declarations statiques des clefs de la map
- static const string ACCOUNT;
- static const string ARGUMENTS;
- static const string CHECKPOINT;
- static const string CKPTINTERVAL;
- static const string CREATIONTIME;
- static const string EGROUP;
- static const string ELIGIBLETIME;
- static const string ENDTIME;
- static const string EUSER;
- static const string EXECUTABLE;
- static const string EXECUTIONHOST;
- static const string EXITCODE;
- static const string HOLD;
- static const string ID;
- static const string INFILE;
- static const string MAIL;
- static const string MAXCPUTIME;
- static const string MAXDISKSIZE;
- static const string MAXRAMSIZE;
- static const string MAXWALLTIME;
- static const string MODIFICATIONTIME;
- static const string NAME;
- static const string NBPROC;
- static const string OUTFILE;
- static const string PID;
- static const string QUEUE;
- static const string QUEUEDTIME;
- static const string SERVER;
- static const string STARTTIME;
- 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;
- static const string HOMEDIR;
+ static const std::string ACCOUNT;
+ static const std::string ARGUMENTS;
+ static const std::string CHECKPOINT;
+ static const std::string CKPTINTERVAL;
+ static const std::string CREATIONTIME;
+ static const std::string EGROUP;
+ static const std::string ELIGIBLETIME;
+ static const std::string ENDTIME;
+ static const std::string EUSER;
+ static const std::string EXECUTABLE;
+ static const std::string EXECUTIONHOST;
+ static const std::string EXITCODE;
+ static const std::string HOLD;
+ static const std::string ID;
+ static const std::string INFILE;
+ static const std::string MAIL;
+ static const std::string MAXCPUTIME;
+ static const std::string MAXDISKSIZE;
+ static const std::string MAXRAMSIZE;
+ static const std::string MAXWALLTIME;
+ static const std::string MODIFICATIONTIME;
+ static const std::string NAME;
+ static const std::string NBPROC;
+ static const std::string OUTFILE;
+ static const std::string PID;
+ static const std::string QUEUE;
+ static const std::string QUEUEDTIME;
+ static const std::string SERVER;
+ static const std::string STARTTIME;
+ static const std::string STATE;
+ static const std::string TEXT;
+ static const std::string TMPDIR;
+ static const std::string USEDCPUTIME;
+ static const std::string USEDDISKSIZE;
+ static const std::string USEDRAMSIZE;
+ static const std::string USEDWALLTIME;
+ static const std::string USER;
+ static const std::string WORKDIR;
+ static const std::string HOMEDIR;
protected:
- map< string, TypeParam > TypeMap; // map interne servant a controler le type de la valeur associee a chaque clef
+ std::map< std::string, TypeParam > TypeMap; // map interne servant a controler le type de la valeur associee a chaque clef
private:
#include "Batch_PyVersatile.hxx"
#include <string>
+using namespace std;
+
namespace Batch {
// Constructeur a partir d'un objet Versatile
#define _PYVERSATILE_H_
+#include "Batch_Defines.hxx"
+
#include <Python.h>
#include "Batch_Versatile.hxx"
#include "Batch_TypeMismatchException.hxx"
#include "Batch_ListIsFullException.hxx"
#include "Batch_InvalidArgumentException.hxx"
-using namespace std;
namespace Batch {
- class PyVersatile : public Versatile
+ class BATCH_EXPORT PyVersatile : public Versatile
{
public:
// Constructeur a partir d'un objet Versatile
#ifndef _RUNTIMEEXCEPTION_H_
#define _RUNTIMEEXCEPTION_H_
+#include "Batch_Defines.hxx"
+
#include "Batch_GenericException.hxx"
namespace Batch {
- class RunTimeException : public GenericException
+ class BATCH_EXPORT RunTimeException : public GenericException
{
public:
// Constructeur
#ifndef _STRINGTYPE_H_
#define _STRINGTYPE_H_
+#include "Batch_Defines.hxx"
+
#include <string>
#include "Batch_GenericType.hxx"
namespace Batch {
- class StringType : public GenericType
+ class BATCH_EXPORT StringType : public GenericType
{
public:
// Constructeur
#ifndef _TYPEMISMATCHEXCEPTION_H_
#define _TYPEMISMATCHEXCEPTION_H_
+#include "Batch_Defines.hxx"
+
#include "Batch_GenericException.hxx"
namespace Batch {
- class TypeMismatchException : public GenericException
+ class BATCH_EXPORT TypeMismatchException : public GenericException
{
public:
// Constructeur
#ifndef _VERSATILE_H_
#define _VERSATILE_H_
+#include "Batch_Defines.hxx"
+
#include <iostream>
#include <list>
#include <string>
int maxelem; // le nombre d'elements autorises
} TypeParam;
- class Versatile : public std::list< GenericType * >
+ class BATCH_EXPORT Versatile : public std::list< GenericType * >
{
public:
// Constructeur standard et destructeur
Batch_BatchManager_ePBS.hxx \
Batch_FactBatchManager_ePBS.hxx \
Batch_JobInfo_ePBS.hxx \
- MpiImpl.hxx
+ MpiImpl.hxx \
+ Batch_Defines.hxx
LIB_SRC = \
${PYTHON_INCLUDES} \
-I$(srcdir)/../Basics \
-I$(srcdir)/../SALOMELocalTrace \
- -I$(top_builddir)/salome_adm/unix
+ -I$(top_builddir)/salome_adm/unix
LIB_LIBADD = \
../SALOMELocalTrace/libSALOMELocalTrace.la \
#ifndef _BL_MPIIMPL_H_
#define _BL_MPIIMPL_H_
+#include "Batch_Defines.hxx"
#include <string>
-class MpiImplException
+class BATCH_EXPORT MpiImplException
{
public:
const std::string msg;
MpiImplException(const std::string m) : msg(m) {}
};
-class MpiImpl
+class BATCH_EXPORT MpiImpl
{
public:
// Constructeur et destructeur
};
-class MpiImpl_LAM : public MpiImpl
+class BATCH_EXPORT MpiImpl_LAM : public MpiImpl
{
public:
// Constructeur et destructeur
};
-class MpiImpl_MPICH1 : public MpiImpl
+class BATCH_EXPORT MpiImpl_MPICH1 : public MpiImpl
{
public:
// Constructeur et destructeur
};
-class MpiImpl_MPICH2 : public MpiImpl
+class BATCH_EXPORT MpiImpl_MPICH2 : public MpiImpl
{
public:
// Constructeur et destructeur
};
-class MpiImpl_OPENMPI : public MpiImpl
+class BATCH_EXPORT MpiImpl_OPENMPI : public MpiImpl
{
public:
// Constructeur et destructeur
};
-class MpiImpl_SLURM : public MpiImpl
+class BATCH_EXPORT MpiImpl_SLURM : public MpiImpl
{
public:
// Constructeur et destructeur