specific WMS example
authorAleš Křenek <ljocha@ics.muni.cz>
Wed, 27 Jan 2010 11:54:01 +0000 (11:54 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Wed, 27 Jan 2010 11:54:01 +0000 (11:54 +0000)
org.glite.lb.client/Makefile
org.glite.lb.client/examples/done_failed_events.c [new file with mode: 0644]

index 2e3903c..34a1dc0 100644 (file)
@@ -147,7 +147,7 @@ PLUSLIB:=libglite_lb_clientpp_${nothrflavour}.la
 THRPLUSLIB:=libglite_lb_clientpp_${thrflavour}.la
 
 TOOLS:=${LB_PERF_TOOLS}
-EXAMPLES_SRC:=log_usertag_proxy.c job_log.c job_reg.c feed_shark.c query_ext.c query_seq_code.c stats.c abort_job.c change_acl.c stresslog.c flood_proxy.c dagids.c stress_context.c parse_eventsfile.c test_changed_jdl.c reg_sandbox_transfer.c
+EXAMPLES_SRC:=log_usertag_proxy.c job_log.c job_reg.c feed_shark.c query_ext.c query_seq_code.c stats.c abort_job.c change_acl.c stresslog.c flood_proxy.c dagids.c stress_context.c parse_eventsfile.c test_changed_jdl.c reg_sandbox_transfer.c done_failed_events.c
 EXAMPLES:=${EXAMPLES_SRC:.c=}
 
 # TODO: migrate them here from branch_RC31_3
diff --git a/org.glite.lb.client/examples/done_failed_events.c b/org.glite.lb.client/examples/done_failed_events.c
new file mode 100644 (file)
index 0000000..46463c2
--- /dev/null
@@ -0,0 +1,111 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <ctype.h>
+#include <time.h>
+
+#include "glite/jobid/cjobid.h"
+#ifdef BUILDING_LB_CLIENT
+#include "consumer.h"
+#else
+#include "glite/lb/consumer.h"
+#endif
+
+static void usage(char *me) {
+       fprintf(stderr,"usage: %s: YYYY-MM-DD:HH:MI YYYY-MM-DD:HH:MI\n"
+                       "\t times specify interval to query\n",me
+               );
+       exit(1);
+}
+
+int main(int argc,char **argv) {
+       edg_wll_Context ctx;
+       struct tm       tm;
+       time_t  from,to;
+       int     i, err = 0;
+
+       edg_wll_QueryRec        cond[3];        /* [2] is terminator */
+       edg_wll_Event   *events = NULL;
+
+       edg_wll_InitContext(&ctx);
+
+       if (argc != 3) usage(argv[0]);
+
+       
+       memset(&tm,0,sizeof tm);
+
+       if (sscanf(argv[1],"%d-%d-%d:%d:%d",
+               &tm.tm_year,
+               &tm.tm_mon,
+               &tm.tm_mday,
+               &tm.tm_hour,
+               &tm.tm_min) != 5) usage(argv[0]);
+
+       tm.tm_mon--;
+       tm.tm_year -= 1900;
+
+       from = mktime(&tm);
+       
+       if (sscanf(argv[2],"%d-%d-%d:%d:%d",
+               &tm.tm_year,
+               &tm.tm_mon,
+               &tm.tm_mday,
+               &tm.tm_hour,
+               &tm.tm_min) != 5) usage(argv[0]);
+
+       tm.tm_mon--;
+       tm.tm_year -= 1900;
+
+       to = mktime(&tm);
+
+       memset(cond,0,sizeof cond);
+       cond[0].attr = EDG_WLL_QUERY_ATTR_TIME;
+       cond[0].op = EDG_WLL_QUERY_OP_WITHIN;
+       cond[0].value.t.tv_sec = from;
+       cond[0].value2.t.tv_sec = to;
+
+       cond[1].attr = EDG_WLL_QUERY_ATTR_EVENT_TYPE;
+       cond[1].value.i = EDG_WLL_EVENT_DONE;
+       
+       if (edg_wll_QueryEventsProxy(ctx,NULL,cond,&events)) {
+               char    *et,*ed;
+               et = ed = NULL;
+
+               edg_wll_Error(ctx,&et,&ed);
+               fprintf(stderr,"edg_wll_QueryEventsProxy: %s, %s\n",
+                       et,ed ? ed : "");
+
+               free(et); free(ed);
+               err = 1;
+               goto cleanup;
+       }
+
+       for (i=0; events[i].type; i++) {
+               edg_wll_Event   *e = events+i;
+
+               if (e->done.status_code == EDG_WLL_DONE_FAILED) {
+                       char    *job = glite_jobid_unparse(e->any.jobId);
+
+                       printf("%s\t%s\t%s\t%s\n",
+                               job,
+                               ctime(&e->done.timestamp.tv_sec),
+                               e->done.host,
+                               e->done.reason
+                               );
+
+                       free(job);
+               }
+       }
+                               
+cleanup:
+       if (events) {
+               for (i=0; events[i].type; i++) edg_wll_FreeEvent(events+i);
+               free(events); events = NULL;
+       }
+
+       edg_wll_FreeContext(ctx);
+
+       return err;
+}