support for shallow resubmission
authorMiloš Mulač <mulac@civ.zcu.cz>
Fri, 3 Jun 2005 14:05:02 +0000 (14:05 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Fri, 3 Jun 2005 14:05:02 +0000 (14:05 +0000)
- not finished, for sharing

org.glite.lb.server/Makefile
org.glite.lb.server/src/get_events.h
org.glite.lb.server/src/jobstat.c
org.glite.lb.server/src/jobstat.h
org.glite.lb.server/src/jobstat_supp.c

index faed144..21be906 100644 (file)
@@ -20,11 +20,10 @@ gsoap_prefix=/opt/gsoap
 
 -include Makefile.inc
 
-GLITE_LB_SERVER_WITH_WS=yes
+GLITE_LB_SERVER_WITH_WS=no
 
 ifeq ($(GLITE_LB_SERVER_WITH_WS),yes)
-       gsoap_version=`${gsoap_prefix}/bin/soapcpp2 -version 2>&1 | cut -d' ' -f4 | perl -F\\\\. -nae '$$F[2] =~ s/\D*$$//; print $$F[2]+100*$$F[1]+10000*$$F[0]'`
-       WS_CFLAGS=-DGLITE_LB_SERVER_WITH_WS -DGSOAP_VERSION=${gsoap_version}
+       WS_CFLAGS=-DGLITE_LB_SERVER_WITH_WS 
 else
        WS_CFLAGS=
 endif
@@ -76,7 +75,7 @@ GLOBUS_LIBS:= -L${globus_prefix}/lib \
        -lglobus_gssapi_gsi_${nothrflavour} \
 
 ifneq (${mysql_prefix},/usr)
-       myslqlib := -L${mysql_prefix}/lib
+       myslqlib := -L${mysql_prefix}/lib/mysql
 endif
 
 ifneq (${expat_prefix},/usr)
@@ -118,32 +117,34 @@ ifeq ($(GLITE_LB_SERVER_WITH_WS),yes)
                ws_query.o ws_fault.o ws_typeref.o 
 
        BKSERVER_LIBS= \
-               ${EXT_LIBS} \
                ${SRVBONES_LIB} \
                -lglite_lb_common_${nothrflavour} \
                -L${gsoap_prefix}/lib -lgsoap \
-               -lglite_security_gsoap_plugin_${nothrflavour}
+               -lglite_security_gsoap_plugin_${nothrflavour} \
+               ${EXT_LIBS}
 else
+       BKSERVER_OBJS:= ${BKSERVER_BASE_OBJS}
+               
        BKSERVER_LIBS= \
-               ${EXT_LIBS} \
                ${SRVBONES_LIB} \
                -lglite_lb_common_${nothrflavour} \
-               -lglite_security_gss_${nothrflavour}
+               -lglite_security_gss_${nothrflavour} \
+               ${EXT_LIBS}
 endif
 
 INDEX_OBJS:= index.o index_parse.o jobstat_supp.o lbs_db.o openserver.o \
        jobstat.o query.o lock.o get_events.o write2rgma.o index_lex.o \
        lb_authz.o store.o bkindex.o
 
-INDEX_LIBS:= ${EXT_LIBS} ${SRVBONES_LIB} ${COMMON_LIBS}
+INDEX_LIBS:= ${SRVBONES_LIB} ${COMMON_LIBS} ${EXT_LIBS} 
 
 WS_CLIENT_OBJS:= $(GSOAP_FILES_PREFIX)C.o $(GSOAP_FILES_PREFIX)Client.o ws_fault.o ws_typeref.o
 WS_CLIENT_LIBS:= -L${stagedir}/lib \
-               ${EXT_LIBS} \
                -lglite_lb_client_${nothrflavour} \
                -lglite_lb_common_${nothrflavour} \
                -L${gsoap_prefix}/lib -lgsoap \
-               -lglite_security_gsoap_plugin_${nothrflavour}
+               -lglite_security_gsoap_plugin_${nothrflavour} \
+               ${EXT_LIBS}
 
 HDRS=index.h lb_authz.h lbs_db.h store.h
 
@@ -167,7 +168,7 @@ glite_lb_plugin.la: lb_plugin.lo
 
 default all: compile
 
-compile: glite_lb_bkserverd glite_lb_bkindex ${STATIC_LIB_BK} glite_lb_plugin.la
+compile: glite_lb_bkserverd glite_lb_bkindex ${STATIC_LIB_BK}
 
 check: compile test.xml test.query
        -echo check.query not complete yet
@@ -185,8 +186,18 @@ lb_xml_parse.c: lb_xml_parse.c.T
 ${GSOAP_FILES_PREFIX}H.h ${GSOAP_FILES_PREFIX}C.c ${GSOAP_FILES_PREFIX}Server.c ${GSOAP_FILES_PREFIX}Client.c ${GSOAP_FILES_PREFIX}ServerLib.c ${GSOAP_FILES_PREFIX}ClientLib.c LoggingAndBookkeeping.nsmap: LB.xh
        ${gsoap_prefix}/bin/soapcpp2 -w -c -p ${GSOAP_FILES_PREFIX} LB.xh
 
-LB.xh: ws_typemap.dat
+# try several times -- LB.wsdl downloads BaseFault.xsd from www.ibm.com which may be failing
+# not used right now but may be useful one day
+# LB.xh: ws_typemap.dat
+#      ${gsoap_prefix}/bin/wsdl2h -c -t ${top_srcdir}/src/ws_typemap.dat -o $@ ${stagedir}/interface/LB.wsdl || \
+#      { sleep 1 ; ${gsoap_prefix}/bin/wsdl2h -c -t ${top_srcdir}/src/ws_typemap.dat -o $@ ${stagedir}/interface/LB.wsdl; } || \
+#      { sleep 4 ; ${gsoap_prefix}/bin/wsdl2h -c -t ${top_srcdir}/src/ws_typemap.dat -o $@ ${stagedir}/interface/LB.wsdl; } || \
+#      { sleep 16 ; ${gsoap_prefix}/bin/wsdl2h -c -t ${top_srcdir}/src/ws_typemap.dat -o $@ ${stagedir}/interface/LB.wsdl; }
+
+LB.xh: ws_typemap.dat ${stagedir}/interface/LB.wsdl
+       cp ${stagedir}/interface/LBTypes.wsdl .
        ${gsoap_prefix}/bin/wsdl2h -c -t ${top_srcdir}/src/ws_typemap.dat -o $@ ${stagedir}/interface/LB.wsdl
+       rm -f LBTypes.wsdl
 
 test.xml: test_xml
        ./test_xml
@@ -302,3 +313,9 @@ test_query_events.o: %.o: %.cpp
 %.lo: %.c
        ${COMPILE} -o $@ -c $<
 
+soap_version.h:
+       ${gsoap_prefix}/bin/soapcpp2 /dev/null
+       perl -ne '$$. == 2 && /.*([0-9])\.([0-9])\.([0-9]).*/ && printf "#define GSOAP_VERSION %d%02d%02d\n",$$1,$$2,$$3' soapH.h >$@
+       -rm soapC.cpp soapH.h soapStub.h soapClient.cpp soapServer.cpp soapClientLib.cpp soapServerLib.cpp
+
+bkserverd.o ws_fault.o: soap_version.h
index cfa07c1..1f64629 100644 (file)
@@ -25,6 +25,7 @@ int edg_wll_QueryJobsServer(edg_wll_Context, const edg_wll_QueryRec **, int, edg
 
 void edg_wll_SortEvents(edg_wll_Event *);
 int edg_wll_compare_seq(const char *, const char *);
+int edg_wll_compare_seq_full(const char *, const char *, const char *);
 
 #ifdef __cplusplus
 }
index 00a8aa4..4a2de3c 100644 (file)
@@ -48,6 +48,7 @@ static void warn (const char* format, ...) UNUSED_VAR ;
 static char *job_owner(edg_wll_Context,char *);
 static char* location_string(const char*, const char*, const char*);
 static int add_stringlist(char ***, const char *) UNUSED_VAR;
+static void free_stringlist(char ***);
 static int add_taglist(edg_wll_TagValue **, const char *, const char *);
 
 
@@ -428,7 +429,7 @@ static int processEvent(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict
        }
 
        if (js->last_seqcode != NULL &&
-               edg_wll_compare_seq(e->any.seqcode, js->last_seqcode) < 0) {
+               edg_wll_compare_seq_full(e->any.seqcode, js->last_seqcode, js->wn_seqcode) < 0) {
                res = RET_LATE;
        }
 
@@ -672,8 +673,16 @@ static int processEvent(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict
                        }
                        if (USABLE_DATA(res, strict)) {
                                rep(js->pub.ce_node, e->running.node);
+                               if (e->running.node)
+                                       add_stringlist(&js->pub.possible_ce_nodes, e->running.node);
                        }
                        break;
+               case EDG_WLL_EVENT_REALLYRUNNING:
+                       if (USABLE_DATA(res, strict)) {
+                               rep(js->wn_seqcode, e->reallyRunning.wn_seq);
+                       }
+                       break;
+
                case EDG_WLL_EVENT_RESUBMISSION:
                        if (USABLE(res, strict)) {
                                if (e->resubmission.result == EDG_WLL_RESUBMISSION_WONTRESUB) {
@@ -685,6 +694,16 @@ static int processEvent(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict
                                        js->wontresub = 1;
                                }
                        }
+                       if (USABLE_DATA(res, strict)) {
+                               if (e->resubmission.result == EDG_WLL_RESUBMISSION_WILLRESUB) {
+                                       free_stringlist(&js->pub.possible_destinations);
+                                       free_stringlist(&js->pub.possible_ce_nodes);
+                                       if (js->wn_seqcode) { 
+                                               free(js->wn_seqcode);
+                                               js->wn_seqcode = NULL;
+                                       }
+                               }
+                       }
                        break;
                case EDG_WLL_EVENT_DONE:
                        if (e->any.source == EDG_WLL_SOURCE_LRMS) {
@@ -726,7 +745,7 @@ static int processEvent(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict
                        break;
                case EDG_WLL_EVENT_CANCEL:
                        if (js->last_cancel_seqcode != NULL &&
-                               edg_wll_compare_seq(e->any.seqcode, js->last_cancel_seqcode) < 0) {
+                               edg_wll_compare_seq_full(e->any.seqcode, js->last_cancel_seqcode, js->wn_seqcode) < 0) {
                                res = RET_LATE;
                        } 
                        if (USABLE(res, strict)) {
@@ -792,6 +811,8 @@ static int processEvent(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict
                        }
                        if (USABLE_DATA(res, strict)) {
                                rep(js->pub.destination, e->match.dest_id);
+                               if (e->match.dest_id) 
+                                       add_stringlist(&js->pub.possible_destinations, e->match.dest_id);
                        }
                        break;
                case EDG_WLL_EVENT_PENDING:
@@ -1009,6 +1030,19 @@ static int add_stringlist(char ***lptr, const char *new_item)
        }
 }
 
+static void free_stringlist(char ***lptr)
+{
+       char **itptr;
+       int i;
+
+       if (*lptr) {
+               for (i = 0, itptr = *lptr; itptr[i] != NULL; i++) 
+                       free(itptr[i]);
+               free(itptr);
+               *lptr = NULL;
+       }
+}
+
 static int add_taglist(edg_wll_TagValue **lptr, const char *new_item, const char *new_item2)
 {
        edg_wll_TagValue        *itptr;
index 1b17c7b..8c5dbee 100644 (file)
@@ -13,6 +13,7 @@ typedef struct _intJobStat {
                int             wontresub;
                char            *last_seqcode;
                char            *last_cancel_seqcode;
+               char            *wn_seqcode;
 
 /*             int             expect_mask; */
        } intJobStat;
index 3f4f3ad..0c9e34e 100644 (file)
@@ -412,6 +412,7 @@ char *enc_intJobStat(char *old, intJobStat* stat)
        if (ret) ret = enc_int(ret, stat->wontresub);
        if (ret) ret = enc_string(ret, stat->last_seqcode);
        if (ret) ret = enc_string(ret, stat->last_cancel_seqcode);
+       if (ret) ret = enc_string(ret, stat->wn_seqcode);
        return ret;
 }
 
@@ -435,6 +436,9 @@ intJobStat* dec_intJobStat(char *in, char **rest)
                if (tmp_in != NULL) {
                        stat->last_cancel_seqcode = dec_string(tmp_in, &tmp_in);
                }
+               if (tmp_in != NULL) {
+                       stat->wn_seqcode = dec_string(tmp_in, &tmp_in);
+               }
        } else if (tmp_in != NULL) {
                edg_wll_FreeStatus(pubstat);
                free(pubstat);
@@ -599,6 +603,77 @@ edg_wll_ErrorCode edg_wll_RefreshIColumns(edg_wll_Context ctx, void *job_index_c
 }
 
 
+/* compare events taking into account shallow resubmission */
+int edg_wll_compare_seq_full(const char *a, const char *b, const char *wn)
+{
+       unsigned int    c[EDG_WLL_SOURCE__LAST];
+       unsigned int    d[EDG_WLL_SOURCE__LAST];
+       unsigned int    w[EDG_WLL_SOURCE__LAST];
+       int             res, i;
+
+       assert(EDG_WLL_SOURCE__LAST == 9);
+
+       if (wn == NULL) return(edg_wll_compare_seq(a,b));
+
+       res =  sscanf(a, "UI=%d:NS=%d:WM=%d:BH=%d:JSS=%d:LM=%d:LRMS=%d:APP=%d",
+                       &c[EDG_WLL_SOURCE_USER_INTERFACE],
+                       &c[EDG_WLL_SOURCE_NETWORK_SERVER],
+                       &c[EDG_WLL_SOURCE_WORKLOAD_MANAGER],
+                       &c[EDG_WLL_SOURCE_BIG_HELPER],
+                       &c[EDG_WLL_SOURCE_JOB_SUBMISSION],
+                       &c[EDG_WLL_SOURCE_LOG_MONITOR],
+                       &c[EDG_WLL_SOURCE_LRMS],
+                       &c[EDG_WLL_SOURCE_APPLICATION]);
+       if (res != EDG_WLL_SOURCE__LAST-1) {
+               syslog(LOG_ERR, "unparsable sequence code %s\n", a);
+               fprintf(stderr, "unparsable sequence code %s\n", a);
+               return -1;
+       }
+
+       res =  sscanf(b, "UI=%d:NS=%d:WM=%d:BH=%d:JSS=%d:LM=%d:LRMS=%d:APP=%d",
+                       &d[EDG_WLL_SOURCE_USER_INTERFACE],
+                       &d[EDG_WLL_SOURCE_NETWORK_SERVER],
+                       &d[EDG_WLL_SOURCE_WORKLOAD_MANAGER],
+                       &d[EDG_WLL_SOURCE_BIG_HELPER],
+                       &d[EDG_WLL_SOURCE_JOB_SUBMISSION],
+                       &d[EDG_WLL_SOURCE_LOG_MONITOR],
+                       &d[EDG_WLL_SOURCE_LRMS],
+                       &d[EDG_WLL_SOURCE_APPLICATION]);
+       if (res != EDG_WLL_SOURCE__LAST-1) {
+               syslog(LOG_ERR, "unparsable sequence code %s\n", b);
+               fprintf(stderr, "unparsable sequence code %s\n", b);
+               return 1;
+       }
+
+       res =  sscanf(wn, "UI=%d:NS=%d:WM=%d:BH=%d:JSS=%d:LM=%d:LRMS=%d:APP=%d",
+                       &w[EDG_WLL_SOURCE_USER_INTERFACE],
+                       &w[EDG_WLL_SOURCE_NETWORK_SERVER],
+                       &w[EDG_WLL_SOURCE_WORKLOAD_MANAGER],
+                       &w[EDG_WLL_SOURCE_BIG_HELPER],
+                       &w[EDG_WLL_SOURCE_JOB_SUBMISSION],
+                       &w[EDG_WLL_SOURCE_LOG_MONITOR],
+                       &w[EDG_WLL_SOURCE_LRMS],
+                       &w[EDG_WLL_SOURCE_APPLICATION]);
+       if (res != EDG_WLL_SOURCE__LAST-1) {
+               syslog(LOG_ERR, "unparsable sequence code %s\n", wn);
+               fprintf(stderr, "unparsable sequence code %s\n", wn);
+               return 1;
+       }
+
+
+       if ( (c[EDG_WLL_SOURCE_WORKLOAD_MANAGER] == w[EDG_WLL_SOURCE_WORKLOAD_MANAGER]) &&
+            (d[EDG_WLL_SOURCE_WORKLOAD_MANAGER] != w[EDG_WLL_SOURCE_WORKLOAD_MANAGER]) )
+               return  1;
+
+       
+       if ( (c[EDG_WLL_SOURCE_WORKLOAD_MANAGER] != w[EDG_WLL_SOURCE_WORKLOAD_MANAGER]) &&
+            (d[EDG_WLL_SOURCE_WORKLOAD_MANAGER] == w[EDG_WLL_SOURCE_WORKLOAD_MANAGER]) )
+               return  -1;
+
+       return(edg_wll_compare_seq(a,b));
+}
+
+
 int edg_wll_compare_seq(const char *a, const char *b)
 {
        unsigned int    c[EDG_WLL_SOURCE__LAST];