Version: 9.12.0
Launcher.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2023 CEA, EDF, 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"
31 
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 
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;
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 
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 exportInputFiles(int job_id);
84  void getJobResults(int job_id, std::string directory);
85  void clearJobWorkingDir(int job_id);
86  bool getJobDumpState(int job_id, std::string directory);
87  bool getJobWorkFile(int job_id, std::string work_file, std::string directory);
88  void stopJob(int job_id);
89  void removeJob(int job_id);
90  std::string dumpJob(int job_id);
91  int restoreJob(const std::string& dumpedJob);
92  JobParameters_cpp getJobParameters(int job_id);
93 
97  std::list<int> loadJobs(const char* jobs_file);
98 
100  void saveJobs(const char* jobs_file);
101 
102  // Useful methods
103  long createJobWithFile(std::string xmlExecuteFile, std::string clusterName);
104  std::map<int, Launcher::Job *> getJobs();
105  void addJobDirectlyToMap(Launcher::Job * new_job);
106  Launcher::Job * findJob(int job_id);
107 
108  // Lib methods
109  void SetResourcesManager( std::shared_ptr<ResourcesManager_cpp>& rm ) {_ResManager = rm;}
110 
111 protected:
112 
113  // Used by SALOME_Launcher
114  std::shared_ptr<ResourcesManager_cpp> _ResManager;
115 
116  virtual void notifyObservers(const std::string & /*event_name*/, const std::string & /*event_data*/) {}
117  int addJob(Launcher::Job * new_job);
118 
119  // Methods used by user interface methods
120 #ifdef WITH_LIBBATCH
121  Batch::BatchManager *FactoryBatchManager(ParserResourcesType& params);
122  std::map <int, Batch::BatchManager*> _batchmap;
123  Batch::BatchManager* getBatchManager(Launcher::Job * job);
124 #endif
125  ParserLauncherType ParseXmlFile(std::string xmlExecuteFile);
126 
127  std::map <int, Launcher::Job *> _launcher_job_map;
128  int _job_cpt; // job number counter
129 };
130 
131 #endif
#define LAUNCHER_EXPORT
Definition: Launcher_Utils.hxx:39
Definition: Launcher_Job.hxx:49
Definition: Launcher.hxx:72
std::shared_ptr< ResourcesManager_cpp > _ResManager
Definition: Launcher.hxx:114
int _job_cpt
Definition: Launcher.hxx:128
std::map< int, Launcher::Job * > _launcher_job_map
Definition: Launcher.hxx:127
void SetResourcesManager(std::shared_ptr< ResourcesManager_cpp > &rm)
Definition: Launcher.hxx:109
virtual void notifyObservers(const std::string &, const std::string &)
Definition: Launcher.hxx:116
Definition: SALOME_ResourcesCatalog_Parser.hxx:90
Definition: Launcher.hxx:41
job_id
Definition: launcher_use_case.py:49
rm
Definition: salome.py:122
Definition: Launcher.hxx:47
std::string pre_command
Definition: Launcher.hxx:51
std::string launcher_args
Definition: Launcher.hxx:68
std::string work_directory
Definition: Launcher.hxx:55
std::list< std::string > in_files
Definition: Launcher.hxx:53
std::string local_directory
Definition: Launcher.hxx:56
std::string launcher_file
Definition: Launcher.hxx:67
std::string extra_params
Definition: Launcher.hxx:65
std::map< std::string, std::string > specific_parameters
Definition: Launcher.hxx:66
resourceParams resource_required
Definition: Launcher.hxx:59
unsigned int mem_per_cpu
Definition: Launcher.hxx:63
std::string result_directory
Definition: Launcher.hxx:57
std::string wckey
Definition: Launcher.hxx:64
std::string job_name
Definition: Launcher.hxx:48
bool exclusive
Definition: Launcher.hxx:62
std::string job_type
Definition: Launcher.hxx:49
std::string queue
Definition: Launcher.hxx:60
std::string env_file
Definition: Launcher.hxx:52
std::string partition
Definition: Launcher.hxx:61
std::string maximum_duration
Definition: Launcher.hxx:58
std::string job_file
Definition: Launcher.hxx:50
std::list< std::string > out_files
Definition: Launcher.hxx:54
Definition: SALOME_Launcher_Parser.hxx:46
Definition: ResourcesManager.hxx:52