~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/libs/sgeobj/sge_report.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*___INFO__MARK_BEGIN__*/
 
2
/*************************************************************************
 
3
 * 
 
4
 *  The Contents of this file are made available subject to the terms of
 
5
 *  the Sun Industry Standards Source License Version 1.2
 
6
 * 
 
7
 *  Sun Microsystems Inc., March, 2001
 
8
 * 
 
9
 * 
 
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
 
16
 * 
 
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.
 
23
 * 
 
24
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
25
 * 
 
26
 *   Copyright: 2001 by Sun Microsystems, Inc.
 
27
 * 
 
28
 *   All Rights Reserved.
 
29
 * 
 
30
 ************************************************************************/
 
31
/*___INFO__MARK_END__*/
 
32
 
 
33
#include "sgermon.h"
 
34
#include "sge_log.h"
 
35
#include "sge_usageL.h"
 
36
#include "sge_job.h"
 
37
#include "sge_ja_task.h"
 
38
#include "sge_pe_task.h"
 
39
#include "sge_report.h"
 
40
 
 
41
#include "msg_sgeobjlib.h"
 
42
 
 
43
 
 
44
#if 0
 
45
/****** sgeobj/report/job_report_print_usage() *******************************
 
46
*  NAME
 
47
*     job_report_print_usage() -- Print usage contained in job report 
 
48
*
 
49
*  SYNOPSIS
 
50
*     void job_report_print_usage(const lListElem *job_report, 
 
51
*                                 FILE *fp) 
 
52
*
 
53
*  FUNCTION
 
54
*     Print usage information conatines in "job_report". Print the 
 
55
*     information to the given file stream "fp" or as debug messages. 
 
56
*
 
57
*  INPUTS
 
58
*     const lListElem *job_report - JR_Type element 
 
59
*     FILE *fp                    - file stream or NULL 
 
60
******************************************************************************/
 
61
void job_report_print_usage(const lListElem *job_report, FILE *fp) 
 
62
{
 
63
   lListElem *uep;
 
64
 
 
65
   DENTER(TOP_LAYER, "job_report_print_usage");
 
66
 
 
67
   if (!job_report) {
 
68
      DEXIT;
 
69
      return;
 
70
   }
 
71
 
 
72
   for_each(uep, lGetList(job_report, JR_usage)) {
 
73
      if (fp) {
 
74
         fprintf(fp, "   \"%s\" =   %.99g\n", lGetString(uep, UA_name),
 
75
                 lGetDouble(uep, UA_value));
 
76
      } else {
 
77
         DPRINTF(("   \"%s\" =   %.99g\n", lGetString(uep, UA_name),
 
78
                  lGetDouble(uep, UA_value)));
 
79
      }
 
80
   }
 
81
 
 
82
   DEXIT;
 
83
   return;
 
84
}
 
85
#endif
 
86
 
 
87
/****** sgeobj/report/job_report_init_from_job() *****************************
 
88
*  NAME
 
89
*     job_report_init_from_job() -- initialize job report 
 
90
*
 
91
*  SYNOPSIS
 
92
*     void job_report_init_from_job(lListElem *job_report, 
 
93
*                                   const lListElem *job, 
 
94
*                                   const lListElem *ja_task, 
 
95
*                                   const lListElem *pe_task) 
 
96
*
 
97
*  FUNCTION
 
98
*     Initialize "job_report" from the attributes obtained from
 
99
*     "job", "ja_task" and "pe_task". 
 
100
*
 
101
*  INPUTS
 
102
*     lListElem *job_report    - JR_Type object
 
103
*     const lListElem *job     - JB_Type object
 
104
*     const lListElem *ja_task - JAT_Type object 
 
105
*     const lListElem *pe_task - PET_Type object 
 
106
******************************************************************************/
 
107
void job_report_init_from_job(lListElem *job_report, 
 
108
                              const lListElem *job, 
 
109
                              const lListElem *ja_task, 
 
110
                              const lListElem *pe_task) 
 
111
{
 
112
   u_long32 job_id = lGetUlong(job, JB_job_number);
 
113
   u_long32 ja_task_id = lGetUlong(ja_task, JAT_task_number);
 
114
   lListElem *queue = NULL;   /* QU_Type */
 
115
 
 
116
   DENTER(TOP_LAYER, "job_report_init_from_job");
 
117
 
 
118
   lSetUlong(job_report, JR_job_number, job_id);
 
119
   lSetUlong(job_report, JR_ja_task_number, ja_task_id);
 
120
 
 
121
   if (pe_task != NULL) {
 
122
      lSetString(job_report, JR_pe_task_id_str, lGetString(pe_task, PET_id));
 
123
      queue = lFirst(lGetList(pe_task, PET_granted_destin_identifier_list));
 
124
   } else {
 
125
      queue = lFirst(lGetList(ja_task, JAT_granted_destin_identifier_list));
 
126
   }
 
127
 
 
128
   if (lGetUlong(ja_task, JAT_status) == JSLAVE){
 
129
      if (pe_task == NULL) {
 
130
         lSetUlong(job_report, JR_state, JSLAVE);
 
131
      } else {
 
132
         lSetUlong(job_report, JR_state, JWRITTEN);
 
133
      }
 
134
   } else {
 
135
      lSetUlong(job_report, JR_state, JWRITTEN);
 
136
   }
 
137
 
 
138
   if (queue != NULL) {
 
139
      lSetString(job_report, JR_queue_name, lGetString(queue, JG_qname));
 
140
   }
 
141
 
 
142
   DEXIT;
 
143
}
 
144