initial implementation of state_history
authorAleš Křenek <ljocha@ics.muni.cz>
Wed, 15 Oct 2008 16:53:31 +0000 (16:53 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Wed, 15 Oct 2008 16:53:31 +0000 (16:53 +0000)
org.glite.lb.utils/Makefile
org.glite.lb.utils/src/state_history.c [new file with mode: 0644]

index 3679bc5..c1634ff 100644 (file)
@@ -55,7 +55,7 @@ COMMON_LIB:=-lglite_lb_common_${nothrflavour}
 CLIENT_LIB:=-lglite_lb_client_${nothrflavour}
 JP_LIBS:=-lglite_jp_common_${nothrflavour}
 
-UTILS:=mon purge dump load dump_exporter
+UTILS:=mon purge dump load dump_exporter state_history
 STATISTICS_OBJS:=statistics.o process_attrs.o process_attrs2.o
 
 MAN_GZ:=glite-lb-mon.1.gz
@@ -72,6 +72,9 @@ ${UTILS}: %: %.o
 statistics: ${STATISTICS_OBJS}
        ${LINK} -rdynamic -o $@ ${STATISTICS_OBJS} ${COMMON_LIB} ${JP_LIBS} ${EXT_LIBS} 
 
+state_history: state_history.o
+       ${LINK} -o $@ state_history.o -L${stagedir}/lib -lglite_lb_statemachine ${CLIENT_LIB} ${COMMON_LIB}
+
 check: compile 
 
 doc: ${MAN_GZ}
diff --git a/org.glite.lb.utils/src/state_history.c b/org.glite.lb.utils/src/state_history.c
new file mode 100644 (file)
index 0000000..6fbdf6a
--- /dev/null
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "glite/lb/context.h"
+#include "glite/lb/consumer.h"
+
+#include "glite/lb/intjobstat.h"
+#include "glite/lb/seqcode_aux.h"
+
+/*comment */
+
+int main (int argc, char ** argv)
+{
+       edg_wll_Context ctx;
+       edg_wll_QueryRec        jc[2];
+       edg_wll_Event   *events;
+       int     i,n;
+       intJobStat      is;
+
+       memset(&jc,0,sizeof jc);
+       if (argc != 2 || glite_jobid_parse(argv[1],&jc[0].value.j)) {
+               fprintf(stderr,"usage: %s <jobid>\n",argv[0]);
+               return 1;
+       }
+
+
+       edg_wll_InitContext(&ctx);
+       jc[0].attr = EDG_WLL_QUERY_ATTR_JOBID;
+       jc[0].op = EDG_WLL_QUERY_OP_EQUAL;
+
+       if (edg_wll_QueryEvents(ctx,jc,NULL,&events)) {
+               char    *ed,*et;
+               edg_wll_Error(ctx,&et,&ed);
+               fprintf(stderr,"%s: %s (%s)\n",argv[1],et,ed);
+               return 1;
+       }
+
+       for (n=0; events[n].type; n++);
+
+       init_intJobStat(&is);
+
+       qsort(events,n,sizeof *events,compare_events_by_seq);
+
+       for (i=0; i<n; i++) {
+               char    *err;
+               if (processEvent(&is,events+i,0,0,&err) == RET_FATAL) {
+                       fprintf(stderr,"event %d: %s\n",i,err);
+                       return 1;
+               }
+
+               printf ("%s %s\n",edg_wll_EventToString(events[i].type),
+                               edg_wll_StatToString(is.pub.state));
+       }
+
+       return 0;
+}