Version: 9.16.0
Launcher_Job.hxx
Go to the documentation of this file.
1// Copyright (C) 2009-2026 CEA, EDF, OPEN CASCADE
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20// Author: André RIBES - EDF R&D
21//
22#ifndef _LAUNCHER_JOB_HXX_
23#define _LAUNCHER_JOB_HXX_
24
25#include "Launcher_Utils.hxx"
26#include "ResourcesManager.hxx"
27
28#include <stdlib.h>
29#include <time.h>
30#include <sys/stat.h>
31
32#include <string>
33#include <list>
34#include <map>
35#include <iostream>
36#include <sstream>
37#include <algorithm>
38#include <exception>
39
40#ifdef WITH_LIBBATCH
41#include <libbatch/Job.hxx>
42#include <libbatch/JobId.hxx>
43#include <libbatch/GenericException.hxx>
44#endif
45
46namespace Launcher
47{
49 {
50 public:
51 Job();
52 virtual ~Job();
53
54 // Launcher managing parameters
55 // State of a Job: CREATED, IN_PROCESS, QUEUED, RUNNING, PAUSED, FINISHED, ERROR
56 void setState(const std::string & state);
57 std::string getState() const;
58 // Get names or ids of hosts assigned to the job
59 std::string getAssignedHostnames();
60
61 void setNumber(const int & number);
62 int getNumber();
63
64 virtual void setResourceDefinition(const ParserResourcesType & resource_definition);
65 ParserResourcesType getResourceDefinition() const;
66
67 // Common parameters
68 void setJobName(const std::string & job_name);
69 virtual void setJobFile(const std::string & job_file);
70 void setPreCommand(const std::string & preCommand);
71 void setWorkDirectory(const std::string & work_directory);
72 void setLocalDirectory(const std::string & local_directory);
73 void setResultDirectory(const std::string & result_directory);
74 void add_in_file(const std::string & file);
75 void add_out_file(const std::string & file);
76 void setMaximumDuration(const std::string & maximum_duration);
77 void setResourceRequiredParams(const resourceParams & resource_required_params);
78 void setQueue(const std::string & queue);
79 void setPartition(const std::string & partition);
80 void setEnvFile(const std::string & env_file);
81 void setExclusive(bool exclusive);
82 void setExclusiveStr(const std::string & exclusiveStr);
83 void setMemPerCpu(unsigned long mem_per_cpu);
84 void setWCKey(const std::string & wckey);
85 void setExtraParams(const std::string & extra_params);
86 void setReference(const std::string & reference);
87 void setVerbosePyLogLevel(const std::string& verbosePyLogLevel);
88 // For COORM
89 void setLauncherFile(const std::string & launcher_file);
90 void setLauncherArgs(const std::string & launcher_args);
91
92 std::string getJobName() const;
93 std::string getJobFile() const;
94 std::string getPreCommand() const;
95 std::string getWorkDirectory() const;
96 std::string getLocalDirectory() const;
97 std::string getResultDirectory() const;
98 const std::list<std::string> & get_in_files() const;
99 const std::list<std::string> & get_out_files() const;
100 std::string getMaximumDuration() const;
101 long getMaximumDurationInSecond() const { return this->_maximum_duration_in_second; }
102 resourceParams getResourceRequiredParams() const;
103 std::string getQueue() const;
104 std::string getPartition() const;
105 std::string getEnvFile() const;
106 std::string getJobType() const;
107 bool getExclusive() const;
108 std::string getExclusiveStr() const;
109 unsigned long getMemPerCpu() const;
110 std::string getWCKey() const;
111 std::string getExtraParams() const;
112 std::string getReference() const;
113 std::string getVerbosePyLogLevel() const;
114
115 // For COORM
116 std::string getLauncherFile() const;
117 std::string getLauncherArgs() const;
118
119 std::string updateJobState();
120
121 void addSpecificParameter(const std::string & name,
122 const std::string & value);
123 const std::map<std::string, std::string> & getSpecificParameters() const;
124 virtual void checkSpecificParameters();
125
126 // Checks
127 void checkMaximumDuration(const std::string & maximum_duration);
128 void checkResourceRequiredParams(const resourceParams & resource_required_params);
129
130 // Helps
131 long convertMaximumDuration(const std::string & maximum_duration);
132 std::string getLaunchDate() const;
133
134 void stopJob();
135 void removeJob();
136
137 // Abstract class
138 virtual void update_job() = 0;
139
140 protected:
142
143 std::string _job_type;
144
145 std::string _state;
146 std::string _assigned_hostnames; // Assigned hostnames
147 std::string _launch_date;
148 std::string _env_file;
149
151
152 std::string _job_name;
153 std::string _job_file;
154 std::string _job_file_name;
156 std::string _pre_command;
157
158 std::string _work_directory;
159 std::string _local_directory;
160 std::string _result_directory;
161 std::list<std::string> _in_files;
162 std::list<std::string> _out_files;
163 std::map<std::string, std::string> _specific_parameters;
164 std::string _maximum_duration;
167 std::string _queue;
168 std::string _partition;
170 unsigned long _mem_per_cpu;
171 std::string _wckey;
172 std::string _extra_params;
173 std::string _reference;
175
176 // Parameters for COORM
177 std::string _launcher_file;
178 std::string _launcher_args;
179
180#ifdef WITH_LIBBATCH
181 // Connection with LIBBATCH
182 public:
183 Batch::Job * getBatchJob();
184 Batch::Parametre common_job_params();
185 void setBatchManagerJobId(Batch::JobId batch_manager_job_id);
186 Batch::JobId getBatchManagerJobId() const;
187
188 protected:
189 Batch::Job * _batch_job;
190 Batch::JobId _batch_job_id;
191#endif
192 protected:
193 mutable int _cnt = 1;
194 };
195}
196
197#endif
#define LAUNCHER_EXPORT
Definition: Launcher_Utils.hxx:39
Definition: Launcher_Job.hxx:49
std::string _launcher_args
Definition: Launcher_Job.hxx:178
long getMaximumDurationInSecond() const
Definition: Launcher_Job.hxx:101
std::string _job_name
Definition: Launcher_Job.hxx:152
std::string _result_directory
Definition: Launcher_Job.hxx:160
std::string _launcher_file
same semantics than driver –verbose_level
Definition: Launcher_Job.hxx:177
std::string _work_directory
Definition: Launcher_Job.hxx:158
virtual void update_job()=0
std::string _reference
Definition: Launcher_Job.hxx:173
std::string _partition
Definition: Launcher_Job.hxx:168
std::string _extra_params
Definition: Launcher_Job.hxx:172
resourceParams _resource_required_params
Definition: Launcher_Job.hxx:166
std::string _job_type
Definition: Launcher_Job.hxx:143
std::list< std::string > _out_files
Definition: Launcher_Job.hxx:162
long _maximum_duration_in_second
Definition: Launcher_Job.hxx:165
std::string _env_file
Definition: Launcher_Job.hxx:148
std::string _verbose_py_log_level
Reference of the job for the batch manager.
Definition: Launcher_Job.hxx:174
unsigned long _mem_per_cpu
Definition: Launcher_Job.hxx:170
std::string _job_file
Definition: Launcher_Job.hxx:153
std::list< std::string > _in_files
Definition: Launcher_Job.hxx:161
std::string _local_directory
Definition: Launcher_Job.hxx:159
int _number
Definition: Launcher_Job.hxx:141
std::string _job_file_name_complete
Definition: Launcher_Job.hxx:155
std::string _launch_date
Definition: Launcher_Job.hxx:147
ParserResourcesType _resource_definition
Definition: Launcher_Job.hxx:150
bool _exclusive
Definition: Launcher_Job.hxx:169
std::string _pre_command
Definition: Launcher_Job.hxx:156
std::map< std::string, std::string > _specific_parameters
Definition: Launcher_Job.hxx:163
std::string _maximum_duration
Definition: Launcher_Job.hxx:164
std::string _queue
Definition: Launcher_Job.hxx:167
std::string _state
Definition: Launcher_Job.hxx:145
std::string _wckey
Definition: Launcher_Job.hxx:171
std::string _assigned_hostnames
Definition: Launcher_Job.hxx:146
std::string _job_file_name
Definition: Launcher_Job.hxx:154
Definition: SALOME_ResourcesCatalog_Parser.hxx:90
Definition: Launcher_Job.hxx:47
file
Definition: Utils_Identity.py:80
job_name
Definition: launcher_use_case.py:48
wckey
Definition: launcher_use_case.py:47
job_file
Definition: launcher_use_case.py:43
result_directory
Definition: launcher_use_case.py:45
work_directory
Definition: launcher_use_case.py:44
local_directory
Definition: launcher_use_case.py:42
string name
Definition: pythfilter.py:56
Definition: ResourcesManager.hxx:52