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

« back to all changes in this revision

Viewing changes to source/libs/mir/sge_mirror.h

  • 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
#ifndef __SGE_MIRROR_H
 
2
#define __SGE_MIRROR_H
 
3
/*___INFO__MARK_BEGIN__*/
 
4
/*************************************************************************
 
5
 * 
 
6
 *  The Contents of this file are made available subject to the terms of
 
7
 *  the Sun Industry Standards Source License Version 1.2
 
8
 * 
 
9
 *  Sun Microsystems Inc., March, 2001
 
10
 * 
 
11
 * 
 
12
 *  Sun Industry Standards Source License Version 1.2
 
13
 *  =================================================
 
14
 *  The contents of this file are subject to the Sun Industry Standards
 
15
 *  Source License Version 1.2 (the "License"); You may not use this file
 
16
 *  except in compliance with the License. You may obtain a copy of the
 
17
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 
18
 * 
 
19
 *  Software provided under this License is provided on an "AS IS" basis,
 
20
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 
21
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 
22
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 
23
 *  See the License for the specific provisions governing your rights and
 
24
 *  obligations concerning the Software.
 
25
 * 
 
26
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
27
 * 
 
28
 *   Copyright: 2001 by Sun Microsystems, Inc.
 
29
 * 
 
30
 *   All Rights Reserved.
 
31
 * 
 
32
 ************************************************************************/
 
33
/*___INFO__MARK_END__*/
 
34
 
 
35
#include "cull.h"
 
36
#include "sge_gdi.h"
 
37
 
 
38
#include "sge_object.h"
 
39
 
 
40
#include "sge_eventL.h"
 
41
#include "evc/sge_event_client.h"
 
42
 
 
43
/****** Eventmirror/--Eventmirror ***************************************
 
44
*
 
45
*  NAME
 
46
*     Eventmirror -- mirroring of master lists through event client interface
 
47
*
 
48
*  FUNCTION
 
49
*     The event mirror interface provides a means to easily implement 
 
50
*     Grid Engine components that need to have access to the masters 
 
51
*     object lists and therefore have to mirror them.
 
52
*     
 
53
*     Such components can be schedulers, proxies, monitoring tools etc.
 
54
*  
 
55
*     It is designed as a layer above the event client interface.
 
56
*
 
57
*     Mirroring can be restricted to certain event types / object types.
 
58
*     Callback functions can be installed to perform actions additional to 
 
59
*     pure mirroring.
 
60
*
 
61
*  BUGS
 
62
*     Not yet operable on the usermapping related objects and lists.
 
63
*
 
64
*  SEE ALSO
 
65
*     Eventmirror/-Eventmirror-Typedefs
 
66
*     Eventmirror/sge_mirror_initialize()
 
67
*     Eventmirror/sge_mirror_shutdown()
 
68
*     Eventmirror/sge_mirror_subscribe()
 
69
*     Eventmirror/sge_mirror_unsubscribe()
 
70
*     Eventmirror/sge_mirror_process_events()
 
71
*     Eventmirror/sge_mirror_update_master_list()
 
72
*     Eventmirror/sge_mirror_update_master_list_host_key()
 
73
*     Eventmirror/sge_mirror_update_master_list_str_key()
 
74
*     Eventmirror/sge_mirror_strerror()
 
75
****************************************************************************
 
76
*/
 
77
 
 
78
/****** Eventmirror/-Eventmirror-Typedefs ***************************************
 
79
*
 
80
*  NAME
 
81
*     Eventmirror -- mirroring of master lists through event client interface
 
82
*
 
83
*  SYNOPSIS
 
84
*     typedef enum {
 
85
*        ...
 
86
*     } sge_event_action;
 
87
*     
 
88
*     typedef enum {
 
89
*        ...
 
90
*     } sge_mirror_error;
 
91
*     
 
92
*     typedef int (*sge_mirror_callback)(sge_object_type type, 
 
93
*                                        sge_event_action action, 
 
94
*                                        lListElem *event, void *clientdata);
 
95
*     
 
96
*
 
97
*  FUNCTION
 
98
*     The following types are defined for use with the event mirroring 
 
99
*     interface:
 
100
*
 
101
*
 
102
*     Different event actions are defined in the enumeration sge_event_action:
 
103
*        SGE_EMA_LIST      - the whole master list has been sent 
 
104
*                            (used at initialization)
 
105
*        SGE_EMA_ADD       - a new object has been created
 
106
*        SGE_EMA_MOD       - an object has been modified
 
107
*        SGE_EMA_DEL       - an object has been deleted
 
108
*        SGE_EMA_TRIGGER   - a certain action has been triggered, 
 
109
*                            e.g. a scheduling run or a shutdown.
 
110
*   
 
111
*     Most functions of the event mirroring interface return error codes that 
 
112
*     are defined in the enumeration sge_mirror_error:
 
113
*        SGE_EM_OK              - action performed successfully
 
114
*        SGE_EM_NOT_INITIALIZED - the interface is not yet initialized 
 
115
*        SGE_EM_BAD_ARG         - some input parameter was incorrect
 
116
*        SGE_EM_TIMEOUT         - a timeout occured
 
117
*        SGE_EM_DUPLICATE_KEY   - an object should be added, but an object 
 
118
*                                 with the same unique identifier already 
 
119
*                                 exists.
 
120
*        SGE_EM_KEY_NOT_FOUND   - an object with the given key was not found.
 
121
*        SGE_EM_CALLBACK_FAILED - a callback function failed
 
122
*        SGE_EM_PROCESS_ERRORS  - an error occured during event processing
 
123
*
 
124
*     The event mirroring interface allows to install callback funktions for
 
125
*     actions on certain event types. These callback functions have to have 
 
126
*     the same prototype as given by the function typedef sge_mirror_callback.
 
127
*  
 
128
****************************************************************************
 
129
*/
 
