Back to index

salome-kernel  6.5.0
Launcher.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #ifndef __LAUNCHER_HXX__
00024 #define __LAUNCHER_HXX__
00025 
00026 #include "Launcher_Utils.hxx"
00027 #include "Launcher_Job.hxx"
00028 
00029 #include "ResourcesManager.hxx"
00030 #include <SALOME_ResourcesCatalog_Parser.hxx>
00031 
00032 #include "SALOME_Launcher_Parser.hxx"
00033 
00034 #include <string>
00035 #include <vector>
00036 
00037 #include <pthread.h>
00038 
00039 class MpiImpl;
00040 
00041 namespace Batch{
00042   class BatchManager_eClient;
00043   class Job;
00044 }
00045 
00046 struct batchParams{
00047   std::string batch_directory;
00048   std::string expected_during_time;
00049   std::string mem;
00050   unsigned long nb_proc;
00051 };
00052 
00053 class LAUNCHER_EXPORT Launcher_cpp
00054 {
00055 
00056 public:
00057   Launcher_cpp();
00058   virtual ~Launcher_cpp();
00059 
00060   // Main interface
00061   void         createJob(Launcher::Job * new_job);
00062   void         launchJob(int job_id);
00063   const char * getJobState(int job_id);
00064   void         getJobResults(int job_id, std::string directory);
00065   bool         getJobDumpState(int job_id, std::string directory);
00066   void         stopJob(int job_id);
00067   void         removeJob(int job_id);
00068 
00069   // Useful methods
00070   long createJobWithFile(std::string xmlExecuteFile, std::string clusterName);
00071   std::map<int, Launcher::Job *> getJobs();
00072   void createBatchManagerForJob(Launcher::Job * job);
00073   void addJobDirectlyToMap(Launcher::Job * new_job, const std::string job_reference);
00074 
00075   // Lib methods
00076   void SetResourcesManager( ResourcesManager_cpp* rm ) {_ResManager = rm;}
00077 
00078   // Used by SALOME_Launcher
00079   ResourcesManager_cpp *_ResManager;
00080 protected:
00081 
00082   virtual void notifyObservers(const std::string & event_name, const std::string & event_data) {}
00083 
00084   // Methods used by user interface methods
00085 #ifdef WITH_LIBBATCH
00086   Batch::BatchManager_eClient *FactoryBatchManager(ParserResourcesType& params);
00087   std::map <int, Batch::BatchManager_eClient*> _batchmap;
00088 #endif
00089   ParserLauncherType ParseXmlFile(std::string xmlExecuteFile);
00090 
00091   std::map <int, Launcher::Job *> _launcher_job_map;  
00092   int _job_cpt; // job number counter
00093   pthread_mutex_t * _job_cpt_mutex; // mutex for job counter
00094 };
00095 
00096 #endif