1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
10
* Sun Industry Standards Source License Version 1.2
11
* =================================================
12
* The contents of this file are subject to the Sun Industry Standards
13
* Source License Version 1.2 (the "License"); You may not use this file
14
* except in compliance with the License. You may obtain a copy of the
15
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
17
* Software provided under this License is provided on an "AS IS" basis,
18
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21
* See the License for the specific provisions governing your rights and
22
* obligations concerning the Software.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
35
#include "sge_string.h"
38
#include "cull_list.h"
40
#include "sgeobj/sge_object.h"
41
#include "sgeobj/sge_answer.h"
43
#include "sgeobj/sge_job.h"
44
#include "sgeobj/sge_ja_task.h"
45
#include "sgeobj/sge_path_alias.h"
46
#include "sgeobj/sge_pe_task.h"
47
#include "sgeobj/sge_var.h"
48
#include "sgeobj/sge_utility.h"
49
#include "sgeobj/sge_usage.h"
51
#include "msg_common.h"
52
#include "sgeobj/msg_sgeobjlib.h"
54
/****** sgeobj/pe_task/pe_task_sum_past_usage() *******************************
56
* pe_task_sum_past_usage() -- sum up pe tasks past usage
59
* lListElem* pe_task_sum_past_usage(lListElem *container,
60
* const lListElem *pe_task)
63
* The pe task list of a ja task can contain one container
64
* element to hold the usage of finished pe tasks no longer
65
* stored in the task list.
67
* This function adds the usage of pe_task to the usage of container.
70
* lListElem *container - container object to hold past usage
71
* const lListElem *pe_task - the pe task from which to copy usage
74
* lListElem* - the container object
77
* sgeobj/pe_task/pe_task_sum_past_usage_all()
78
* sgeobj/pe_task/pe_task_sum_past_usage_list()
79
*******************************************************************************/
81
pe_task_sum_past_usage(lListElem *container, const lListElem *pe_task)
83
lList *container_usage;
84
const lList *pe_task_usage;
85
lList *container_reported_usage;
86
const lList *pe_task_reported_usage;
88
DENTER(TOP_LAYER, "pe_task_sum_past_usage");
90
/* invalid input - nothing to do */
91
if (container == NULL || pe_task == NULL) {
95
if (container == pe_task) {
96
/* container and pe_task are the same element - nothing to do */
100
/* we sum up the scaled_usage */
101
container_usage = lGetOrCreateList(container, PET_scaled_usage, "reported_usage", UA_Type);
102
pe_task_usage = lGetList(pe_task, PET_scaled_usage);
103
if (pe_task_usage != NULL) {
104
usage_list_sum(container_usage, pe_task_usage);
108
* and we sum up the already reported usage
109
* (for long running jobs having intermediate usage records)
111
container_reported_usage = lGetOrCreateList(container, PET_reported_usage, "reported_usage", UA_Type);
112
pe_task_reported_usage = lGetList(pe_task, PET_reported_usage);
113
if (pe_task_reported_usage != NULL) {
114
usage_list_sum(container_reported_usage, pe_task_reported_usage);
120
/****** sgeobj/pe_task/pe_task_sum_past_usage_all() ***************************
122
* pe_task_sum_past_usage_all() -- sum up all pe tasks past usage
125
* lListElem* pe_task_sum_past_usage_all(lList *pe_task_list)
128
* Similar to pe_task_sum_past_usage, but will sum up the usage of
129
* all pe tasks in a task list to the container object in this list.
131
* If the container object does not yet exist, it will be created.
134
* lList *pe_task_list - the pe task list to process
137
* lListElem* - the container object
140
* sgeobj/pe_task/pe_task_sum_past_usage()
141
* sgeobj/pe_task/pe_task_sum_past_usage_list()
142
*******************************************************************************/
143
lListElem *pe_task_sum_past_usage_all(lList *pe_task_list)
145
lListElem *container = NULL;
146
const lListElem *pe_task;
148
DENTER(TOP_LAYER, "pe_task_sum_past_usage_all");
150
/* no pe task list - nothing to do */
151
if (pe_task_list == NULL) {
155
/* loop over all pe tasks and sum up usage */
156
for_each(pe_task, pe_task_list) {
157
if (container == NULL) {
158
container = pe_task_sum_past_usage_list(pe_task_list, pe_task);
160
pe_task_sum_past_usage(container, pe_task);
167
/****** sgeobj/pe_task/pe_task_sum_past_usage_list() **************************
169
* pe_task_sum_past_usage_list() -- sum up pe tasks past usage
173
* pe_task_sum_past_usage_list(lList *pe_task_list,
174
* const lListElem *pe_task)
177
* Similar to pe_task_sum_past_usage.
178
* The container is retrieved from pe_task_list, if it does not
179
* yet exist it is created and inserted into pe_task_list as
183
* lList *pe_task_list - list containing the container object
184
* const lListElem *pe_task - the pe task from which to copy usage
187
* lListElem* - the container object
190
* sgeobj/pe_task/pe_task_sum_past_usage()
191
* sgeobj/pe_task/pe_task_sum_past_usage_all()
192
******************************************************************************/
194
pe_task_sum_past_usage_list(lList *pe_task_list, const lListElem *pe_task)
196
lListElem *container;
198
DENTER(TOP_LAYER, "pe_task_sum_past_usage_list");
200
/* no pe task list - nothing to do */
201
if (pe_task_list == NULL) {
205
/* get container - if it does not yet exist, create it as first element in pe task list */
206
container = lGetElemStr(pe_task_list, PET_id, PE_TASK_PAST_USAGE_CONTAINER);
207
if (container == NULL) {
208
container = lCreateElem(PET_Type);
209
lSetString(container, PET_id, PE_TASK_PAST_USAGE_CONTAINER);
210
lInsertElem(pe_task_list, NULL, container);
214
pe_task_sum_past_usage(container, pe_task);
219
/****** sge_pe_task/pe_task_verify_request() ***********************************
221
* pe_task_verify_request() -- verify a pe task request object
225
* pe_task_verify_request(const lListElem *petr, lList **answer_list)
228
* Verifies structure and contents of a pe task request.
229
* A pe task request is sent to sge_execd by qrsh -inherit.
232
* const lListElem *petr - the object to verify
233
* lList **answer_list - answer list to pass back error messages
236
* bool - true on success,
237
* false on error with error message in answer_list
240
* MT-NOTE: pe_task_verify_request() is MT safe
243
* The function is far from being complete.
244
* Currently, only the CULL structure is verified, not the contents.
247
* sge_object/object_verify_cull()
248
*******************************************************************************/
250
pe_task_verify_request(const lListElem *petr, lList **answer_list) {
253
DENTER(TOP_LAYER, "pe_task_verify_request");
256
answer_list_add_sprintf(answer_list, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR,
257
MSG_NULLELEMENTPASSEDTO_S, SGE_FUNC);
262
if (!object_verify_cull(petr, PETR_Type)) {
263
answer_list_add_sprintf(answer_list, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR,
264
MSG_OBJECT_STRUCTURE_ERROR);
270
* A pe task request entering execd must have some additional properties:
272
* - PETR_jataskid > 0
273
* - PETR_owner != NULL
274
* - verify PETR_queuename, if != NULL
275
* - verify PETR_cwd, if it is != NULL
276
* - verify PETR_path_aliases, if they are != NULL
277
* - verify PETR_environment, if it is != NULL
278
* - PETR_submission_time (currently unused)
282
ret = object_verify_ulong_not_null(petr, answer_list, PETR_jobid);
286
ret = object_verify_ulong_not_null(petr, answer_list, PETR_jataskid);
290
ret = object_verify_string_not_null(petr, answer_list, PETR_owner);
294
const char *queue_name = lGetString(petr, PETR_queuename);
296
if (queue_name != NULL) {
298
answer_list, queue_name, MAX_VERIFY_STRING,
299
lNm2Str(PETR_queuename), KEY_TABLE) != STATUS_OK) {
306
const char *cwd = lGetString(petr, PETR_cwd);
309
ret = path_verify(cwd, answer_list, "cwd", true);
314
const lList *path_aliases = lGetList(petr, PETR_path_aliases);
316
if (path_aliases != NULL) {
317
ret = path_alias_verify(path_aliases, answer_list);
322
const lList *env_list = lGetList(petr, PETR_environment);
324
if (env_list != NULL) {
325
ret = var_list_verify(env_list, answer_list);