130
typedef enum {
 
131
   SGE_EMA_LIST = 1,
 
132
   SGE_EMA_ADD,
 
133
   SGE_EMA_MOD,
 
134
   SGE_EMA_DEL,
 
135
   SGE_EMA_TRIGGER
 
136
} sge_event_action;
 
137
 
 
138
typedef enum {
 
139
   SGE_EMA_FAILURE = 0, /* the processing of events is stoped */
 
140
   SGE_EMA_OK = 1,      /* everything is fine */
 
141
   SGE_EMA_IGNORE = 2   /* no further processing for this event is done */
 
142
} sge_callback_result;
 
143
 
 
144
typedef sge_callback_result (*sge_mirror_callback)(sge_evc_class_t *evc,
 
145
                                                   object_description *object_base, 
 
146
                                                   sge_object_type type, 
 
147
                                                   sge_event_action action, 
 
148
                                                   lListElem *event, 
 
149
                                                   void *clientdata);
 
150
 
 
151
typedef enum {
 
152
   SGE_EM_OK = 0,
 
153
   SGE_EM_NOT_INITIALIZED,
 
154
   
 
155
   SGE_EM_BAD_ARG,
 
156
   SGE_EM_TIMEOUT,
 
157
   
 
158
   SGE_EM_DUPLICATE_KEY,
 
159
   SGE_EM_KEY_NOT_FOUND,
 
160
 
 
161
   SGE_EM_CALLBACK_FAILED,
 
162
 
 
163
   SGE_EM_PROCESS_ERRORS,
 
164
 
 
165
   SGE_EM_LAST_ERRNO
 
166
} sge_mirror_error;
 
167
 
 
168
/* Initialization - Shutdown */
 
169
sge_mirror_error 
 
170
sge_mirror_initialize(sge_evc_class_t *evc, ev_registration_id id, const char *name,
 
171
                      bool use_global_data, event_client_update_func_t update_func,
 
172
                      evm_mod_func_t mod_func, evm_add_func_t add_func,
 
173
                      evm_remove_func_t remove_func, evm_ack_func_t ack_func);
 
174
 
 
175
sge_mirror_error sge_mirror_shutdown(sge_evc_class_t *evc);
 
176
 
 
177
/* Subscription */
 
178
sge_mirror_error sge_mirror_subscribe(sge_evc_class_t *evc, 
 
179
                                      sge_object_type type, 
 
180
                                      sge_mirror_callback callback_before, 
 
181
                                      sge_mirror_callback callback_after, 
 
182
                                      void *clientdata,
 
183
                                      const lCondition *where, const lEnumeration *what);
 
184
 
 
185
sge_mirror_error sge_mirror_unsubscribe(sge_evc_class_t *evc,
 
186
                                        sge_object_type type);
 
187
 
 
188
/* Event Processing */
 
189
 
 
190
sge_mirror_error
 
191
sge_mirror_process_event_list(sge_evc_class_t *evc, lList *event_list);
 
192
 
 
193
sge_mirror_error 
 
194
sge_mirror_process_events(sge_evc_class_t *evc);
 
195
 
 
196
sge_mirror_error 
 
197
sge_mirror_update_master_list(lList **list, const lDescr *list_descr,
 
198
                              lListElem *ep, const char *key, 
 
199
                              sge_event_action action, lListElem *event);
 
200
 
 
201
sge_mirror_error 
 
202
sge_mirror_update_master_list_host_key(lList **list, const lDescr *list_descr, 
 
203
                                       int key_nm, const char *key, 
 
204
                                       sge_event_action action, 
 
205
                                       lListElem *event);
 
206
 
 
207
sge_mirror_error 
 
208
sge_mirror_update_master_list_str_key(lList **list, const lDescr *list_descr, 
 
209
                                      int key_nm, const char *key, 
 
210
                                      sge_event_action action, 
 
211
                                      lListElem *event);
 
212
 
 
213
/* Error Handling */
 
214
const char *sge_mirror_strerror(sge_mirror_error num);
 
215
 
 
216
#endif /* __SGE_MIRROR_H */