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

« back to all changes in this revision

Viewing changes to source/daemons/qmaster/sched_conf_qmaster.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
#include <stdio.h>
 
33
#include <stdlib.h>
 
34
#include <string.h>
 
35
#include <errno.h>
 
36
 
 
37
#include "sgermon.h"
 
38
#include "sge_schedd_conf.h"
 
39
#include "sge_usageL.h"
 
40
#include "sge_confL.h"
 
41
#include "sched_conf_qmaster.h"
 
42
#include "sge_event_master.h"
 
43
#include "sge_sched.h"
 
44
#include "sge_log.h"
 
45
#include "setup_path.h"
 
46
#include "sge_answer.h"
 
47
#include "sge_centry.h"
 
48
#include "sge_conf.h"
 
49
#include "configuration_qmaster.h"
 
50
 
 
51
#include "sge_persistence_qmaster.h"
 
52
#include "spool/sge_spooling.h"
 
53
 
 
54
#include "msg_qmaster.h"
 
55
#include "msg_common.h"
 
56
 
 
57
 
 
58
 
 
59
static void check_reprioritize_interval(sge_gdi_ctx_class_t *ctx, lList **alpp, char *ruser, char *rhost);
 
60
 
 
61
 
 
62
int sge_read_sched_configuration(sge_gdi_ctx_class_t *ctx, lListElem *aSpoolContext, lList **anAnswer)
 
63
{
 
64
   lList *sched_conf = NULL;
 
65
   bool job_spooling = ctx->get_job_spooling(ctx);
 
66
 
 
67
   DENTER(TOP_LAYER, "sge_read_sched_configuration");
 
68
 
 
69
   spool_read_list(anAnswer, aSpoolContext, &sched_conf, SGE_TYPE_SCHEDD_CONF);
 
70
 
 
71
   if (lGetNumberOfElem(sched_conf) == 0)
 
72
   {
 
73
      lListElem *ep = sconf_create_default();
 
74
 
 
75
      if (sched_conf == NULL) {
 
76
         sched_conf = lCreateList("schedd_config_list", SC_Type);
 
77
      }
 
78
   
 
79
      lAppendElem(sched_conf, ep);
 
80
      spool_write_object(anAnswer, spool_get_default_context(), ep, "schedd_conf", SGE_TYPE_SCHEDD_CONF, job_spooling);
 
81
   }
 
82
   
 
83
   if (!sconf_set_config(&sched_conf, anAnswer))
 
84
   {
 
85
      lFreeList(&sched_conf);
 
86
      DEXIT;
 
87
      return -1;
 
88
   } 
 
89
 
 
90
   check_reprioritize_interval(ctx, anAnswer, "local" , "local");
 
91
 
 
92
   DEXIT;
 
93
   return 0;
 
94
}
 
95
        
 
96
 
 
97
/************************************************************
 
98
  sge_mod_sched_configuration - Master code
 
99
 
 
100
  Modify scheduler configuration. We have only one entry in
 
101
  Master_Sched_Config_List. So we replace it with the new one.
 
102
 ************************************************************/
 
103
int sge_mod_sched_configuration(
 
104
sge_gdi_ctx_class_t *ctx,
 
105
lListElem *confp,
 
106
lList **alpp,
 
107
char *ruser,
 
108
char *rhost 
 
109
) {
 
110
   lList *temp_conf_list = NULL;
 
111
   
 
112
   DENTER(TOP_LAYER, "sge_mod_sched_configuration");
 
113
 
 
114
   if ( !confp || !ruser || !rhost ) {
 
115
      CRITICAL((SGE_EVENT, MSG_SGETEXT_NULLPTRPASSED_S, SGE_FUNC));
 
116
      answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
 
117
      DEXIT;
 
118
      return STATUS_EUNKNOWN;
 
119
   }
 
120
   temp_conf_list = lCreateList("sched config", SC_Type);
 
121
 
 
122
   lSetUlong(confp, SC_weight_tickets_override, 
 
123
             sconf_get_weight_tickets_override());
 
124
 
 
125
   confp = lCopyElem(confp);
 
126
   lAppendElem(temp_conf_list, confp);
 
127
 
 
128
   /* just check and log */
 
129
   if (!sconf_set_config(&temp_conf_list, alpp)) {
 
130
      lFreeList(&temp_conf_list);
 
131
      DEXIT;
 
132
      return STATUS_EUNKNOWN;
 
133
   }
 
134
 
 
135
   if (!sge_event_spool(ctx,
 
136
                        alpp, 0, sgeE_SCHED_CONF, 
 
137
                        0, 0, "schedd_conf", NULL, NULL,
 
138
                        confp, NULL, NULL, true, true)) {
 
139
      answer_list_add(alpp, MSG_SCHEDCONF_CANTCREATESCHEDULERCONFIGURATION, STATUS_ESEMANTIC, ANSWER_QUALITY_ERROR);
 
140
      DEXIT;
 
141
      return -1;
 
142
   }
 
143
 
 
144
   check_reprioritize_interval(ctx, alpp, ruser, rhost);
 
145
 
 
146
   INFO((SGE_EVENT, MSG_SGETEXT_MODIFIEDINLIST_SSSS, ruser, rhost, "scheduler", "scheduler configuration"));
 
147
   answer_list_add(alpp, SGE_EVENT, STATUS_OK, ANSWER_QUALITY_INFO);
 
148
 
 
149
   DEXIT;
 
150
   return STATUS_OK;
 
151
} /* sge_mod_sched_configuration */
 
152
 
 
153
 
 
154
static void check_reprioritize_interval(sge_gdi_ctx_class_t *ctx, lList **alpp, char *ruser, char *rhost)
 
155
{
 
156
   DENTER(TOP_LAYER, "check_reprioritize_interval");
 
157
 
 
158
   if (((sconf_get_reprioritize_interval() == 0) && (mconf_get_reprioritize())) ||
 
159
       ((sconf_get_reprioritize_interval() != 0) && (!mconf_get_reprioritize()))) {
 
160
      bool flag       = (sconf_get_reprioritize_interval() != 0) ? true : false;
 
161
      lListElem *conf = sge_get_configuration_for_host(SGE_GLOBAL_NAME);
 
162
 
 
163
      sge_set_conf_reprioritize(conf, flag);
 
164
 
 
165
      sge_mod_configuration(ctx, conf, alpp, ruser, rhost);
 
166
 
 
167
      lFreeElem(&conf);
 
168
   }
 
169
 
 
170
   DEXIT;
 
171
   return;
 
172
} /* check_reprioritize_interval */
 
173