1 // Copyright (C) 2009-2013 CEA/DEN, EDF R&D, OPEN CASCADE
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
20 // Author: André RIBES - EDF R&D
22 #ifndef _LAUNCHER_JOB_HXX_
23 #define _LAUNCHER_JOB_HXX_
25 #include "Launcher_Utils.hxx"
26 #include "ResourcesManager.hxx"
41 #include <libbatch/Job.hxx>
42 #include <libbatch/JobId.hxx>
43 #include <libbatch/GenericException.hxx>
46 #include <libxml/parser.h>
50 class LAUNCHER_EXPORT Job
56 // Launcher managing parameters
57 // State of a Job: CREATED, IN_PROCESS, QUEUED, RUNNING, PAUSED, FINISHED, ERROR
58 void setState(const std::string & state);
59 std::string getState();
60 // Get names or ids of hosts assigned to the job
61 std::string getAssignedHostnames();
63 void setNumber(const int & number);
66 virtual void setResourceDefinition(const ParserResourcesType & resource_definition);
67 ParserResourcesType getResourceDefinition();
70 void setJobName(const std::string & job_name);
71 virtual void setJobFile(const std::string & job_file);
72 void setWorkDirectory(const std::string & work_directory);
73 void setLocalDirectory(const std::string & local_directory);
74 void setResultDirectory(const std::string & result_directory);
75 void add_in_file(const std::string & file);
76 void add_out_file(const std::string & file);
77 void setMaximumDuration(const std::string & maximum_duration);
78 void setResourceRequiredParams(const resourceParams & resource_required_params);
79 void setQueue(const std::string & queue);
80 void setEnvFile(const std::string & env_file);
83 void setLauncherFile(const std::string & launcher_file);
84 void setLauncherArgs(const std::string & launcher_args);
86 std::string getJobName();
87 std::string getJobFile();
88 std::string getWorkDirectory();
89 std::string getLocalDirectory();
90 std::string getResultDirectory();
91 const std::list<std::string> & get_in_files();
92 const std::list<std::string> & get_out_files();
93 std::string getMaximumDuration();
94 resourceParams getResourceRequiredParams();
95 std::string getQueue();
96 std::string getEnvFile();
97 std::string getJobType();
100 std::string getLauncherFile();
101 std::string getLauncherArgs();
103 std::string updateJobState();
105 void addSpecificParameter(const std::string & name,
106 const std::string & value);
107 const std::map<std::string, std::string> & getSpecificParameters();
108 virtual void checkSpecificParameters();
111 void checkMaximumDuration(const std::string & maximum_duration);
112 void checkResourceRequiredParams(const resourceParams & resource_required_params);
115 long convertMaximumDuration(const std::string & maximum_duration);
116 std::string getLaunchDate();
119 void addToXmlDocument(xmlNodePtr root_node);
125 virtual void update_job() = 0;
130 std::string _job_type;
133 std::string _assigned_hostnames; // Assigned hostnames
134 std::string _launch_date;
135 std::string _env_file;
137 ParserResourcesType _resource_definition;
139 std::string _job_name;
140 std::string _job_file;
141 std::string _job_file_name;
142 std::string _job_file_name_complete;
144 std::string _work_directory;
145 std::string _local_directory;
146 std::string _result_directory;
147 std::list<std::string> _in_files;
148 std::list<std::string> _out_files;
149 std::map<std::string, std::string> _specific_parameters;
150 std::string _maximum_duration;
151 long _maximum_duration_in_second;
152 resourceParams _resource_required_params;
155 // Parameters for COORM
156 std::string _launcher_file;
157 std::string _launcher_args;
160 // Connection with LIBBATCH
162 Batch::Job * getBatchJob();
163 Batch::Parametre common_job_params();
164 void setBatchManagerJobId(Batch::JobId batch_manager_job_id);
165 Batch::JobId getBatchManagerJobId();
168 Batch::Job * _batch_job;
169 Batch::JobId _batch_job_id;