]> SALOME platform Git repositories - modules/kernel.git/blob - src/Launcher/Launcher.hxx
Salome HOME
Copyright update 2020
[modules/kernel.git] / src / Launcher / Launcher.hxx
1 // Copyright (C) 2007-2020  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, or (at your option) any later version.
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
23 #ifndef __LAUNCHER_HXX__
24 #define __LAUNCHER_HXX__
25
26 #include "Launcher_Utils.hxx"
27 #include "Launcher_Job.hxx"
28
29 #include "ResourcesManager.hxx"
30 #include <SALOME_ResourcesCatalog_Parser.hxx>
31
32 #include "SALOME_Launcher_Parser.hxx"
33
34 #include <string>
35 #include <vector>
36 #include <list>
37 #include <memory>
38
39 class MpiImpl;
40
41 namespace Batch{
42   class BatchManager;
43   class Job;
44 }
45
46 struct LAUNCHER_EXPORT JobParameters_cpp
47 {
48   std::string job_name;
49   std::string job_type;
50   std::string job_file;
51   std::string pre_command;
52   std::string env_file;
53   std::list<std::string> in_files;
54   std::list<std::string> out_files;
55   std::string work_directory;
56   std::string local_directory;
57   std::string result_directory;
58   std::string maximum_duration;
59   resourceParams resource_required;
60   std::string queue;
61   std::string partition;
62   bool exclusive;
63   unsigned int mem_per_cpu;
64   std::string wckey;
65   std::string extra_params;
66   std::map<std::string, std::string> specific_parameters;
67   std::string launcher_file;
68   std::string launcher_args;
69 };
70
71 class LAUNCHER_EXPORT Launcher_cpp
72 {
73 public:
74   Launcher_cpp();
75   virtual ~Launcher_cpp();
76
77   // Main interface
78   void         createJob(Launcher::Job * new_job);
79   int          createJob(const JobParameters_cpp& job_parameters);
80   void         launchJob(int job_id);
81   std::string  getJobState(int job_id);
82   std::string  getAssignedHostnames(int job_id); // Get names or ids of hosts assigned to the job
83   void         getJobResults(int job_id, std::string directory);
84   void         clearJobWorkingDir(int job_id);
85   bool         getJobDumpState(int job_id, std::string directory);
86   bool         getJobWorkFile(int job_id, std::string work_file, std::string directory);
87   void         stopJob(int job_id);
88   void         removeJob(int job_id);
89   std::string  dumpJob(int job_id);
90   int restoreJob(const std::string& dumpedJob);
91   JobParameters_cpp getJobParameters(int job_id);
92
93   /*! Load the jobs from the file "jobs_file" and add them to the Launcher.
94    *  Return a list with the IDs of the jobs that were successfully loaded.
95    */
96   std::list<int> loadJobs(const char* jobs_file);
97
98   //! Save the jobs of the Launcher to the file "jobs_file".
99   void saveJobs(const char* jobs_file);
100
101   // Useful methods
102   long createJobWithFile(std::string xmlExecuteFile, std::string clusterName);
103   std::map<int, Launcher::Job *> getJobs();
104   void addJobDirectlyToMap(Launcher::Job * new_job);
105   Launcher::Job * findJob(int job_id);
106
107   // Lib methods
108   void SetResourcesManager( std::shared_ptr<ResourcesManager_cpp>& rm ) {_ResManager = rm;}
109
110 protected:
111
112   // Used by SALOME_Launcher
113   std::shared_ptr<ResourcesManager_cpp> _ResManager;
114
115   virtual void notifyObservers(const std::string & event_name, const std::string & event_data) {}
116   int addJob(Launcher::Job * new_job);
117
118   // Methods used by user interface methods
119 #ifdef WITH_LIBBATCH
120   Batch::BatchManager *FactoryBatchManager(ParserResourcesType& params);
121   std::map <int, Batch::BatchManager*> _batchmap;
122   Batch::BatchManager* getBatchManager(Launcher::Job * job);
123 #endif
124   ParserLauncherType ParseXmlFile(std::string xmlExecuteFile);
125
126   std::map <int, Launcher::Job *> _launcher_job_map;  
127   int _job_cpt; // job number counter
128 };
129
130 #endif