STAGETO=include/${globalprefix}/${lbprefix}
STATIC_H=consumer.h context.h dump.h load.h notification.h notifid.h purge.h \
Notification.h CountRef.h Job.h LoggingExceptions.h ServerConnection.h \
- consumer_fake.h
+ consumer_fake.h producer_fake.h
GEN_H=events.h jobstat.h producer.h Event.h JobStatus.h
-/* $Id: */
+/*
+ * fake implementation of the consumer API
+ */
#ifndef WORKLOAD_LOGGING_CLIENT_CONSUMER_FAKE_H
#define WORKLOAD_LOGGING_CLIENT_CONSUMER_FAKE_H
typedef int (edg_wll_QueryEvents_cb_f)(edg_wll_Context context, edg_wll_Event **events);
typedef int (edg_wll_QueryListener_cb_f)(edg_wll_Context context, char **host, uint16_t *port);
-int egd_wll_RegisterTestQueryEvents(edg_wll_QueryEvents_cb_f *cb);
-int egd_wll_RegisterTestQueryListener(edg_wll_QueryListener_cb_f *cb);
-void egd_wll_UnregisterTestQueryEvents();
-void egd_wll_UnregisterTestQueryListener();
+int edg_wll_RegisterTestQueryEvents(edg_wll_QueryEvents_cb_f *cb);
+int edg_wll_RegisterTestQueryListener(edg_wll_QueryListener_cb_f *cb);
+void edg_wll_UnregisterTestQueryEvents();
+void edg_wll_UnregisterTestQueryListener();
#endif /* WORKLOAD_LOGGING_CLIENT_CONSUMER_FAKE_H */
--- /dev/null
+/*
+ * fake implementation of the producer API
+ */
+
+#ifndef WORKLOAD_LOGGING_CLIENT_PRODUCER_FAKE_H
+#define WORKLOAD_LOGGING_CLIENT_PRODUCER_FAKE_H
+
+typedef int (edg_wll_Logging_cb_f)(edg_wll_Context context);
+
+int edg_wll_RegisterTestLogging(edg_wll_Logging_cb_f *cb);
+int edg_wll_RegisterTestLoggingProxy(edg_wll_Logging_cb_f *cb);
+void edg_wll_UnregisterTestLogging();
+void edg_wll_UnregisterTestLoggingProxy();
+
+#endif /* WORKLOAD_LOGGING_CLIENT_PRODUCER_FAKE_H */
VPATH=${top_srcdir}/src:${top_srcdir}/test:${top_srcdir}/examples
AT3=perl -I${top_srcdir}/project ${top_srcdir}/project/at3
+GENSAM=${top_srcdir}/examples/gen_sample_job
+
+SUFFIXES = .T .l
+
+l_SRC = \
+ chkpt.l \
+ cleared.l \
+ done.l \
+ done_dag.l \
+ done_subjob.l \
+ ready.l \
+ ready_dag.l \
+ ready_subjob.l \
+ running.l \
+ running_dag.l \
+ running_subjob.l \
+ scheduled.l \
+ scheduled_dag.l \
+ scheduled_subjob.l \
+ submitted.l \
+ submitted_dag.l \
+ submitted_subjob.l \
+ waiting.l \
+ waiting_dag.l \
+ waiting_subjob.l \
+ failed_dag.l \
+ failed_subjob.l \
+ aborted.l \
+ cancelled.l
+
+sh_PROGS = $(l_SRC:.l=.sh)
-SUFFIXES = .T
DEBUG:=-g -O0 -Wall
LIBOBJS:=connection.o consumer.o notification.o prod_proto.o \
producer.o uiwrap.o
-TESTLIBOBJS:=consumer_fake.o
+TESTLIBOBJS:=consumer_fake.o producer_fake.o
PLUSOBJS:=Event.o Job.o JobStatus.o Notification.o ServerConnection.o
PUB_HDRS:=CountRef.h Event.h JobJobStatus.h Notification.h ServerConnection.h \
TOOLS:=dump load purge
#EXAMPLES:=log_usertag_proxy job_reg feed_shark notify
EXAMPLES:=job_reg feed_shark notify
-FAKE_EXAMPLES:=jog_log_fake
+FAKE_EXAMPLES:=job_log_fake job_reg_fake
+FAKE_EXAMPLES_SOURCES:=job_log.c job_reg.c
${LIB}: ${LIBOBJS}
${LINK} -o $@ ${LIBLOBJS} -rpath ${glite_location}/lib -lglite_lb_common_${nothrflavour}
logevent: logevent.o args.o
${LINK} -o $@ logevent.o args.o ${LIB} ${EXT_LIB} ${GLOBUS_LIBS}
+logevent_fake: logevent_fake.o args.o
+ ${LINK} -o $@ logevent_fake.o args.o ${TESTLIB} ${EXT_LIB} ${GLOBUS_LIBS}
+
${TOOLS} ${EXAMPLES}: %: %.o
${LINK} -o $@ $< ${LIB} ${EXT_LIB} ${GLOBUS_LIBS}
-${FAKE_EXAMPLES}: job_log_fake.o ${TESTLIB}
+${FAKE_EXAMPLES}: %: %.o ${TESTLIB}
${LINK} -o $@ $< ${TESTLIB} ${EXT_LIB} ${GLOBUS_LIBS}
${TOOLS}: ${LIB}
-job_log_fake.o: job_log.c
- ${COMPILE} ${GLOBUSINC} -c $< -o $@
+${FAKE_EXAMPLES:=.o}: ${FAKE_EXAMPLES_SOURCES}
+ ${COMPILE} ${GLOBUSINC} -DUSE_CALLBACKS -c $< -o $@
${PLUSOBJS}: %.o: %.cpp
${CXXCOMPILE} ${GLOBUSINC} -c $<
${LIBTHROBJS} ${TESTLIBTHROBJS}: %.thr.o: %.c
${COMPILE} ${GLOBUSTHRINC} -o $@ -c $<
+logevent_fake.o: logevent.c
+ ${COMPILE} ${GLOBUSINC} -DFAKE -c $< -o $@
+
# catches $TOOLS and logevent compilation
%.o: %.c
${CC} ${CFLAGS} ${GLOBUSINC} -c $<
${AT3} $< >$@ || rm -f $@
chmod -w $@ >/dev/null
+%.sh: %.l gen_begin gen_sample_job
+ rm -f $@
+ $(GENSAM) $< >$@ || rm -f $@
+ chmod -w,+x $@ > /dev/null
+
default: all
-compile all: ${LIB} ${THRLIB} ${TOOLS} logevent ${EXAMPLES} ${PLUSLIB} ${THRPLUSLIB} ${TESTLIB} ${TESTTHRLIB} ${FAKE_EXAMPLES}
+compile all: ${LIB} ${THRLIB} ${TOOLS} logevent ${PLUSLIB} ${THRPLUSLIB} ${TESTLIB} ${TESTTHRLIB} examples
-examples: ${EXAMPLES}
+examples: ${EXAMPLES} ${FAKE_EXAMPLES} ${sh_PROGS} logevent_fake
check: compile check.producer
mkdir -p ${PREFIX}/share/doc/${package}-${version}
${INSTALL} -m 644 ${LIB} ${THRLIB} ${PLUSLIB} ${THRPLUSLIB} ${TESTLIB} ${TESTTHRLIB} ${PREFIX}/lib
${INSTALL} -m 644 ${top_srcdir}/LICENSE ${PREFIX}/share/doc/${package}-${version}
- for p in ${TOOLS} logevent ${FAKE_EXAMPLES}; do \
+ for p in ${TOOLS} logevent ${EXAMPLES} ${FAKE_EXAMPLES} logevent_fake ${sh_PROGS}; do \
${INSTALL} -m 755 "$$p" "${PREFIX}/bin/glite-lb-$$p"; \
done
--- /dev/null
+:ready:
+-s JobController,-e Abort,--reason "just to test"
--- /dev/null
+:running:
+-s LogMonitor, -e Done, --status_code=CANCELLED, --reason="reason for the change", --exit_code=0
--- /dev/null
+# macro definition for DONE state
+
+:running:
+-s LRMS, -e Chkpt, --tag=chkpt1, --classad=""
+-s LRMS, -e Chkpt, --tag=chkpt2, --classad=""
+-s LogMonitor, -e Done, --status_code=OK, --reason="reason for the change", --exit_code=0
--- /dev/null
+# macro definition for DONE state
+
+:done:
+-s LogMonitor, -e Clear, --reason=USER
-/* $Id: */
+/*
+ * fake implementation of the consumer API
+ */
#include <stddef.h>
#include <string.h>
--- /dev/null
+# macro definition for DONE state
+
+:running:
+-s LogMonitor, -e Done, --status_code=OK, --reason="reason for the change", --exit_code=0
--- /dev/null
+# macro definition for DONE state
+
+:running_dag:
+-s LogMonitor, -e Done, --status_code=OK, --reason="reason for the change", --exit_code=0
--- /dev/null
+# macro definition for DONE state
+
+:running_subjob:
+-s LogMonitor, -e Done, --status_code=OK, --reason="reason for the change", --exit_code=0
--- /dev/null
+:running_dag:
+
+-s LogMonitor, -e Done, --status_code=Failed, --exit_code=1, --reason=shit
--- /dev/null
+:running_subjob:
+
+-s LogMonitor, -e Done, --status_code=Failed, --exit_code=1, --reason=shit
--- /dev/null
+#!/bin/sh
+# script for generating sample jobs
+
+if test ! -z "$FAKE"; then
+ SUFFIX="_fake"
+fi
+LOGFD=${LOGFD:-2}
+LOGEV=${LOGEV:-`dirname $0`/glite-lb-logevent}${SUFFIX}
+JOB_REG=${JOB_REG:-`dirname $0`/glite-lb-job_reg}${SUFFIX}
+EDG_JOBID=
+
+usage()
+{
+ echo "Usage : $0 [-m bkserver_machine_name][-j job_id]"
+ exit 4
+}
+
+# read parameters
+while test -n "$1"
+do
+ case "$1" in
+ "-m") shift; BKSERVER_HOST="$1" ;;
+ "-j") shift; EDG_JOBID="$1" ;;
+ "*") usage ;;
+ esac
+ shift
+done
+
+test \( -z "$BKSERVER_HOST" \) -a \( -z "$EDG_JOBID" \) && usage
+
+if [ -z "$EDG_JOBID" ]
+then
+ # initial sequence code & jobid (normaly returned by job_reg)
+ EDG_JOBID=
+ SCRIPT=`$JOB_REG -m $BKSERVER_HOST -s UserInterface | tail -n 2`
+ eval $SCRIPT
+ test -z "$EDG_JOBID" && exit 4
+ echo EDG_JOBID=$EDG_JOBID
+else
+ test -z "$EDG_WL_SEQUENCE" && EDG_WL_SEQUENCE="UI=000003:NS=0000000000:WM=000000:BH=0000000000:JSS=000000:LM=000000:LRMS=000000:APP=000000"
+fi
+
+send_log_ev()
+{
+ echo $LOGEV -j "$EDG_JOBID" -c "$EDG_WL_SEQUENCE" "$@" 1>&$LOGFD
+ EDG_WL_SEQUENCE=`$LOGEV -j $EDG_JOBID -c $EDG_WL_SEQUENCE "$@" 2>/dev/null`
+ test $? -ne 0 -o -z "$EDG_WL_SEQUENCE" && exit 4
+ true
+}
+
--- /dev/null
+#!/bin/sh
+
+me=$0
+mydir=`dirname $0`;
+export me mydir
+
+
+set -- `getopt n $*`
+# test whether it is recursive call
+
+NESTED="-v nested=0"
+while [ $1 != '--' ]; do case $1 in
+ -n) NESTED="-v nested=1"; shift ;;
+esac; done
+shift
+
+awk -F, $NESTED \
+'BEGIN {
+ if (nested==0) system("cat $mydir/gen_begin");
+ OFS = ",";
+ nlines = 0;
+}
+/^#/ || /^[ ]*$/ { next; }
+{
+ source = $2;
+
+ event = $1;
+
+ nline++;
+}
+# events processing
+
+/-e Transfer/ { logit();
+ next;}
+
+/-e Accepted/ { if (checkNOP(7) == 0) logit();
+ next;}
+
+/-e Refused/ { if (checkNOP(6) == 0) logit();
+ next;}
+
+/-e EnQueued/ { if (checkNOP(6) == 0) logit();
+ next;}
+
+/-e DeQueued/ { if (checkNOP(4) == 0) logit();
+ next;}
+
+/-e HelperCall/ { if (checkNOP(5) == 0) logit();
+ next;}
+
+/-e HelperReturn/ { if (checkNOP(5) == 0) logit();
+ next;}
+
+/-e Running/ { if (checkNOP(3) == 0) logit();
+ next;}
+
+/-e Resubmission/ { if (checkNOP(5) == 0) logit();
+ next;}
+
+/-e Done/ { if (checkNOP(5) == 0) logit();
+ next;}
+
+/-e Cancel/ { if (checkNOP(4) == 0) logit();
+ next;}
+
+/-e Abort/ { if (checkNOP(3) == 0) logit();
+ next;}
+
+/-e Clear/ { if (checkNOP(3) == 0) logit();
+ next;}
+
+/-e Purge/ { if (checkNOP(2) == 0) logit();
+ next;}
+
+/-e Match/ { if (checkNOP(3) == 0) logit();
+ next;}
+
+/-e Pending/ { if (checkNOP(3) == 0) logit();
+ next;}
+
+/-e RegJob/ { if (checkNOP(7) == 0) logit();
+ next;}
+
+/-e Chkpt/ { if (checkNOP(4) == 0) logit();
+ next;}
+
+/-e Listener/ { if (checkNOP(5) == 0) logit();
+ next;}
+
+/-e CurDescr/ { if (checkNOP(3) == 0) logit();
+ next;}
+
+/-e UserTag/ { if (checkNOP(4) == 0) logit();
+ next;}
+
+
+# macro processing - macro name starts and ends with ':'
+# in a file gen_MACRONAME.txt is the macro describtion
+
+/^:.*:$/ {system("$me -n $mydir/"substr($1,2,(length($1) - 2))".l" )}
+
+
+function checkNOP(NOP)
+{
+ if (NF != NOP) { print nline" : "$2": "NOP" args required ("NF" supplied)" > "/dev/stderr"; return 1 }
+ else return 0;
+}
+
+function logit()
+{
+ split($0,f);
+
+ ff = "";
+ for (i=1; i<=NF; i++) ff = ff " " f[i];
+
+ print "send_log_ev" ff;
+}
+' $1
+
--- /dev/null
+/*
+ * fake implementation of the producer API
+ */
+
+#include "glite/lb/producer.h"
+#include "glite/lb/context-int.h"
+#include "glite/lb/producer_fake.h"
+
+#define FAKE_VERSION 1
+
+#include "../src/producer.c"
+
+
+static edg_wll_Logging_cb_f *Logging_cb = NULL;
+static edg_wll_Logging_cb_f *LoggingProxy_cb = NULL;
+
+
+/* register the logging callback */
+int edg_wll_RegisterTestLogging(edg_wll_Logging_cb_f *cb) {
+ if (Logging_cb) return 0;
+
+ Logging_cb = cb;
+ return 1;
+}
+
+
+/* register the proxy logging callback */
+int edg_wll_RegisterTestLoggingProxy(edg_wll_Logging_cb_f *cb) {
+ if (LoggingProxy_cb) return 0;
+
+ LoggingProxy_cb = cb;
+ return 1;
+}
+
+
+/* unregister the logging callback */
+void edg_wll_UnregisterTestLogging() {
+ Logging_cb = NULL;
+}
+
+
+/* unregister the proxy logging callback */
+void edg_wll_UnregisterTestLoggingProxy() {
+ LoggingProxy_cb = NULL;
+}
+
+
+/* "fake" implementation of function sending formated UML string */
+int edg_wll_DoLogEvent(edg_wll_Context context, edg_wll_LogLine logLine) {
+ if (Logging_cb)
+ return Logging_cb(context);
+ else
+ return edg_wll_Error(context, NULL, NULL);
+}
+
+
+/* "fake" implementation of function sending formated ULM string */
+int edg_wll_DoLogEventProxy(edg_wll_Context context, edg_wll_LogLine logline) {
+ if (Logging_cb)
+ return Logging_cb(context);
+ else
+ return edg_wll_Error(context, NULL, NULL);
+}
--- /dev/null
+# macro definition for WAITING state
+
+:waiting:
+# NetworkServer
+
+-s NetworkServer,-e EnQueued, --queue="destination queue", --job="job description in receiver language", --result=OK, --reason="detailed description of transfer"
+# -s NetworkServer,-e Transfer,--destination="WorkloadManager",--dest_host="destination hostname",--dest_instance="destination instance",--dest_jobid="job description in receiver language",--result=OK,--reason="detailed description of transfer",--dest_jobid="destination internal jobid"
+
+# WorkloadManager
+
+-s WorkloadManager,-e DeQueued, --queue="queue name", --local_jobid="new jobId assigned by the receiving component"
+-s WorkloadManager,-e HelperCall, --helper_name="name of the called component",--helper_params="parameters of the call", --src_role=CALLING
+#-s Helper,-e HelperCall, --helper_name="name of the called component",--helper_params="parameters of the call", --src_role=CALLED
+#-s Helper,-e HelperReturn, --helper_name="name of the called component",--retval="returned data", --src_role=CALLED
+-s WorkloadManager,-e Match,--dest_id="Id of the destination CE/queue"
+-s WorkloadManager,-e HelperReturn, --helper_name="name of the called component",--retval="returned data", --src_role=CALLING
+-s WorkloadManager,-e EnQueued, --queue="destination queue", --job="job description in receiver language", --result=OK, --reason="detailed description of transfer"
+
--- /dev/null
+# macro definition for WAITING state
+
+:waiting_dag:
+# NetworkServer
+
+-s NetworkServer,-e EnQueued, --queue="destination queue", --job="job description in receiver language", --result=OK, --reason="detailed description of transfer"
+
+# WorkloadManager
+
+-s WorkloadManager,-e DeQueued, --queue="queue name", --local_jobid="new jobId assigned by the receiving component"
+
+-s WorkloadManager,-e EnQueued, --queue="destination queue", --job="job description in receiver language", --result=OK, --reason="detailed description of transfer"
+
--- /dev/null
+# macro definition for WAITING state
+
+:waiting_subjob:
+# WorkloadManager
+
+-s WorkloadManager,-e Match,--dest_id="Id of the destination CE/queue"
+-s WorkloadManager,-e HelperReturn, --helper_name="name of the called component",--retval="returned data", --src_role=CALLING
+
--- /dev/null
+# macro definition for RUNNING state
+
+:scheduled:
+-s LogMonitor,-e Running,--node"worker node where the executable is run"
--- /dev/null
+# macro definition for RUNNING state
+
+:scheduled_dag:
+-s LogMonitor,-e Running,--node"DAGMan running on server"
--- /dev/null
+# macro definition for RUNNING state
+
+:scheduled_subjob:
+-s LogMonitor,-e Running,--node"worker node where the executable is run"
--- /dev/null
+# macro definition for SCHEDULED state
+
+:ready:
+# JobSubmition
+
+-s JobController,-e DeQueued, --queue="queue name", --local_jobid="new jobId assigned by the receiving component"
+-s JobController,-e Transfer,--destination="LRMS",--dest_host="destination hostname",--dest_instance="destination instance",--dest_jobid="job description in receiver language",--result=OK,--reason="detailed description of transfer",--dest_jobid="destination internal jobid"
+
+# LogMonitor
+
+-s LogMonitor,-e Accepted, --from="JobController", --from_host="sending component hostname", --from_instance="sending component instance", --local_jobid="new jobId (Condor, Globus ...)"
+-s LogMonitor,-e Transfer,--destination="LRMS",--dest_host="destination hostname",--dest_instance="destination instance",--dest_jobid="job description in receiver language",--result=OK,--reason="detailed description of transfer",--dest_jobid="destination internal jobid"
+
--- /dev/null
+# macro definition for SCHEDULED state
+
+:ready_dag:
+# JobSubmition
+
+-s JobController,-e DeQueued, --queue="queue name", --local_jobid="new jobId assigned by the receiving component"
+-s JobController,-e Transfer,--destination="LogMonitor",--dest_host="destination hostname",--dest_instance="destination instance",--dest_jobid="job description in receiver language",--result=START,--reason="detailed description of transfer",--dest_jobid="destination internal jobid"
+
+# LogMonitor
+
+-s LogMonitor,-e Accepted, --from="JobController", --from_host="sending component hostname", --from_instance="sending component instance", --local_jobid="new jobId (Condor, Globus ...)"
+
--- /dev/null
+# macro definition for SCHEDULED state
+
+:ready_subjob:
+# LogMonitor
+
+-s LogMonitor,-e Transfer,--destination="LRMS",--dest_host="destination hostname",--dest_instance="destination instance",--dest_jobid="job description in receiver language",--result=OK,--reason="detailed description of transfer",--dest_jobid="destination internal jobid"
+
--- /dev/null
+# macro definition for SUBMITTED state
+
+# only job registration needed for submitted state
+#-p,-s UserInterface,-e Transfer,--destination="NetworkServer",--destination_host="destination hostname",--destination_instance="destination instance",--destination_jobid="job description in receiver language",--result=OK,--reason="detailed description of transfer",--destination_jobid="destination internal jobid"
+
--- /dev/null
+# macro definition for SUBMITTED state
+
+# only job registration needed for submitted state
+
--- /dev/null
+# macro definition for SUBMITTED state
+
+# only job registration needed for submitted state
+
--- /dev/null
+# macro definition for WAITING state
+
+:submitted:
+# NetworkServer
+
+-s NetworkServer,-e Accepted, --from="UserInterface", --from_host="sending component hostname", --from_instance="sending component instance", --local_jobid="new jobId (Condor, Globus ...)"
--- /dev/null
+# macro definition for WAITING state
+
+:submitted_dag:
+# NetworkServer
+
+-s NetworkServer,-e Accepted, --from="UserInterface", --from_host="sending component hostname", --from_instance="sending component instance", --local_jobid="new jobId (Condor, Globus ...)"
--- /dev/null
+# macro definition for WAITING state
+
+:submitted_subjob:
+# WorkloadManager
+
+-s WorkloadManager,-e HelperCall, --helper_name="name of the called component",--helper_params="parameters of the call", --src_role=CALLING
static const char* socket_path="/tmp/lb_proxy_store.sock";
+#ifdef FAKE_VERSION
+int edg_wll_DoLogEvent(edg_wll_Context context, edg_wll_LogLine logline);
+int edg_wll_DoLogEventProxy(edg_wll_Context context, edg_wll_LogLine logline);
+#else
/**
*----------------------------------------------------------------------
* Connects to local-logger and sends already formatted ULM string
return edg_wll_Error(context, NULL, NULL);
}
+#endif /* FAKE_VERSION */
/**