~ubuntu-branches/ubuntu/oneiric/globus-gram-client/oneiric

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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
/*
 * Copyright 1999-2006 University of Chicago
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
/**
 * @file gram_client.h
 *
 * This header file contains the exported client interface of 
 * the Resource Allocation Management System.
 *
 * CVS Information:
 *  $Source: /home/globdev/CVS/globus-packages/gram/client/source/globus_gram_client.h,v $
 *  $Date: 2010/02/10 11:15:20 $
 *  $Revision: 1.59.2.2 $
 *  $Author: bester $
 */
#endif

#ifndef GLOBUS_I_GRAM_CLIENT_INCLUDE
#define GLOBUS_I_GRAM_CLIENT_INCLUDE

/* Include header files */
#include "globus_common.h"
#include "globus_io.h"
#include "globus_gram_protocol_constants.h"

#ifndef EXTERN_C_BEGIN
#ifdef __cplusplus
#define EXTERN_C_BEGIN extern "C" {
#define EXTERN_C_END }
#else
#define EXTERN_C_BEGIN
#define EXTERN_C_END
#endif
#endif
 
EXTERN_C_BEGIN


/** 
 * @mainpage Resource Management Client API
 * @anchor globus_gram_client_main
 *
 * The resource management API provides function for requesting
 * that a job be started or terminated, as well as for requesting
 * information about the status of a job.
 */

/******************************************************************************
                               Type definitions
******************************************************************************/


/**
 * @defgroup globus_gram_client_callback Job state callbacks
 */

/**
 * @brief Signature for GRAM state notification callback functions
 * @ingroup globus_gram_client_callback
 *
 * @details
 * The @a globus_gram_client_callback_func_t type describes the function
 * signature for job state callbacks.  A pointer to a function
 * of this type is passed to the @a globus_gram_client_callback_allow()
 * function to create a callback contact. The contact string can be passed to
 * @a globus_gram_client_job_request() or
 * @a globus_gram_client_job_callback_register() to let the job management
 * service know to where to send information on GRAM job state changes.
 *
 * @param user_callback_arg
 *     A pointer to application-specific data.
 * @param job_contact
 *     A string containing the job contact. This string indicates which job
 *     this callback is referring to. It should in most cases match the return
 *     value @a job_contact from a call to @a globus_gram_client_job_request()
 *     or in the @a job_contact parameter to the
 *     @a globus_gram_client_nonblocking_func_t used with
 *     @a globus_gram_client_register_job_request(). However, in some cases,
 *     the port number in the job contact URL may change if the job manager
 *     is restarted.
 * @param state
 *     The new state (one of the #globus_gram_protocol_job_state_t values)
 *     of the job.
 * @param errorcode
 *     The error code if the @a state parameter is equal to
 *     GLOBUS_GRAM_PROTOCOL_JOB_STATE_FAILED.
 */
typedef void (* globus_gram_client_callback_func_t)(
    void *                              user_callback_arg,
    char *                              job_contact,
    int                                 state,
    int                                 errorcode);

/**
 * @brief Extensible job information structure
 * @ingroup globus_gram_client_callback
 *
 * @details
 * The @a #globus_gram_client_job_info_t data type is used to pass protocol
 * extensions along with the standard job status
 * information included in the GRAM2 protocol. This structure contains the
 * information returned in job state callbacks plus a hash table of extension
 * entries that contain @a #globus_gram_protocol_extension_t name-value pairs.
 */
typedef struct globus_gram_client_job_info_s
{
    /**
     * Table of extension values
     */
    globus_hashtable_t                  extensions;
    /**
     * GRAM Job Contact String
     */
    char *                              job_contact;
    /**
     * GRAM Job State
     */
    int                                 job_state;
    /**
     * GRAM Error Code
     */
    int                                 protocol_error_code;
}
globus_gram_client_job_info_t;

/**
 * @brief Signature for GRAM state notification callback functions with
 * extension support
 * @ingroup globus_gram_client_callback
 *
 * @details
 * The @a #globus_gram_client_info_callback_func_t type describes the function
 * signature for job state callbacks that carry any GRAM protocol extensions
 * beyond the set used in GRAM2.  A pointer to a function
 * of this type is passed to the @a globus_gram_client_info_callback_allow()
 * function to create a callback contact that can handle extensions. The
 * contact string can be passed to
 * @a globus_gram_client_job_request() or
 * @a globus_gram_client_job_callback_register() to let the job management
 * service know to where to send information on GRAM job state changes.
 *
 * @param  user_callback_arg
 *     Application-specific callback information.
 * @param job_contact
 *     Job this information is related to
 * @param job_info
 *     Job state and extensions
 *
 * @see globus_gram_client_info_callback_allow()
 */
