All examples build, consumer examples work.
authorZdeněk Šustr <sustr4@cesnet.cz>
Tue, 16 Dec 2008 16:16:57 +0000 (16:16 +0000)
committerZdeněk Šustr <sustr4@cesnet.cz>
Tue, 16 Dec 2008 16:16:57 +0000 (16:16 +0000)
org.glite.lb.doc/examples/README
org.glite.lb.doc/examples/cons_example1.c
org.glite.lb.doc/examples/cons_example2.c
org.glite.lb.doc/examples/cons_example3.c
org.glite.lb.doc/examples/prod_example1.c

index 7f85175..94e640a 100644 (file)
@@ -1,2 +1,19 @@
+
 This directory contains source code of examples from LB Developer's Guide
 To build these examples, set the GLITE_LOCATION variable and run make.
+
+Consumer examples:
+
+cons_example1
+-------------
+Retrieves a list of jobs based on state and destination.
+
+cons_example2
+-------------
+Retrieves a list of jobs based on state and ORed destination conditions.
+
+
+cons_example3
+-------------
+Retrieves a list of jobs based on ORed user tag conditions.
+
index 4b955b1..92f895d 100644 (file)
@@ -14,7 +14,8 @@
 
 static struct option opts[] = {
        {"help",                0,      NULL,   'h'},
-       {"sock",                1,      NULL,   's'},
+       {"server",              1,      NULL,   's'},
+       {"port",                1,      NULL,   'p'},
        {"jobid",               1,      NULL,   'j'},
        {"user",                1,      NULL,   'u'},
 };
@@ -23,7 +24,8 @@ 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-s, --server    Server address.\n"
+                       "\t-p, --port      Query server port.\n"
                        "\t-j, --jobid     ID of requested job.\n"
                        "\t-u, --user      User DN.\n"
                        , me);
@@ -34,19 +36,23 @@ int main(int argc, char *argv[])
 {
        char                       *server, *jobid_s, *user;
        int                                     opt, err = 0;
+       edg_wlc_JobId                   jobid = NULL;
+       long                            i;
+       int port = 0;
 
-       server = code = jobid_s = name = value = NULL;
-       while ( (opt = getopt_long(argc, argv, "hs:j:u:c:n:v:", opts, NULL)) != EOF)
+       server = jobid_s = user = NULL;
+       while ( (opt = getopt_long(argc, argv, "hs:p:j:u:c:n:v:", opts, NULL)) != EOF)
                switch (opt) {
-               case 'h': usage(name); return 0;
+               case 'h': usage(argv[0]); return 0;
                case 's': server = strdup(optarg); break;
+               case 'p': port = atoi(optarg); break;
                case 'j': jobid_s = strdup(optarg); break;
                case 'u': user = strdup(optarg); break;
-               case '?': usage(name); return 1;
+               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 ( !server ) { fprintf(stderr, "LB proxy socket not given\n"); return 1; }
 
        /*variables*/
        edg_wll_Context         ctx;
@@ -61,7 +67,7 @@ int main(int argc, char *argv[])
        edg_wll_InitContext(&ctx);
        
        edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER, server);
-       edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER_PORT, port);
+       if (port) edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER_PORT, port);
        /*end context*/
 
        /*queryrec*/
@@ -82,7 +88,7 @@ int main(int argc, char *argv[])
        if ( err == E2BIG ) {
                fprintf(stderr,"Warning: only limited result returned!\n");
                return 0;
-       } elseif (err) {
+       } else if (err) {
                char    *et,*ed;
                
                edg_wll_Error(ctx,&et,&ed);
index 4a00e4e..905942c 100644 (file)
@@ -14,7 +14,8 @@
 
 static struct option opts[] = {
        {"help",                0,      NULL,   'h'},
-       {"sock",                1,      NULL,   's'},
+       {"server",              1,      NULL,   's'},
+       {"port",                1,      NULL,   'p'},
        {"jobid",               1,      NULL,   'j'},
        {"user",                1,      NULL,   'u'},
 };
@@ -23,7 +24,8 @@ 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-s, --server    LB server.\n"
+                       "\t-p, --port      LB server port.\n"
                        "\t-j, --jobid     ID of requested job.\n"
                        "\t-u, --user      User DN.\n"
                        , me);
@@ -33,20 +35,23 @@ static void usage(char *me)
 int main(int argc, char *argv[])
 {
        char                       *server, *jobid_s, *user;
+       edg_wlc_JobId                   jobid = NULL;
        int                                     opt, err = 0;
+       long                            i;
+       int port = 0; 
 
-       server = code = jobid_s = name = value = NULL;
-       while ( (opt = getopt_long(argc, argv, "hs:j:u:c:n:v:", opts, NULL)) != EOF)
+       server = jobid_s = user = NULL;
+       while ( (opt = getopt_long(argc, argv, "hs:p:j:u:c:n:v:", opts, NULL)) != EOF)
                switch (opt) {
-               case 'h': usage(name); return 0;
+               case 'h': usage(argv[0]); return 0;
                case 's': server = strdup(optarg); break;
+               case 'p': port = atoi(optarg); break;
                case 'j': jobid_s = strdup(optarg); break;
                case 'u': user = strdup(optarg); break;
-               case '?': usage(name); return 1;
+               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; }
 
        /*variables*/
        edg_wll_Context         ctx;
@@ -61,7 +66,7 @@ int main(int argc, char *argv[])
        edg_wll_InitContext(&ctx);
        
        edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER, server);
