]> SALOME platform Git repositories - modules/kernel.git/blob - src/Launcher/Launcher_Job.hxx
Salome HOME
be0284932e3bd32448a3515438a5f7adf224d13b
[modules/kernel.git] / src / Launcher / Launcher_Job.hxx
1 //  Copyright (C) 2009-2010  CEA/DEN, EDF R&D
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.
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 <iostream>
35 #include <sstream>
36 #include <algorithm>
37 #include <exception>
38
39 #ifdef WITH_LIBBATCH
40 #include <Batch/Batch_Job.hxx>
41 #include <Batch/Batch_Date.hxx>
42 #include <Batch/Batch_JobId.hxx>
43 #include <Batch/Batch_EmulationException.hxx>
44 #endif
45
46 #include <libxml/parser.h>
47
48 namespace Launcher
49 {
50   class LAUNCHER_EXPORT Job
51   {
52     public:
53       Job();
54       virtual ~Job();
55
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
61       void setNumber(const int & number);
62       int getNumber();
63
64       virtual void setResourceDefinition(const ParserResourcesType & resource_definition);
65       ParserResourcesType getResourceDefinition();
66
67       // Common parameters
68       void setJobName(const std::string & job_name);
69       virtual void setJobFile(const std::string & job_file);
70       void setWorkDirectory(const std::string & work_directory);
71       void setLocalDirectory(const std::string & local_directory);
72       void setResultDirectory(const std::string & result_directory);
73       void add_in_file(const std::string & file);
74       void add_out_file(const std::string & file);
75       void setMaximumDuration(const std::string & maximum_duration);
76       void setResourceRequiredParams(const resourceParams & resource_required_params);
77       void setQueue(const std::string & queue);
78       void setEnvFile(const std::string & env_file);
79
80       std::string getJobName();
81       std::string getJobFile();
82       std::string getWorkDirectory();
83       std::string getLocalDirectory();
84       std::string getResultDirectory();
85       const std::list<std::string> & get_in_files();
86       const std::list<std::string> & get_out_files();
87       std::string getMaximumDuration();
88       resourceParams getResourceRequiredParams();
89       std::string getQueue();
90       std::string getEnvFile();
91       std::string getJobType();
92
93       std::string updateJobState();
94
95       // Checks
96       void checkMaximumDuration(const std::string & maximum_duration);
97       void checkResourceRequiredParams(const resourceParams & resource_required_params);
98
99       // Helps
100       long convertMaximumDuration(const std::string & maximum_duration);
101       std::string getLaunchDate();
102
103       // Xml method
104       void addToXmlDocument(xmlNodePtr root_node);
105
106       // Abstract class
107       virtual void update_job() = 0;
108
109     protected:
110       int _number;
111
112       std::string _job_type;
113
114       std::string _state;
115       std::string _launch_date;
116       std::string _env_file;
117
118       ParserResourcesType _resource_definition;
119
120       std::string _job_name;
121       std::string _job_file;
122       std::string _job_file_name;
123       std::string _job_file_name_complete;
124
125       std::string _work_directory;
126       std::string _local_directory;
127       std::string _result_directory;
128       std::list<std::string> _in_files;
129       std::list<std::string> _out_files;
130       std::string _maximum_duration;
131       long _maximum_duration_in_second;
132       resourceParams _resource_required_params;
133       std::string _queue;
134
135 #ifdef WITH_LIBBATCH
136     // Connection with LIBBATCH
137     public:      
138       Batch::Job * getBatchJob();
139       Batch::Parametre common_job_params();
140       void setBatchManagerJobId(Batch::JobId batch_manager_job_id);
141       Batch::JobId getBatchManagerJobId();
142
143     protected:
144       Batch::Job * _batch_job;
145       Batch::JobId _batch_job_id;
146 #endif
147   };
148 }
149
150 #endif
151