From 641027a3c14451bae7d702a73749cb94cdd7028e Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Mon, 28 Feb 2005 07:56:04 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create branch 'glite-lb- client_branch_1_0_0'. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Cherrypick from master 2005-02-28 07:56:03 UTC František Dvořák 'Compile referenced job_status example.': org.glite.lb.client/examples/job_status.c --- org.glite.lb.client/examples/job_status.c | 232 ++++++++++++++++++++++++++++++ 1 file changed, 232 insertions(+) create mode 100644 org.glite.lb.client/examples/job_status.c diff --git a/org.glite.lb.client/examples/job_status.c b/org.glite.lb.client/examples/job_status.c new file mode 100644 index 0000000..dd25c45 --- /dev/null +++ b/org.glite.lb.client/examples/job_status.c @@ -0,0 +1,232 @@ +#ident "$Header$" + +#include +#include +#include +#include +#include + +#include + +#include "glite/lb/context-int.h" +#include "glite/lb/consumer.h" +#include "glite/lb/xml_conversions.h" + +static void dgerr(edg_wll_Context,char *); +static void printstat(edg_wll_JobStat,int); + +#define MAX_SERVERS 20 + +static char *myname; + + +int main(int argc,char *argv[]) +{ + edg_wll_Context ctx, sctx[MAX_SERVERS]; + int i, result=0, nsrv=0; + char *servers[MAX_SERVERS]; + char *errstr = NULL; + + + myname = argv[0]; + printf("\n"); + + if (argc < 2 || strcmp(argv[1],"--help") == 0) { + fprintf(stderr,"Usage: %s job_id [job_id [...]]\n",argv[0]); + fprintf(stderr," %s -all\n",argv[0]); + return 1; + } + else if (argc >= 2 && strcmp(argv[1],"-all") == 0) { + edg_wll_JobStat *statesOut; + edg_wlc_JobId *jobsOut; + edg_wll_QueryRec jc[2]; + + jobsOut = NULL; + statesOut = NULL; +/* init context */ + if (edg_wll_InitContext(&ctx)) { + fprintf(stderr,"%s: cannot initialize edg_wll_Context\n",myname); + exit(1); + } +/* retrieve job ID's */ + memset(jc,0,sizeof jc); + + jc[0].attr = EDG_WLL_QUERY_ATTR_OWNER; + jc[0].op = EDG_WLL_QUERY_OP_EQUAL; + jc[0].value.c = NULL; /* is NULL, peerName filled in on server side */ + jc[1].attr = EDG_WLL_QUERY_ATTR_UNDEF; + + //if (edg_wll_QueryJobs(ctx,jc,EDG_WLL_STAT_CLASSADS | EDG_WLL_STAT_CHILDREN | EDG_WLL_STAT_CHILDSTAT, + result = edg_wll_QueryJobs(ctx,jc,0,&jobsOut, &statesOut); + if (result == E2BIG) { + int r; + edg_wll_Error(ctx, NULL, &errstr); + if (edg_wll_GetParam(ctx, EDG_WLL_PARAM_QUERY_RESULTS, &r)) { + dgerr(ctx,"edg_wll_GetParam(EDG_WLL_PARAM_QUERY_RESULTS)"); + free(errstr); + result=1; goto cleanup; + } + if (r != EDG_WLL_QUERYRES_LIMITED) goto late_error; + } else if (result) { + dgerr(ctx,"edg_wll_QueryJobs"); + result=1; goto cleanup; + } + +/* retrieve and print status of each job */ + for (i=0; statesOut[i].state; i++) + printstat(statesOut[i],0); + +late_error: if (result) { + edg_wll_SetError(ctx, result, errstr); + free(errstr); + dgerr(ctx,"edg_wll_QueryJobs"); + result=1; + } + +cleanup: + if (jobsOut) + { + for (i=0; jobsOut[i]; i++) edg_wlc_JobIdFree(jobsOut[i]); + free(jobsOut); + } + if (statesOut) + { + for (i=0; statesOut[i].state; i++) edg_wll_FreeStatus(&statesOut[i]); + free(statesOut); + } + edg_wll_FreeContext(ctx); + } + else { + for (i=1; i