3
/*___INFO__MARK_BEGIN__*/
4
/*************************************************************************
6
* The Contents of this file are made available subject to the terms of
7
* the Sun Industry Standards Source License Version 1.2
9
* Sun Microsystems Inc., March, 2001
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
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.
26
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
28
* Copyright: 2001 by Sun Microsystems, Inc.
30
* All Rights Reserved.
32
************************************************************************/
33
/*___INFO__MARK_END__*/
38
#include "sge_object.h"
40
#include "sge_eventL.h"
41
#include "evc/sge_event_client.h"
43
/****** Eventmirror/--Eventmirror ***************************************
46
* Eventmirror -- mirroring of master lists through event client interface
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.
53
* Such components can be schedulers, proxies, monitoring tools etc.
55
* It is designed as a layer above the event client interface.
57
* Mirroring can be restricted to certain event types / object types.
58
* Callback functions can be installed to perform actions additional to
62
* Not yet operable on the usermapping related objects and lists.
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
****************************************************************************
78
/****** Eventmirror/-Eventmirror-Typedefs ***************************************
81
* Eventmirror -- mirroring of master lists through event client interface
92
* typedef int (*sge_mirror_callback)(sge_object_type type,
93
* sge_event_action action,
94
* lListElem *event, void *clientdata);
98
* The following types are defined for use with the event mirroring
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.
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
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
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.
128
****************************************************************************
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;
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,
153
SGE_EM_NOT_INITIALIZED,
158
SGE_EM_DUPLICATE_KEY,
159
SGE_EM_KEY_NOT_FOUND,
161
SGE_EM_CALLBACK_FAILED,
163
SGE_EM_PROCESS_ERRORS,
168
/* Initialization - Shutdown */
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);
175
sge_mirror_error sge_mirror_shutdown(sge_evc_class_t *evc);
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,
183
const lCondition *where, const lEnumeration *what);
185
sge_mirror_error sge_mirror_unsubscribe(sge_evc_class_t *evc,
186
sge_object_type type);
188
/* Event Processing */
191
sge_mirror_process_event_list(sge_evc_class_t *evc, lList *event_list);
194
sge_mirror_process_events(sge_evc_class_t *evc);
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);
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,
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,
214
const char *sge_mirror_strerror(sge_mirror_error num);
216
#endif /* __SGE_MIRROR_H */