File: execd_get_new_conf.c

package info (click to toggle)
gridengine 8.1.9%2Bdfsg-13.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 57,140 kB
  • sloc: ansic: 432,689; java: 87,068; cpp: 31,958; sh: 29,445; jsp: 7,757; perl: 6,336; xml: 5,828; makefile: 4,704; csh: 3,934; ruby: 2,221; tcl: 1,676; lisp: 669; yacc: 519; python: 503; lex: 361; javascript: 200
file content (151 lines) | stat: -rw-r--r-- 5,131 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*___INFO__MARK_BEGIN__*/
/*************************************************************************
 * 
 *  The Contents of this file are made available subject to the terms of
 *  the Sun Industry Standards Source License Version 1.2
 * 
 *  Sun Microsystems Inc., March, 2001
 * 
 * 
 *  Sun Industry Standards Source License Version 1.2
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.2 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 * 
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 * 
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 * 
 *   Copyright: 2001 by Sun Microsystems, Inc.
 * 
 *   All Rights Reserved.
 * 
 ************************************************************************/
/*___INFO__MARK_END__*/

#include <string.h>
#include <errno.h>

#include "uti/sge_rmon.h"
#include "uti/sge_string.h"
#include "uti/sge_log.h"

#include "sgeobj/sge_conf.h"
#include "sgeobj/sge_object.h"
#include "sgeobj/sge_qinstance.h"
#include "sgeobj/sge_pe_task.h"
#include "sgeobj/sge_job.h"
#include "sgeobj/sge_ja_task.h"
#include "exec_job.h"

#include "dispatcher.h"
#include "execd_get_new_conf.h"
#include "sge_load_sensor.h"
#include "admin_mail.h"
#include "load_avg.h"
#include "msg_common.h"

#ifdef COMPILE_DC
#  include "ptf.h"
#endif

/*
** DESCRIPTION
**   retrieves new configuration from qmaster, very similar to what is
**   executed on startup. This function is triggered by the execd
**   dispatcher table when the tag TAG_GET_NEW_CONF is received.
*/
int do_get_new_conf(sge_gdi_ctx_class_t *ctx, struct_msg_t *aMsg)
{
   int ret;
   bool use_qidle = mconf_get_use_qidle();
   u_long32 dummy; /* always 0 */ 
   char* old_spool = NULL;
   char* spool_dir = NULL;
   int old_reprioritization_enabled = mconf_get_reprioritize(); 

   DENTER(TOP_LAYER, "do_get_new_conf");

   unpackint(&(aMsg->buf), &dummy);

   old_spool = mconf_get_execd_spool_dir();  

   ret = gdi2_get_merged_configuration(ctx, &Execd_Config_List);
  
   spool_dir = mconf_get_execd_spool_dir(); 
   if (strcmp(old_spool, spool_dir)) {
      WARNING((SGE_EVENT, MSG_WARN_CHANGENOTEFFECTEDUNTILRESTARTOFEXECHOSTS, "execd_spool_dir"));
   }

#ifdef COMPILE_DC
   if (old_reprioritization_enabled != mconf_get_reprioritize()) {
      /* Here we will make sure that each job which was started
         in SGEEE-Mode (reprioritization) will get its initial
         queue priority if this execd alternates to SGE-Mode */
      lListElem *job, *jatask, *petask;

      errno = 0;
      if (sge_switch2start_user()) {
         CRITICAL((SGE_EVENT, MSG_SWITCH_USER_S, strerror(errno)));
      }

      for_each(job, *(object_type_get_master_list(SGE_TYPE_JOB))) {
         lListElem *master_queue;

         for_each (jatask, lGetList(job, JB_ja_tasks)) {
            int priority;

            master_queue = responsible_queue(jatask, NULL);
            priority = atoi(lGetString(master_queue, QU_priority));

            DPRINTF(("Set priority of job "sge_u32"."sge_u32" running in"
               " queue  %s to %d\n", 
            lGetUlong(job, JB_job_number), 
            lGetUlong(jatask, JAT_task_number),
            lGetString(master_queue, QU_full_name), priority));
            ptf_reinit_queue_priority(lGetUlong(job, JB_job_number),
                                      lGetUlong(jatask, JAT_task_number),
                                      NULL, priority);

            for_each(petask, lGetList(jatask, JAT_task_list)) {
               master_queue = responsible_queue(jatask, petask);
               priority = atoi(lGetString(master_queue, QU_priority));
               DPRINTF(("Set priority of task "sge_u32"."sge_u32"-%s running "
                        "in queue %s to %d\n", 
               lGetUlong(job, JB_job_number), 
               lGetUlong(jatask, JAT_task_number),
               lGetString(petask, PET_id),
               lGetString(master_queue, QU_full_name), priority));
               ptf_reinit_queue_priority(lGetUlong(job, JB_job_number),
                                         lGetUlong(jatask, JAT_task_number),
                                          lGetString(petask, PET_id),
                                          priority);
            }
         }
      }
      sge_switch2admin_user();
   }
#endif

   /*
   ** admin mail block is released on new conf
   */
   adm_mail_reset(BIT_ADM_NEW_CONF);

   sge_ls_qidle(use_qidle);
   DPRINTF(("use_qidle: %d\n", use_qidle));

   sge_free(&old_spool);
   sge_free(&spool_dir);

   DRETURN(ret);
}