1 // Copyright (C) 2009-2020 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 DEBTRACE("Creating BL::Job");
30 _batch_params.batch_directory = "";
31 _batch_params.maximum_duration = "";
32 _batch_params.mem_limit = 0;
33 _batch_params.mem_req_type = MEM_PER_NODE;
34 _batch_params.nb_proc = 0;
35 _batch_params.nb_node = 0;
36 _batch_params.exclusive = false;
37 _files_params.result_directory = "";
38 _resource_choosed = "";
40 _batch_partition = "";
41 _state = BL::Job::CREATED;
42 _thread_state = BL::Job::NOTHING;
43 _salome_launcher_id = -1;
45 _yacs_driver_options = "";
48 // Parameters for COORM
49 _batch_params.launcher_file = "";
50 _batch_params.launcher_args = "";
53 BL::Job::Job(const std::string & name)
55 DEBTRACE("Creating BL::Job with name : " << name);
61 _batch_params.batch_directory = "";
62 _batch_params.maximum_duration = "";
63 _batch_params.mem_limit = 0;
64 _batch_params.mem_req_type = MEM_PER_NODE;
65 _batch_params.nb_proc = 0;
66 _batch_params.nb_node = 0;
67 _batch_params.exclusive = false;
68 _files_params.result_directory = "";
69 _resource_choosed = "";
71 _batch_partition = "";
72 _state = BL::Job::CREATED;
73 _thread_state = BL::Job::NOTHING;
74 _salome_launcher_id = -1;
76 _yacs_driver_options = "";
79 // Parameters for COORM
80 _batch_params.launcher_file = "";
81 _batch_params.launcher_args = "";
88 BL::Job::setName(const std::string & name)
100 BL::Job::setType(BL::Job::JobType type)
106 BL::Job::setType(const std::string & type)
108 if (type == "command")
110 setType(BL::Job::COMMAND);
112 else if (type == "yacs_file")
114 setType(BL::Job::YACS_SCHEMA);
116 else if (type == "python_salome")
118 setType(BL::Job::PYTHON_SALOME);
120 else if (type == "command_salome")
122 setType(BL::Job::COMMAND_SALOME);
133 BL::Job::setDumpYACSState(const int & dump_yacs_state)
135 _dump_yacs_state = dump_yacs_state;
139 BL::Job::getDumpYACSState()
141 return _dump_yacs_state;
145 BL::Job::setYacsDriverOptions(const std::string& options)
147 _yacs_driver_options = options;
151 BL::Job::getYacsDriverOptions()const
153 return _yacs_driver_options;
157 BL::Job::setJobFile(const std::string & job_file)
159 _job_file = job_file;
163 BL::Job::getJobFile()
169 BL::Job::setEnvFile(const std::string & env_file)
171 _env_file = env_file;
175 BL::Job::getEnvFile()
181 BL::Job::setPreCommand(const std::string & pre_command)
183 _pre_command = pre_command;
187 BL::Job::getPreCommand()
193 BL::Job::setBatchParameters(const BL::Job::BatchParam & param)
195 _batch_params = param;
198 const BL::Job::BatchParam &
199 BL::Job::getBatchParameters()
201 return _batch_params;
205 BL::Job::setFilesParameters(BL::Job::FilesParam & param)
207 _files_params.result_directory = param.result_directory;
208 _files_params.input_files_list = param.input_files_list;
209 _files_params.output_files_list = param.output_files_list;
212 BL::Job::FilesParam &
213 BL::Job::getFilesParameters()
215 return _files_params;
219 BL::Job::setResource(const std::string & resource)
221 _resource_choosed = resource;
225 BL::Job::getResource()
227 return _resource_choosed;
231 BL::Job::setBatchQueue(const std::string & queue)
233 _batch_queue = queue;
237 BL::Job::getBatchQueue()
243 BL::Job::setBatchPartition(const std::string & partition)
245 _batch_partition = partition;
249 BL::Job::getBatchPartition()
251 return _batch_partition;
255 BL::Job::setWCKey(const std::string & wckey)
267 BL::Job::setExtraParams(const std::string & extra_params)
269 _extra_params = extra_params;
273 BL::Job::getExtraParams()
275 return _extra_params;
279 BL::Job::setLoadLevelerJobType(const std::string & jobtype)
281 _ll_jobtype = jobtype;
285 BL::Job::getLoadLevelerJobType()
291 BL::Job::setState(BL::Job::State state)
303 BL::Job::setStringState(const std::string & state)
305 std::string result("");
307 // Check if state is an error
308 if (state != "CREATED" &&
309 state != "IN_PROCESS" &&
311 state != "RUNNING" &&
313 state != "FINISHED" &&
315 state != "NOT_CREATED" &&
319 DEBTRACE("Error state in setStringState");
320 result = "RefreshError";
325 if (state == "CREATED")
327 if (_state != BL::Job::CREATED)
329 setState(BL::Job::CREATED);
333 else if (state == "NOT_CREATED")
335 if (_state != BL::Job::NOT_CREATED)
337 setState(BL::Job::NOT_CREATED);
341 else if (state == "QUEUED")
343 if (_state != BL::Job::QUEUED)
345 setState(BL::Job::QUEUED);
349 else if (state == "IN_PROCESS")
351 if (_state != BL::Job::IN_PROCESS)
353 setState(BL::Job::IN_PROCESS);
357 else if (state == "RUNNING")
359 if (_state != BL::Job::RUNNING)
361 setState(BL::Job::RUNNING);
365 else if (state == "PAUSED")
367 if (_state != BL::Job::PAUSED)
369 setState(BL::Job::PAUSED);
373 else if (state == "FINISHED")
375 if (_state != BL::Job::FINISHED)
377 setState(BL::Job::FINISHED);
381 else if (state == "ERROR")
383 if (_state != BL::Job::ERROR)
385 setState(BL::Job::ERROR);
389 else if (state == "FAILED")
391 if (_state != BL::Job::FAILED)
393 setState(BL::Job::FAILED);
402 BL::Job::setThreadState(BL::Job::ThreadState state)
404 _thread_state = state;
408 BL::Job::getThreadState()
410 return _thread_state;
414 BL::Job::setSalomeLauncherId(int id)
416 _salome_launcher_id = id;
420 BL::Job::getSalomeLauncherId()
422 return _salome_launcher_id;