typedef void (* globus_gram_client_info_callback_func_t)(
    void *                              user_callback_arg,
    const char *                        job_contact,
    globus_gram_client_job_info_t *     job_info);

/**
 * @brief GRAM client operation attribute
 * @ingroup globus_gram_client_attr
 *
 * @details
 * The @a #globus_gram_client_attr_t type is an opaque type describing
 * GRAM attributes. It can be accessed or modified by functions in the 
 * @ref globus_gram_client_attr documentation.
 */
typedef void * globus_gram_client_attr_t;


/**
 * @brief Default GRAM client operation attribute
 * @ingroup globus_gram_client_attr
 * @hideinitializer
 * @details
 * The @a GLOBUS_GRAM_CLIENT_NO_ATTR macro defines a constant for use
 * when a user of the GRAM client API does not want to specify any
 * non-default GRAM attributes.
 */
#define GLOBUS_GRAM_CLIENT_NO_ATTR (globus_gram_client_attr_t) NULL

/**
 * @brief Signature for callbacks signalling completion of non-blocking GRAM requests
 * @ingroup globus_gram_client_callback
 *
 * @details
 * The @a #globus_gram_client_info_callback_func_t type describes the function
 * signature for callbacks which indicate that a GRAM operation has completed.
 * A pointer to a function of this type is passed to the
 * following functions:
 * - @a globus_gram_client_register_job_request()
 * - @a globus_gram_client_register_job_cancel()
 * - @a globus_gram_client_register_job_status()
 * - @a globus_gram_client_register_job_refresh_credentials()
 * - @a globus_gram_client_register_job_signal()
 * - @a globus_gram_client_register_job_callback_registration()
 * - @a globus_gram_client_register_job_callback_unregistration()
 * - @a globus_gram_client_register_ping()
 * 
 * @param user_callback_arg
 *     Application-specific callback information.
 * @param operation_failure_code
 *     The result of the nonblocking operation , indicating whether the
 *     operation was processed by the job manager successfully or not.
 * @param job_contact
 *     A string containing the job contact associated with this non-blocking
 *     operation.
 * @param job_state
 *     The state (one of the #globus_gram_protocol_job_state_t
 *     values) of the job related to this non-blocking operation.
 * @param job_failure_code
 *     The error code of the job request if the job_state parameter
 *     is GLOBUS_GRAM_PROTOCOL_JOB_STATE_FAILED. Otherwise, its value is
 *     undefined.
 */
typedef void (* globus_gram_client_nonblocking_func_t)(
    void *                              user_callback_arg,
    globus_gram_protocol_error_t        operation_failure_code,
    const char *                        job_contact,
    globus_gram_protocol_job_state_t    job_state,
    globus_gram_protocol_error_t        job_failure_code);


/**
 * @defgroup globus_gram_client_job_functions GRAM Job Functions
 */

/******************************************************************************
                              Function prototypes
******************************************************************************/
int 
globus_gram_client_callback_allow(
    globus_gram_client_callback_func_t  callback_func,
    void *                              user_callback_arg,
    char **                             callback_contact);


int
globus_gram_client_info_callback_allow(
    globus_gram_client_info_callback_func_t
                                        callback_func,
    void *                              user_callback_arg,
    char **                             callback_contact);

int
globus_gram_client_register_job_request(
    const char *                        resource_manager_contact,
    const char *                        description,
    int                                 job_state_mask,
    const char *                        callback_contact,
    globus_gram_client_attr_t           attr,
    globus_gram_client_nonblocking_func_t
                                        register_callback,
    void *                              register_callback_arg);

int 
globus_gram_client_job_request(
    const char *                        resource_manager_contact,
    const char *                        description,
    int                                 job_state_mask,
    const char *                        callback_contact,
    char **                             job_contact);

int
globus_gram_client_register_job_request_with_info(
    const char *                        resource_manager_contact,
    const char *                        description,
    int                                 job_state_mask,
    const char *                        callback_contact,
    globus_gram_client_attr_t           attr,
    globus_gram_client_info_callback_func_t
                                        callback,
    void *                              callback_arg);

int 
globus_gram_client_job_request_with_info(
    const char *                        resource_manager_contact,
    const char *                        description,
    int                                 job_state_mask,
    const char *                        callback_contact,
    char **                             job_contact,
    globus_gram_client_job_info_t *     info);

int
globus_gram_client_register_job_cancel(
    const char *                        job_contact,
    globus_gram_client_attr_t           attr,
    globus_gram_client_nonblocking_func_t
                                        register_callback,
    void *                              register_callback_arg);

int 
globus_gram_client_job_cancel(
    const char *                        job_contact);

int
globus_gram_client_register_job_status(
    const char *                        job_contact,
    globus_gram_client_attr_t           attr,
    globus_gram_client_nonblocking_func_t
                                        register_callback,
    void *                              register_callback_arg);

