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

« back to all changes in this revision

Viewing changes to source/daemons/execd/execd_ticket.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
 
 
35
 
 
36
#include "dispatcher.h"
 
37
#include "execd_ticket.h"
 
38
#include "sge_log.h"
 
39
#include "msg_execd.h"
 
40
#include "sge_feature.h"
 
41
#include "sgeobj/sge_job.h"
 
42
#include "sgeobj/sge_pe.h"
 
43
#include "sgeobj/sge_ja_task.h"
 
44
 
 
45
#ifdef COMPILE_DC
 
46
#  include "ptf.h"
 
47
#endif
 
48
 
 
49
/*************************************************************************
 
50
 EXECD function called by dispatcher
 
51
 
 
52
 get a list of jobid/tickets tuples and pass them to the PTF
 
53
 *************************************************************************/
 
54
 
 
55
int do_ticket(sge_gdi_ctx_class_t *ctx, struct_msg_t *aMsg)
 
56
{
 
57
   u_long32 jobid, jataskid;
 
58
   double ticket;
 
59
   lListElem *job_ticket, *task_ticket;
 
60
   lList *ticket_modifier = NULL;
 
61
 
 
62
   DENTER(TOP_LAYER, "do_ticket");
 
63
 
 
64
   while (pb_unused(&(aMsg->buf))>0) {
 
65
      lList *jatasks = NULL;
 
66
 
 
67
      if (unpackint(&(aMsg->buf), &jobid) || unpackint(&(aMsg->buf), &jataskid)
 
68
          || unpackdouble(&(aMsg->buf), &ticket)) {
 
69
         ERROR((SGE_EVENT, MSG_JOB_TICKETFORMAT));
 
70
         DRETURN(0);
 
71
      }
 
72
      DPRINTF(("got %lf new tickets for job "sge_u32"."sge_u32"\n", ticket, jobid, jataskid));
 
73
      job_ticket = lAddElemUlong(&ticket_modifier, JB_job_number, jobid, JB_Type);   
 
74
      if (job_ticket) {
 
75
         task_ticket = lAddElemUlong(&jatasks, JAT_task_number, jataskid, JAT_Type);
 
76
         if (task_ticket) {
 
77
            lSetDouble(task_ticket, JAT_tix, ticket);
 
78
         }
 
79
         lSetList(job_ticket, JB_ja_tasks, jatasks);
 
80
      }
 
81
   }
 
82
  
 
83
   DPRINTF(("got new tickets for %d jobs\n", lGetNumberOfElem(ticket_modifier)));
 
84
 
 
85
#ifdef COMPILE_DC
 
86
   { 
 
87
      int ptf_error;
 
88
      /* forward new tickets to ptf */
 
89
      if ((ptf_error=ptf_process_job_ticket_list(ticket_modifier))) {
 
90
         ERROR((SGE_EVENT, MSG_JOB_TICKETPASS2PTF_IS, 
 
91
            lGetNumberOfElem(ticket_modifier), 
 
92
            ptf_errstr(ptf_error)));
 
93
      }
 
94
 
 
95
      sge_switch2start_user();
 
96
      DPRINTF(("ADJUST PRIORITIES\n"));
 
97
      ptf_adjust_job_priorities();
 
98
      sge_switch2admin_user();
 
99
   }
 
100
#endif
 
101
 
 
102
   lFreeList(&ticket_modifier);
 
103
 
 
104
   DRETURN(0);
 
105
}
 
106
 
 
107