From 98ef2264c4cefaa9d680477377cd8e5c3bdc1ec4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ji=C5=99=C3=AD=20=C5=A0kr=C3=A1bal?= Date: Fri, 3 Dec 2004 07:20:31 +0000 Subject: [PATCH] - example --- org.glite.lb.client/examples/query_seq_code.c | 87 +++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 org.glite.lb.client/examples/query_seq_code.c diff --git a/org.glite.lb.client/examples/query_seq_code.c b/org.glite.lb.client/examples/query_seq_code.c new file mode 100644 index 0000000..87e342d --- /dev/null +++ b/org.glite.lb.client/examples/query_seq_code.c @@ -0,0 +1,87 @@ +#include +#include +#include +#include +#include +#include + +#include + +#include "glite/wmsutils/jobid/cjobid.h" +#include "glite/lb/consumer.h" + + +static struct option opts[] = { + {"help", 0, NULL, 'h'}, + {"sock", 1, NULL, 's'}, + {"jobid", 1, NULL, 'j'}, +}; + +static void usage(char *me) +{ + fprintf(stderr, "usage: %s [option]\n" + "\t-h, --help Shows this screen.\n" + "\t-s, --server LB Proxy socket.\n" + "\t-j, --jobid ID of requested job.\n" + , me); +} + + +int main(int argc, char *argv[]) +{ + edg_wll_Context ctx; + edg_wlc_JobId jobid = NULL; + char *server, *jobid_s, *code; + int opt, err = 0; + + + server = code = jobid_s = NULL; + while ( (opt = getopt_long(argc, argv, "hs:j:c:n:v:", opts, NULL)) != EOF) + switch (opt) { + case 'h': usage(argv[0]); return 0; + case 's': server = strdup(optarg); break; + case 'j': jobid_s = strdup(optarg); break; + case '?': usage(argv[0]); return 1; + } + + if ( !jobid_s ) { fprintf(stderr, "JobId not given\n"); return 1; } + if ( !server ) { fprintf(stderr, "LB proxy socket not given\n"); return 1; } + + if ( (errno = edg_wlc_JobIdParse(jobid_s, &jobid)) ) { perror(jobid_s); return 1; } + + if (globus_module_activate(GLOBUS_COMMON_MODULE) != GLOBUS_SUCCESS) { + fprintf(stderr, "Cannot initialize Globus common module\n"); + exit(1); + } + + edg_wll_InitContext(&ctx); + + edg_wll_SetParam(ctx, EDG_WLL_PARAM_SOURCE, EDG_WLL_SOURCE_USER_INTERFACE); + edg_wll_SetParam(ctx, EDG_WLL_PARAM_LBPROXY_SERVE_SOCK, server); + +/* + if (edg_wll_SetLoggingJob(ctx, jobid, code, EDG_WLL_SEQ_NORMAL)) { + char *et,*ed; + edg_wll_Error(ctx,&et,&ed); + fprintf(stderr,"SetLoggingJob(%s,%s): %s (%s)\n",jobid_s,code,et,ed); + exit(1); + } +*/ + if ( (err = edg_wll_QuerySequenceCodeProxy(ctx, jobid, &code)) ) { + char *et,*ed; + + edg_wll_Error(ctx,&et,&ed); + fprintf(stderr,"%s: edg_wll_QuerySequenceCodeProxy(): %s (%s)\n", + argv[0],et,ed); + free(et); free(ed); + } + + if ( code ) { + puts(code); + free(code); + } + + edg_wll_FreeContext(ctx); + + return err; +} -- 1.8.2.3