From 148f5c6ddc24a29034b3435fdadfa48cd173829a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ale=C5=A1=20K=C5=99enek?= Date: Wed, 24 Jan 2007 15:17:23 +0000 Subject: [PATCH] - jobtype switch in processEvent() - trivial processEvent for PBS jobs --- org.glite.lb.server/Makefile | 8 +++--- org.glite.lb.server/src/jobstat.h | 1 + org.glite.lb.server/src/jobstat_supp.c | 6 ++--- org.glite.lb.server/src/process_event.c | 40 ++++++++++++++++++++++++++++- org.glite.lb.server/src/process_event_pbs.c | 30 ++++++++++++++++++++++ 5 files changed, 77 insertions(+), 8 deletions(-) create mode 100644 org.glite.lb.server/src/process_event_pbs.c diff --git a/org.glite.lb.server/Makefile b/org.glite.lb.server/Makefile index 673d283..0b875ae 100644 --- a/org.glite.lb.server/Makefile +++ b/org.glite.lb.server/Makefile @@ -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 \ diff --git a/org.glite.lb.server/src/jobstat.h b/org.glite.lb.server/src/jobstat.h index 2d346db..17b5fc7 100644 --- a/org.glite.lb.server/src/jobstat.h +++ b/org.glite.lb.server/src/jobstat.h @@ -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 *); diff --git a/org.glite.lb.server/src/jobstat_supp.c b/org.glite.lb.server/src/jobstat_supp.c index c665cf6..dfff581 100644 --- a/org.glite.lb.server/src/jobstat_supp.c +++ b/org.glite.lb.server/src/jobstat_supp.c @@ -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)); diff --git a/org.glite.lb.server/src/process_event.c b/org.glite.lb.server/src/process_event.c index 573a163..7133219 100644 --- a/org.glite.lb.server/src/process_event.c +++ b/org.glite.lb.server/src/process_event.c @@ -20,6 +20,44 @@ #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 index 0000000..264e9d1 --- /dev/null +++ b/org.glite.lb.server/src/process_event_pbs.c @@ -0,0 +1,30 @@ +#ident "$Header$" + +#include +#include +#include +#include +#include +#include + +#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; +} + -- 1.8.2.3