1 // Copyright (C) 2009-2013 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.
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");
28 _batch_params.batch_directory = "";
29 _batch_params.maximum_duration = "";
30 _batch_params.expected_memory = "";
31 _batch_params.nb_proc = 0;
32 _files_params.result_directory = "";
33 _resource_choosed = "";
35 _state = BL::Job::CREATED;
36 _thread_state = BL::Job::NOTHING;
37 _salome_launcher_id = -1;
41 // Parameters for COORM
42 _batch_params.launcher_file = "";
43 _batch_params.launcher_args = "";
46 BL::Job::Job(const std::string & name)
48 DEBTRACE("Creating BL::Job with name : " << name);
52 _batch_params.batch_directory = "";
53 _batch_params.maximum_duration = "";
54 _batch_params.expected_memory = "";
55 _batch_params.nb_proc = 0;
56 _files_params.result_directory = "";
57 _resource_choosed = "";
59 _state = BL::Job::CREATED;
60 _thread_state = BL::Job::NOTHING;
61 _salome_launcher_id = -1;
65 // Parameters for COORM
66 _batch_params.launcher_file = "";
67 _batch_params.launcher_args = "";
74 BL::Job::setName(const std::string & name)
86 BL::Job::setType(BL::Job::JobType type)
92 BL::Job::setType(const std::string & type)
94 if (type == "command")
96 setType(BL::Job::COMMAND);
98 else if (type == "yacs_file")
100 setType(BL::Job::YACS_SCHEMA);
102 else if (type == "python_salome")
104 setType(BL::Job::PYTHON_SALOME);
115 BL::Job::setDumpYACSState(const int & dump_yacs_state)
117 _dump_yacs_state = dump_yacs_state;
121 BL::Job::getDumpYACSState()
123 return _dump_yacs_state;
127 BL::Job::setJobFile(const std::string & job_file)
129 _job_file = job_file;
133 BL::Job::getJobFile()
139 BL::Job::setEnvFile(const std::string & env_file)
141 _env_file = env_file;
145 BL::Job::getEnvFile()
151 BL::Job::setBatchParameters(BL::Job::BatchParam & param)
153 _batch_params.batch_directory = param.batch_directory;
154 _batch_params.maximum_duration = param.maximum_duration;
155 _batch_params.expected_memory = param.expected_memory;
156 _batch_params.nb_proc = param.nb_proc;
158 // Parameters for COORM
159 _batch_params.launcher_file = param.launcher_file;
160 _batch_params.launcher_args = param.launcher_args;
163 BL::Job::BatchParam &
164 BL::Job::getBatchParameters()
166 return _batch_params;
170 BL::Job::setFilesParameters(BL::Job::FilesParam & param)
172 _files_params.result_directory = param.result_directory;
173 _files_params.input_files_list = param.input_files_list;
174 _files_params.output_files_list = param.output_files_list;
177 BL::Job::FilesParam &
178 BL::Job::getFilesParameters()
180 return _files_params;
184 BL::Job::setResource(const std::string & resource)
186 _resource_choosed = resource;
190 BL::Job::getResource()
192 return _resource_choosed;
196 BL::Job::setBatchQueue(const std::string & queue)
198 _batch_queue = queue;
202 BL::Job::getBatchQueue()
208 BL::Job::setLoadLevelerJobType(const std::string & jobtype)
210 _ll_jobtype = jobtype;
214 BL::Job::getLoadLevelerJobType()
220 BL::Job::setState(BL::Job::State state)
232 BL::Job::setStringState(const std::string & state)
234 std::string result("");
236 // Check if state is an error
237 if (state != "CREATED" &&
238 state != "IN_PROCESS" &&
240 state != "RUNNING" &&
242 state != "FINISHED" &&
244 state != "NOT_CREATED" &&
248 DEBTRACE("Error state in setStringState");
249 result = "RefreshError";
254 if (state == "CREATED")
256 if (_state != BL::Job::CREATED)
258 setState(BL::Job::CREATED);
262 else if (state == "NOT_CREATED")
264 if (_state != BL::Job::NOT_CREATED)
266 setState(BL::Job::NOT_CREATED);
270 else if (state == "QUEUED")
272 if (_state != BL::Job::QUEUED)
274 setState(BL::Job::QUEUED);
278 else if (state == "IN_PROCESS")
280 if (_state != BL::Job::IN_PROCESS)
282 setState(BL::Job::IN_PROCESS);
286 else if (state == "RUNNING")
288 if (_state != BL::Job::RUNNING)
290 setState(BL::Job::RUNNING);
294 else if (state == "PAUSED")
296 if (_state != BL::Job::PAUSED)
298 setState(BL::Job::PAUSED);
302 else if (state == "FINISHED")
304 if (_state != BL::Job::FINISHED)
306 setState(BL::Job::FINISHED);
310 else if (state == "ERROR")
312 if (_state != BL::Job::ERROR)
314 setState(BL::Job::ERROR);
318 else if (state == "FAILED")
320 if (_state != BL::Job::FAILED)
322 setState(BL::Job::FAILED);
331 BL::Job::setThreadState(BL::Job::ThreadState state)
333 _thread_state = state;
337 BL::Job::getThreadState()
339 return _thread_state;
343 BL::Job::setSalomeLauncherId(int id)
345 _salome_launcher_id = id;
349 BL::Job::getSalomeLauncherId()
351 return _salome_launcher_id;