int
globus_gram_client_register_job_status_with_info(
    const char *                        job_contact,
    globus_gram_client_attr_t           attr,
    globus_gram_client_info_callback_func_t
                                        info_callback,
    void *                              callback_arg);


int
globus_gram_client_job_refresh_credentials(
    char *                              job_contact,
    gss_cred_id_t                       creds);

int
globus_gram_client_register_job_refresh_credentials(
    char *                              job_contact,
    gss_cred_id_t                       creds,
    globus_gram_client_attr_t           attr,
    globus_gram_client_nonblocking_func_t
                                        register_callback,
    void *                              register_callback_arg);

int
globus_gram_client_job_status(
    const char *                        job_contact,
    int *                               job_status,
    int *                               failure_code);

int
globus_gram_client_job_status_with_info(
    const char *                        job_contact,
    globus_gram_client_job_info_t *     job_info);

int
globus_gram_client_register_job_signal(
    const char *                        job_contact,
    globus_gram_protocol_job_signal_t   signal,
    const char *                        signal_arg,
    globus_gram_client_attr_t           attr,
    globus_gram_client_nonblocking_func_t
                                        register_callback,
    void *                              register_callback_arg);

int
globus_gram_client_job_signal(
    const char *                        job_contact,
    globus_gram_protocol_job_signal_t   signal,
    const char *                        signal_arg,
    int *                               job_status,
    int *                               failure_code);


int
globus_gram_client_register_job_callback_registration(
    const char *                        job_contact,
    int                                 job_state_mask,
    const char *                        callback_contact,
    globus_gram_client_attr_t           attr,
    globus_gram_client_nonblocking_func_t
                                        register_callback,
    void *                              register_callback_arg);

int
globus_gram_client_job_callback_register(
    const char *                        job_contact,
    int                                 job_state_mask,
    const char *                        callback_contact,
    int *                               job_status,
    int *                               failure_code);

int
globus_gram_client_register_job_callback_unregistration(
    const char *                        job_contact,
    const char *                        callback_contact,
    globus_gram_client_attr_t           attr,
    globus_gram_client_nonblocking_func_t
                                        register_callback,
    void *                              register_callback_arg);

int
globus_gram_client_job_callback_unregister(
    const char *                        job_contact,
    const char *                        callback_contact,
    int *                               job_status,
    int *                               failure_code);

int 
globus_gram_client_callback_disallow(
    char *                              callback_contact);

int 
globus_gram_client_job_contact_free(
    char *                              job_contact);

/**
 * @defgroup globus_gram_client Other GRAM Client Functions
 */
const char *
globus_gram_client_error_string(
    int                                 error_code);

int
globus_gram_client_version(void);

int
globus_gram_client_set_credentials(gss_cred_id_t new_credentials);

int 
globus_gram_client_ping(
    const char *                        resource_manager_contact);

int 
globus_gram_client_register_ping(
    const char *                        resource_manager_contact,
    globus_gram_client_attr_t           attr,
    globus_gram_client_nonblocking_func_t
                                        register_callback,
    void *                              register_callback_arg);

int 
globus_gram_client_get_jobmanager_version(
    const char *                        resource_manager_contact,
    globus_hashtable_t *                extensions);

int 
globus_gram_client_register_get_jobmanager_version(
    const char *                        resource_manager_contact,
    globus_gram_client_attr_t           attr,
    globus_gram_client_info_callback_func_t
                                        info_callback,
    void *                              callback_arg);

void
globus_gram_client_debug(void);

/**
 * @defgroup globus_gram_client_attr GRAM Client Attribute Functions
 */
int
globus_gram_client_attr_init(
    globus_gram_client_attr_t *         attr);
int
globus_gram_client_attr_destroy(
    globus_gram_client_attr_t *         attr);

int
globus_gram_client_attr_set_credential(
    globus_gram_client_attr_t           attr,
    gss_cred_id_t                       credential);

int
globus_gram_client_attr_get_credential(
    globus_gram_client_attr_t           attr,
    gss_cred_id_t *                     credential);

int
globus_gram_client_attr_set_delegation_mode(
    globus_gram_client_attr_t           attr,
    globus_io_secure_delegation_mode_t  mode);

int
globus_gram_client_attr_get_delegation_mode(
    globus_gram_client_attr_t           attr,
    globus_io_secure_delegation_mode_t *mode);

void
globus_gram_client_job_info_destroy(
    globus_gram_client_job_info_t *     info);

#define GLOBUS_GRAM_CLIENT_MODULE (&globus_gram_client_module)

extern globus_module_descriptor_t       globus_gram_client_module;

EXTERN_C_END
#endif /* GLOBUS_I_GRAM_CLIENT_INCLUDE */