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

« back to all changes in this revision

Viewing changes to source/libs/mir/sge_queue_mirror.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 "sge.h"
 
34
#include "sgermon.h"
 
35
#include "sge_log.h"
 
36
 
 
37
#include "sge_object.h"
 
38
#include "sge_cqueue.h"
 
39
#include "sge_qinstance.h"
 
40
#include "sge_qinstance_state.h"
 
41
 
 
42
#include "msg_mirlib.h"
 
43
 
 
44
#include "sge_mirror.h"
 
45
#include "sge_queue_mirror.h"
 
46
 
 
47
sge_callback_result
 
48
cqueue_update_master_list(sge_evc_class_t *evc, object_description *object_base, sge_object_type type, 
 
49
                          sge_event_action action, lListElem *event, void *clientdata)
 
50
{
 
51
   sge_callback_result ret = SGE_EMA_OK;
 
52
   const char *name = NULL;
 
53
   lList *qinstance_list = NULL;
 
54
   lListElem *cqueue = NULL;
 
55
   lList **list = NULL;
 
56
   const lDescr *list_descr = NULL;
 
57
 
 
58
   DENTER(TOP_LAYER, "cqueue_update_master_list");
 
59
   name = lGetString(event, ET_strkey);
 
60
   list = sge_master_list(object_base, SGE_TYPE_CQUEUE); 
 
61
   list_descr = lGetListDescr(lGetList(event, ET_new_version));
 
62
   cqueue = cqueue_list_locate(*list, name);
 
63
 
 
64
   if ((action == SGE_EMA_MOD || action == SGE_EMA_ADD) 
 
65
       && cqueue != NULL) {
 
66
      /*
 
67
       * modify events for CQ_Type objects; we may not update
 
68
       * - CQ_qinstances - it is maintained by QINSTANCE events
 
69
       */         
 
70
      lXchgList(cqueue, CQ_qinstances, &qinstance_list);
 
71
   }
 
72
   
 
73
   ret &= (sge_mirror_update_master_list(list, list_descr, cqueue,
 
74
                         name, action, event) == SGE_EM_OK) ? SGE_EMA_OK : SGE_EMA_FAILURE;
 
75
   cqueue = cqueue_list_locate(*list, name);
 
76
 
 
77
   if ((action == SGE_EMA_MOD || action == SGE_EMA_ADD)
 
78
       && cqueue != NULL) {
 
79
      /*
 
80
       * Replace CQ_qinstances list
 
81
       */         
 
82
      lXchgList(cqueue, CQ_qinstances, &qinstance_list);
 
83
      lFreeList(&qinstance_list);
 
84
   }
 
85
 
 
86
   DEXIT;
 
87
   return ret;
 
88
}
 
89
 
 
90
sge_callback_result
 
91
qinstance_update_cqueue_list(sge_evc_class_t *evc, object_description *object_base, sge_object_type type, 
 
92
                             sge_event_action action, lListElem *event, void *clientdata)
 
93
{
 
94
   sge_callback_result ret = SGE_EMA_OK;
 
95
   const char *name = NULL;
 
96
   const char *hostname = NULL;
 
97
   lListElem *cqueue = NULL;
 
98
 
 
99
   DENTER(TOP_LAYER, "qinstance_update_cqueue_list");
 
100
   name = lGetString(event, ET_strkey);
 
101
   hostname = lGetString(event, ET_strkey2);
 
102
 
 
103
   cqueue = cqueue_list_locate( *(sge_master_list(object_base, SGE_TYPE_CQUEUE)), name);
 
104
                        
 
105
   if (cqueue != NULL) {
 
106
      dstring key_buffer = DSTRING_INIT;
 
107
      lList *list = lGetList(cqueue, CQ_qinstances);
 
108
      const lDescr *list_descr = lGetListDescr(lGetList(event, ET_new_version));
 
109
      
 
110
      lListElem *qinstance = qinstance_list_locate(list, hostname, NULL);
 
111
      const char *key = NULL;
 
112
      bool is_list = list != NULL ? true : false;
 
113
      
 
114
      sge_dstring_sprintf(&key_buffer, SFN"@"SFN, name, hostname);
 
115
      key = sge_dstring_get_string(&key_buffer);
 
116
 
 
117
      if (action == SGE_EMA_MOD) {
 
118
         u_long32 type = lGetUlong(event, ET_type);
 
119
 
 
120
         if (type == sgeE_QINSTANCE_SOS || 
 
121
             type == sgeE_QINSTANCE_USOS) {
 
122
            if (qinstance != NULL) {
 
123
               if (type == sgeE_QINSTANCE_SOS) {
 
124
                  qinstance_state_set_susp_on_sub(qinstance, true);
 
125
               } else {
 
126
                  qinstance_state_set_susp_on_sub(qinstance, false);
 
127
               }
 
128
            } else {
 
129
               ERROR((SGE_EVENT, MSG_QINSTANCE_CANTFINDFORUPDATEIN_SS, key,
 
130
                      SGE_FUNC));
 
131
               ret = SGE_EMA_FAILURE;
 
132
            }
 
133
            sge_dstring_free(&key_buffer);
 
134
            DEXIT;
 
135
            return ret;
 
136
         }
 
137
      }
 
138
      ret &= (sge_mirror_update_master_list(&list, list_descr, qinstance, key,
 
139
                             action, event) == SGE_EM_OK) ? true : false;
 
140
      sge_dstring_free(&key_buffer);
 
141
      if (!is_list) {
 
142
         lSetList(cqueue, CQ_qinstances, list);
 
143
      }
 
144
   } else {
 
145
      ERROR((SGE_EVENT, MSG_CQUEUE_CANTFINDFORUPDATEIN_SS, name, SGE_FUNC));
 
146
      ret = SGE_EMA_FAILURE;
 
147
   }
 
148
 
 
149
   DEXIT;
 
150
   return ret;
 
151
}