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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#ifndef __SGE_PACKET_H
#define __SGE_PACKET_H
/*___INFO__MARK_BEGIN__*/
/*************************************************************************
 * 
 *  The Contents of this file are made available subject to the terms of
 *  the Sun Industry Standards Source License Version 1.2
 * 
 *  Sun Microsystems Inc., March, 2001
 * 
 * 
 *  Sun Industry Standards Source License Version 1.2
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.2 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 * 
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 * 
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 * 
 *   Copyright: 2001 by Sun Microsystems, Inc.
 * 
 *   All Rights Reserved.
 * 
 ************************************************************************/
/*___INFO__MARK_END__*/

#include "basis_types.h"

#ifdef  __cplusplus
extern "C" {
#endif

#define GDI_PACKET_MUTEX "gdi_pack_mutex"

typedef struct _sge_gdi_task_class_t sge_gdi_task_class_t;

typedef struct _sge_gdi_packet_class_t sge_gdi_packet_class_t;

struct _sge_gdi_task_class_t {
   /*
    * id identifying the GDI packet uniquely within the
    * context of a GDI client
    */
   u_long32 id;

   /*
    * common parts of a GDI request
    */
   u_long32 command;
   u_long32 target;
   lList *data_list;
   lList *answer_list;
   lCondition *condition;
   lEnumeration *enumeration;

   /*
    * This flag is used in qmaster to identify if a special 
    * optimization can be done. This optimization can only be
    * done for GDI GET requests where the client is
    * an external GDI client (no thread using GDI). 
    *
    * In that case it is possible that the lSelectHashPack()
    * function is called with a packbuffer so that the function
    * directly packs into this packbuffer.
    * 
    * This avoids a copy operation 
    */
   bool do_select_pack_simultaneous;

   /*
    * pointer to the next task in a multi GDI request
    */
   sge_gdi_task_class_t *next;
};

struct _sge_gdi_packet_class_t {
   /* 
    * mutex to gard the "is_handled" flag of this structure 
    */
   pthread_mutex_t mutex;

   /*
    * condition used for synchronisation of multiple threads
    * which want to access this structure
    */
   pthread_cond_t cond;

   /*
    * true if the worker thread does not need to access this
    * structure anymore. Guarded with "mutex" part of this 
    * structure
    */
   bool is_handled;

   /*
    * true if this structure was created by a qmaster
    * internal thread (scheduler, JVM...)
    */
   bool is_intern_request;

   /*
    * true if the packet contains a GDI request otherwise
    * is containes a report request
    */
   bool is_gdi_request;

   /*
    * unique id identifying this packet uniquely in the context
    * of the creating process/thread
    */
   u_long32 id;

   /*
    * set in qmaster to identify the source for this GDI packet.
    * qmaster will use that information to send a response
    * to the correct external communication partner using the
    * commlib infrastructure
    */
   char *host;
   char *commproc;
   u_short commproc_id;
   u_long32 response_id;

   /*
    * GDI version of this structure
    */
   u_long32 version;

   /*
    * pointers to the first and last task part of a multi
    * GDI request. This list contains at least one element
    */
   sge_gdi_task_class_t *first_task;
   sge_gdi_task_class_t *last_task;  

   /*
    * encrypted authenitication information. This information will 
    * be decrypted to the field "uid", "gid", "user" and "group"
    * part of this structure 
    *
    * EB: TODO: Cleanup: remove "auth_info" from sge_gdi_packet_class_t
    *
    *    authinfo is not needed in this structure because the
    *    same information is stored in "uid", "gid", "user" and "group"
    *    If these elements are initialized during unpacking a packet
    *    and if the GDI functions don't want to access auth_info
    *    anymore then we can remove that field from this structure.
    */
   char *auth_info;  

   /*
    * User/group information of that user which used GDI functionality.
    * Used in qmasters GDI handling code to identify if that
    * user has the allowance to do the requested GDI activities. 
    */
   uid_t uid;
   gid_t gid;
   char user[128];
   char group[128];

   /*
    * Packbuffer used for GDI GET requests to directly store the 
    * result of lSelectHashPack()
    *
    * EB: TODO: Cleanup: eleminate "pb" from sge_gdi_packet_class_t
    *    
    *    We might eleminate this member as soon as pure GDI GET
    *    requests are handled by some kind of read only thread.
    *    in qmaster. Write requests don't need the packbuffer.
    *    Due to that fact we could create and release the packbuffer
    *    in the the listener thread and use cull lists (part
    *    of the task sublist) to transfer GDI result information
    *    from the worker to the listener then we are able to
    *    remove pb. 
    */
   sge_pack_buffer pb;

   /* 
    * if this packet is part of a packet queue then this
    * pointer might point to the next packet in the queue
    */
   sge_gdi_packet_class_t *next;
};

sge_gdi_packet_class_t *
sge_gdi_packet_create_base(lList **answer_list);

sge_gdi_packet_class_t *
sge_gdi_packet_create(sge_gdi_ctx_class_t *ctx, lList **answer_list);

bool
sge_gdi_packet_free(sge_gdi_packet_class_t **packet_handle);

bool 
sge_gdi_packet_append_task(sge_gdi_packet_class_t *packet, lList **answer_list,
                           u_long32 target, u_long32 command, lList **lp, lList **a_list,
                           lCondition **condition, lEnumeration **enumeration,
                           bool do_copy, bool do_verify);

u_long32 
sge_gdi_packet_get_last_task_id(sge_gdi_packet_class_t *packet);

bool 
sge_gdi_packet_verify_version(sge_gdi_packet_class_t *packet, lList **alpp);

const char *
sge_gdi_task_get_operation_name(sge_gdi_task_class_t *task);

#ifdef  __cplusplus
}
#endif

#endif