-       edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER_PORT, port);
+       if (port) edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER_PORT, port);
        /*end context*/
 
        /*queryrec*/
@@ -97,7 +102,7 @@ int main(int argc, char *argv[])
        if ( err == E2BIG ) {
                fprintf(stderr,"Warning: only limited result returned!\n");
                return 0;
-       } elseif (err) {
+       } else if (err) {
                char    *et,*ed;
                
                edg_wll_Error(ctx,&et,&ed);
index 2d92d4a..6d226e1 100644 (file)
@@ -14,7 +14,8 @@
 
 static struct option opts[] = {
        {"help",                0,      NULL,   'h'},
-       {"sock",                1,      NULL,   's'},
+       {"server",              1,      NULL,   's'},
+       {"port",                1,      NULL,   'p'},
        {"jobid",               1,      NULL,   'j'},
        {"user",                1,      NULL,   'u'},
 };
@@ -23,7 +24,8 @@ 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-s, --server    LB server.\n"
+                       "\t-p, --port      LB server port.\n"
                        "\t-j, --jobid     ID of requested job.\n"
                        "\t-u, --user      User DN.\n"
                        , me);
@@ -34,19 +36,23 @@ int main(int argc, char *argv[])
 {
        char                       *server, *jobid_s, *user;
        int                                     opt, err = 0;
+       edg_wlc_JobId                   jobid = NULL;
+       long                            i;
+       int port = 0;
 
-       server = code = jobid_s = name = value = NULL;
-       while ( (opt = getopt_long(argc, argv, "hs:j:u:c:n:v:", opts, NULL)) != EOF)
+
+       server = jobid_s = NULL;
+       while ( (opt = getopt_long(argc, argv, "hs:p:j:u:c:n:v:", opts, NULL)) != EOF)
                switch (opt) {
-               case 'h': usage(name); return 0;
+               case 'h': usage(argv[0]); return 0;
                case 's': server = strdup(optarg); break;
+               case 'p': port = atoi(optarg); break;
                case 'j': jobid_s = strdup(optarg); break;
                case 'u': user = strdup(optarg); break;
-               case '?': usage(name); return 1;
+               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; }
 
        /*variables*/
        edg_wll_Context     ctx;
@@ -61,7 +67,7 @@ int main(int argc, char *argv[])
        edg_wll_InitContext(&ctx);
        
        edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER, server);
-       edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER_PORT, port);
+       if (port) edg_wll_SetParam(ctx, EDG_WLL_PARAM_QUERY_SERVER_PORT, port);
        /*end context*/
 
        /*queryrec*/
@@ -84,7 +90,7 @@ int main(int argc, char *argv[])
        if ( err == E2BIG ) {
                fprintf(stderr,"Warning: only limited result returned!\n");
                return 0;
-       } elseif (err) {
+       } else if (err) {
                char    *et,*ed;
                
                edg_wll_Error(ctx,&et,&ed);
@@ -93,15 +99,17 @@ int main(int argc, char *argv[])
                free(et); free(ed);
        }
 
+       if ( err == ENOENT ) return err;
+
        /*printevents*/
-       for (i = 0; eventsOut[i].type; i++ ) {
-               printf("jobId : %s\n", edg_wlc_JobIdUnparse(eventsOut[i].jobId));
+       for (i = 0; eventsOut && (eventsOut[i].type); i++ ) {
+               //printf("jobId : %s\n", edg_wlc_JobIdUnparse(eventsOut[i].jobId));
                printf("event : %s\n\n", edg_wll_EventToString(eventsOut[i].type));
        }
        /*end printevents*/
 
        if ( eventsOut ) {
-               for (i=0; eventsOut[i]; i++) edg_wlc_JobIdFree(eventsOut[i]);
+               for (i=0; &(eventsOut[i]); i++) edg_wll_FreeEvent(&(eventsOut[i]));
                free(eventsOut);
        }
 
index 9e8d911..b0e891a 100644 (file)
@@ -42,17 +42,17 @@ int main(int argc, char *argv[])
        int                                     opt, err = 0;
 
 
-       server = code = jobid_s = name = value = NULL;
+       server = seq_code = jobid_s = name = value = NULL;
        while ( (opt = getopt_long(argc, argv, "hs:j:u:c:n:v:", opts, NULL)) != EOF)
                switch (opt) {
-               case 'h': usage(name); return 0;
+               case 'h': usage(argv[0]); return 0;
                case 's': server = strdup(optarg); break;
                case 'j': jobid_s = strdup(optarg); break;
                case 'u': user = strdup(optarg); break;
                case 'c': seq_code = strdup(optarg); break;
                case 'n': name = strdup(optarg); break;
                case 'v': value = strdup(optarg); break;
-               case '?': usage(name); return 1;
+               case '?': usage(argv[0]); return 1;
                }
 
        if ( !jobid_s ) { fprintf(stderr, "JobId not given\n"); return 1; }
@@ -71,7 +71,7 @@ int main(int argc, char *argv[])
        
        edg_wll_SetParam(ctx, EDG_WLL_PARAM_SOURCE, EDG_WLL_SOURCE_USER_INTERFACE);
        edg_wll_SetParam(ctx, EDG_WLL_PARAM_HOST, server);
-       edg_wll_SetParam(ctx, EDG_WLL_PARAM_PORT, port);
+       //edg_wll_SetParam(ctx, EDG_WLL_PARAM_PORT, port);
        /*end context*/
 
        /*sequence*/