- jobtype switch in processEvent()
authorAleš Křenek <ljocha@ics.muni.cz>
Wed, 24 Jan 2007 15:17:23 +0000 (15:17 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Wed, 24 Jan 2007 15:17:23 +0000 (15:17 +0000)
- trivial processEvent for PBS jobs

org.glite.lb.server/Makefile
org.glite.lb.server/src/jobstat.h
org.glite.lb.server/src/jobstat_supp.c
org.glite.lb.server/src/process_event.c
org.glite.lb.server/src/process_event_pbs.c [new file with mode: 0644]

index 673d283..0b875ae 100644 (file)
@@ -170,10 +170,10 @@ COMMON_LIBS:= -L${stagedir}/lib  -lglite_lb_common_${nothrflavour} -lglite_secur
 PLUGIN_LIBS:= -L${stagedir}/lib -lglite_lb_common_${nothrflavour}\
        ${classadslib} -lstdc++ ${expatlib} -lexpat\
 
-PLUGIN_LOBJS:= lb_plugin.lo jobstat_supp.lo process_event.lo lbs_db_supp.lo
+PLUGIN_LOBJS:= lb_plugin.lo jobstat_supp.lo process_event.lo lbs_db_supp.lo process_event_pbs.lo
 
 BKSERVER_BASE_OBJS:= \
-       bkserverd.o il_lbproxy.o get_events.o index.o jobstat.o jobstat_supp.o process_event.o \
+       bkserverd.o il_lbproxy.o get_events.o index.o jobstat.o jobstat_supp.o process_event.o process_event_pbs.o \
        seqcode.o write2rgma.o lbs_db.o lbs_db_supp.o lb_html.o lb_http.o lb_proto.o lb_xml_parse.o \
        lb_xml_parse_V21.o \
        lock.o openserver.o query.o userjobs.o db_store.o request.o store.o \
@@ -205,7 +205,7 @@ else
 endif
 
 INDEX_OBJS:= index.o index_parse.o jobstat_supp.o lbs_db.o lbs_db_supp.o openserver.o \
-       jobstat.o process_event.o query.o lock.o get_events.o write2rgma.o index_lex.o \
+       jobstat.o process_event.o process_event_pbs.o query.o lock.o get_events.o write2rgma.o index_lex.o \
        lb_authz.o store.o bkindex.o stats.o\
        request.o db_store.o srv_purge.o notif_match.o il_lbproxy.o dump.o lb_xml_parse.o il_notification.o lb_proto.o server_state.o lb_xml_parse_V21.o lb_html.o notification.o seqcode.o userjobs.o load.o
 
@@ -226,7 +226,7 @@ WS_CLIENT_LIBS:= ${GSOAP_LIB} -lglite_lb_common_${nothrflavour} \
 HDRS=index.h lb_authz.h lbs_db.h store.h
 
 LIB_OBJS_BK:= \
-       il_lbproxy.o get_events.o index.o jobstat.o jobstat_supp.o process_event.o \
+       il_lbproxy.o get_events.o index.o jobstat.o jobstat_supp.o process_event.o process_event_pbs.o \
        seqcode.o lbs_db.o lbs_db_supp.o lb_html.o lb_http.o lb_proto.o lb_xml_parse.o \
        lb_xml_parse_V21.o \
        lock.o openserver.o query.o userjobs.o db_store.o request.o store.o \
index 2d346db..17b5fc7 100644 (file)
@@ -79,6 +79,7 @@ int same_branch(const char *, const char *);
 int component_seqcode(const char *a, edg_wll_Source index);
 char * set_component_seqcode(char *s,edg_wll_Source index,int val);
 int processEvent(intJobStat *, edg_wll_Event *, int, int, char **);
+int processEvent_PBS(intJobStat *, edg_wll_Event *, int, int, char **);
 
 int add_stringlist(char ***, const char *);
 int edg_wll_compare_seq(const char *, const char *);
index c665cf6..dfff581 100644 (file)
@@ -869,8 +869,8 @@ static int compare_events_by_seq(const void *a, const void *b)
 
 static int compare_pevents_by_seq(const void *a, const void *b)
 {
-        const edg_wll_Event **e = (edg_wll_Event **) a;
-        const edg_wll_Event **f = (edg_wll_Event **) b;
+        const edg_wll_Event **e = (const edg_wll_Event **) a;
+        const edg_wll_Event **f = (const edg_wll_Event **) b;
        return compare_events_by_seq(*e,*f);
 }
 
@@ -900,7 +900,7 @@ void edg_wll_SortPEvents(edg_wll_Event **e)
 void init_intJobStat(intJobStat *p)
 {
        memset(p, 0, sizeof(intJobStat));
-       p->pub.jobtype = EDG_WLL_STAT_SIMPLE;
+       p->pub.jobtype = -1 /* why? EDG_WLL_STAT_SIMPLE */;
        p->pub.children_hist = (int*) calloc(1+EDG_WLL_NUMBER_OF_STATCODES, sizeof(int));
        p->pub.children_hist[0] = EDG_WLL_NUMBER_OF_STATCODES;
        p->pub.stateEnterTimes = (int*) calloc(1+EDG_WLL_NUMBER_OF_STATCODES, sizeof(int));
index 573a163..7133219 100644 (file)
 #define UNUSED_VAR
 #endif
 
+static int processEvent_glite(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring);
+
+int processEvent(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring)
+{
+       if (js->pub.jobtype == -1 && e->type == EDG_WLL_EVENT_REGJOB)
+               switch (e->regJob.jobtype) {
+                       case EDG_WLL_REGJOB_SIMPLE:
+                               js->pub.jobtype = EDG_WLL_STAT_SIMPLE;
+                               break;
+                       case EDG_WLL_REGJOB_DAG: 
+                       case EDG_WLL_REGJOB_PARTITIONABLE:
+                       case EDG_WLL_REGJOB_PARTITIONED:
+                               js->pub.jobtype = EDG_WLL_STAT_DAG;
+                               break;
+                       case EDG_WLL_REGJOB_COLLECTION:
+                               js->pub.jobtype = EDG_WLL_STAT_COLLECTION;
+                               break;
+                       case EDG_WLL_REGJOB_PBS:
+                               js->pub.jobtype = EDG_WLL_STAT_PBS;
+                               break;
+                       default:
+                               asprintf(errstring,"unknown job type %d in registration",e->regJob.jobtype);
+                               return RET_FAIL;
+       }
+
+       switch (js->pub.jobtype) {
+               case EDG_WLL_STAT_SIMPLE:
+               case EDG_WLL_STAT_DAG:
+               case EDG_WLL_STAT_COLLECTION:
+                       return processEvent_glite(js,e,ev_seq,strict,errstring);
+               case EDG_WLL_STAT_PBS: 
+                       return processEvent_PBS(js,e,ev_seq,strict,errstring);
+               default: 
+                       asprintf(errstring,"undefined job type %d",js->pub.jobtype);
+                       return RET_FAIL;
+       }
+}
+
 #define rep(a,b) { free(a); a = (b == NULL) ? NULL : strdup(b); }
 
 static void free_stringlist(char ***lptr)
@@ -218,7 +256,7 @@ static int badEvent(intJobStat *js UNUSED_VAR, edg_wll_Event *e, int ev_seq UNUS
 #define LRMS_STATE(state) ((state) == EDG_WLL_JOB_RUNNING || (state) == EDG_WLL_JOB_DONE)
 #define PARSABLE_SEQCODE(code) (component_seqcode((code),0) >= 0)
 
-int processEvent(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring)
+static int processEvent_glite(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring)
 {
        edg_wll_JobStatCode     old_state = js->pub.state;
        enum edg_wll_StatDone_code      old_done_code = js->pub.done_code;
diff --git a/org.glite.lb.server/src/process_event_pbs.c b/org.glite.lb.server/src/process_event_pbs.c
new file mode 100644 (file)
index 0000000..264e9d1
--- /dev/null
@@ -0,0 +1,30 @@
+#ident "$Header$"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <assert.h>
+#include <syslog.h>
+
+#include "glite/lb/producer.h"
+#include "glite/lb/context-int.h"
+
+#include "jobstat.h"
+#include "lock.h"
+
+/* TBD: share in whole logging or workload */
+#ifdef __GNUC__
+#define UNUSED_VAR __attribute__((unused))
+#else
+#define UNUSED_VAR
+#endif
+
+int processEvent_PBS(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring)
+{
+       fputs("processEvent_PBS()",stderr);
+
+       if (! js->pub.location) js->pub.location = strdup("this is PBS");
+       return RET_OK;
+}
+