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

« back to all changes in this revision

Viewing changes to source/libs/gdi/sge_gdi_packet.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_PACKET_H
 
2
#define __SGE_PACKET_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 "basis_types.h"
 
36
 
 
37
#ifdef  __cplusplus
 
38
extern "C" {
 
39
#endif
 
40
 
 
41
#define GDI_PACKET_MUTEX "gdi_pack_mutex"
 
42
 
 
43
typedef struct _sge_gdi_task_class_t sge_gdi_task_class_t;
 
44
 
 
45
typedef struct _sge_gdi_packet_class_t sge_gdi_packet_class_t;
 
46
 
 
47
struct _sge_gdi_task_class_t {
 
48
   /*
 
49
    * id identifying the GDI packet uniquely within the
 
50
    * context of a GDI client
 
51
    */
 
52
   u_long32 id;
 
53
 
 
54
   /*
 
55
    * common parts of a GDI request
 
56
    */
 
57
   u_long32 command;
 
58
   u_long32 target;
 
59
   lList *data_list;
 
60
   lList *answer_list;
 
61
   lCondition *condition;
 
62
   lEnumeration *enumeration;
 
63
 
 
64
   /*
 
65
    * This flag is used in qmaster to identify if a special 
 
66
    * optimization can be done. This optimization can only be
 
67
    * done for GDI GET requests where the client is
 
68
    * an external GDI client (no thread using GDI). 
 
69
    *
 
70
    * In that case it is possible that the lSelectHashPack()
 
71
    * function is called with a packbuffer so that the function
 
72
    * directly packs into this packbuffer.
 
73
    * 
 
74
    * This avoids a copy operation 
 
75
    */
 
76
   bool do_select_pack_simultaneous;
 
77
 
 
78
   /*
 
79
    * pointer to the next task in a multi GDI request
 
80
    */
 
81
   sge_gdi_task_class_t *next;
 
82
};
 
83
 
 
84
struct _sge_gdi_packet_class_t {
 
85
   /* 
 
86
    * mutex to gard the "is_handled" flag of this structure 
 
87
    */
 
88
   pthread_mutex_t mutex;
 
89
 
 
90
   /*
 
91
    * condition used for synchronisation of multiple threads
 
92
    * which want to access this structure
 
93
    */
 
94
   pthread_cond_t cond;
 
95
 
 
96
   /*
 
97
    * true if the worker thread does not need to access this
 
98
    * structure anymore. Guarded with "mutex" part of this 
 
99
    * structure
 
100
    */
 
101
   bool is_handled;
 
102
 
 
103
   /*
 
104
    * true if this structure was created by a qmaster
 
105
    * internal thread (scheduler, JVM...)
 
106
    */
 
107
   bool is_intern_request;
 
108
 
 
109
   /*
 
110
    * true if the packet contains a GDI request otherwise
 
111
    * is containes a report request
 
112
    */
 
113
   bool is_gdi_request;
 
114
 
 
115
   /*
 
116
    * unique id identifying this packet uniquely in the context
 
117
    * of the creating process/thread
 
118
    */
 
119
   u_long32 id;
 
120
 
 
121
   /*
 
122
    * set in qmaster to identify the source for this GDI packet.
 
123
    * qmaster will use that information to send a response
 
124
    * to the correct external communication partner using the
 
125
    * commlib infrastructure
 
126
    */
 
127
   char *host;
 
128
   char *commproc;
 
129
   u_short commproc_id;
 
130
   u_long32 response_id;
 
131
 
 
132
   /*
 
133
    * GDI version of this structure
 
134
    */
 
135
   u_long32 version;
 
136
 
 
137
   /*
 
138
    * pointers to the first and last task part of a multi
 
139
    * GDI request. This list contains at least one element
 
140
    */
 
141
   sge_gdi_task_class_t *first_task;
 
142
   sge_gdi_task_class_t *last_task;  
 
143
 
 
144
   /*
 
145
    * encrypted authenitication information. This information will 
 
146
    * be decrypted to the field "uid", "gid", "user" and "group"
 
147
    * part of this structure 
 
148
    *
 
149
    * EB: TODO: Cleanup: remove "auth_info" from sge_gdi_packet_class_t
 
150
    *
 
151
    *    authinfo is not needed in this structure because the
 
152
    *    same information is stored in "uid", "gid", "user" and "group"
 
153
    *    If these elements are initialized during unpacking a packet
 
154
    *    and if the GDI functions don't want to access auth_info
 
155
    *    anymore then we can remove that field from this structure.
 
156
    */
 
157
   char *auth_info;  
 
158
 
 
159
   /*
 
160
    * User/group information of that user which used GDI functionality.
 
161
    * Used in qmasters GDI handling code to identify if that
 
162
    * user has the allowance to do the requested GDI activities. 
 
163
    */
 
164
   uid_t uid;
 
165
   gid_t gid;
 
166
   char user[128];
 
167
   char group[128];
 
168
 
 
169
   /*
 
170
    * Packbuffer used for GDI GET requests to directly store the 
 
171
    * result of lSelectHashPack()
 
172
    *
 
173
    * EB: TODO: Cleanup: eleminate "pb" from sge_gdi_packet_class_t
 
174
    *    
 
175
    *    We might eleminate this member as soon as pure GDI GET
 
176
    *    requests are handled by some kind of read only thread.
 
177
    *    in qmaster. Write requests don't need the packbuffer.
 
178
    *    Due to that fact we could create and release the packbuffer
 
179
    *    in the the listener thread and use cull lists (part
 
180
    *    of the task sublist) to transfer GDI result information
 
181
    *    from the worker to the listener then we are able to
 
182
    *    remove pb. 
 
183
    */
 
184
   sge_pack_buffer pb;
 
185
 
 
186
   /* 
 
187
    * if this packet is part of a packet queue then this
 
188
    * pointer might point to the next packet in the queue
 
189
    */
 
190
   sge_gdi_packet_class_t *next;
 
191
};
 
192
 
 
193
sge_gdi_packet_class_t *
 
194
sge_gdi_packet_create_base(lList **answer_list);
 
195
 
 
196
sge_gdi_packet_class_t *
 
197
sge_gdi_packet_create(sge_gdi_ctx_class_t *ctx, lList **answer_list);
 
198
 
 
199
bool
 
200
sge_gdi_packet_free(sge_gdi_packet_class_t **packet_handle);
 
201
 
 
202
bool 
 
203
sge_gdi_packet_append_task(sge_gdi_packet_class_t *packet, lList **answer_list,
 
204
                           u_long32 target, u_long32 command, lList **lp, lList **a_list,
 
205
                           lCondition **condition, lEnumeration **enumeration,
 
206
                           bool do_copy, bool do_verify);
 
207
 
 
208
u_long32 
 
209
sge_gdi_packet_get_last_task_id(sge_gdi_packet_class_t *packet);
 
210
 
 
211
bool 
 
212
sge_gdi_packet_verify_version(sge_gdi_packet_class_t *packet, lList **alpp);
 
213
 
 
214
const char *
 
215
sge_gdi_task_get_operation_name(sge_gdi_task_class_t *task);
 
216
 
 
217
#ifdef  __cplusplus
 
218
}
 
219
#endif
 
220
 
 
221
#endif 
 
222
 
 
223
 
 
224