Salome HOME
CCAR:
[modules/kernel.git] / src / Launcher / Launcher.hxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 #ifndef __LAUNCHER_HXX__
23 #define __LAUNCHER_HXX__
24
25 #ifdef WIN32
26 # if defined LAUNCHER_EXPORTS || defined Launcher_EXPORTS
27 #  define LAUNCHER_EXPORT __declspec(dllexport)
28 # else
29 #  define LAUNCHER_EXPORT __declspec(dllimport)
30 # endif
31 #else
32 # define LAUNCHER_EXPORT
33 #endif
34
35 #include <SALOME_ResourcesCatalog_Parser.hxx>
36 #include "ResourcesManager.hxx"
37 #include "SALOME_Launcher_Parser.hxx"
38
39 #include <string>
40 #include <vector>
41
42 class MpiImpl;
43
44 namespace Batch{
45   class BatchManager_eClient;
46   class Job;
47 }
48
49 struct batchParams{
50   std::string batch_directory;
51   std::string expected_during_time;
52   std::string mem;
53   unsigned long nb_proc;
54 };
55
56 class LAUNCHER_EXPORT LauncherException
57 {
58 public:
59   const std::string msg;
60
61   LauncherException(const std::string m) : msg(m) {}
62 };
63
64 class LAUNCHER_EXPORT Launcher_cpp
65 {
66
67 public:
68   Launcher_cpp();
69   ~Launcher_cpp();
70
71   long submitJob(const std::string xmlExecuteFile,
72                  const std::string clusterName) throw(LauncherException);
73
74   long submitSalomeJob(const std::string fileToExecute ,
75                        const std::vector<std::string>& filesToExport ,
76                        const std::vector<std::string>& filesToImport ,
77                        const batchParams& batch_params,
78                        const machineParams& params) throw(LauncherException);
79
80   std::string queryJob( const long jobId, const machineParams& params) throw(LauncherException);
81   std::string queryJob( const long jobId, const std::string clusterName);
82   void deleteJob( const long jobId, const machineParams& params) throw(LauncherException);
83   void deleteJob( const long jobId, const std::string clusterName);
84   void getResultsJob( const std::string directory, const long jobId, const machineParams& params ) throw(LauncherException);
85   void getResultsJob( const std::string directory, const long jobId, const std::string clusterName );
86
87   void SetResourcesManager( ResourcesManager_cpp* rm ) { _ResManager = rm; }
88
89 protected:
90
91   std::string buildSalomeCouplingScript(const std::string fileToExecute, const std::string dirForTmpFiles, const ParserResourcesType& params);
92   MpiImpl *FactoryMpiImpl(MpiImplType mpiImpl) throw(LauncherException);
93   Batch::BatchManager_eClient *FactoryBatchManager( const ParserResourcesType& params ) throw(LauncherException);
94   std::string getTmpDirForBatchFiles();
95   std::string getRemoteFile( std::string remoteDir, std::string localFile );
96   std::string getHomeDir(const ParserResourcesType& p, const std::string & tmpdir);  
97
98   std::map <std::string,Batch::BatchManager_eClient*> _batchmap;
99   std::map < std::pair<std::string,long> , Batch::Job* > _jobmap;
100   ResourcesManager_cpp *_ResManager;
101   bool check(const batchParams& batch_params);
102   long getWallTime(std::string edt);
103   long getRamSize(std::string mem);
104   void ParseXmlFile(std::string xmlExecuteFile);
105
106   //! will contain the informations on the data type catalog(after parsing)
107   ParserLauncherType _launch;
108
109 };
110
111 #endif