3
/*___INFO__MARK_BEGIN__*/
4
/*************************************************************************
6
* The Contents of this file are made available subject to the terms of
7
* the Sun Industry Standards Source License Version 1.2
9
* Sun Microsystems Inc., March, 2001
12
* Sun Industry Standards Source License Version 1.2
13
* =================================================
14
* The contents of this file are subject to the Sun Industry Standards
15
* Source License Version 1.2 (the "License"); You may not use this file
16
* except in compliance with the License. You may obtain a copy of the
17
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
19
* Software provided under this License is provided on an "AS IS" basis,
20
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
21
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
22
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
23
* See the License for the specific provisions governing your rights and
24
* obligations concerning the Software.
26
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
28
* Copyright: 2001 by Sun Microsystems, Inc.
30
* All Rights Reserved.
32
************************************************************************/
33
/*___INFO__MARK_END__*/
35
#include "sge_htable.h"
36
#include "sge_dstring.h"
38
#include "sge_job_refL.h"
39
#include "sge_messageL.h"
41
/****** sgeobj/job/jb_now *****************************************************
43
* jb_now -- macros to handle flag JB_type
54
* When a job of this type fails and the error condition usually
55
* would result in the job error state the job is finished. Thus
56
* no qmod -c "*" is supported.
57
*******************************************************************************/
59
#define JOB_TYPE_IMMEDIATE 0x01L
60
#define JOB_TYPE_QSH 0x02L
61
#define JOB_TYPE_QLOGIN 0x04L
62
#define JOB_TYPE_QRSH 0x08L
63
#define JOB_TYPE_QRLOGIN 0x10L
64
#define JOB_TYPE_NO_ERROR 0x20L
66
/* submitted via "qsub -b y" or "qrsh [-b y]" */
67
#define JOB_TYPE_BINARY 0x40L
69
/* array job (qsub -t ...) */
70
#define JOB_TYPE_ARRAY 0x80L
71
/* Do a raw exec (qsub -noshell) */
72
#define JOB_TYPE_NO_SHELL 0x100L
74
#define JOB_TYPE_QXXX_MASK \
75
(JOB_TYPE_QSH | JOB_TYPE_QLOGIN | JOB_TYPE_QRSH | JOB_TYPE_QRLOGIN | JOB_TYPE_NO_ERROR)
77
#define JOB_TYPE_STR_IMMEDIATE "IMMEDIATE"
78
#define JOB_TYPE_STR_QSH "INTERACTIVE"
79
#define JOB_TYPE_STR_QLOGIN "QLOGIN"
80
#define JOB_TYPE_STR_QRSH "QRSH"
81
#define JOB_TYPE_STR_QRLOGIN "QRLOGIN"
82
#define JOB_TYPE_STR_NO_ERROR "NO_ERROR"
84
#define JOB_TYPE_CLEAR_IMMEDIATE(jb_now) \
85
jb_now = jb_now & ~JOB_TYPE_IMMEDIATE
87
#define JOB_TYPE_SET_IMMEDIATE(jb_now) \
88
jb_now = jb_now | JOB_TYPE_IMMEDIATE
90
#define JOB_TYPE_SET_QSH(jb_now) \
91
jb_now = (jb_now & (~JOB_TYPE_QXXX_MASK)) | JOB_TYPE_QSH
93
#define JOB_TYPE_SET_QLOGIN(jb_now) \
94
jb_now = (jb_now & (~JOB_TYPE_QXXX_MASK)) | JOB_TYPE_QLOGIN
96
#define JOB_TYPE_SET_QRSH(jb_now) \
97
jb_now = (jb_now & ~JOB_TYPE_QXXX_MASK) | JOB_TYPE_QRSH
99
#define JOB_TYPE_SET_QRLOGIN(jb_now) \
100
jb_now = (jb_now & ~JOB_TYPE_QXXX_MASK) | JOB_TYPE_QRLOGIN
102
#define JOB_TYPE_SET_BINARY(jb_now) \
103
jb_now = jb_now | JOB_TYPE_BINARY
105
#define JOB_TYPE_SET_ARRAY(jb_now) \
106
jb_now = jb_now | JOB_TYPE_ARRAY
108
#define JOB_TYPE_CLEAR_NO_ERROR(jb_now) \
109
jb_now = jb_now & ~JOB_TYPE_NO_ERROR
111
#define JOB_TYPE_SET_NO_ERROR(jb_now) \
112
jb_now = jb_now | JOB_TYPE_NO_ERROR
114
#define JOB_TYPE_SET_NO_SHELL(jb_now) \
115
jb_now = jb_now | JOB_TYPE_NO_SHELL
117
#define JOB_TYPE_UNSET_BINARY(jb_now) \
118
jb_now = jb_now & ~JOB_TYPE_BINARY
120
#define JOB_TYPE_UNSET_NO_SHELL(jb_now) \
121
jb_now = jb_now & ~JOB_TYPE_NO_SHELL
123
#define JOB_TYPE_IS_IMMEDIATE(jb_now) (jb_now & JOB_TYPE_IMMEDIATE)
124
#define JOB_TYPE_IS_QSH(jb_now) (jb_now & JOB_TYPE_QSH)
125
#define JOB_TYPE_IS_QLOGIN(jb_now) (jb_now & JOB_TYPE_QLOGIN)
126
#define JOB_TYPE_IS_QRSH(jb_now) (jb_now & JOB_TYPE_QRSH)
127
#define JOB_TYPE_IS_QRLOGIN(jb_now) (jb_now & JOB_TYPE_QRLOGIN)
128
#define JOB_TYPE_IS_BINARY(jb_now) (jb_now & JOB_TYPE_BINARY)
129
#define JOB_TYPE_IS_ARRAY(jb_now) (jb_now & JOB_TYPE_ARRAY)
130
#define JOB_TYPE_IS_NO_ERROR(jb_now) (jb_now & JOB_TYPE_NO_ERROR)
131
#define JOB_TYPE_IS_NO_SHELL(jb_now) (jb_now & JOB_TYPE_NO_SHELL)
134
bool job_is_enrolled(const lListElem *job,
135
u_long32 ja_task_number);
137
u_long32 job_get_ja_tasks(const lListElem *job);
139
u_long32 job_get_not_enrolled_ja_tasks(const lListElem *job);
141
u_long32 job_get_enrolled_ja_tasks(const lListElem *job);
143
u_long32 job_get_submit_ja_tasks(const lListElem *job);
145
lListElem *job_enroll(lListElem *job, lList **answer_list,
146
u_long32 task_number);
148
void job_delete_not_enrolled_ja_task(lListElem *job, lList **answer_list,
149
u_long32 ja_task_number);
151
int job_count_pending_tasks(lListElem *job, bool count_all);
153
bool job_has_soft_requests(lListElem *job);
155
bool job_is_ja_task_defined(const lListElem *job, u_long32 ja_task_number);
157
void job_set_hold_state(lListElem *job,
158
lList **answer_list, u_long32 ja_task_id,
159
u_long32 new_hold_state);
161
u_long32 job_get_hold_state(lListElem *job, u_long32 ja_task_id);
163
/* int job_add_job(lList **job_list, char *name, lListElem *job, int check,
164
int hash, htable* Job_Hash_Table); */
166
void job_list_print(lList *job_list);
168
lListElem *job_get_ja_task_template(const lListElem *job, u_long32 ja_task_id);
170
lListElem *job_get_ja_task_template_hold(const lListElem *job,
172
u_long32 hold_state);
174
lListElem *job_get_ja_task_template_pending(const lListElem *job,
175
u_long32 ja_task_id);
177
lListElem *job_search_task(const lListElem *job, lList **answer_list, u_long32 ja_task_id);
178
lListElem *job_create_task(lListElem *job, lList **answer_list, u_long32 ja_task_id);
180
void job_add_as_zombie(lListElem *zombie, lList **answer_list,
181
u_long32 ja_task_id);
183
int job_list_add_job(lList **job_list, const char *name, lListElem *job,
186
u_long32 job_get_ja_task_hold_state(const lListElem *job, u_long32 ja_task_id);
188
void job_destroy_hold_id_lists(const lListElem *job, lList *id_list[16]);
190
void job_create_hold_id_lists(const lListElem *job, lList *id_list[16],
191
u_long32 hold_state[16]);
193
bool job_is_zombie_job(const lListElem *job);
195
const char *job_get_shell_start_mode(const lListElem *job,
196
const lListElem *queue,
197
const char *conf_shell_start_mode);
199
bool job_is_array(const lListElem *job);
201
bool job_is_parallel(const lListElem *job);
203
bool job_is_tight_parallel(const lListElem *job, const lList *pe_list);
205
bool job_might_be_tight_parallel(const lListElem *job, const lList *pe_list);
207
void job_get_submit_task_ids(const lListElem *job, u_long32 *start,
208
u_long32 *end, u_long32 *step);
210
int job_set_submit_task_ids(lListElem *job, u_long32 start, u_long32 end,
213
u_long32 job_get_smallest_unenrolled_task_id(const lListElem *job);
215
u_long32 job_get_smallest_enrolled_task_id(const lListElem *job);
217
u_long32 job_get_biggest_unenrolled_task_id(const lListElem *job);
219
u_long32 job_get_biggest_enrolled_task_id(const lListElem *job);
221
int job_list_register_new_job(const lList *job_list, u_long32 max_jobs,
222
int force_registration);
224
void jatask_list_print_to_string(const lList *task_list, dstring *range_string);
226
lList* ja_task_list_split_group(lList **task_list);
228
int job_initialize_id_lists(lListElem *job, lList **answer_list);
230
void job_initialize_env(lListElem *job,
232
const lList* path_alias_list,
233
const char *unqualified_hostname,
234
const char *qualified_hostname);
236
const char* job_get_env_string(const lListElem *job, const char *variable);
238
void job_set_env_string(lListElem *job, const char *variable,
241
void job_check_correct_id_sublists(lListElem *job, lList **answer_list);
243
const char *job_get_id_string(u_long32 job_id, u_long32 ja_task_id,
244
const char *pe_task_id, dstring *buffer);
246
const char *job_get_job_key(u_long32 job_id, dstring *buffer);
248
const char *job_get_key(u_long32 job_id, u_long32 ja_task_id,
249
const char *pe_task_id, dstring *buffer);
251
const char *jobscript_get_key(lListElem *jep, dstring *buffer);
253
char *jobscript_parse_key(char *key,const char **exec_file);
255
bool job_parse_key(char *key, u_long32 *job_id, u_long32 *ja_task_id,
256
char **pe_task_id, bool *only_job);
258
bool job_is_pe_referenced(const lListElem *job, const lListElem *pe);
260
bool job_is_ckpt_referenced(const lListElem *job, const lListElem *ckpt);
262
void job_get_state_string(char *str, u_long32 op);
264
lListElem *job_list_locate(lList *job_list, u_long32 job_id);
266
void job_add_parent_id_to_context(lListElem *job);
268
int job_check_qsh_display(const lListElem *job,
270
bool output_warning);
272
int job_check_owner(const char *user_name, u_long32 job_id, lList *master_job_list);
274
int job_resolve_host_for_path_list(const lListElem *job, lList **answer_list, int name);
277
job_get_request(const lListElem *this_elem, const char *centry_name);
280
job_get_contribution(const lListElem *this_elem, lList **answer_list,
281
const char *name, double *value,
282
const lListElem *implicit_centry);
284
/* unparse functions */
285
bool sge_unparse_string_option_dstring(dstring *category_str, const lListElem *job_elem,
286
int nm, char *option);
288
bool sge_unparse_ulong_option_dstring(dstring *category_str, const lListElem *job_elem,
289
int nm, char *option);
291
bool sge_unparse_pe_dstring(dstring *category_str, const lListElem *job_elem, int pe_pos, int range_pos,
294
bool sge_unparse_resource_list_dstring(dstring *category_str, lListElem *job_elem,
295
int nm, const char *option);
297
bool sge_unparse_queue_list_dstring(dstring *category_str, lListElem *job_elem,
298
int nm, const char *option);
300
bool sge_unparse_acl_dstring(dstring *category_str, const char *owner, const char *group,
301
const lList *acl_list, const char *option);
303
bool job_verify(const lListElem *job, lList **answer_list);
304
bool job_verify_submitted_job(const lListElem *job, lList **answer_list);
305
bool job_verify_execd_job(const lListElem *job, lList **answer_list);
307
bool job_get_wallclock_limit(u_long32 *limit, const lListElem *jep);
309
#endif /* __SGE_JOB_H */