]> SALOME platform Git repositories - modules/kernel.git/blob - src/Launcher/Launcher_Job.hxx
Salome HOME
Merge from V5_1_main 14/05/2010
[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 <SALOMEconfig.h>
26 #include "Launcher_Utils.hxx"
27 #include "ResourcesManager.hxx"
28
29 #include <stdlib.h>
30 #include <time.h>
31 #include <sys/stat.h>
32
33 #include <string>
34 #include <list>
35 #include <iostream>
36 #include <sstream>
37 #include <algorithm>
38 #include <exception>
39
40 #ifdef WITH_LIBBATCH
41 #include <Batch/Batch_Job.hxx>
42 #include <Batch/Batch_Date.hxx>
43 #include <Batch/Batch_JobId.hxx>
44 #include <Batch/Batch_EmulationException.hxx>
45 #endif
46
47 namespace Launcher
48 {
49   class LAUNCHER_EXPORT Job
50   {
51     public:
52       Job();
53       virtual ~Job();
54
55       // Launcher managing parameters
56       // State of a Job: CREATED, IN_PROCESS, QUEUED, RUNNING, PAUSED, FINISHED, ERROR
57       void setState(const std::string & state);
58       std::string getState();
59
60       void setNumber(const int & number);
61       int getNumber();
62
63       virtual void setResourceDefinition(const ParserResourcesType & resource_definition);
64       ParserResourcesType getResourceDefinition();
65       
66       // Common parameters
67       virtual void setJobFile(const std::string & job_file);
68       void setWorkDirectory(const std::string & work_directory);
69       void setLocalDirectory(const std::string & local_directory);
70       void setResultDirectory(const std::string & result_directory);
71       void add_in_file(const std::string & file);
72       void add_out_file(const std::string & file);
73       void setMaximumDuration(const std::string & maximum_duration);
74       void setResourceRequiredParams(const resourceParams & resource_required_params);
75       void setQueue(const std::string & queue);
76       void setEnvFile(const std::string & env_file);
77
78       std::string getJobFile();
79       std::string getWorkDirectory();
80       std::string getLocalDirectory();
81       std::string getResultDirectory();
82       const std::list<std::string> & get_in_files();
83       const std::list<std::string> & get_out_files();
84       std::string getMaximumDuration();
85       resourceParams getResourceRequiredParams();
86       std::string getQueue();
87       std::string getEnvFile();
88       
89       std::string updateJobState();
90
91       // Checks
92       void checkMaximumDuration(const std::string & maximum_duration);
93       void checkResourceRequiredParams(const resourceParams & resource_required_params);
94
95       // Helps
96       long convertMaximumDuration(const std::string & maximum_duration);
97       std::string getLaunchDate();
98
99       // Abstract class
100       virtual void update_job() = 0;
101
102     protected:
103       int _number;
104
105       std::string _state;
106       std::string _launch_date;
107       std::string _env_file;
108
109       ParserResourcesType _resource_definition;
110
111       std::string _job_file;
112       std::string _job_file_name;
113       std::string _job_file_name_complete;
114
115       std::string _work_directory;
116       std::string _local_directory;
117       std::string _result_directory;
118       std::list<std::string> _in_files;
119       std::list<std::string> _out_files;
120       std::string _maximum_duration;
121       long _maximum_duration_in_second;
122       resourceParams _resource_required_params;
123       std::string _queue;
124
125 #ifdef WITH_LIBBATCH
126     // Connection with LIBBATCH
127     public:      
128       Batch::Job * getBatchJob();
129       Batch::Parametre common_job_params();
130       void setBatchManagerJobId(Batch::JobId batch_manager_job_id);
131       Batch::JobId getBatchManagerJobId();
132
133     protected:
134       Batch::Job * _batch_job;
135       Batch::JobId _batch_job_id;
136 #endif
137   };
138 }
139
140 #endif
141