From: cvs2svn Date: Tue, 19 Sep 2006 18:01:27 +0000 (+0000) Subject: This commit was manufactured by cvs2svn to create tag 'merge_31_src'. X-Git-Tag: merge_31_src X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=a9fb515a8494e30b4f87d8695ff2465827d0ab4b;p=jra1mw.git This commit was manufactured by cvs2svn to create tag 'merge_31_src'. Sprout from connpool_branch 2006-06-05 09:42:14 UTC cvs2svn 'This commit was manufactured by cvs2svn to create branch 'connpool_branch'.' Cherrypick from master 2006-04-02 05:33:50 UTC Master Builder 'Incremented build number [GLBUILDER]': org.glite.lb.client-interface/Makefile org.glite.lb.client-interface/interface/context.h org.glite.lb.client-interface/interface/producer.h.T org.glite.lb.client-interface/project/build.number org.glite.lb.client/project/build.number org.glite.lb.client/src/prod_proto.c org.glite.lb.common/Makefile org.glite.lb.common/interface/il_msg.h org.glite.lb.common/interface/il_string.h org.glite.lb.common/project/build.number org.glite.lb.common/project/configure.properties.xml org.glite.lb.common/src/il_msg.c org.glite.lb.common/src/il_string.c org.glite.lb.common/test/il_msg_test.cpp org.glite.lb.common/test/il_string_test.cpp org.glite.lb.logger/Makefile org.glite.lb.logger/project/build.number org.glite.lb.logger/project/configure.properties.xml org.glite.lb.logger/src/il_master.c org.glite.lb.logger/src/input_queue_socket.c org.glite.lb.logger/src/interlogd.c org.glite.lb.logger/src/interlogd.h org.glite.lb.logger/src/logd_proto.c org.glite.lb.logger/src/server_msg.c org.glite.lb.proxy/Makefile org.glite.lb.proxy/examples/test.sh org.glite.lb.proxy/project/build.number org.glite.lb.proxy/project/configure.properties.xml org.glite.lb.server-bones/Makefile org.glite.lb.server-bones/project/build.number org.glite.lb.server/project/build.number org.glite.lb.server/project/configure.properties.xml org.glite.lb.server/src/db_store.c org.glite.lb.server/src/lb_http.c org.glite.lb.server/src/load.c org.glite.lb.server/src/request.c org.glite.lb.server/src/stored_master.c org.glite.lb.utils/project/build.number org.glite.lb.utils/project/configure.properties.xml org.glite.lb/project/build.number Cherrypick from glite-lb-server_branch_1_4_0_RC31 2006-09-13 08:59:22 UTC Jan Pospíšil 'more FIXMEs :((': org.glite.lb.server/Makefile org.glite.lb.server/config/startup org.glite.lb.server/interface/job-attrs.xsd org.glite.lb.server/interface/job-record.xsd org.glite.lb.server/project/version.properties org.glite.lb.server/src/bkserverd.c org.glite.lb.server/src/get_events.h org.glite.lb.server/src/il_lbproxy.c org.glite.lb.server/src/il_notification.c org.glite.lb.server/src/jobstat_supp.c org.glite.lb.server/src/lb_authz.c org.glite.lb.server/src/lb_plugin.c org.glite.lb.server/src/lbs_db.c org.glite.lb.server/src/lbs_db_supp.c org.glite.lb.server/src/lock.c org.glite.lb.server/src/notification.c org.glite.lb.server/src/process_event.c org.glite.lb.server/src/seqcode.c org.glite.lb.server/src/srv_purge.c org.glite.lb.server/src/stats.c org.glite.lb.server/src/store.c.T Cherrypick from glite-lb-client_branch_2_2_0_RC31 2006-09-19 18:01:25 UTC Aleš Křenek 'merge from 3.0': org.glite.lb.client/Makefile org.glite.lb.client/examples/dagids.c org.glite.lb.client/examples/flood_proxy.c org.glite.lb.client/examples/job_reg.c org.glite.lb.client/examples/lbmon.c org.glite.lb.client/examples/stress_context.c org.glite.lb.client/examples/ulmfields.pl org.glite.lb.client/project/configure.properties.xml org.glite.lb.client/project/version.properties org.glite.lb.client/src/connection.c org.glite.lb.client/src/connection.h org.glite.lb.client/src/export.sh org.glite.lb.client/src/lb_dump_exporter.c org.glite.lb.client/src/notification.c org.glite.lb.client/src/producer.c org.glite.lb.client/test/producer_test.cpp Cherrypick from glite-lb-common_branch_3_1_0_RC31 2006-09-01 13:40:50 UTC Miloš Mulač 'usec filenames granularity': org.glite.lb.common/interface/lb_maildir.h org.glite.lb.common/project/version.properties org.glite.lb.common/src/lb_maildir.c org.glite.lb.common/src/lb_plain_io.c org.glite.lb.common/src/mini_http.c org.glite.lb.common/src/notifid.c org.glite.lb.common/src/param.c Cherrypick from glite-lb-logger_branch_1_3_0_RC31 2006-07-27 12:17:05 UTC Miloš Mulač 'push version': org.glite.lb.logger/project/version.properties org.glite.lb.logger/src/event_store.c org.glite.lb.logger/src/logd.c org.glite.lb.logger/src/send_event.c Cherrypick from glite-lb-utils_branch_1_1_0_RC31 2006-09-12 22:37:41 UTC Jan Pospíšil 'added option -o for output file and updated last/fullStatusHistory': org.glite.lb.utils/Makefile org.glite.lb.utils/src/lb_statistics.c org.glite.lb.utils/src/mon-db.c org.glite.lb.utils/src/statistics.c Cherrypick from glite-lb_branch_1_3_0_RC31 2006-07-27 12:53:16 UTC Miloš Mulač 'restored': org.glite.lb/deployment/README org.glite.lb/deployment/deploy_lb.diff org.glite.lb/project/dependencies.properties org.glite.lb/project/version.properties Cherrypick from glite-lb-ws-interface_branch_2_2_0_RC31 2006-08-15 20:07:54 UTC Aleš Křenek 'merge of changes betwen merge_for_3_1_src and merge_30_31_src': org.glite.lb.ws-interface/Makefile org.glite.lb.ws-interface/project/build.number org.glite.lb.ws-interface/src/puke-ug.xsl Cherrypick from glite-lb-proxy_branch_1_3_0_RC31 2006-07-27 12:20:24 UTC Miloš Mulač 'push version': org.glite.lb.proxy/project/version.properties org.glite.lb.proxy/src/lbproxy.c Cherrypick from glite-lb-server-bones_branch_2_2_0_RC31 2006-05-10 10:59:13 UTC Aleš Křenek 'push version': org.glite.lb.server-bones/project/version.properties org.glite.lb.server-bones/src/srvbones.c Cherrypick from glite-lb-client-interface_branch_2_2_0_RC31 2006-08-15 20:06:22 UTC Aleš Křenek 'merge of changes betwen merge_for_3_1_src and merge_30_31_src': org.glite.lb.client-interface/interface/notifid.h Delete: org.glite.lb.client/examples/export.sh org.glite.lb.client/src/perftest_jobreg.c org.glite.lb.client/src/perftest_logjobs.c org.glite.lb.common/interface/lb_perftest.h org.glite.lb.common/src/lb_perftest.c org.glite.lb.common/src/perftest_common.sh org.glite.lb.logger/src/perftest_il.sh org.glite.lb.logger/src/perftest_ll.sh org.glite.lb.proxy/examples/test1.sh org.glite.lb.proxy/examples/test2.sh org.glite.lb.proxy/examples/test3.sh org.glite.lb.proxy/src/perftest_proxy.sh org.glite.lb.server/interface/srv_perf.h org.glite.lb/doc/README.lb4vdt org.glite.lb/lb4vdt/LB_install.sh org.glite.lb/lb4vdt/Makefile.inc org.glite.lb/lb4vdt/patches/org.gridsite.core.patch org.glite.lb/lb4vdt/scripts/org.gridsite.core.build --- diff --git a/org.glite.lb.client-interface/Makefile b/org.glite.lb.client-interface/Makefile index ee12a59..fd3191a 100644 --- a/org.glite.lb.client-interface/Makefile +++ b/org.glite.lb.client-interface/Makefile @@ -11,9 +11,6 @@ version=0.0.0 PREFIX=/opt/glite -include Makefile.inc --include ../project/version.properties - -version=${module.version} SUFFIXES = .T @@ -42,14 +39,8 @@ check: interface_version.h: ${top_srcdir}/project/version.properties echo "#define GLITE_LB_CLIENT_INTERFACE \"${version}\"" >$@ - -ifdef LB_STANDALONE stage: generate - $(MAKE) install PREFIX=${stagedir} DOSTAGE=yes -else -stage: generate doc $(MAKE) install PREFIX=${top_srcdir}/${stagedir} DOSTAGE=yes -endif dist: distsrc distbin @@ -64,19 +55,17 @@ distbin: cd ${top_srcdir}/tmpbuilddir && tar -czf ${top_srcdir}/${distdir}/${package}-${version}_bin.tar.gz * rm -rf ${top_srcdir}/tmpbuilddir -doc: generate +doc: generate doxygen C.dox doxygen CPP.dox -install: generate +install: generate doc -mkdir -p ${PREFIX}/${STAGETO} -mkdir -p ${PREFIX}/share/doc/${package}-${version} install -m 644 ${GEN_H} ${PREFIX}/${STAGETO} install -m 644 ${top_srcdir}/LICENSE ${PREFIX}/share/doc/${package}-${version} cd ${top_srcdir}/interface && install -m 644 ${STATIC_H} ${PREFIX}/${STAGETO} -ifndef LB_STANDALONE cd ${top_srcdir}/doc && cp -r C CPP ${PREFIX}/share/doc/${package}-${version} -endif if [ x${DOSTAGE} = xyes ]; then \ cd ${top_srcdir}/interface && install -m 644 ${FAKE_H} ${PREFIX}/${STAGETO} ; \ fi diff --git a/org.glite.lb.client-interface/interface/context.h b/org.glite.lb.client-interface/interface/context.h index 747c44c..3fed100 100644 --- a/org.glite.lb.client-interface/interface/context.h +++ b/org.glite.lb.client-interface/interface/context.h @@ -6,9 +6,7 @@ * \brief L&B API common context (publicly visible) and related definitions */ -#ifndef LB_STANDALONE #include "glite/wmsutils/exception/exception_codes.h" -#endif #include "glite/wmsutils/jobid/cjobid.h" #ident "$Header$" @@ -161,10 +159,6 @@ int edg_wll_GetParam( /* XXX: cleanup required */ -#ifndef GLITE_WMS_LOGGING_ERROR_BASE -#define GLITE_WMS_LOGGING_ERROR_BASE 1400 -#endif - typedef enum _edg_wll_ErrorCode { /** Base for L&B specific code. Use the constant from common/ */ EDG_WLL_ERROR_BASE = GLITE_WMS_LOGGING_ERROR_BASE, diff --git a/org.glite.lb.client-interface/interface/notifid.h b/org.glite.lb.client-interface/interface/notifid.h index 3ef1054..1a78c1b 100644 --- a/org.glite.lb.client-interface/interface/notifid.h +++ b/org.glite.lb.client-interface/interface/notifid.h @@ -77,6 +77,14 @@ char *edg_wll_NotifIdGetUnique(const edg_wll_NotifId notifid); */ int edg_wll_NotifIdSetUnique(edg_wll_NotifId *notifid, const char *unique); +/** + * Duplicate a NotifId + * \param[in] src a notifid to duplicate + * \retval pointer to allocated memory containg the duplicated notifid + * \retval NULL if memory allocation fails or notifid is invalid + */ +edg_wll_NotifId *edg_wll_NotifIdDup(const edg_wll_NotifId src); + /* *@} end of group */ diff --git a/org.glite.lb.client-interface/interface/producer.h.T b/org.glite.lb.client-interface/interface/producer.h.T index f84d623..cfbafb2 100644 --- a/org.glite.lb.client-interface/interface/producer.h.T +++ b/org.glite.lb.client-interface/interface/producer.h.T @@ -372,23 +372,6 @@ extern int edg_wll_RegisterJobProxy( edg_wlc_JobId ** subjobs ); -#ifdef LB_PERF -/* register only to LBProxy */ -/* useful for performance measurements */ - -extern int edg_wll_RegisterJobProxyOnly( - edg_wll_Context context, - const edg_wlc_JobId job, - enum edg_wll_RegJobJobtype type, - const char * jdl, - const char * ns, - int num_subjobs, - const char * seed, - edg_wlc_JobId ** subjobs -); -#endif - - /** * Register subjobs in a batch. diff --git a/org.glite.lb.client-interface/project/build.number b/org.glite.lb.client-interface/project/build.number index ae6bf21..d67eddb 100644 --- a/org.glite.lb.client-interface/project/build.number +++ b/org.glite.lb.client-interface/project/build.number @@ -1,2 +1,2 @@ -#Mon Apr 03 07:25:40 CEST 2006 -module.build=0243 +#Sun Apr 02 07:05:37 CEST 2006 +module.build=0242 diff --git a/org.glite.lb.client/Makefile b/org.glite.lb.client/Makefile index 6acead6..4006993 100644 --- a/org.glite.lb.client/Makefile +++ b/org.glite.lb.client/Makefile @@ -19,12 +19,8 @@ expat_prefix=/opt/expat CC:=gcc CXX:=g++ -LB_PERF=yes - -include Makefile.inc --include ../project/version.properties -version=${module.version} VPATH=${top_srcdir}/src:${top_srcdir}/test:${top_srcdir}/examples:${top_srcdir}/doc AT3=perl -I${top_srcdir}/project ${top_srcdir}/project/at3 @@ -69,47 +65,31 @@ DEBUG:=-g -O0 -Wall GLOBUSINC:= -I${globus_prefix}/include/${nothrflavour} GLOBUSTHRINC:= -I${globus_prefix}/include/${thrflavour} -ifdef LB_STANDALONE - LB_STANDALONE_FLAGS:=-DLB_STANDALONE -endif - -ifdef LB_PERF - LB_PERF_FLAGS:=-DLB_PERF - LB_PERF_TOOLS:=perftest_logjobs perftest_jobreg -endif -COMMON_LIB:=-lglite_lb_common_${nothrflavour} -COMMON_LIB_THR:=-lglite_lb_common_${thrflavour} - CFLAGS:=${DEBUG} \ -I${top_srcdir}/src -I${top_srcdir}/interface \ -I${stagedir}/include \ -I${glite_location}/include \ - -I${expat_prefix}/include \ - -I${mysql_prefix}/include -I${mysql_prefix}/include/mysql \ ${COVERAGE_FLAGS} \ - -D_GNU_SOURCE ${LB_STANDALONE_FLAGS} ${LB_PERF_FLAGS} + -D_GNU_SOURCE -CXXFLAGS:=${CFLAGS} +# -I${expat_prefix}/include \ +# -I${mysql_prefix}/include -I${mysql_prefix}/include/mysql \ -ifneq (${mysql_prefix},/usr) - ifeq ($(shell echo ${mysql_version} | cut -d. -f1,2),4.1) - mysqlib := -L${mysql_prefix}/lib/mysql - else - mysqlib := -L${mysql_prefix}/lib - endif -endif +CXXFLAGS:=${CFLAGS} -ifneq (${expat_prefix},/usr) - EXPAT_LIBS:=-L${expat_prefix}/lib -endif -EXPAT_LIBS := ${EXPAT_LIBS} -lexpat +#ifneq (${expat_prefix},/usr) +# EXPAT_LIBS:=-L${expat_prefix}/lib +#endif +#EXPAT_LIBS := ${EXPAT_LIBS} -lexpat -EXT_LIB:= ${mysqlib} -lmysqlclient -lz\ - ${EXPAT_LIBS} +EXT_LIB:= +#${mysqlib} -lmysqlclient -lz\ +# ${EXPAT_LIBS} TEST_LIBS:=-L${cppunit_prefix}/lib -lcppunit TEST_INC:=-I${cppunit_prefix}/include +COMMON_LIB=-lglite_lb_common_${nothrflavour} LDFLAGS:=-L${stagedir}/lib \ ${COVERAGE_FLAGS} @@ -148,10 +128,10 @@ FAKETHRLIB:=libglite_lb_client_fake_${thrflavour}.la PLUSLIB:=libglite_lb_clientpp_${nothrflavour}.la THRPLUSLIB:=libglite_lb_clientpp_${thrflavour}.la -TOOLS:=dump load purge lb_dump_exporter ${LB_PERF_TOOLS} -EXAMPLES:=log_usertag_proxy job_log job_reg feed_shark notify query_ext query_seq_code stats abort_job change_acl stresslog +TOOLS:=dump load purge lb_dump_exporter +EXAMPLES:=log_usertag_proxy job_log job_reg feed_shark notify query_ext query_seq_code stats abort_job change_acl stresslog lbmon flood_proxy dagids stress_context -EXAMPLES_CL=user_jobs job_status +EXAMPLES_CL=user_jobs job_status FAKE_EXAMPLES:=job_log_fake MAN_GZ:=glite-lb-logevent.1.gz @@ -167,22 +147,22 @@ version_info:=-version-info ${shell \ ${LIB}: ${LIBOBJS} ${LINK} ${version_info} -o $@ ${LIBLOBJS} -rpath ${glite_location}/lib \ - ${COMMON_LIB} \ + -lglite_lb_common_${nothrflavour} \ -lglite_security_gss_${nothrflavour} ${THRLIB}: ${LIBTHROBJS} ${LINK} ${version_info} -o $@ ${LIBTHRLOBJS} -rpath ${glite_location}/lib \ - ${COMMON_LIB_THR} \ + -lglite_lb_common_${thrflavour} \ -lglite_security_gss_${thrflavour} ${FAKELIB}: ${FAKELIBOBJS} ${LINK} ${version_info} -o $@ ${FAKELIBLOBJS} -rpath ${glite_location}/lib \ - ${COMMON_LIB} \ + -lglite_lb_common_${nothrflavour} \ -lglite_security_gss_${nothrflavour} ${FAKETHRLIB}: ${FAKELIBTHROBJS} ${LINK} ${version_info} -o $@ ${FAKELIBTHRLOBJS} -rpath ${glite_location}/lib \ - ${COMMON_LIB_THR} \ + -lglite_lb_common_${thrflavour} \ -lglite_security_gss_${thrflavour} ${PLUSLIB}: ${PLUSOBJS} @@ -228,9 +208,6 @@ ${MAN_GZ}: ${MAN} gzip $(notdir $?) -perftest_logjobs.o: perftest_logjobs.c - ${CC} ${CFLAGS} -DLB_PERF_DROP ${GLOBUSINC} -c $< - # catches $TOOLS and logevent compilation %.o: %.c ${CC} ${CFLAGS} ${GLOBUSINC} -c $< @@ -253,11 +230,7 @@ perftest_logjobs.o: perftest_logjobs.c default: all -ifdef LB_STANDALONE -compile all: ${LIB} ${THRLIB} ${TOOLS} logevent examples ${MAN_GZ} -else -compile all: ${LIB} ${THRLIB} ${TOOLS} logevent ${PLUSLIB} ${THRPLUSLIB} examples ${MAN_GZ} -endif +compile all: check_version ${LIB} ${THRLIB} ${TOOLS} logevent ${PLUSLIB} ${THRPLUSLIB} examples ${MAN_GZ} examples: ${EXAMPLES} ${EXAMPLES_CL} ${sh_PROGS} @@ -275,7 +248,7 @@ producer_test.o: %.o: %.cpp ${CXX} -c ${CXXFLAGS} ${TEST_INC} ${GLOBUSINC} $< man: ${MAN_GZ} - + stage: compile ${FAKELIB} ${FAKETHRLIB} $(MAKE) install PREFIX=${stagedir} ${INSTALL} -m 644 ${FAKELIB} ${FAKETHRLIB} ${stagedir}/lib @@ -292,22 +265,18 @@ distbin: $(MAKE) install PREFIX=`pwd`/tmpbuilddir${stagedir} save_dir=`pwd`; cd tmpbuilddir${stagedir} && tar -czf $$save_dir/${top_srcdir}/${distdir}/${package}-${version}_bin.tar.gz *; cd $$save_dir rm -rf tmpbuilddir - + install: mkdir -p ${PREFIX}/bin mkdir -p ${PREFIX}/sbin mkdir -p ${PREFIX}/lib mkdir -p ${PREFIX}/share/doc/${package}-${version} mkdir -p ${PREFIX}/share/man/man1 -ifdef LB_STANDALONE - ${INSTALL} -m 644 ${LIB} ${THRLIB} ${PREFIX}/lib -else ${INSTALL} -m 644 ${LIB} ${THRLIB} ${PLUSLIB} ${THRPLUSLIB} ${PREFIX}/lib -endif ${INSTALL} -m 644 ${top_srcdir}/LICENSE ${PREFIX}/share/doc/${package}-${version} ${INSTALL} -m 644 ${top_srcdir}/doc/README-fake ${top_srcdir}/doc/README-notify ${PREFIX}/share/doc/${package}-${version} mkdir -p ${PREFIX}/examples - for p in logevent ; do \ + for p in logevent; do \ ${INSTALL} -m 755 "$$p" "${PREFIX}/bin/glite-lb-$$p"; \ done for p in ${TOOLS} ; do \ @@ -316,8 +285,7 @@ endif for p in ${EXAMPLES} ${EXAMPLES_CL} ${sh_PROGS} ; do \ ${INSTALL} -m 755 "$$p" "${PREFIX}/examples/glite-lb-$$p"; \ done - ${INSTALL} -m 755 ${top_srcdir}/examples/export.sh "${PREFIX}/examples/glite-lb-export.sh" -# ${INSTALL} -m 755 ${top_srcdir}/examples/log_dag.sh "${PREFIX}/examples/glite-lb-log_dag.sh" + ${INSTALL} -m 755 ${top_srcdir}/src/export.sh "${PREFIX}/sbin/glite-lb-export.sh" ${INSTALL} -m 644 ${MAN_GZ} ${PREFIX}/share/man/man1 clean: diff --git a/org.glite.lb.client/examples/dagids.c b/org.glite.lb.client/examples/dagids.c new file mode 100644 index 0000000..d45b90f --- /dev/null +++ b/org.glite.lb.client/examples/dagids.c @@ -0,0 +1,61 @@ +#include +#include +#include +#include +#include +#include + +#include "glite/wmsutils/jobid/cjobid.h" +#include "glite/lb/producer.h" +#include "glite/lb/events.h" + +extern char *optarg; +extern int opterr,optind; + +static void usage(char *me) +{ + fprintf(stderr,"usage: %s -m bkserver -n num_subjobs [-s seed]\n", me); +} + +int main(int argc, char *argv[]) +{ + char *seed = "seed", *server = NULL,*p; + int done = 0,num_subjobs = 0,i; + edg_wll_Context ctx; + edg_wlc_JobId jobid,*subjobs; + + + edg_wll_InitContext(&ctx); + opterr = 0; + + do { + switch (getopt(argc,argv,"m:n:s:")) { + case 's': seed = strdup(optarg); break; + case 'm': server = strdup(optarg); break; + case 'n': num_subjobs = atoi(optarg); break; + case '?': usage(argv[0]); exit(EINVAL); + case -1: done = 1; break; + } + } while (!done); + + if (!server) { + fprintf(stderr,"%s: -m server required\n",argv[0]); + exit(1); + } + + if (!num_subjobs) { + fprintf(stderr,"%s: -n num_subjobs required\n",argv[0]); + exit(1); + } + + p = strchr(server,':'); + if (p) *p=0; + edg_wlc_JobIdCreate(server,p?atoi(p+1):0,&jobid); + printf("seed=\"%s\"\nnodes=%d\ndag=\"%s\"\n",seed,num_subjobs,edg_wlc_JobIdUnparse(jobid)); + + edg_wll_GenerateSubjobIds(ctx,jobid,num_subjobs,seed,&subjobs); + + for (i=0; i +#include +#include +#include +#include +#include +#include +#include + +#include "glite/lb/producer.h" +#include "glite/wmsutils/jobid/cjobid.h" + +static void slave(); + +int main(int argc,char **argv) +{ + int i,nproc; + + if (argc != 2) { + fprintf(stderr,"usage: %s nproc\n",argv[0]); + return 1; + } + + nproc = atoi(argv[1]); + if (nproc < 1) { + fprintf(stderr,"%s: nproc must be >= 1\n",argv[0]); + return 1; + } + + for (i=0; i0) { reg_subjobs = 1; break; } case 'l': jdl = (char *) strdup(optarg); break; + case 'e': seed = strdup(optarg); break; case '?': usage(argv[0]); exit(EINVAL); case -1: done = 1; break; } @@ -88,7 +89,7 @@ int main(int argc, char *argv[]) if (edg_wll_RegisterJobProxy(ctx,jobid, num_subjobs?EDG_WLL_REGJOB_DAG:EDG_WLL_REGJOB_SIMPLE, jdl ? jdl : "blabla", "NNNSSSS", - num_subjobs,NULL,&subjobs)) + num_subjobs,seed,&subjobs)) { char *et,*ed; edg_wll_Error(ctx,&et,&ed); @@ -99,7 +100,7 @@ int main(int argc, char *argv[]) if (edg_wll_RegisterJobSync(ctx,jobid, num_subjobs?EDG_WLL_REGJOB_DAG:EDG_WLL_REGJOB_SIMPLE, jdl ? jdl : "blabla", "NNNSSSS", - num_subjobs,NULL,&subjobs)) + num_subjobs,seed,&subjobs)) { char *et,*ed; edg_wll_Error(ctx,&et,&ed); diff --git a/org.glite.lb.client/examples/lbmon.c b/org.glite.lb.client/examples/lbmon.c new file mode 100644 index 0000000..2d466b9 --- /dev/null +++ b/org.glite.lb.client/examples/lbmon.c @@ -0,0 +1,137 @@ +#ident "$Header$" + +#include +#include +#include +#include +#include +#include + +#include "glite/lb/consumer.h" + +static void usage(char *); +static int query_all(edg_wll_Context, int, struct timeval, edg_wll_JobStat **, edg_wlc_JobId **); +static void dgerr(edg_wll_Context,char *); + +static char *myname = NULL; +static int debug = 0, verbose = 0, lbproxy =0; +static const char rcsid[] = "@(#)$Id$"; + +static struct option const long_options[] = { + { "help", no_argument, 0, 'h' }, + { "version", no_argument, 0, 'V' }, + { "verbose", no_argument, 0, 'v' }, + { "debug", no_argument, 0, 'd' }, + { "lbproxy", required_argument, 0, 'x' }, + { NULL, 0, NULL, 0} +}; + +int main(int argc,char *argv[]) { + edg_wll_Context ctx; + edg_wll_JobStat *statesOut = NULL; + edg_wlc_JobId *jobsOut = NULL; + struct timeval time_now; + + int i, result, opt, nJobs; + i = result = opt = 0; + gettimeofday(&time_now,0); + + myname = argv[0]; + fprintf(stdout,"\n"); + /* get arguments */ + while ((opt = getopt_long(argc,argv, + "h" /* help */ + "V" /* version */ + "v" /* verbose */ + "d" /* debug */ + "x", /* lbproxy */ + long_options, (int *) 0)) != EOF) { + + switch (opt) { + case 'V': fprintf(stdout,"%s:\t%s\n",argv[0],rcsid); exit(0); + case 'v': verbose = 1; break; + case 'd': debug = 1; break; + case 'x': lbproxy = 1; break; + case 'h': + default: + usage(argv[0]); exit(0); + } + } + if ( edg_wll_InitContext(&ctx) ) { + fprintf(stderr,"%s: cannot initialize edg_wll_Context\n ",myname); + exit(1); + } + + if ( (result = query_all(ctx, EDG_WLL_JOB_CLEARED, time_now, &statesOut, &jobsOut)) ) { + dgerr(ctx, "edg_wll_QueryJobs"); + } else { + fprintf(stdout,"Number of jobs... "); + } + + nJobs = 0; + if ( jobsOut ) { + for (i=0; jobsOut[i]; i++) edg_wlc_JobIdFree(jobsOut[i]); { + nJobs++; + free(jobsOut); + } + } + if ( statesOut ) { + for (i=0; statesOut[i].state; i++) edg_wll_FreeStatus(&statesOut[i]); + free(statesOut); + } + edg_wll_FreeContext(ctx); + + + return result; +} + +static void +usage(char *name) { + fprintf(stderr,"Usage: %s [-x]\n", name); +} + +static int +query_all(edg_wll_Context ctx, int query_status, struct timeval query_time, edg_wll_JobStat **statesOut, edg_wlc_JobId **jobsOut) { + edg_wll_QueryRec jc[3]; + int ret; + + memset(jc, 0, sizeof jc); + + /* jobs in the state 'query_status' within last hour */ + jc[0].attr = EDG_WLL_QUERY_ATTR_STATUS; + jc[0].op = EDG_WLL_QUERY_OP_EQUAL; + jc[0].value.i = query_status; + jc[1].attr = EDG_WLL_QUERY_ATTR_TIME; + jc[1].attr_id.state = query_status; + jc[1].op = EDG_WLL_QUERY_OP_WITHIN; + jc[1].value.t.tv_sec = query_time.tv_sec - 3600; + jc[1].value.t.tv_usec = query_time.tv_usec; + jc[1].value2.t.tv_sec = query_time.tv_sec; + jc[1].value2.t.tv_usec = query_time.tv_usec; + jc[2].attr = EDG_WLL_QUERY_ATTR_UNDEF; + + if ( (ret = edg_wll_QueryJobs(ctx, jc, 0, jobsOut, statesOut)) ) { + if ( ret == E2BIG ) { + int r; + if ( edg_wll_GetParam(ctx, EDG_WLL_PARAM_QUERY_RESULTS, &r) ) return ret; + if ( r != EDG_WLL_QUERYRES_LIMITED ) return ret; + + fprintf(stderr," edg_wll_QueryJobs() Warning: only limited result returned!\n"); + return 0; + } else return ret; + } + + return ret; +} + +static void +dgerr(edg_wll_Context ctx,char *where) { + char *etxt,*edsc; + + edg_wll_Error(ctx,&etxt,&edsc); + fprintf(stderr,"%s: %s: %s",myname,where,etxt); + if (edsc) fprintf(stderr," (%s)",edsc); + putc('\n',stderr); + if(etxt) free(etxt); + if(edsc) free(edsc); +} diff --git a/org.glite.lb.client/examples/stress_context.c b/org.glite.lb.client/examples/stress_context.c new file mode 100644 index 0000000..405f4d1 --- /dev/null +++ b/org.glite.lb.client/examples/stress_context.c @@ -0,0 +1,110 @@ +#include +#include +#include +#include +#include + +#include "glite/wmsutils/jobid/cjobid.h" +#include "glite/lb/producer.h" +#include "glite/lb/events.h" + +char *outfile = "context_errors"; +edg_wlc_JobId job; + +static int stop; + +struct { + int err; + char *text,*desc; +} *errors; + +int nerrors; + +static void killslaves(int sig) +{ + kill(0,SIGTERM); + exit(0); +} + +static void terminate(int sig) +{ + stop = sig; +} + +static void slave(int num) +{ + int good = 0,i; + char fname[PATH_MAX]; + FILE *errf; + edg_wll_Context ctx; + + signal(SIGINT,terminate); + signal(SIGTERM,terminate); + signal(SIGHUP,terminate); + + + while (!stop) { + edg_wll_InitContext(&ctx); + edg_wll_SetParam(ctx, EDG_WLL_PARAM_SOURCE, EDG_WLL_SOURCE_WORKLOAD_MANAGER); + + if (edg_wll_SetLoggingJobProxy(ctx,job,NULL,"/I/am/the/user",EDG_WLL_SEQ_NORMAL) && !stop) { + errors = realloc(errors,(nerrors+1) * sizeof(*errors)); + errors[nerrors].err = edg_wll_Error(ctx,&errors[nerrors].text,&errors[nerrors].desc); + nerrors++; + } + else good++; + + edg_wll_FreeContext(ctx); + } + + sprintf(fname,"%s_%03d",outfile,num); + errf = fopen(fname,"w"); + if (!errf) { perror(fname); exit(1); } + + for (i=0; i diff --git a/org.glite.lb.client/project/version.properties b/org.glite.lb.client/project/version.properties index 1d60a4f..c4facf2 100644 --- a/org.glite.lb.client/project/version.properties +++ b/org.glite.lb.client/project/version.properties @@ -1,4 +1,4 @@ #Fri Sep 02 14:17:41 CEST 2005 # glite-lb-client_branch_3_0_0_RC15 tag is taken! -module.version=2.2.0 +module.version=2.2.3 module.age=0 diff --git a/org.glite.lb.client/src/connection.c b/org.glite.lb.client/src/connection.c index 232be5b..4230b07 100644 --- a/org.glite.lb.client/src/connection.c +++ b/org.glite.lb.client/src/connection.c @@ -17,7 +17,7 @@ #include "glite/lb/context-int.h" #include "glite/lb/mini_http.h" - +#include "connection.h" static void CloseConnection(edg_wll_Context ctx, int conn_index) { @@ -116,7 +116,7 @@ int edg_wll_close_proxy(edg_wll_Context ctx) { edg_wll_plain_close(&ctx->connProxy->conn); - return edg_wll_Error(ctx, NULL, NULL); + return edg_wll_ResetError(ctx); } @@ -202,7 +202,13 @@ int edg_wll_open_proxy(edg_wll_Context ctx) { struct sockaddr_un saddr; int flags; - + int err; + char *ed = NULL; + int retries = 0; + + edg_wll_ResetError(ctx); + + edg_wll_ResetError(ctx); if (ctx->connProxy->conn.sock > -1) { // XXX: test path socket here? @@ -234,19 +240,48 @@ int edg_wll_open_proxy(edg_wll_Context ctx) goto err; } - if (connect(ctx->connProxy->conn.sock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) { - edg_wll_SetError(ctx, errno, "connect()"); + while ((err = connect(ctx->connProxy->conn.sock, (struct sockaddr *)&saddr, sizeof(saddr))) < 0 && + errno == EAGAIN && + ctx->p_tmp_timeout.tv_sec >= 0 && ctx->p_tmp_timeout.tv_usec >= 0 && + !(ctx->p_tmp_timeout.tv_sec == 0 && ctx->p_tmp_timeout.tv_usec == 0) + ) + { + struct timespec ns = { 0, PROXY_CONNECT_RETRY * 1000000 /* 10 ms */ },rem; + + nanosleep(&ns,&rem); + + ctx->p_tmp_timeout.tv_usec -= ns.tv_nsec/1000; + ctx->p_tmp_timeout.tv_usec += rem.tv_nsec/1000; + + ctx->p_tmp_timeout.tv_sec -= ns.tv_sec; + ctx->p_tmp_timeout.tv_sec += rem.tv_sec; + + if (ctx->p_tmp_timeout.tv_usec < 0) { + ctx->p_tmp_timeout.tv_usec += 1000000; + ctx->p_tmp_timeout.tv_sec--; + } + retries++; + } + + /* printf("retries %d\n",retries); */ + + if (err) { + if (errno == EAGAIN) edg_wll_SetError(ctx,ETIMEDOUT, "edg_wll_open_proxy()"); + else edg_wll_SetError(ctx, errno, "connect()"); goto err; } - return edg_wll_Error(ctx,NULL,NULL); + return 0; err: /* some error occured; close created connection */ + err = edg_wll_Error(ctx,NULL,&ed); edg_wll_close_proxy(ctx); + edg_wll_SetError(ctx,err,ed); + free(ed); - return edg_wll_Error(ctx,NULL,NULL); + return err; } diff --git a/org.glite.lb.client/src/connection.h b/org.glite.lb.client/src/connection.h index 7de349d..1b12058 100644 --- a/org.glite.lb.client/src/connection.h +++ b/org.glite.lb.client/src/connection.h @@ -1,7 +1,7 @@ #ifndef __EDG_WORKLOAD_LOGGING_CLIENT_CONNECTION_H__ #define __EDG_WORKLOAD_LOGGING_CLIENT_CONNECTION_H__ -#ident "$Header" +#ident "$Header$" int edg_wll_close(edg_wll_Context ctx); int edg_wll_open(edg_wll_Context ctx); @@ -13,5 +13,7 @@ int edg_wll_http_send_recv_proxy(edg_wll_Context, char *, const char * const *, int http_check_status(edg_wll_Context, char *); +#define PROXY_CONNECT_RETRY 10 /* ms */ + #endif /* __EDG_WORKLOAD_LOGGING_CLIENT_CONNECTION_H__ */ diff --git a/org.glite.lb.client/examples/export.sh b/org.glite.lb.client/src/export.sh similarity index 56% rename from org.glite.lb.client/examples/export.sh rename to org.glite.lb.client/src/export.sh index 0d00941..eda817c 100644 --- a/org.glite.lb.client/examples/export.sh +++ b/org.glite.lb.client/src/export.sh @@ -30,29 +30,45 @@ fi # dump directory of bkserver +GLITE_LB_EXPORT_PURGEDIR=${GLITE_LB_EXPORT_PURGEDIR:-/tmp/purge} GLITE_LB_EXPORT_DUMPDIR=${GLITE_LB_EXPORT_DUMPDIR:-/tmp/dump} -GLITE_LB_EXPORT_DUMPDIR_OLD=${GLITE_LB_EXPORT_DUMPDIR_OLD:-$GLITE_LB_EXPORT_DUMPDIR.old} +GLITE_LB_EXPORT_PURGEDIR_KEEP=${GLITE_LB_EXPORT_PURGEDIR_KEEP:-""} +GLITE_LB_EXPORT_DUMPDIR_KEEP=${GLITE_LB_EXPORT_DUMPDIR_KEEP:-""} # maildir dump directory for jp importer GLITE_LB_EXPORT_JPDUMP_MAILDIR=${GLITE_LB_EXPORT_JPDUMP_MAILDIR:-/tmp/jpdump} # directory with exported data (file per job) -GLITE_LB_EXPORT_EXPORTDIR=${GLITE_LB_EXPORT_EXPORTDIR:-/tmp/lbexport} +GLITE_LB_EXPORT_JOBSDIR=${GLITE_LB_EXPORT_JOBSDIR:-/tmp/lbexport} # purge args (timeouts) -GLITE_LB_EXPORT_PURGE_ARGS=${GLITE_LB_EXPORT_PURGE_ARGS:--a 1h -c 1h -n 1h -o 1d} +GLITE_LB_EXPORT_PURGE_ARGS=${GLITE_LB_EXPORT_PURGE_ARGS:---cleared 2d --aborted 2w --cancelled 2w --other 2m} # Book Keeping Server -GLITE_LB_EXPORT_BKSERVER=${GLITE_LB_EXPORT_BKSERVER:-localhost:9000} +GLITE_LB_SERVER_PORT=${GLITE_LB_SERVER_PORT:-9000} +GLITE_LB_EXPORT_BKSERVER=${GLITE_LB_EXPORT_BKSERVER:-localhost:$GLITE_LB_SERVER_PORT} [ -d $GLITE_LB_EXPORT_JPDUMP_MAILDIR ] || mkdir -p $GLITE_LB_EXPORT_JPDUMP_MAILDIR [ -d $GLITE_LB_EXPORT_DUMPDIR ] || mkdir -p $GLITE_LB_EXPORT_DUMPDIR -[ -d $GLITE_LB_EXPORT_DUMPDIR_OLD ] || mkdir -p $GLITE_LB_EXPORT_DUMPDIR_OLD -[ -d $GLITE_LB_EXPORT_EXPORTDIR ] || mkdir -p $GLITE_LB_EXPORT_EXPORTDIR +[ -d $GLITE_LB_EXPORT_PURGEDIR ] || mkdir -p $GLITE_LB_EXPORT_PURGEDIR +[ -d $GLITE_LB_EXPORT_DUMPDIR_KEEP ] || mkdir -p $GLITE_LB_EXPORT_DUMPDIR_KEEP +[ -d $GLITE_LB_EXPORT_PURGEDIR_KEEP ] || mkdir -p $GLITE_LB_EXPORT_PURGEDIR_KEEP +[ -d $GLITE_LB_EXPORT_JOBSDIR ] || mkdir -p $GLITE_LB_EXPORT_JOBSDIR X509_USER_CERT="$X509_USER_CERT" X509_USER_KEY="$X509_USER_KEY" $PREFIX/sbin/glite-lb-purge $GLITE_LB_EXPORT_PURGE_ARGS -l -m $GLITE_LB_EXPORT_BKSERVER -for file in $GLITE_LB_EXPORT_DUMPDIR/*; do +for file in $GLITE_LB_EXPORT_PURGEDIR/*; do if [ -s $file ]; then - $PREFIX/sbin/glite-lb-lb_dump_exporter -d $file -s $GLITE_LB_EXPORT_EXPORTDIR -m $GLITE_LB_EXPORT_JPDUMP_MAILDIR - mv $file $GLITE_LB_EXPORT_DUMPDIR_OLD + $PREFIX/sbin/glite-lb-lb_dump_exporter -d $file -s $GLITE_LB_EXPORT_JOBSDIR -m $GLITE_LB_EXPORT_JPDUMP_MAILDIR + if [ -n "$GLITE_LB_EXPORT_PURGEDIR_KEEP" ]; then + mv $file $GLITE_LB_EXPORT_PURGEDIR_KEEP + else + rm $file + fi else rm $file fi done + +if [ -n "$GLITE_LB_EXPORT_DUMPDIR_KEEP" ]; then + ls $GLITE_LB_EXPORT_DUMPDIR | xargs -i'{}' cp $GLITE_LB_EXPORT_DUMPDIR/'{}' $GLITE_LB_EXPORT_DUMPDIR_KEEP; +else + ls $GLITE_LB_EXPORT_DUMPDIR | xargs -i'{}' rm -f $GLITE_LB_EXPORT_DUMPDIR/'{}' +fi + diff --git a/org.glite.lb.client/src/lb_dump_exporter.c b/org.glite.lb.client/src/lb_dump_exporter.c index 2eb1850..97a63ab 100644 --- a/org.glite.lb.client/src/lb_dump_exporter.c +++ b/org.glite.lb.client/src/lb_dump_exporter.c @@ -9,6 +9,8 @@ #include #include #include +#include + #include "glite/lb/context.h" #include "glite/lb/events.h" @@ -149,8 +151,9 @@ int main(int argc, char **argv) } if ( !(st = dump_storage_find(dstorage, jobid)) ) { - int fd, i; + int fd, i; char fname[PATH_MAX]; + struct timeval tv; i = 0; while ( 1 ) { @@ -159,9 +162,10 @@ int main(int argc, char **argv) perror("Can't create dump file - max tries limit reached "); cleanup(1); } - snprintf(fname, PATH_MAX, "%s/%s.%ld", store_pref, unique, (long) time(NULL)); + gettimeofday(&tv, NULL); + snprintf(fname, PATH_MAX, "%s/%s.%ld_%ld", store_pref, unique, tv.tv_sec, tv.tv_usec); if ( (fd = open(fname, O_CREAT|O_EXCL|O_RDWR, 00640)) < 0 ) { - if ( errno == EEXIST ) { sleep(2); continue; } + if ( errno == EEXIST ) { usleep(1000); continue; } perror(fname); cleanup(1); } diff --git a/org.glite.lb.client/src/notification.c b/org.glite.lb.client/src/notification.c index 5899d9b..c9d8579 100644 --- a/org.glite.lb.client/src/notification.c +++ b/org.glite.lb.client/src/notification.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "glite/security/glite_gss.h" #include "glite/lb/notification.h" @@ -707,7 +708,7 @@ err: #endif /* NotifReceive */ { - fd_set fds; + struct pollfd pollfds[1]; struct sockaddr_in a; int recv_sock, alen; edg_wll_Event *event = NULL; @@ -731,8 +732,8 @@ err: } } - FD_ZERO(&fds); - FD_SET(fd,&fds); + pollfds[0].fd = fd; + pollfds[0].events = POLLIN; tv.tv_sec = timeout->tv_sec; tv.tv_usec = timeout->tv_usec; @@ -750,14 +751,18 @@ select: if (ctx->connPoolNotif[0].gss.context == GSS_C_NO_CONTEXT) { int ret; - switch(select(fd+1, &fds, NULL, NULL, &tv)) { + switch(poll(pollfds, 1, tv.tv_sec*1000+tv.tv_usec/1000)) { case -1: - edg_wll_SetError(ctx, errno, "select() failed"); + edg_wll_SetError(ctx, errno, "edg_wll_NotifReceive: poll() failed"); goto err; case 0: - edg_wll_SetError(ctx, ETIMEDOUT, "select() timeouted"); + edg_wll_SetError(ctx, ETIMEDOUT, "edg_wll_NotifReceive: poll() timed out"); goto err; default: + if (!(pollfds[0].revents & POLLIN)) { + edg_wll_SetError(ctx, errno, "edg_wll_NotifReceive: error on filedescriptor"); + goto err; + } break; } @@ -818,13 +823,9 @@ select: goto err; /* error set in send_reply() */ } - { - il_octet_string_t ev; - - if(decode_il_msg(&ev, ctx->connPoolNotif[0].buf) < 0) - return edg_wll_SetError(ctx, EDG_WLL_IL_PROTO, "decoding event string"); - event_char = ev.data; - } + if(decode_il_msg(&event_char, ctx->connPoolNotif[0].buf) < 0) + return edg_wll_SetError(ctx, EDG_WLL_IL_PROTO, "decoding event string"); + /****************************************************************/ /* end of notif-interlogger message exchange */ /****************************************************************/ diff --git a/org.glite.lb.client/src/perftest_jobreg.c b/org.glite.lb.client/src/perftest_jobreg.c deleted file mode 100644 index 816ff8f..0000000 --- a/org.glite.lb.client/src/perftest_jobreg.c +++ /dev/null @@ -1,183 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/lb/producer.h" -#include "glite/lb/events.h" - -#define PROXY_SERVER "localhost:9000" - -#define tv_sub(a,b) {\ - (a).tv_usec -= (b).tv_usec;\ - (a).tv_sec -= (b).tv_sec;\ - if ((a).tv_usec < 0) {\ - (a).tv_sec--;\ - (a).tv_usec += 1000000;\ - }\ -} - - - -extern char *optarg; -extern int opterr,optind; - -static void usage(char *me) -{ - fprintf(stderr,"usage: %s [-m bkserver] [-x] [-n num_subjobs [-S]] [-l jdl_file] [-N num_repeat]\n" - " -m address:port of bkserver\n" - " -x use LBProxy\n" - " -n number of subjobs of DAG\n" - " -S register subjobs\n" - " -l file with JDL\n" - " -N repeat whole registration N-times\n", - me); -} - -int main(int argc, char *argv[]) -{ - char *server = NULL,*jdl = NULL; - int lbproxy = 0, N = 1; - int done = 0,num_subjobs = 0,reg_subjobs = 0, i, j; - edg_wll_Context ctx; - edg_wlc_JobId *jobids,*subjobs; - struct timeval start, stop; - - - edg_wll_InitContext(&ctx); - opterr = 0; - - do { - switch (getopt(argc,argv,"xm:n:Sl:N:")) { - case 'x': lbproxy = 1; break; - case 'm': server = strdup(optarg); break; - case 'n': num_subjobs = atoi(optarg); break; - case 'S': if (num_subjobs>0) { reg_subjobs = 1; break; } - case 'l': jdl = (char *) strdup(optarg); break; - case 'N': N = atoi(optarg); break; - case '?': usage(argv[0]); exit(EINVAL); - case -1: done = 1; break; - } - } while (!done); - - if (!server && !lbproxy) { - fprintf(stderr,"%s: either -m server or -x has to be specified\n",argv[0]); - exit(1); - } - - /* prepare set of N jobid before starting timer */ - jobids = (edg_wlc_JobId *) malloc(N * sizeof(edg_wlc_JobId)); - printf("generating jobids..."); - { - char *name=server?server:strdup(PROXY_SERVER); - char *p = strchr(name,':'); - int port; - - if (p) { *p=0; port = atoi(p+1); } - else port = 0; - for (i=0; i 0; p += c); - if (c<0) { - perror("read()"); - exit (1); - } - jdl[p] = 0; - } - - edg_wll_SetParam(ctx,EDG_WLL_PARAM_SOURCE,edg_wll_StringToSource("Application")); - - /* start measurement */ - gettimeofday(&start, NULL); - - for (i=0; i -#include -#include -#include -#include -#include -#include "glite/lb/context-int.h" -#include "glite/lb/lb_perftest.h" -#include "glite/lb/log_proto.h" - -extern int edg_wll_DoLogEvent(edg_wll_Context context, edg_wll_LogLine logline); -extern int edg_wll_DoLogEventProxy(edg_wll_Context context, edg_wll_LogLine logline); -extern int edg_wll_DoLogEventDirect(edg_wll_Context context, edg_wll_LogLine logline); - -#define DEFAULT_SOCKET "/tmp/interlogger.sock" - -/* -extern char *optarg; -extern int opterr,optind; - -Vzorem by mel byt examples/stresslog.c, ovsem s mirnymi upravami: - -1) nacte udalosti jednoho jobu z daneho souboru, rozparsuje a ulozi do pameti -2) je-li pozadan, zaregistruje dany pocet jobid -3) vypise timestamp -4) odesle rozparsovane udalosti pod ruznymi jobid (tolika, kolik ma - byt jobu - argument) na dany cil (localloger, interlogger, bkserver, proxy) -5) odesle specialni ukoncovaci udalost -6) exit - - read_job("small_job",&event_lines); - gettimeoday(&zacatek) - for (i=0; i<1000; i++) { - for (e=0; event_lines[e]; e++) - edg_wll_ParseEvent(event_lines[e],&event[e]); - } - gettimeofday(&konec); - - printf("parsovani",konec-zacatek/1000); - - gettimeofday(&zacatek); - switch (event[e].type) { - ... - edg_wll_LogBlaBla() - - -*/ - -static struct option const long_options[] = { - { "help", no_argument, 0, 'h' }, - { "dst", required_argument, NULL, 'd' }, - { "test", required_argument, NULL, 't' }, - { "file", required_argument, NULL, 'f'}, - { "num", required_argument, NULL, 'n'}, - { "machine", required_argument, NULL, 'm'}, - { NULL, 0, NULL, 0} -}; - - -void -usage(char *program_name) -{ - fprintf(stderr, "Usage: %s [-d destname] [-t testname] -f filename -n numjobs \n" - "-h, --help display this help and exit\n" - "-d, --dst destination component\n" - "-m, --machine destination host\n" - "-t, --test name of the test\n" - "-f, --file name of the file with prototyped job events\n" - "-n, --num number of jobs to generate\n", - program_name); -} - - -int edg_wll_DoLogEventIl( - edg_wll_Context context, - edg_wll_LogLine logline) -{ - static int filepos = 0; - int ret = 0; - struct timeval timeout; - - timeout.tv_sec = 1; - timeout.tv_usec = 0; - ret = edg_wll_log_event_send(context, DEFAULT_SOCKET, filepos, logline, strlen(logline), 1, &timeout); - filepos += strlen(logline); - - return(ret); -} - - -int -main(int argc, char *argv[]) -{ - - char *destname= NULL,*hostname=NULL,*testname = NULL,*filename = NULL; - char *event; - int num_jobs = 1; - int opt; - edg_wll_Context ctx; - enum { - DEST_UNDEF = 0, - DEST_LL, - DEST_IL, - DEST_PROXY, - DEST_BKSERVER - } dest = 0; - - - edg_wll_InitContext(&ctx); - - opterr = 0; - - while ((opt = getopt_long(argc,argv,"hd:t:f:n:x", - long_options, (int *) 0)) != EOF) { - - switch (opt) { - case 'd': destname = (char *) strdup(optarg); break; - case 't': testname = (char *) strdup(optarg); break; - case 'f': filename = (char *) strdup(optarg); break; - case 'm': hostname = (char *) strdup(optarg); break; - case 'n': num_jobs = atoi(optarg); break; - case 'h': - default: - usage(argv[0]); exit(0); - } - } - - if(destname) { - if(!strncasecmp(destname, "pr", 2)) - dest=DEST_PROXY; - else if(!strncasecmp(destname, "lo", 2) || !strncasecmp(destname, "ll", 2)) - dest=DEST_LL; - else if(!strncasecmp(destname, "in", 2) || !strncasecmp(destname, "il", 2)) - dest=DEST_IL; - else if(!strncasecmp(destname, "bk", 2) || !strncasecmp(destname, "se", 2)) - dest=DEST_BKSERVER; - else { - fprintf(stderr,"%s: wrong destination\n",argv[0]); - usage(argv[0]); - exit(1); - } - } - - if (num_jobs <= 0) { - fprintf(stderr,"%s: wrong number of jobs\n",argv[0]); - usage(argv[0]); - exit(1); - } - - if (!filename && destname) { - fprintf(stderr,"%s: -f required\n",argv[0]); - usage(argv[0]); - exit(1); - } - - if (glite_wll_perftest_init(hostname, NULL, testname, filename, num_jobs) < 0) { - fprintf(stderr,"%s: glite_wll_perftest_init failed\n",argv[0]); - } - - if(dest) { - while (glite_wll_perftest_produceEventString(&event)) { - switch(dest) { - case DEST_PROXY: - ctx->p_tmp_timeout = ctx->p_sync_timeout; - if (edg_wll_DoLogEventProxy(ctx,event)) { - char *et,*ed; - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"edg_wll_DoLogEventProxy(): %s (%s)\n",et,ed); - exit(1); - } - break; - - case DEST_LL: - ctx->p_tmp_timeout = ctx->p_log_timeout; - if (edg_wll_DoLogEvent(ctx,event)) { - char *et,*ed; - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"edg_wll_DoLogEvent(): %s (%s)\n",et,ed); - exit(1); - } - break; - - case DEST_BKSERVER: - ctx->p_tmp_timeout = ctx->p_log_timeout; - if (edg_wll_DoLogEventDirect(ctx, event)) { - char *et,*ed; - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"edg_wll_DoLogEventDirect(): %s (%s)\n",et,ed); - exit(1); - } - - case DEST_IL: - ctx->p_tmp_timeout = ctx->p_log_timeout; - if (edg_wll_DoLogEventIl(ctx, event)) { - char *et,*ed; - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"edg_wll_DoLogEventIl(): %s (%s)\n",et,ed); - exit(1); - } - - default: - break; - } - free(event); - } - } else { - /* no destination - only print jobid's that would be used */ - char *jobid; - - while(jobid = glite_wll_perftest_produceJobId()) { - fprintf(stdout, "%s\n", jobid); - free(jobid); - } - } - edg_wll_FreeContext(ctx); - return 0; - -} diff --git a/org.glite.lb.client/src/prod_proto.c b/org.glite.lb.client/src/prod_proto.c index a652916..19822e6 100644 --- a/org.glite.lb.client/src/prod_proto.c +++ b/org.glite.lb.client/src/prod_proto.c @@ -288,13 +288,7 @@ int edg_wll_log_proto_client_proxy(edg_wll_Context context, edg_wll_PlainConnect lbproto_code = 0; edg_wll_ResetError(context); - { - il_octet_string_t ll; - - ll.len = strlen(logline); - ll.data = logline; - len = encode_il_msg(&buffer, &ll); - } + len = encode_il_msg(&buffer, logline); if(len < 0) { edg_wll_SetError(context,ENOMEM,"edg_wll_log_proto_client_proxy(): error encoding message"); goto edg_wll_log_proto_client_proxy_end; @@ -370,12 +364,7 @@ int edg_wll_log_proto_client_direct(edg_wll_Context context, edg_wll_GssConnecti edg_wll_ResetError(context); /* encode message */ - { - il_octet_string_t ll; - - ll.len=strlen(logline); ll.data=logline; - len = encode_il_msg(&buffer, &ll); - } + len = encode_il_msg(&buffer, logline); if(len < 0) { edg_wll_SetError(context, ENOMEM, "edg_wll_log_proto_client_direct(): error encoding message"); goto edg_wll_log_proto_client_direct_end; diff --git a/org.glite.lb.client/src/producer.c b/org.glite.lb.client/src/producer.c index 3094432..4239d24 100644 --- a/org.glite.lb.client/src/producer.c +++ b/org.glite.lb.client/src/producer.c @@ -27,6 +27,7 @@ #include "glite/lb/escape.h" #include "prod_proto.h" +#include "connection.h" static const char* socket_path="/tmp/lb_proxy_store.sock"; @@ -156,7 +157,7 @@ int edg_wll_DoLogEventProxy( edg_wll_LogLine logline) { int answer; - int flags; + int flags,retries; char *name_esc,*dguser; struct sockaddr_un saddr; edg_wll_PlainConnection conn; @@ -187,6 +188,10 @@ int edg_wll_DoLogEventProxy( close(conn.sock); goto edg_wll_DoLogEventProxy_end; } + +/* non-retry variant (pre bug #18994) + * XXX: what is the EISCONN case good for? conn.sock is created above. + * if (connect(conn.sock, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) { if(errno != EISCONN) { edg_wll_SetError(context,answer = errno,"connect()"); @@ -194,6 +199,40 @@ int edg_wll_DoLogEventProxy( goto edg_wll_DoLogEventProxy_end; } } +*/ + + retries = 0; + while ((answer = connect(conn.sock, (struct sockaddr *)&saddr, sizeof(saddr))) < 0 && + errno == EAGAIN && + context->p_tmp_timeout.tv_sec >= 0 && context->p_tmp_timeout.tv_usec >= 0 && + !(context->p_tmp_timeout.tv_sec == 0 && context->p_tmp_timeout.tv_usec == 0) + ) + { + struct timespec ns = { 0, PROXY_CONNECT_RETRY * 1000000 /* 10 ms */ },rem; + + nanosleep(&ns,&rem); + + context->p_tmp_timeout.tv_usec -= ns.tv_nsec/1000; + context->p_tmp_timeout.tv_usec += rem.tv_nsec/1000; + + context->p_tmp_timeout.tv_sec -= ns.tv_sec; + context->p_tmp_timeout.tv_sec += rem.tv_sec; + + if (context->p_tmp_timeout.tv_usec < 0) { + context->p_tmp_timeout.tv_usec += 1000000; + context->p_tmp_timeout.tv_sec--; + } + retries++; + } + + if (answer) { + if (errno == EAGAIN) edg_wll_SetError(context,answer = ETIMEDOUT,"edg_wll_DoLogEventProxy connect()"); + else edg_wll_SetError(context,answer = errno,"connect()"); + close(conn.sock); + goto edg_wll_DoLogEventProxy_end; + } + +/* just debug if (retries) printf("edg_wll_DoLogEventProxy connect retries %d\n",retries); */ /* add DG.USER to the message: */ name_esc = edg_wll_LogEscape(context->p_user_lbproxy); @@ -408,7 +447,6 @@ static int edg_wll_LogEventMaster( } /* and send the message */ -#ifndef LB_PERF_DROP if (flags & LOGFLAG_NORMAL) { /* to the local-logger: */ ret = edg_wll_DoLogEvent(context, out); @@ -421,7 +459,6 @@ static int edg_wll_LogEventMaster( } else { edg_wll_SetError(context,ret = EINVAL,"edg_wll_LogEventMaster(): wrong flag specified"); } -#endif edg_wll_logeventmaster_end: va_end(fmt_args); @@ -701,10 +738,9 @@ int edg_wll_SetLoggingJobProxy( edg_wll_SetParamString(context, EDG_WLL_PARAM_LBPROXY_USER, user); /* query LBProxyServer for sequence code if not user-suplied */ -/* FIXME: doesn't work yet */ if (!code) { - edg_wll_QuerySequenceCodeProxy(context, job, &code_loc); - goto edg_wll_setloggingjobproxy_end; + if (edg_wll_QuerySequenceCodeProxy(context, job, &code_loc)) + goto edg_wll_setloggingjobproxy_end; } else { code_loc = strdup(code); } @@ -772,10 +808,7 @@ static int edg_wll_RegisterJobMaster( (char *)jdl,ns,parent_s,type_s,num_subjobs,intseed); } } else if (flags & LOGFLAG_PROXY) { - /* first obtain the certificate */ - /* used in edg_wll_DoLogEventProxy() for field DG.USER */ - /* not mandatory now */ - + /* first obtain the certiicate */ err = edg_wll_gss_acquire_cred_gsi( context->p_proxy_filename ? context->p_proxy_filename : context->p_cert_filename, context->p_proxy_filename ? context->p_proxy_filename : context->p_key_filename, @@ -862,26 +895,6 @@ int edg_wll_RegisterJobProxy( return edg_wll_RegisterJobMaster(context,LOGFLAG_PROXY,job,type,jdl,ns,NULL,num_subjobs,seed ? seed : MY_SEED,subjobs); } - -#ifdef LB_PERF -// function for loggin only to LBProxy -// useful for performace measuring -int edg_wll_RegisterJobProxyOnly( - edg_wll_Context context, - const edg_wlc_JobId job, - enum edg_wll_RegJobJobtype type, - const char * jdl, - const char * ns, - int num_subjobs, - const char * seed, - edg_wlc_JobId ** subjobs) -{ -#define MY_SEED "edg_wll_RegisterJobProxy()" - return edg_wll_RegisterJobMaster(context,LOGFLAG_PROXY,job,type,jdl,ns,NULL,num_subjobs,seed ? seed : MY_SEED,subjobs); -} - -#endif - int edg_wll_RegisterSubjob( edg_wll_Context context, const edg_wlc_JobId job, @@ -921,6 +934,8 @@ int edg_wll_RegisterSubjobs( edg_wlc_JobId const *psubjob; edg_wlc_JobId oldctxjob; char * oldctxseq; + int errcode = 0; + char * errdesc = NULL; if (edg_wll_GetLoggingJob(ctx, &oldctxjob)) return edg_wll_Error(ctx, NULL, NULL); oldctxseq = edg_wll_GetSequenceCode(ctx); @@ -931,14 +946,19 @@ int edg_wll_RegisterSubjobs( while (*pjdl != NULL) { if (edg_wll_RegisterSubjob(ctx, *psubjob, EDG_WLL_REGJOB_SIMPLE, *pjdl, ns, parent, 0, NULL, NULL) != 0) { + errcode = edg_wll_Error(ctx, NULL, &errdesc); goto edg_wll_registersubjobs_end; } pjdl++; psubjob++; } +edg_wll_registersubjobs_end: edg_wll_SetLoggingJob(ctx, oldctxjob, oldctxseq, EDG_WLL_SEQ_NORMAL); -edg_wll_registersubjobs_end: + if (errcode) { + edg_wll_SetError(ctx, errcode, errdesc); + free(errdesc); + } return edg_wll_Error(ctx, NULL, NULL); } @@ -953,6 +973,8 @@ int edg_wll_RegisterSubjobsProxy( edg_wlc_JobId const *psubjob; edg_wlc_JobId oldctxjob; char * oldctxseq; + int errcode = 0; + char * errdesc = NULL; if (edg_wll_GetLoggingJob(ctx, &oldctxjob)) return edg_wll_Error(ctx, NULL, NULL); oldctxseq = edg_wll_GetSequenceCode(ctx); @@ -963,14 +985,19 @@ int edg_wll_RegisterSubjobsProxy( while (*pjdl != NULL) { if (edg_wll_RegisterSubjobProxy(ctx, *psubjob, EDG_WLL_REGJOB_SIMPLE, *pjdl, ns, parent, 0, NULL, NULL) != 0) { + errcode = edg_wll_Error(ctx, NULL, &errdesc); goto edg_wll_registersubjobsproxy_end; } pjdl++; psubjob++; } +edg_wll_registersubjobsproxy_end: edg_wll_SetLoggingJobProxy(ctx, oldctxjob, oldctxseq, NULL, EDG_WLL_SEQ_NORMAL); -edg_wll_registersubjobsproxy_end: + if (errcode) { + edg_wll_SetError(ctx, errcode, errdesc); + free(errdesc); + } return edg_wll_Error(ctx, NULL, NULL); } diff --git a/org.glite.lb.client/test/producer_test.cpp b/org.glite.lb.client/test/producer_test.cpp index c2199c5..33da719 100644 --- a/org.glite.lb.client/test/producer_test.cpp +++ b/org.glite.lb.client/test/producer_test.cpp @@ -55,14 +55,14 @@ private: void log_proto_server(int con, char *logline) { int i; - char b[4]; + char b[5]; char *buf; ssize_t size, retsize; // read DGLOG retsize = read(con, b, 5); CPPUNIT_ASSERT(retsize == 5); - CPPUNIT_ASSERT(b[0] = 'D' && b[1] == 'G' && b[2] == 'L' && b[3] == 'O' && b[4] == 'G'); + CPPUNIT_ASSERT(b[0] == 'D' && b[1] == 'G' && b[2] == 'L' && b[3] == 'O' && b[4] == 'G'); // read size (including '\0', little endian) for (i = 0; i < 4; i++) diff --git a/org.glite.lb.common/Makefile b/org.glite.lb.common/Makefile index fdc9ac5..58fdde0 100644 --- a/org.glite.lb.common/Makefile +++ b/org.glite.lb.common/Makefile @@ -17,15 +17,12 @@ thrflavour=gcc32pthr expat_prefix=/opt/expat -include Makefile.inc --include ../project/version.properties - -jobiddir=${top_srcdir}/../org.glite.wms-utils.jobid - -version=${module.version} +-include ../Makefile.inc VPATH=${top_srcdir}/src:${top_srcdir}/test AT3=perl -I${top_srcdir}/project ${top_srcdir}/project/at3 + SUFFIXES = .T CC=gcc @@ -34,25 +31,14 @@ DEBUG:=-g -O0 -Wall GLOBUSINC:= -I${globus_prefix}/include/${nothrflavour} GLOBUSTHRINC:= -I${globus_prefix}/include/${thrflavour} -ifdef LB_STANDALONE - JOBID_OBJS:=cjobid.o strmd5.o - LB_STANDALONE_FLAGS:=-DLB_STANDALONE -else - JOBID_LIB:=-lglite_wmsutils_cjobid -endif - -PERF_HDRS:=lb_perftest.h -PERF_OBJS:=lb_perftest.o - CFLAGS:=${DEBUG} -I${top_srcdir}/src -I${top_srcdir}/interface \ - -I. \ -I${top_srcdir}/test \ -I${stagedir}/include \ -I${glite_location}/include \ -I${expat_prefix}/include \ ${COVERAGE_FLAGS} \ -D_GNU_SOURCE \ - -DDATAGRID_EXTENSION ${LB_STANDALONE_FLAGS} + -DDATAGRID_EXTENSION # We must follow major version changes of org.glite.lb.client-interface due to # binary compatibility. However, we may live a life of our own, changing our @@ -79,21 +65,26 @@ EXPAT_LIBS:=${EXPAT_LIBS} -lexpat LDFLAGS:=-L${stagedir}/lib \ ${COVERAGE_FLAGS} -EXT_LIBS:= ${EXPAT_LIBS} ${GLOBUS_LIBS} ${JOBID_LIB} -EXT_THRLIBS:= ${EXPAT_LIBS} ${GLOBUS_THRLIBS} ${JOBID_LIB} +EXT_LIBS:= ${EXPAT_LIBS} ${GLOBUS_LIBS} +EXT_THRLIBS:= ${EXPAT_LIBS} ${GLOBUS_THRLIBS} + +# breaks linking when not installed in /opt, /home/dimeglio etc. +# ${GLITE_LIBS} \ +# ${GLOBUS_LIBS} \ +# ${EXPAT_LIBS} -TEST_LIBS:=-L${cppunit_prefix}/lib -lcppunit -TEST_INC:=-I${cppunit_prefix}/include +TEST_LIBS:=-L${cppunit}/lib -lcppunit +TEST_INC:=-I${cppunit}/include COMPILE:=libtool --mode=compile ${CC} LINK:=libtool --mode=link ${CC} -rpath ${stagedir}/lib ${LDFLAGS} LINKXX:=libtool --mode=link ${CXX} -rpath ${stagedir}/lib ${LDFLAGS} INSTALL:=libtool --mode=install install -OBJS:=${JOBID_OBJS} ${PERF_OBJS} lb_plain_io.o escape.o events.o mini_http.o query_rec.o \ +OBJS:=lb_plain_io.o escape.o events.o mini_http.o query_rec.o \ status.o xml_conversions.o xml_parse.o ulm_parse.o param.o \ events_parse.o il_string.o il_int.o notifid.o \ - il_log.o il_msg.o log_msg.o context.o trio.o strio.o lb_maildir.o + il_log.o il_msg.o log_msg.o context.o trio.o strio.o lb_maildir.o LOBJS:=${OBJS:.o=.lo} TRIO_OBJS:=escape.o trio.o strio.o @@ -107,7 +98,7 @@ THRLOBJS:=${OBJS:.o=.thr.lo} HDRS:=context-int.h lb_plain_io.h mini_http.h authz.h xml_parse.h \ xml_conversions.h log_proto.h events_parse.h il_string.h il_msg.h \ - escape.h ulm_parse.h trio.h lb_maildir.h ${PERF_HDRS} + escape.h ulm_parse.h trio.h lb_maildir.h STATICLIB:=libglite_lb_common_${nothrflavour}.a THRSTATICLIB:=libglite_lb_common_${thrflavour}.a @@ -116,18 +107,10 @@ THRLTLIB:=libglite_lb_common_${thrflavour}.la REPORTS:=${top_srcdir}/reports -ifdef LB_PERF -STAGE_PERFTEST=mkdir -p ${PREFIX}/examples/perftest; \ - install -m 644 ${top_srcdir}/examples/*.log ${PREFIX}/examples/perftest; \ - install -m 755 ${top_srcdir}/src/perftest_common.sh ${PREFIX}/sbin -else -STAGE_PERFTEST=true -endif - default: all -#all compile: check_version ${STATICLIB} ${LTLIB} ${THRSTATICLIB} ${THRLTLIB} ${TRIO_LIB} ${MAILDIR_LIB} -all compile: ${STATICLIB} ${LTLIB} ${THRSTATICLIB} ${THRLTLIB} ${TRIO_LIB} ${MAILDIR_LIB} +all compile: check_version ${STATICLIB} ${LTLIB} ${THRSTATICLIB} ${THRLTLIB} ${TRIO_LIB} ${MAILDIR_LIB} +# all compile: ${STATICLIB} ${LTLIB} ${THRSTATICLIB} ${THRLTLIB} # FIXME: to use libtool versioning correcty, we should have: # @@ -164,12 +147,14 @@ ${THRSTATICLIB}: ${THROBJS} ${LTLIB}: ${OBJS} ${LINK} ${version_info} -o $@ ${LOBJS} \ -lglite_security_gss_${nothrflavour} \ + -lglite_wmsutils_cjobid \ ${EXT_LIBS} \ -lm ${THRLTLIB}: ${THROBJS} ${LINK} ${version_info} -o $@ ${THRLOBJS} \ -lglite_security_gss_${thrflavour} \ + -lglite_wmsutils_cjobid \ ${EXT_THRLIBS} \ -lm @@ -212,14 +197,6 @@ distbin: save_dir=`pwd`; cd tmpbuilddir${stagedir} && tar -czf $$save_dir/${top_srcdir}/${distdir}/${package}-${version}_bin.tar.gz *; cd $$save_dir rm -rf tmpbuilddir -cjobid.c strmd5.c: - if [ ! -d ${jobiddir} ]; then echo "Directory ${jobiddir} not found"; exit 1; fi - mkdir -p glite/wmsutils/jobid - rm -f jobid && ln -fs . jobid - cp -rv ${jobiddir}/interface/glite/wmsutils/jobid/cjobid.h glite/wmsutils/jobid/ - cp -rv ${jobiddir}/src/jobid/*.h glite/wmsutils/jobid/ - cp -rv ${jobiddir}/src/jobid/*.[ch] . - install: mkdir -p ${PREFIX}/lib mkdir -p ${PREFIX}/share/doc/${package}-${version} @@ -229,11 +206,6 @@ install: mkdir -p ${PREFIX}/include/${globalprefix}/${lbprefix} ; \ (cd ${top_srcdir}/interface && install -m 644 ${HDRS} ${PREFIX}/include/${globalprefix}/${lbprefix}) ; \ install -m 644 ${STATICLIB} ${THRSTATICLIB} ${TRIO_LIB} ${PREFIX}/lib; \ - if [ x${LB_STANDALONE} = xyes ]; then \ - mkdir -p ${PREFIX}/include/glite/wmsutils/jobid ; \ - install -m 644 glite/wmsutils/jobid/*.h ${PREFIX}/include/glite/wmsutils/jobid/ ; \ - fi ; \ - ${STAGE_PERFTEST} ; \ fi clean: diff --git a/org.glite.lb.common/interface/il_msg.h b/org.glite.lb.common/interface/il_msg.h index c00a7d0..a2e33a4 100644 --- a/org.glite.lb.common/interface/il_msg.h +++ b/org.glite.lb.common/interface/il_msg.h @@ -1,8 +1,6 @@ #ifndef IL_MSG_H #define IL_MSG_H -#include "il_string.h" - #ident "$Header$" /* @@ -31,23 +29,12 @@ * */ -int encode_il_msg(char **, const il_octet_string_t *); +int encode_il_msg(char **, const char *); int encode_il_reply(char **, int, int, const char *); -int decode_il_msg(il_octet_string_t *, const char *); +int decode_il_msg(char **, const char *); int decode_il_reply(int *, int *, char **, const char *); int read_il_data(void *user_data, char **buffer, int (*reader)(void *user_data, char *buffer, const int)); -enum { - LB_OK = 0, - LB_NOMEM = 200, - LB_PROTO = 400, - LB_AUTH = 500, - LB_PERM = 600, - LB_DBERR = 700, - LB_SYS = 800, - LB_TIME = 900 -}; - #endif diff --git a/org.glite.lb.common/interface/il_string.h b/org.glite.lb.common/interface/il_string.h index 2a3d479..db480f7 100644 --- a/org.glite.lb.common/interface/il_string.h +++ b/org.glite.lb.common/interface/il_string.h @@ -3,20 +3,28 @@ #ident "$Header$" -typedef struct il_octet_string { - int len; - char *data; -} il_octet_string_t; +#define MAXLEN 1024 char *put_int(char *p, int d); char *_put_int(char *p, int d); -char *put_string(char *p, il_octet_string_t *s); +char *put_string(char *p, char *s); char *get_int(char *p, int *d); char *_get_int(char *p, int *d); -char *get_string(char *p, il_octet_string_t *s); +char *get_string(char *p, char **s); -int len_string(il_octet_string_t *s); +int len_string(char *s); int len_int(int d); +enum { + LB_OK = 0, + LB_NOMEM = 200, + LB_PROTO = 400, + LB_AUTH = 500, + LB_PERM = 600, + LB_DBERR = 700, + LB_SYS = 800, + LB_TIME = 900 +}; + #endif diff --git a/org.glite.lb.common/interface/lb_maildir.h b/org.glite.lb.common/interface/lb_maildir.h index 45b2da8..50eb8d4 100644 --- a/org.glite.lb.common/interface/lb_maildir.h +++ b/org.glite.lb.common/interface/lb_maildir.h @@ -17,7 +17,7 @@ extern char lbm_errdesc[]; extern int edg_wll_MaildirInit(const char *); extern int edg_wll_MaildirStoreMsg(const char *, const char *, const char *); -extern int edg_wll_MaildirRetryTransStart(const char *, time_t, char **, char **); +extern int edg_wll_MaildirRetryTransStart(const char *, time_t, time_t, char **, char **); extern int edg_wll_MaildirTransStart(const char *, char **, char **); extern int edg_wll_MaildirTransEnd(const char *, char *, int); diff --git a/org.glite.lb.common/interface/lb_perftest.h b/org.glite.lb.common/interface/lb_perftest.h deleted file mode 100644 index 398938c..0000000 --- a/org.glite.lb.common/interface/lb_perftest.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef LB_PERFTEST_H -#define LB_PERFTEST_H - -#ident "$Header$" - -#include "glite/wmsutils/jobid/cjobid.h" -#include "glite/wmsutils/jobid/strmd5.h" -#include "glite/lb/events.h" - -#define PERFTEST_END_TAG_NAME "lb_perftest" -#define PERFTEST_END_TAG_VALUE "+++ konec testu +++" - -int -glite_wll_perftest_init(const char *host, /** hostname */ - const char *user, /** user running this test */ - const char *testname, /** name of the test */ - const char *filename, /** file with events for job source */ - int n); /** number of jobs for job source */ - -char * -glite_wll_perftest_produceJobId(); - -int -glite_wll_perftest_produceEventString(char **event); - -int -glite_wll_perftest_consumeEvent(edg_wll_Event *event); - -int -glite_wll_perftest_consumeEventString(const char *event_string); - -int -glite_wll_perftest_consumeEventIlMsg(const char *msg); - -int -glite_wll_perftest_createJobId(const char *bkserver, - int port, - const char *test_user, - const char *test_name, - int job_num, - edg_wlc_JobId *jobid); - -#endif diff --git a/org.glite.lb.common/project/build.number b/org.glite.lb.common/project/build.number index 62ff45d..4e13dcd 100644 --- a/org.glite.lb.common/project/build.number +++ b/org.glite.lb.common/project/build.number @@ -1,2 +1,2 @@ -#Mon Apr 03 07:27:37 CEST 2006 -module.build=0242 +#Sun Apr 02 07:07:33 CEST 2006 +module.build=0241 diff --git a/org.glite.lb.common/project/configure.properties.xml b/org.glite.lb.common/project/configure.properties.xml index 2a9c5bc..979c6f1 100644 --- a/org.glite.lb.common/project/configure.properties.xml +++ b/org.glite.lb.common/project/configure.properties.xml @@ -20,9 +20,6 @@ Revision history: $Log$ - Revision 1.4 2006/03/15 17:53:14 akrenek - cares - Revision 1.3 2004/08/31 07:57:17 akrenek very first unit test @@ -54,9 +51,9 @@ version=${module.version} glite_location=${with.glite.location} globus_prefix=${with.globus.prefix} expat_prefix=${with.expat.prefix} -cppunit_prefix=${with.cppunit.prefix} thrflavour=${with.globus.thr.flavor} nothrflavour=${with.globus.nothr.flavor} +cppunit=${with.cppunit.prefix} diff --git a/org.glite.lb.common/project/version.properties b/org.glite.lb.common/project/version.properties index 6ce0f36..725b2a0 100644 --- a/org.glite.lb.common/project/version.properties +++ b/org.glite.lb.common/project/version.properties @@ -1,3 +1,3 @@ #Fri Sep 02 14:17:07 CEST 2005 -module.version=3.1.0 +module.version=3.1.2 module.age=0 diff --git a/org.glite.lb.common/src/il_msg.c b/org.glite.lb.common/src/il_msg.c index 39c1f9e..4154ee9 100644 --- a/org.glite.lb.common/src/il_msg.c +++ b/org.glite.lb.common/src/il_msg.c @@ -6,23 +6,19 @@ #include #include #include -#include -#include #define IL_PROTOCOL_MAGIC_WORD "michal" int -encode_il_msg(char **buffer, const il_octet_string_t *event) +encode_il_msg(char **buffer, const char *event) { int len; char *p; - il_octet_string_t protocol_magic_word; - - protocol_magic_word.data = IL_PROTOCOL_MAGIC_WORD; - protocol_magic_word.len = strlen(IL_PROTOCOL_MAGIC_WORD); + char *protocol_magic_word = IL_PROTOCOL_MAGIC_WORD; + /* allocate enough room to hold the message */ - len = 17 + len_string(&protocol_magic_word) + len_string((il_octet_string_t*)event); + len = 17 + len_string(protocol_magic_word) + len_string((char*)event); if((*buffer = malloc(len)) == NULL) { return(-1); } @@ -34,8 +30,8 @@ encode_il_msg(char **buffer, const il_octet_string_t *event) p += 17; /* write rest of the message */ - p = put_string(p, &protocol_magic_word); - p = put_string(p, (il_octet_string_t*)event); + p = put_string(p, protocol_magic_word); + p = put_string(p, (char*)event); return(p - *buffer); } @@ -48,11 +44,8 @@ encode_il_reply(char **buffer, { int len; char *p; - il_octet_string_t emsg; - emsg.data = (char*)err_msg; - emsg.len = strlen(err_msg); - len = 17 + len_int(err_code) + len_int(err_code_min) + len_string(&emsg); + len = 17 + len_int(err_code) + len_int(err_code_min) + len_string((char*)err_msg); if((*buffer = malloc(len)) == NULL) { return(-1); } @@ -61,34 +54,32 @@ encode_il_reply(char **buffer, p = *buffer + 17; p = put_int(p, err_code); p = put_int(p, err_code_min); - p = put_string(p, &emsg); + p = put_string(p, (char*)err_msg); return(p - *buffer); } int -decode_il_msg(il_octet_string_t *event, const char *buf) +decode_il_msg(char **event, const char *buf) { char *p; - il_octet_string_t protocol_magic_word; + char *protocol_magic_word=NULL; int magic_word_check_failed = 0; - assert( event != NULL ); - /* First check that the protocol 'magic' word is there */ p = get_string((char*)buf, &protocol_magic_word); - if (protocol_magic_word.data) { - if (strcmp (protocol_magic_word.data, IL_PROTOCOL_MAGIC_WORD) != 0) { + if (protocol_magic_word) { + if (strcmp (protocol_magic_word, IL_PROTOCOL_MAGIC_WORD) != 0) { magic_word_check_failed = 1; } - free(protocol_magic_word.data); + free(protocol_magic_word); } if (magic_word_check_failed != 0) return (-1); p = get_string(p, event); if(p == NULL) { - if(event->data) { free(event->data); event->data = NULL; }; + if(*event) { free(*event); *event = NULL; }; return(-1); } return(p - buf); @@ -98,19 +89,17 @@ decode_il_msg(il_octet_string_t *event, const char *buf) int decode_il_reply(int *maj, int *min, char **err, const char * buf) { - char *p = (char*)buf; - il_octet_string_t e; + char *p = buf; p = get_int(p, maj); if(p == NULL) return(-1); p = get_int(p, min); if(p == NULL) return(-1); - p = get_string(p, &e); + p = get_string(p, err); if(p == NULL) { - if(e.data) { free(e.data); e.data = NULL; }; + if(*err) { free(*err); *err = NULL; }; return(-1); } - *err = e.data; return(p - buf); } diff --git a/org.glite.lb.common/src/il_string.c b/org.glite.lb.common/src/il_string.c index 8006aff..2c4034d 100644 --- a/org.glite.lb.common/src/il_string.c +++ b/org.glite.lb.common/src/il_string.c @@ -7,54 +7,54 @@ #include "il_string.h" char * -put_string(char *p, il_octet_string_t *s) +put_string(char *p, char *s) { + int len = strlen(s); + assert( p != NULL ); - assert( s != NULL ); - p = _put_int(p, s->len); + p = _put_int(p, len); *p++ = ' '; - /* strncpy(p, s->data, s->len); */ - memcpy(p, s->data, s->len); - p += s->len; + strncpy(p, s, len); + p += len; *p++ = '\n'; return(p); } int -len_string(il_octet_string_t *s) +len_string(char *s) { - int len; + int len, slen; assert( s != NULL ); - len = len_int(s->len); - return(len + s->len + 1); + slen = strlen(s); + len = len_int(slen); + + return(len + slen + 1); } char * -get_string(char *p, il_octet_string_t *s) +get_string(char *p, char **s) { int len; assert( p != NULL ); - assert( s != NULL ); - s->data = NULL; + *s = NULL; p = _get_int(p, &len); if(*p != ' ') return(NULL); else { - s->data = malloc(len + 1); - if(s->data == NULL) + *s = malloc(len + 1); + if(*s == NULL) return(NULL); - /* strncpy(s->data, ++p, len); */ - memcpy(s->data, ++p, len); - (s->data)[len] = '\0'; + strncpy(*s, ++p, len); + (*s)[len] = '\0'; p += len; return( *p++ == '\n' ? p : NULL ); } diff --git a/org.glite.lb.common/src/lb_maildir.c b/org.glite.lb.common/src/lb_maildir.c index 14bda68..f68598a 100644 --- a/org.glite.lb.common/src/lb_maildir.c +++ b/org.glite.lb.common/src/lb_maildir.c @@ -6,6 +6,8 @@ #include #include #include +#include + #include "context-int.h" #include "lb_maildir.h" @@ -16,10 +18,11 @@ enum { LBMD_DIR_TMP = 0, LBMD_DIR_NEW, LBMD_DIR_WORK, - LBMD_DIR_POST + LBMD_DIR_POST, + LBMD_DIR_UNDELIVERABLE }; -static const char *dirs[] = { "tmp", "new", "work", "post" }; +static const char *dirs[] = { "tmp", "new", "work", "post", "undeliverable" }; #define MAX_ERR_LEN 1024 @@ -36,8 +39,10 @@ static int check_mkdir(const char *dir) } else return 1; } - else if (S_ISDIR(sbuf.st_mode)) return 0; - else return 1; + + if (!S_ISDIR(sbuf.st_mode)) return 1; + + if (access(dir, R_OK | W_OK)) return 1; return 0; } @@ -68,16 +73,17 @@ int edg_wll_MaildirInit( int edg_wll_MaildirStoreMsg( - const char *root, - const char *srvname, - const char *msg) + const char *root, + const char *srvname, + const char *msg) { - char fname[PATH_MAX], - newfname[PATH_MAX]; - int fhnd, - written, - msgsz, - ct, i; + char fname[PATH_MAX], + newfname[PATH_MAX]; + int fhnd, + written, + msgsz, + ct, i; + struct timeval tv; if ( !root ) root = DEFAULT_ROOT; @@ -90,9 +96,10 @@ int edg_wll_MaildirStoreMsg( snprintf(lbm_errdesc, MAX_ERR_LEN, "Maximum tries limit reached with unsuccessful file creation"); return -1; } - snprintf(fname, PATH_MAX, "%s/%s/%ld.%d.%s", root, dirs[LBMD_DIR_TMP], (long) time(NULL), getpid(), srvname); + gettimeofday(&tv, NULL); + snprintf(fname, PATH_MAX, "%s/%s/%ld_%ld.%s", root, dirs[LBMD_DIR_TMP], tv.tv_sec, tv.tv_usec, srvname); if ( (fhnd = open(fname, O_CREAT|O_EXCL|O_WRONLY, 00600)) < 0 ) { - if ( errno == EEXIST ) { sleep(2); continue; } + if ( errno == EEXIST ) { usleep(1000); continue; } snprintf(lbm_errdesc, MAX_ERR_LEN, "Can't create file %s", fname); return -1; } @@ -167,21 +174,22 @@ int edg_wll_MaildirTransEnd( int edg_wll_MaildirRetryTransStart( - const char *root, - time_t tm, - char **msg, - char **fname) + const char *root, + time_t retry, + time_t remove, + char **msg, + char **fname) { - static DIR *dir = NULL; - struct dirent *ent; - time_t tlimit; - struct stat st; - char newfname[PATH_MAX], - oldfname[PATH_MAX], - *buf = NULL; - int fhnd, - toread, ct, - bufsz, bufuse; + static DIR *dir = NULL; + struct dirent *ent; + time_t tlimit_retry, tlimit_remove; + struct stat st; + char newfname[PATH_MAX], + oldfname[PATH_MAX], + *buf = NULL; + int fhnd, + toread, ct, + bufsz, bufuse; if ( !root ) root = DEFAULT_ROOT; @@ -195,7 +203,8 @@ int edg_wll_MaildirRetryTransStart( } } - tlimit = time(NULL) - tm; + tlimit_retry = time(NULL) - retry; + tlimit_remove = time(NULL) - remove; do { errno = 0; if ( !(ent = readdir(dir)) ) { @@ -219,7 +228,15 @@ int edg_wll_MaildirRetryTransStart( goto err; } - if ( st.st_ctime > tlimit ) continue; + /* if we cannot deliver the file for 'remove' time limit, */ + /* it is moved to undeliverable folder and forgotten */ + if ( st.st_mtime < tlimit_remove ) { + snprintf(newfname, PATH_MAX, "%s/%s/%s", + root, dirs[LBMD_DIR_UNDELIVERABLE], ent->d_name); + } + /* try to deliver file every 'retry' seconds */ + else if ( st.st_ctime > tlimit_retry ) continue; + if ( rename(oldfname, newfname) ) { if ( errno == ENOENT ) { @@ -230,8 +247,17 @@ int edg_wll_MaildirRetryTransStart( goto err; } } else { - /* we have found and moved the file with which we will work now */ - break; + if (st.st_mtime < tlimit_remove) { + /* we have moved undeliverable file to undeliverable folder */ + /* no other action needed */ + snprintf(oldfname, PATH_MAX, "%s/%s/%s", root, dirs[LBMD_DIR_TMP], ent->d_name); + unlink(oldfname); + continue; + } else { + /* we have found and moved the file to work folder */ + /* going to process it */ + break; + } } } while ( 1 ); @@ -261,6 +287,7 @@ int edg_wll_MaildirRetryTransStart( close(fhnd); if ( !(*fname = strdup(ent->d_name)) ) goto err; + buf[bufuse] = 0; *msg = buf; return 1; diff --git a/org.glite.lb.common/src/lb_perftest.c b/org.glite.lb.common/src/lb_perftest.c deleted file mode 100644 index a971b05..0000000 --- a/org.glite.lb.common/src/lb_perftest.c +++ /dev/null @@ -1,505 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "lb_perftest.h" -#include "glite/lb/producer.h" -#include "glite/lb/trio.h" -#include "il_msg.h" - -#ident "$Header$" - -static pthread_mutex_t perftest_lock = PTHREAD_MUTEX_INITIALIZER; -static struct timeval endtime; -static char *termination_string; -static char **events; /* in fact it is *events[] */ -static int nevents; -static int njobs = 0; -static int cur_event = 0; -static int cur_job = 0; -static char *test_user; -static char *test_name; -static char *dest_host; -static int dest_port; - -#define EVENTS_BUFSIZ 16 -#define BUFFSZ 1024 - - -/* - * strnstr - look only in first n characters - * (taken from NSPR) - */ -static -char * -_strnstr(const char *big, const char *little, size_t max) -{ - size_t ll; - - if( ((const char *)0 == big) || ((const char *)0 == little) ) return (char *)0; - if( ((char)0 == *big) || ((char)0 == *little) ) return (char *)0; - - ll = strlen(little); - if( ll > (size_t)max ) return (char *)0; - max -= ll; - max++; - - for( ; max && *big; big++, max-- ) - if( *little == *big ) - if( 0 == strncmp(big, little, ll) ) - return (char *)big; - - return (char *)0; -} - - -/* - * reading lines (pasted from load.c) - */ - -static -int -read_line(int fd, char **buff, size_t *maxsize) -{ - int ct, i; - void *tmp; - - - if ( *buff == NULL ) - { - *buff = malloc(BUFFSZ); - if ( *buff == NULL ) - return -1; - *maxsize = BUFFSZ; - } - - i = 0; - while ( 1 ) - { - if (i >= *maxsize) { - (*maxsize) *= 2; - if ((tmp = realloc(*buff, *maxsize)) == NULL) return -1; - *buff = (char *)tmp; - } - if ( (ct = read(fd, (*buff)+i, 1)) == -1 ) - return -1; - - if ( ct == 0 ) - return 0; - - if ( (*buff)[i] == '\n' ) - { - (*buff)[i--] = '\0'; - while ( (i != -1) && isspace((*buff)[i]) ) i--; - if ( i == -1 ) - { - /** empty line - */ - i = 0; - continue; - } - else { - /* i points to the last nonspace, nonnull character in line */ - /* add \n - we need it later */ - (*buff)[++i] = '\n'; /* now we are at \0 or at space */ - if(i >= *maxsize) { - (*maxsize) += 1; - if((tmp = realloc(*buff, *maxsize)) == NULL) return -1; - *buff = (char *)tmp; - } - (*buff)[++i] = '\0'; - return 1; - } - } - - i++; - } - -} - - -/* - * read events from the stream - */ -static -int -read_events(int fd, char ***evts /* *(*evts)[] */) -{ - void *tmp; - size_t maxlinesize; - char **e = NULL, *line = NULL; - size_t i = 0, max = EVENTS_BUFSIZ; - - if ((e = malloc(max * sizeof(char *))) == NULL) goto nomem; - - while (read_line(fd, &line, &maxlinesize)) { - if (i + 1 >= max) { - max <<= 1; - if ((tmp = realloc(e, max * sizeof(char *))) == NULL) goto nomem; - e = (char **)tmp; - } - if ((e[i] = strdup(line)) == NULL) goto nomem; - free(line); line = NULL; - i++; - } - - *evts = e; - return i; - -nomem: - if(e) free(e); - if(line) free(line); - fprintf(stderr, "read_events: insufficient memory\n"); - return -1; -} - - -int -glite_wll_perftest_init(const char *host, - const char *user, - const char *testname, - const char *filename, - int n) -{ - - if(trio_asprintf(&termination_string, EDG_WLL_FORMAT_USERTAG, - PERFTEST_END_TAG_NAME, PERFTEST_END_TAG_VALUE) < 0) - return(-1); - - /* set parameters */ - if(user) - test_user = strdup(user); - else { - test_user = getenv("PERFTEST_USER"); - if(test_user == NULL) - test_user = "anonymous"; - } - if(testname) - test_name = strdup(testname); - else { - test_name = getenv("PERFTEST_NAME"); - if(test_name == NULL) - test_name = "unspecified"; - } - if(host == NULL) { - host = getenv("PERFTEST_HOST"); - if(host == NULL) - host = "localhost"; - } - { - char *p; - - p = strchr(host, ':'); - if(p) - *p = 0; - dest_host = strdup(host); - if(p) { - *p++ = ':'; - dest_port = atoi(p)+1; - } else - dest_port = GLITE_WMSC_JOBID_DEFAULT_PORT+1; - } - - /* reset event source */ - cur_event = cur_job = 0; - njobs = n; - - /* if we are asked to read events in, read them */ - if(filename) { - int fd; - - if((fd=open(filename, O_RDONLY)) < 0) { - fprintf(stderr, "glite_wll_perftest_init: Could not open event file %s: %s", - filename, strerror(errno)); - return(-1); - } - - if((nevents=read_events(fd, &events)) < 0) - return(-1); - - close(fd); - - - fprintf(stderr, "PERFTEST_JOB_SIZE=%d\n", nevents); - fprintf(stderr, "PERFTEST_NUM_JOBS=%d\n", njobs); - } - - return(0); -} - - -/** - * This produces njobs+1 jobids, one for each call. - * - * WARNING: do not mix calls to this function with calls to produceEventString! - */ -char * -glite_wll_perftest_produceJobId() -{ - edg_wlc_JobId jobid; - char *jobids; - - if(pthread_mutex_lock(&perftest_lock) < 0) - abort(); - - /* is there anything to send? */ - if(cur_job < 0) { - if(pthread_mutex_unlock(&perftest_lock) < 0) - abort(); - return(NULL); - } - - if(glite_wll_perftest_createJobId(dest_host, - dest_port, - test_user, - test_name, - cur_job, - &jobid) != 0) { - fprintf(stderr, "produceJobId: error creating jobid\n"); - if(pthread_mutex_unlock(&perftest_lock) < 0) - abort(); - return(NULL); - } - if((jobids=edg_wlc_JobIdUnparse(jobid)) == NULL) { - fprintf(stderr, "produceJobId: error unparsing jobid\n"); - if(pthread_mutex_unlock(&perftest_lock) < 0) - abort(); - return(NULL); - } - - if(cur_job++ >= njobs) - cur_job = -1; - - return(jobids); -} - - -/** - * This produces (njobs*nevents + 1) events, one event for each call. - * For every nevents (one job) new jobid is generated and inserted into - * event. The last event is termination - usertag. - */ -int -glite_wll_perftest_produceEventString(char **event) -{ - static char *cur_jobid = NULL; - char *e; - - assert(event != NULL); - - if(pthread_mutex_lock(&perftest_lock) < 0) - abort(); - - /* is there anything to send? */ - if(cur_job < 0) { - if(pthread_mutex_unlock(&perftest_lock) < 0) - abort(); - return(0); - } - - /* did we send all jobs? */ - if(cur_job >= njobs) { - - /* construct termination event */ - if(trio_asprintf(&e, EDG_WLL_FORMAT_COMMON EDG_WLL_FORMAT_USERTAG "\n", - "now", /* date */ - "localhost", /* host */ - "highest", /* level */ - 0, /* priority */ - "UserInterface", /* source */ - "me again", /* source instance */ - "UserTag", /* event */ - cur_jobid, /* jobid */ - "last", /* sequence */ - PERFTEST_END_TAG_NAME, - PERFTEST_END_TAG_VALUE) < 0) { - fprintf(stderr, "produceEventString: error creating termination event\n"); - if(pthread_mutex_unlock(&perftest_lock) < 0) - abort(); - return(-1); - } - - /* and refuse to produce more */ - cur_job = -1; - cur_event = -1; - - } else { - - /* are we starting new job? */ - if(cur_event == 0) { - edg_wlc_JobId jobid; - - /* is this the first event? */ - if(cur_jobid) { - free(cur_jobid); - } else { - struct timeval now; - - gettimeofday(&now, NULL); - fprintf(stderr, "PERFTEST_BEGIN_TIMESTAMP=%lu.%06lu\n", - (unsigned long)now.tv_sec,(unsigned long)now.tv_usec); - - } - - /* generate new jobid */ - if(glite_wll_perftest_createJobId(dest_host, - dest_port, - test_user, - test_name, - cur_job, - &jobid) != 0) { - fprintf(stderr, "produceEventString: error creating jobid\n"); - if(pthread_mutex_unlock(&perftest_lock) < 0) - abort(); - return(-1); - } - if((cur_jobid=edg_wlc_JobIdUnparse(jobid)) == NULL) { - fprintf(stderr, "produceEventString: error unparsing jobid\n"); - if(pthread_mutex_unlock(&perftest_lock) < 0) - abort(); - return(-1); - } - } - - /* return current event with jobid filled in */ - if(trio_asprintf(&e, "DG.JOBID=\"%s\" %s", cur_jobid, events[cur_event]) < 0) { - fprintf(stderr, "produceEventString: error generating event\n"); - if(pthread_mutex_unlock(&perftest_lock) < 0) - abort(); - return(-1); - } - } - - *event = e; - - /* advance to the next event */ - if(++cur_event >= nevents) { - cur_job++; - cur_event = 0; - } - - if(pthread_mutex_unlock(&perftest_lock) < 0) - abort(); - - return(strlen(e)); -} - - -int -glite_wll_perftest_consumeEvent(edg_wll_Event *event) -{ - int ret = 0; - - assert(event != NULL); - - if(pthread_mutex_lock(&perftest_lock) < 0) - abort(); - - gettimeofday(&endtime, NULL); - - /* check for the termination event */ - if((event->any.type == EDG_WLL_EVENT_USERTAG) && - (strcmp(event->userTag.name, PERFTEST_END_TAG_NAME) == 0) && - (strcmp(event->userTag.value, PERFTEST_END_TAG_VALUE) == 0)) { - /* print the timestamp */ - fprintf(stderr, "PERFTEST_END_TIMESTAMP=%lu.%06lu\n", - (unsigned long)endtime.tv_sec,(unsigned long)endtime.tv_usec); - ret = 1; - } - - if(pthread_mutex_unlock(&perftest_lock) < 0) - abort(); - - return(ret); -} - - -int -glite_wll_perftest_consumeEventString(const char *event_string) -{ - int ret = 0; - - assert(event_string != NULL); - - if(pthread_mutex_lock(&perftest_lock) < 0) - abort(); - - gettimeofday(&endtime, NULL); - - /* check for the termination event */ - /* if it is not in the first 1k chars, it is not there */ - if(_strnstr(event_string, termination_string, 1024) != NULL) { - /* print the timestamp */ - fprintf(stderr, "PERFTEST_END_TIMESTAMP=%lu.%06lu\n", - (unsigned long)endtime.tv_sec,(unsigned long)endtime.tv_usec); - ret = 1; - } - - if(pthread_mutex_unlock(&perftest_lock) < 0) - abort(); - - return(ret); -} - - -int -glite_wll_perftest_consumeEventIlMsg(const char *msg) -{ - int ret = 0; - il_octet_string_t event; - - assert(msg != NULL); - - if(pthread_mutex_lock(&perftest_lock) < 0) - abort(); - - gettimeofday(&endtime, NULL); - - /* decode event */ - if(decode_il_msg(&event, msg) < 0) { - fprintf(stderr, "PERFTEST: error decoding consumed event, aborting!\n"); - abort(); - } - - /* check for the termination event */ - if(_strnstr(event.data, termination_string, 1024) != NULL) { - /* print the timestamp */ - fprintf(stderr, "PERFTEST_END_TIMESTAMP=%lu.%06lu\n", - endtime.tv_sec, endtime.tv_usec); - ret = 1; - } - - if(pthread_mutex_unlock(&perftest_lock) < 0) - abort(); - - free(event.data); - - return(ret); -} - - -int -glite_wll_perftest_createJobId(const char *bkserver, - int port, - const char *test_user, - const char *test_name, - int job_num, - edg_wlc_JobId *jobid) -{ - char unique[256]; - - if(snprintf(unique, sizeof(unique), "%s_%s_%d", - test_user, test_name, job_num) >= sizeof(unique)) - return(E2BIG); - - return(edg_wlc_JobIdRecreate(bkserver, port, str2md5base64(unique), jobid)); -} diff --git a/org.glite.lb.common/src/lb_plain_io.c b/org.glite.lb.common/src/lb_plain_io.c index 7915dfa..1de8e37 100644 --- a/org.glite.lb.common/src/lb_plain_io.c +++ b/org.glite.lb.common/src/lb_plain_io.c @@ -13,6 +13,10 @@ #include #include #include +#include +#ifndef INFTIM +#define INFTIM (-1) +#endif #include "lb_plain_io.h" @@ -68,7 +72,8 @@ int edg_wll_plain_read( struct timeval *to) { int ct, toread = 0; - fd_set fds; + struct pollfd pollfds[1]; + int polltime = 0; struct timeval timeout, before, after; @@ -89,11 +94,16 @@ int edg_wll_plain_read( toread = 0; do { - FD_ZERO(&fds); - FD_SET(conn->sock, &fds); - switch (select(conn->sock+1, &fds, NULL, NULL, to ? &timeout : NULL)) { - case 0: errno = ETIMEDOUT; goto cleanup; break; - case -1: goto cleanup; break; + pollfds[0].fd = conn->sock; + pollfds[0].events = POLLIN; + polltime = to ? (timeout.tv_sec*1000+timeout.tv_usec/1000) : INFTIM; + switch (poll(pollfds, 1, polltime)) { + case 0: errno = ETIMEDOUT; goto cleanup; break; + case -1: goto cleanup; break; + default: if (!(pollfds[0].revents & POLLIN)) { + errno = EIO; + goto cleanup; break; + } } if ( conn->bufUse == conn->bufSize ) { @@ -125,6 +135,7 @@ cleanup: if ( to->tv_sec < 0 ) to->tv_sec = to->tv_usec = 0; } + if ( errno == ECONNRESET) errno = ENOTCONN; if ( errno ) return -1; if ( conn->bufUse > 0 ) { @@ -173,7 +184,8 @@ int edg_wll_plain_write_full( { size_t written = 0; int ct = -1; - fd_set fds; + struct pollfd pollfds[1]; + int polltime = 0; struct timeval timeout, before, after; struct sigaction sa,osa; @@ -188,12 +200,18 @@ int edg_wll_plain_write_full( errno = 0; while ( written < bufsz ) { - FD_ZERO(&fds); - FD_SET(conn->sock, &fds); - switch ( select(conn->sock+1, NULL, &fds, NULL, to? &timeout: NULL) ) { + pollfds[0].fd = conn->sock; + pollfds[0].events = POLLOUT; + polltime = to ? (timeout.tv_sec*1000+timeout.tv_usec/1000) : INFTIM; + + switch (poll(pollfds, 1, polltime)) { case 0: errno = ETIMEDOUT; goto end; break; case -1: goto end; break; + default: if (!(pollfds[0].revents & POLLOUT)) { + errno = ENOTCONN; + goto end; break; + } } if ( (ct=write(conn->sock, ((char*)buf)+written, bufsz-written)) < 0 ) { if ( errno == EINTR ) { errno = 0; continue; } diff --git a/org.glite.lb.common/src/mini_http.c b/org.glite.lb.common/src/mini_http.c index fcb3157..0535aa6 100644 --- a/org.glite.lb.common/src/mini_http.c +++ b/org.glite.lb.common/src/mini_http.c @@ -55,6 +55,7 @@ edg_wll_ErrorCode edg_wll_http_recv(edg_wll_Context ctx,char **firstOut,char *** edg_wll_SetErrorGss(ctx, "receving HTTP request", &gss_code); goto error; case EDG_WLL_GSS_ERROR_ERRNO: + if (errno == ECONNRESET) errno = ENOTCONN; edg_wll_SetError(ctx,errno,"edg_wll_gss_read()"); goto error; case EDG_WLL_GSS_ERROR_TIMEOUT: diff --git a/org.glite.lb.common/src/notifid.c b/org.glite.lb.common/src/notifid.c index 8a1d5fe..ee3c162 100644 --- a/org.glite.lb.common/src/notifid.c +++ b/org.glite.lb.common/src/notifid.c @@ -86,3 +86,20 @@ char* edg_wll_NotifIdGetUnique(const edg_wll_NotifId notifid) free(id); return NULL; } + +edg_wll_NotifId * +edg_wll_NotifIdDup(const edg_wll_NotifId src) +{ + char *str; + edg_wll_NotifId id = NULL; + int ret; + + str = edg_wll_NotifIdUnparse(src); + if (str == NULL) + return NULL; + + ret = edg_wll_NotifIdParse((const char *)str, &id); + free(str); + + return id; +} diff --git a/org.glite.lb.common/src/perftest_common.sh b/org.glite.lb.common/src/perftest_common.sh deleted file mode 100644 index 1884f98..0000000 --- a/org.glite.lb.common/src/perftest_common.sh +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/bash - -# those files should be staged by invoking -# LB_PERF=1 make stage (or ant equivalent) -# in org.glite.lb.common - -JOB_AVG_SIMPLE=${JOB_AVG_SIMPLE:-$STAGEDIR/examples/perftest/perf_simple_avg_events.log} -JOB_MAX_SIMPLE=${JOB_MAX_SIMPLE:-$STAGEDIR/examples/perftest/perf_simple_max_events.log} -JOB_AVG_DAG=${JOB_AVG_DAG:-$STAGEDIR/examples/perftest/perf_dag_avg_events.log} -JOB_MAX_DAG=${JOB_MAX_DAG:-$STAGEDIR/examples/perftest/perf_dag_max_events.log} - -# path to the job event producer -LOGJOBS=${LOGJOBS:-$STAGEDIR/sbin/glite-lb-perftest_logjobs} - -# some defaults for log files -CONSUMER_LOG=/tmp/perftest_consumer.log -PRODUCER_LOG=/tmp/perftest_producer.log - - -check_file_readable() -{ - [[ $DEBUG -gt 0 ]] && echo -n "Looking up file $1..." - [[ -r $1 ]] - RV=$? - [[ $DEBUG -gt 0 ]] && ( [[ $RV -eq 0 ]] && echo "OK" || echo "FAILED" ) - return $RV -} - -check_file_executable() -{ - [[ $DEBUG -gt 0 ]] && echo -n "Looking up program $1..." - [[ -x $1 ]] - RV=$? - [[ $DEBUG -gt 0 ]] && ( [[ $RV -eq 0 ]] && echo "OK" || echo "FAILED" ) - return $RV -} - -check_test_files() -{ - check_file_readable $JOB_AVG_SIMPLE && \ - check_file_readable $JOB_MAX_SIMPLE && \ - check_file_readable $JOB_AVG_DAG && \ - check_file_readable $JOB_MAX_DAG && \ - check_file_executable $LOGJOBS -} - - -get_result() -{ - tmpfile=`mktemp -p /tmp` - grep PERFTEST $CONSUMER_LOG > $tmpfile - . $tmpfile - grep PERFTEST $PRODUCER_LOG > $tmpfile - . $tmpfile - rm $tmpfile - [[ $DEBUG -gt 0 ]] && echo "Timestamps: from $PERFTEST_BEGIN_TIMESTAMP to $PERFTEST_END_TIMESTAMP" - total=`echo "scale=6; $PERFTEST_END_TIMESTAMP - $PERFTEST_BEGIN_TIMESTAMP" | bc` - PERFTEST_EVENT_THROUGHPUT=`echo "scale=6; $PERFTEST_NUM_JOBS * $PERFTEST_JOB_SIZE / $total" |bc` - PERFTEST_JOB_THROUGPUT=`echo "scale=6; $PERFTEST_NUM_JOBS / $total" |bc` - PERFTEST_DAY_JOB_THROUGHPUT=`echo "scale=6; $PERFTEST_NUM_JOBS / $total * 3600 * 24" |bc` -} - -shutdown() -{ - [[ -z $1 ]] && return - kill -0 $1 > /dev/null 2>&1 && kill $1 - if kill -0 $1 >/dev/null 2>&1 - then - sleep 10 - kill -9 $1 - fi -} - -# run_test dest numjobs [testname] -run_test() -{ - local i file lj_flags linesbefore linesafter CONSUMER_PID COMPONENT_PID - rm -f $CONSUMER_LOG $PRODUCER_LOG - touch $CONSUMER_LOG $PRODUCER_LOG - if [[ $DEBUG -gt 1 ]] - then - tail -f $CONSUMER_LOG & - tail -f $PRODUCER_LOG & - fi - # set args to logjobs - lj_flags="$LOGJOBS_ARGS -d $1 -n $2" - [[ -n $3 ]] && lj_flags="$lj_flags -t $3" - # There is always consumer - start it - $PERFTEST_CONSUMER $CONSUMER_ARGS > $CONSUMER_LOG 2>&1 & - CONSUMER_PID=$! - sleep 2 - # Start component (if specified) - if [[ -n $PERFTEST_COMPONENT ]] - then - $PERFTEST_COMPONENT $COMPONENT_ARGS & - COMPONENT_PID=$! - fi - # wait for components to come up - sleep 2 - # feed the beast - i=0 - for file in $JOB_AVG_SIMPLE $JOB_MAX_SIMPLE $JOB_AVG_DAG $JOB_MAX_DAG - do - [[ $DEBUG -gt 0 ]] && echo -e "\n\nRunning test with input $file" - linesbefore=`grep PERFTEST $CONSUMER_LOG|wc -l` - $LOGJOBS $lj_flags -f $file >> $PRODUCER_LOG 2>&1 - linesafter=`grep PERFTEST $CONSUMER_LOG|wc -l` - # if there are no new lines in the log, give it some time - [[ $linesbefore -eq $linesafter ]] && sleep 5 - linesafter=`grep PERFTEST $CONSUMER_LOG|wc -l` - if [[ $linesbefore -eq $linesafter ]] - then - echo "Test failed - consumer did not report timestamp." - PERFTEST_THROUGHPUT[$i]=0 - PERFTEST_EV_THROUGHPUT[$i]=0 - else - get_result - [[ $DEBUG -gt 0 ]] && echo Result: $PERFTEST_DAY_JOB_THROUGHPUT - PERFTEST_THROUGHPUT[$i]=$PERFTEST_DAY_JOB_THROUGHPUT - PERFTEST_EV_THROUGHPUT[$i]=$PERFTEST_EVENT_THROUGHPUT - fi - i=$(($i + 1)) - done - # clean up - shutdown $COMPONENT_PID - shutdown $CONSUMER_PID - [[ $DEBUG -gt 1 ]] && killall tail -} - - diff --git a/org.glite.lb.common/test/il_msg_test.cpp b/org.glite.lb.common/test/il_msg_test.cpp index 754e498..99c0311 100644 --- a/org.glite.lb.common/test/il_msg_test.cpp +++ b/org.glite.lb.common/test/il_msg_test.cpp @@ -2,7 +2,6 @@ #include extern "C" { -#include #include "il_string.h" #include "il_msg.h" } @@ -19,11 +18,7 @@ class IlMsgTest : public CppUnit::TestFixture public: void setUp() { - il_octet_string_t s; - - s.data = "zprava"; - s.len = strlen(s.data); - len_msg = encode_il_msg(&buffer_msg, &s); + len_msg = encode_il_msg(&buffer_msg, "zprava"); len_rep = encode_il_reply(&buffer_rep, 10, 20, "chyba"); } @@ -39,14 +34,14 @@ public: } void testDecodeMsg() { - il_octet_string_t s; + char *s; int l; l = decode_il_msg(&s, buffer_msg + 17); CPPUNIT_ASSERT_EQUAL(l, len_msg - 17); - CPPUNIT_ASSERT(s.data != NULL); - CPPUNIT_ASSERT( !strcmp(s.data, "zprava") ); - free(s.data); + CPPUNIT_ASSERT(s != NULL); + CPPUNIT_ASSERT( !strcmp(s, "zprava") ); + free(s); } void testEncodeReply() { diff --git a/org.glite.lb.common/test/il_string_test.cpp b/org.glite.lb.common/test/il_string_test.cpp index 1f138ac..2f03a94 100644 --- a/org.glite.lb.common/test/il_string_test.cpp +++ b/org.glite.lb.common/test/il_string_test.cpp @@ -1,7 +1,6 @@ #include extern "C" { -#include #include "il_string.h" } @@ -21,29 +20,21 @@ public: } void testPutString() { - il_octet_string_t s; - s.data = "ahoj"; - s.len = strlen(s.data); - put_string(buffer, &s); + put_string(buffer, "ahoj"); CPPUNIT_ASSERT( !strncmp(buffer,"4 ahoj\n",7) ); } void testGetString() { - il_octet_string_t s; + char *s; get_string("4 ahoj\n", &s); - CPPUNIT_ASSERT( s.data != NULL ); - CPPUNIT_ASSERT( !strcmp(s.data, "ahoj") ); - CPPUNIT_ASSERT( s.data[4] == 0 ); - free(s.data); + CPPUNIT_ASSERT( s != NULL ); + CPPUNIT_ASSERT( !strcmp(s, "ahoj") ); + CPPUNIT_ASSERT( s[4] == 0 ); + free(s); } void testLenString() { - il_octet_string_t s; - int d; - - s.data = "ahoj"; - s.len = strlen(s.data); - d = len_string(&s); + int d = len_string("ahoj"); CPPUNIT_ASSERT( d == 7); } diff --git a/org.glite.lb.logger/Makefile b/org.glite.lb.logger/Makefile index b6f1292..313bc41 100644 --- a/org.glite.lb.logger/Makefile +++ b/org.glite.lb.logger/Makefile @@ -17,9 +17,6 @@ thrflavour=gcc32pthr expat_prefix=/opt/expat -include Makefile.inc --include ../project/version.properties - -version=${module.version} CC=gcc @@ -33,17 +30,12 @@ GLOBUSINC=-I${globus_prefix}/include/${nothrflavour} GLOBUSTHRINC=-I${globus_prefix}/include/${thrflavour} -ifdef LB_STANDALONE - LB_STANDALONE_FLAGS:=-DLB_STANDALONE -endif - - DEBUG:=-g -O0 CFLAGS:=${DEBUG} \ -I${stagedir}/include -I${top_srcdir}/src \ -D_GNU_SOURCE \ ${COVERAGE_FLAGS} \ - ${VERSION} ${LB_STANDALONE_FLAGS} ${LB_PERF_FLAGS} + ${VERSION} LDFLAGS:=-L${stagedir}/lib \ ${COVERAGE_FLAGS} @@ -67,38 +59,19 @@ EXPAT_LIBS:=${EXPAT_LIBS} -lexpat EXT_LIBS:= ${EXPAT_LIBS} COMMON_LIB:=-lglite_lb_common - GLITE_GSS_LIB:=-lglite_security_gss TEST_LIBS:=-L${cppunit_prefix}/lib -lcppunit TEST_INC:=-I${cppunit_prefix}/include -ifdef LB_PERF - LOGD:=glite-lb-logd-perf glite-lb-logd-perf-nofile - INTERLOGD:=glite-lb-interlogd-perf \ - glite-lb-interlogd-perf-empty -# glite-lb-interlogd-perf-inline-empty - NOTIF_INTERLOGD:=glite-lb-notif-interlogd -else - LOGD:=glite-lb-logd - INTERLOGD:=glite-lb-interlogd - NOTIF_INTERLOGD:=glite-lb-notif-interlogd -endif - - LOGD_OBJS:= logd_proto.o logd.o -LOGD_NOBJS:=${LOGD_OBJS:.o=.no} - INTERLOG_OBJS:=il_error.o input_queue_socket.o \ recover.o send_event.o \ event_queue.o event_store.o il_master.o interlogd.o \ queue_mgr.o server_msg.o queue_thread.o INTERLOG_NOBJS:=${INTERLOG_OBJS:.o=.no} -INTERLOG_PERF_OBJS:=${INTERLOG_OBJS:.o=.po} -INTERLOG_EMPTY_OBJS:=${INTERLOG_OBJS:.o=.eo} -#INTERLOG_INLINE_EMPTY_OBJS:=${INTERLOG_OBJS:.o=.io} INTERLOG_TEST_OBJS:= \ il_error.o \ @@ -117,37 +90,20 @@ INTERLOG_TEST_OBJS:= \ IlTestBase.o \ il_test.o -default: all - -all compile: $(LOGD) $(INTERLOGD) $(NOTIF_INTERLOGD) - -glite-lb-logd: ${LOGD_OBJS} - ${LINK} -o $@ ${LOGD_OBJS} ${COMMON_LIB}_${nothrflavour} - -glite-lb-logd-perf: ${LOGD_OBJS} +glite_lb_logd: ${LOGD_OBJS} ${LINK} -o $@ ${LOGD_OBJS} ${COMMON_LIB}_${nothrflavour} -glite-lb-logd-nofile: ${LOGD_NOBJS} - ${LINK} -o $@ ${LOGD_NOBJS} ${COMMON_LIB}_${nothrflavour} - -glite-lb-logd-perf-nofile: ${LOGD_NOBJS} - ${LINK} -o $@ ${LOGD_NOBJS} ${COMMON_LIB}_${nothrflavour} - -glite-lb-interlogd: ${INTERLOG_OBJS} - ${LINK} -o $@ ${INTERLOG_OBJS} ${COMMON_LIB}_${thrflavour} +glite_lb_interlogd: ${INTERLOG_OBJS} + ${LINK} -o $@ ${INTERLOG_OBJS} \ + ${COMMON_LIB}_${thrflavour} -glite-lb-notif-interlogd: ${INTERLOG_NOBJS} - ${LINK} -o $@ ${INTERLOG_NOBJS} ${COMMON_LIB}_${thrflavour} +glite_lb_notif_interlogd: ${INTERLOG_NOBJS} + ${LINK} -o $@ ${INTERLOG_NOBJS} \ + ${COMMON_LIB}_${thrflavour} -glite-lb-interlogd-perf: ${INTERLOG_OBJS} - ${LINK} -o $@ ${INTERLOG_OBJS} ${COMMON_LIB}_${thrflavour} +default: all -glite-lb-interlogd-perf-empty: ${INTERLOG_EMPTY_OBJS} - ${LINK} -o $@ ${INTERLOG_EMPTY_OBJS} ${COMMON_LIB}_${thrflavour} - -#glite-lb-interlogd-perf-inline-empty: ${INTERLOG_INLINE_EMPTY_OBJS} -# ${LINK} -o $@ ${INTERLOG_INLINE_EMPTY_OBJS} \ -# ${COMMON_LIB}_${thrflavour} +all compile: glite_lb_logd glite_lb_interlogd glite_lb_notif_interlogd stage: compile $(MAKE) install PREFIX=${stagedir} DOSTAGE=yes @@ -183,32 +139,20 @@ install: -mkdir -p ${PREFIX}/bin -mkdir -p ${PREFIX}/etc/init.d -mkdir -p ${PREFIX}/share/doc/${package}-${version} - ${INSTALL} -m 755 ${LOGD} ${PREFIX}/bin - ${INSTALL} -m 755 ${INTERLOGD} ${PREFIX}/bin + ${INSTALL} -m 755 glite_lb_logd ${PREFIX}/bin/glite-lb-logd + ${INSTALL} -m 755 glite_lb_interlogd ${PREFIX}/bin/glite-lb-interlogd if [ x${DOSTAGE} = xyes ]; then \ - ${INSTALL} -m 755 ${NOTIF_INTERLOGD} ${PREFIX}/bin; \ + ${INSTALL} -m 755 glite_lb_notif_interlogd ${PREFIX}/bin/glite-lb-notif-interlogd; \ fi ${INSTALL} -m 755 ${top_srcdir}/config/startup ${PREFIX}/etc/init.d/glite-lb-locallogger ${INSTALL} -m 644 ${top_srcdir}/LICENSE ${PREFIX}/share/doc/${package}-${version} -${INTERLOG_NOBJS}: %.no: %.c +%.no: %.c ${CC} ${CFLAGS} ${GLOBUSTHRINC} -DIL_NOTIFICATIONS -c $< -o $@ ${INTERLOG_OBJS}: %.o: %.c ${CC} ${CFLAGS} ${GLOBUSTHRINC} -c $< -o $@ -${INTERLOG_EMPTY_OBJS}: %.eo: %.c - ${CC} ${CFLAGS} ${GLOBUSTHRINC} -DLB_PERF -DPERF_EMPTY -c $< -o $@ - -${INTERLOG_PERF_OBJS}: %.po: %.c - ${CC} ${CFLAGS} ${GLOBUSTHRINC} -DLB_PERF -c $< -o $@ - -#${INTERLOG_INLINE_EMPTY_OBJS}: %.io: %.c -# ${CC} ${CFLAGS} ${GLOBUSTHRINC} -DLB_PERF -DPERF_EMPTY -DPERF_EVENTS_INLINE -c $< -o $@ - -${LOGD_NOBJS}: %.no: %.c - ${CC} ${CFLAGS} ${GLOBUSINC} -DLB_PERF -DLOGD_NOFILE -c $< -o $@ - ${LOGD_OBJS}: %.o: %.c ${CC} ${CFLAGS} ${GLOBUSINC} -c $< -o $@ diff --git a/org.glite.lb.logger/project/build.number b/org.glite.lb.logger/project/build.number index 298e0c1..59f9170 100644 --- a/org.glite.lb.logger/project/build.number +++ b/org.glite.lb.logger/project/build.number @@ -1,2 +1,2 @@ -#Mon Apr 03 07:45:18 CEST 2006 -module.build=0242 +#Sun Apr 02 07:25:19 CEST 2006 +module.build=0241 diff --git a/org.glite.lb.logger/project/configure.properties.xml b/org.glite.lb.logger/project/configure.properties.xml index 3279d84..6918019 100644 --- a/org.glite.lb.logger/project/configure.properties.xml +++ b/org.glite.lb.logger/project/configure.properties.xml @@ -20,9 +20,6 @@ Revision history: $Log$ - Revision 1.3 2006/03/15 18:25:31 akrenek - cares - Revision 1.2 2004/08/31 13:44:44 mvocu * added cppunit @@ -56,10 +53,10 @@ PREFIX=${install.dir} version=${module.version} glite_location=${with.glite.location} globus_prefix=${with.globus.prefix} -expat_prefix=${with.expat.prefix} -cppunit_prefix=${with.cppunit.prefix} thrflavour=${with.globus.thr.flavor} nothrflavour=${with.globus.nothr.flavor} +expat_prefix=${with.expat.prefix} +cppunit_prefix=${with.cppunit.prefix} diff --git a/org.glite.lb.logger/project/version.properties b/org.glite.lb.logger/project/version.properties index 9d49a61..20d2a2c 100644 --- a/org.glite.lb.logger/project/version.properties +++ b/org.glite.lb.logger/project/version.properties @@ -1,3 +1,3 @@ #Fri Sep 02 14:18:17 CEST 2005 -module.version=1.3.0 +module.version=1.3.2 module.age=0 diff --git a/org.glite.lb.logger/src/event_store.c b/org.glite.lb.logger/src/event_store.c index 365406b..feab102 100644 --- a/org.glite.lb.logger/src/event_store.c +++ b/org.glite.lb.logger/src/event_store.c @@ -426,14 +426,8 @@ event_store_recover(struct event_store *es) ret = -1; /* create message for server */ - { - il_octet_string_t e; - - e.data = event_s; - e.len = strlen(event_s); - msg = server_msg_create(&e, last); - free(event_s); - } + msg = server_msg_create(event_s, last); + free(event_s); if(msg == NULL) { il_log(LOG_ALERT, " event file corrupted! Please move it to quarantine (ie. somewhere else) and restart interlogger.\n"); break; diff --git a/org.glite.lb.logger/src/il_master.c b/org.glite.lb.logger/src/il_master.c index c09499d..b045112 100644 --- a/org.glite.lb.logger/src/il_master.c +++ b/org.glite.lb.logger/src/il_master.c @@ -11,10 +11,6 @@ #include "interlogd.h" -#ifdef LB_PERF -#include "glite/lb/lb_perftest.h" -#endif - int enqueue_msg(struct event_queue *eq, struct server_msg *msg) { @@ -128,7 +124,7 @@ parse_cmd(char *event, char **job_id_s, long *receipt, int *timeout) static int -handle_cmd(il_octet_string_t *event, long offset) +handle_cmd(char *event, long offset) { char *job_id_s; struct event_queue *eq; @@ -139,7 +135,7 @@ handle_cmd(il_octet_string_t *event, long offset) struct timeval tv; /* parse command */ - if(parse_cmd(event->data, &job_id_s, &receipt, &timeout) < 0) + if(parse_cmd(event, &job_id_s, &receipt, &timeout) < 0) return(0); #if defined(INTERLOGD_FLUSH) @@ -304,7 +300,7 @@ cmd_error: static int -handle_msg(il_octet_string_t *event, long offset) +handle_msg(char *event, long offset) { struct server_msg *msg = NULL; #if !defined(IL_NOTIFICATIONS) @@ -386,22 +382,17 @@ loop() { /* receive events */ while(1) { - il_octet_string_t msg; + char *msg; long offset; int ret; - if(killflg) - exit(0); - clear_error(); if((ret = input_queue_get(&msg, &offset, INPUT_TIMEOUT)) < 0) { if(error_get_maj() == IL_PROTO) { il_log(LOG_DEBUG, " premature EOF while receiving event\n"); /* problems with socket input, try to catch up from files */ -#ifndef PERF_EMPTY event_store_recover_all(); -#endif continue; } else return(-1); @@ -410,18 +401,12 @@ loop() continue; } -#ifdef PERF_EMPTY - glite_wll_perftest_consumeEventString(msg.data); - free(msg.data); - continue; -#endif - #ifdef INTERLOGD_HANDLE_CMD - ret = handle_cmd(&msg, offset); + ret = handle_cmd(msg, offset); if(ret == 0) #endif - ret = handle_msg(&msg, offset); - free(msg.data); + ret = handle_msg(msg, offset); + free(msg); if(ret < 0) switch (error_get_maj()) { case IL_SYS: diff --git a/org.glite.lb.logger/src/input_queue_socket.c b/org.glite.lb.logger/src/input_queue_socket.c index 19c81e3..f183319 100644 --- a/org.glite.lb.logger/src/input_queue_socket.c +++ b/org.glite.lb.logger/src/input_queue_socket.c @@ -68,96 +68,32 @@ void input_queue_detach() } -#define DEFAULT_CHUNK_SIZE 1024 - static -int -read_event(int sock, long *offset, il_octet_string_t *msg) +char * +read_event(int sock, long *offset) { char *buffer, *p, *n; - int len, alen, i, chunk_size = DEFAULT_CHUNK_SIZE; - static char buf[1024]; - - msg->data = NULL; - msg->len = 0; + int len, alen; + char buf[256]; /* receive offset */ len = recv(sock, offset, sizeof(*offset), MSG_NOSIGNAL); if(len < sizeof(*offset)) { set_error(IL_PROTO, errno, "read_event: error reading offset"); - return(-1); + return(NULL); } /* receive event string */ - buffer=malloc(8*chunk_size); + buffer=malloc(1024); if(buffer == NULL) { set_error(IL_NOMEM, ENOMEM, "read_event: no room for event"); - return(-1); + return(NULL); } p = buffer; - alen = 8*chunk_size; - /* Variables used here: - - buffer points to allocated memory, - - alen is the allocated memory size, - - p points to the first free location in buffer, - - len is the amount actually read by recv, - - i is the amount of data belonging to the current event (including separator). - - n points to event separator or is NULL - Hence: - (p - buffer) gives the amount of valid data read so far, - (alen - (p - buffer)) is the free space, - */ - -#if 1 - /* Reading events - optimized version. Attempts to increase chunks read by recv - * when there are more data, reads directly into destination memory (instead of - * copying from static buffer) etc. - * - * For some reason it is not much faster than the old variant. - */ - do { - /* prepare at least chunk_size bytes for next data */ - if(alen - (p - buffer) < chunk_size) { - alen += (chunk_size < 8192) ? 8192 : 8*chunk_size; - n = realloc(buffer, alen); - if(n == NULL) { - free(buffer); - set_error(IL_NOMEM, ENOMEM, "read_event: no room for event"); - return(-1); - } - p = n + (p - buffer); - buffer = n; - } - - /* read chunk */ - if((len=recv(sock, p, chunk_size, MSG_PEEK | MSG_NOSIGNAL)) > 0) { - /* find the end of event, if any */ - /* faster (and dirty) way of doing strnchr (which is not in libc, anyway) */ - if((n=memccpy(p, p, EVENT_SEPARATOR, len)) != NULL) { - i = n - p; /* length including separator */ - } else { - i = len; - /* long event, huh? try reading more data at once */ - chunk_size += 1024; - } - /* remove the relevant data from input */ - /* i > 0 */ - if(recv(sock, p, i, MSG_NOSIGNAL) != i) { - set_error(IL_SYS, errno, "read_event: error reading data"); - free(buffer); - return(-1); - } - /* move the pointer to the first free place, separator is considered free space */ - p = (n == NULL) ? p + len : n - 1; - } - } while ( (len > 0) && (n == NULL) ); - -#else - /* Reading events - original version. - * Appears to behave quite good, anyway. - */ + alen = 1024; while((len=recv(sock, buf, sizeof(buf), MSG_PEEK | MSG_NOSIGNAL)) > 0) { + int i; /* we have to be prepared for sizeof(buf) bytes */ if(alen - (p - buffer) < (int)sizeof(buf)) { @@ -166,41 +102,27 @@ read_event(int sock, long *offset, il_octet_string_t *msg) if(n == NULL) { free(buffer); set_error(IL_NOMEM, ENOMEM, "read_event: no room for event"); - return(-1); + return(NULL); } p = p - buffer + n; buffer = n; } /* copy all relevant bytes from buffer */ - n = (char*)memccpy(p, buf, EVENT_SEPARATOR, len); - if(n) { - /* separator found */ - n--; /* but do not preserve it */ - i = n - p; - p = n; - } else { - /* separator not found */ - i = len; - p += len; - } - /* This was definitely slowing us down: - * for(i=0; (i < len) && (buf[i] != EVENT_SEPARATOR); i++) - * *p++ = buf[i]; - */ + for(i=0; (i < len) && (buf[i] != EVENT_SEPARATOR); i++) + *p++ = buf[i]; /* remove the data from queue */ if(i > 0) if(recv(sock, buf, i, MSG_NOSIGNAL) != i) { set_error(IL_SYS, errno, "read_event: error reading data"); free(buffer); - return(-1); + return(NULL); } if(i < len) /* the event is complete */ break; } -#endif /* terminate buffer */ *p = 0; @@ -208,17 +130,16 @@ read_event(int sock, long *offset, il_octet_string_t *msg) if(len < 0) { set_error(IL_SYS, errno, "read_event: error reading data"); free(buffer); - return(-1); + return(NULL); } /* if len == 0, we have not encountered EVENT_SEPARATOR and thus the event is not complete */ if(len == 0) { set_error(IL_PROTO, errno, "read_event: error reading data - premature EOF"); free(buffer); - return(-1); + return(NULL); } -#if 0 /* this is probably not necessary at all: either len <=0, which was covered before, or 0 <= i < len => p > buffer; @@ -227,13 +148,10 @@ read_event(int sock, long *offset, il_octet_string_t *msg) if(p == buffer) { set_error(IL_PROTO, errno, "read_event: error reading data - no data received"); free(buffer); - return(-1); + return(NULL); } -#endif - msg->data = buffer; - msg->len = p - buffer; - return(msg->len); + return(buffer); } @@ -241,26 +159,8 @@ read_event(int sock, long *offset, il_octet_string_t *msg) * Returns: -1 on error, 0 if no message available, message length otherwise * */ -#ifdef PERF_EVENTS_INLINE -int -input_queue_get(il_octet_string *buffer, long *offset, int timeout) -{ - static long o = 0; - int len; - - len = glite_wll_perftest_produceEventString(&buffer->data); - buffer->len = len; - if(len) { - o += len; - *offset = o; - } else if (len == 0) { - sleep(timeout); - } - return(len); -} -#else int -input_queue_get(il_octet_string_t *buffer, long *offset, int timeout) +input_queue_get(char **buffer, long *offset, int timeout) { fd_set fds; struct timeval tv; @@ -281,17 +181,11 @@ input_queue_get(il_octet_string_t *buffer, long *offset, int timeout) return(0); case -1: /* error */ - switch(errno) { - case EINTR: - il_log(LOG_DEBUG, " interrupted while waiting for event!\n"); - return(0); - - default: - set_error(IL_SYS, errno, "input_queue_get: error waiting for event"); - return(-1); - } + set_error(IL_SYS, errno, "input_queue_get: error waiting for event"); + return(-1); + default: - break; + break; } if((accepted=accept(sock, NULL, NULL)) < 0) { @@ -299,16 +193,15 @@ input_queue_get(il_octet_string_t *buffer, long *offset, int timeout) return(-1); } - read_event(accepted, offset, buffer); + *buffer = read_event(accepted, offset); close(accepted); - if(buffer->data == NULL) { + if(*buffer == NULL) { if(error_get_maj() != IL_OK) return(-1); else return(0); } - return(buffer->len); + return(strlen(*buffer)); } -#endif diff --git a/org.glite.lb.logger/src/interlogd.c b/org.glite.lb.logger/src/interlogd.c index aff7510..d2d53b3 100644 --- a/org.glite.lb.logger/src/interlogd.c +++ b/org.glite.lb.logger/src/interlogd.c @@ -14,9 +14,6 @@ #include "interlogd.h" #include "glite/lb/consumer.h" #include "glite/security/glite_gss.h" -#ifdef LB_PERF -#include "glite/lb/lb_perftest.h" -#endif #define EXIT_FAILURE 1 #if defined(IL_NOTIFICATIONS) @@ -30,7 +27,7 @@ /* The name the program was run with, stripped of any leading path. */ char *program_name; -int killflg = 0; +static int killflg = 0; int TIMEOUT = DEFAULT_TIMEOUT; @@ -56,13 +53,6 @@ static void usage (int status) " -b, --book send events to bookkeeping server only\n" " -l, --log-server specify address of log server\n" " -s, --socket non-default path of local socket\n" -#ifdef LB_PERF - " -n, --nosend PERFTEST: consume events instead of sending\n" -#ifdef PERF_EVENTS_INLINE - " -e, --event_file PERFTEST: file to read test events from\n" - " -j, --njobs PERFTEST: number of jobs to send\n" -#endif -#endif , program_name, program_name); exit(status); } @@ -73,11 +63,6 @@ static int debug; static int verbose = 0; char *file_prefix = DEFAULT_PREFIX; int bs_only = 0; -#ifdef LB_PERF -int nosend = 0; -char *event_source = NULL; -int njobs = 0; -#endif char *cert_file = NULL; char *key_file = NULL; @@ -98,13 +83,6 @@ static struct option const long_options[] = {"CAdir", required_argument, 0, 'C'}, {"log-server", required_argument, 0, 'l'}, {"socket", required_argument, 0, 's'}, -#ifdef LB_PERF - {"nosend", no_argument, 0, 'n'}, -#ifdef PERF_EVENTS_INLINE - {"event_file", required_argument, 0, 'e'}, - {"njobs", required_argument, NULL, 'j'}, -#endif -#endif {NULL, 0, NULL, 0} }; @@ -130,13 +108,6 @@ decode_switches (int argc, char **argv) "b" /* only bookeeping */ "l:" /* log server */ "d" /* debug */ -#ifdef LB_PERF - "n" /* nosend */ -#ifdef PERF_EVENTS_INLINE - "e:" /* event file */ - "j:" /* num jobs */ -#endif -#endif "s:", /* socket */ long_options, (int *) 0)) != EOF) { @@ -185,22 +156,6 @@ decode_switches (int argc, char **argv) socket_path = strdup(optarg); break; -#ifdef LB_PERF - case 'n': - nosend = 1; - break; - -#ifdef PERF_EVENTS_INLINE - case 'e': - event_source = strdup(optarg); - break; - - case 'j': - njobs = atoi(optarg); - break; -#endif -#endif - default: usage (EXIT_FAILURE); } @@ -251,15 +206,6 @@ main (int argc, char **argv) exit(EXIT_FAILURE); } -#ifdef LB_PERF - /* this must be called after installing signal handlers */ - glite_wll_perftest_init(NULL, /* host */ - NULL, /* user */ - NULL, /* test name */ - event_source, - njobs); -#endif - il_log(LOG_INFO, "Initializing input queue...\n"); if(input_queue_attach() < 0) { il_log(LOG_CRIT, "Failed to initialize input queue: %s\n", error_get_msg()); @@ -304,7 +250,6 @@ main (int argc, char **argv) exit(EXIT_FAILURE); } -#ifndef PERF_EMPTY /* find all unsent events waiting in files */ { pthread_t rid; @@ -316,7 +261,6 @@ main (int argc, char **argv) } pthread_detach(rid); } -#endif il_log(LOG_INFO, "Entering main loop...\n"); diff --git a/org.glite.lb.logger/src/interlogd.h b/org.glite.lb.logger/src/interlogd.h index 846d9ea..64c6889 100644 --- a/org.glite.lb.logger/src/interlogd.h +++ b/org.glite.lb.logger/src/interlogd.h @@ -5,7 +5,6 @@ #include "il_error.h" #include "glite/security/glite_gss.h" -#include "glite/lb/il_msg.h" #include #include @@ -27,10 +26,6 @@ #define DEFAULT_LOG_SERVER "localhost" #define DEFAULT_TIMEOUT 60 -#ifdef LB_PERF -#include "glite/lb/lb_perftest.h" -#endif - #if defined(IL_NOTIFICATIONS) #include "glite/lb/notifid.h" @@ -69,13 +64,7 @@ extern char *cert_file; extern char *key_file; extern char *CAcert_dir; extern int bs_only; -extern int killflg; -#ifdef LB_PERF -extern int nosend; -#ifdef PERF_EVENTS_INLINE -extern char *event_source; -#endif -#endif + /* shared data for thread communication */ #ifdef INTERLOGD_FLUSH @@ -140,9 +129,9 @@ struct event_queue { /* server msg methods */ -struct server_msg *server_msg_create(il_octet_string_t *, long); +struct server_msg *server_msg_create(char *, long); struct server_msg *server_msg_copy(struct server_msg *); -int server_msg_init(struct server_msg *, il_octet_string_t *); +int server_msg_init(struct server_msg *, char *); #if defined(INTERLOGD_EMS) int server_msg_is_priority(struct server_msg *); #endif @@ -180,7 +169,7 @@ int event_queue_cond_unlock(struct event_queue *); /* input queue */ int input_queue_attach(); void input_queue_detach(); -int input_queue_get(il_octet_string_t *, long *, int); +int input_queue_get(char **, long *, int); /* queue management functions */ int queue_list_init(char *); diff --git a/org.glite.lb.logger/src/logd.c b/org.glite.lb.logger/src/logd.c index 736a00a..4c32f2b 100644 --- a/org.glite.lb.logger/src/logd.c +++ b/org.glite.lb.logger/src/logd.c @@ -17,9 +17,6 @@ #include "logd_proto.h" #include "glite/lb/consumer.h" #include "glite/security/glite_gss.h" -#ifdef LB_PERF -#include "glite/lb/lb_perftest.h" -#endif static const char rcsid[] = "@(#)$Id$"; static int verbose = 0; @@ -238,8 +235,7 @@ int main(int argc, char *argv[]) /* welcome */ fprintf(stdout,"\ -This is LocalLogger, part of Workload Management System in EU DataGrid.\ -Copyright (c) 2002 CERN, INFN and CESNET on behalf of the EU DataGrid.\n"); +This is LocalLogger, part of Workload Management System in EU DataGrid & EGEE.\n"); /* get arguments */ while ((opt = getopt_long(argc,argv, @@ -276,11 +272,7 @@ Copyright (c) 2002 CERN, INFN and CESNET on behalf of the EU DataGrid.\n"); usage(argv[0]); exit(0); } } -#ifdef LB_PERF - edg_wll_ll_log_init(verbose ? LOG_INFO : LOG_ERR); -#else edg_wll_ll_log_init(verbose ? LOG_DEBUG : LOG_INFO); -#endif edg_wll_ll_log(LOG_INFO,"Initializing...\n"); /* check noParse */ @@ -333,10 +325,6 @@ Copyright (c) 2002 CERN, INFN and CESNET on behalf of the EU DataGrid.\n"); if (mysignal(SIGTERM, handle_signal) == SIG_ERR) { perror("signal"); exit(1); } if (mysignal(SIGCHLD, handle_signal) == SIG_ERR) { perror("signal"); exit(1); } -#ifdef LB_PERF - glite_wll_perftest_init(NULL, NULL, NULL, NULL, 0); -#endif - edg_wll_gss_watch_creds(cert_file,&cert_mtime); /* XXX DK: support noAuth */ ret = edg_wll_gss_acquire_cred_gsi(cert_file, key_file, &cred, &my_subject_name, diff --git a/org.glite.lb.logger/src/logd_proto.c b/org.glite.lb.logger/src/logd_proto.c index f39b24d..5e31fcf 100644 --- a/org.glite.lb.logger/src/logd_proto.c +++ b/org.glite.lb.logger/src/logd_proto.c @@ -463,21 +463,15 @@ int edg_wll_log_proto_server(edg_wll_GssConnection *con, char *name, char *prefi /* if not command, save message to file */ -#ifdef LOGD_NOFILE - edg_wll_ll_log(LOG_DEBUG,"Calling perftest\n"); - glite_wll_perftest_consumeEventString(msg); - edg_wll_ll_log(LOG_DEBUG,"o.k.\n"); - filepos = 0; -#else if(strstr(msg, "DG.TYPE=\"command\"") == NULL) { /* compose the name of the log file */ - edg_wll_ll_log(LOG_DEBUG,"Composing filename from prefix \"%s\" and jobId \"%s\"...",prefix,jobId); +// edg_wll_ll_log(LOG_DEBUG,"Composing filename from prefix \"%s\" and jobId \"%s\"...",prefix,jobId); count = strlen(prefix); strncpy(outfilename,prefix,count); count_total=count; strncpy(outfilename+count_total,".",1); count_total+=1; count=strlen(jobId); strncpy(outfilename+count_total,jobId,count); count_total+=count; outfilename[count_total]='\0'; - edg_wll_ll_log(LOG_DEBUG,"o.k.\n"); +// edg_wll_ll_log(LOG_DEBUG,"o.k.\n"); edg_wll_ll_log(LOG_INFO,"Writing message to \"%s\"...",outfilename); i = 0; @@ -495,7 +489,6 @@ open_event_file: } else { filepos = 0; } -#endif /* if not priority send now the answer back to client */ diff --git a/org.glite.lb.logger/src/perftest_il.sh b/org.glite.lb.logger/src/perftest_il.sh deleted file mode 100644 index e9562f9..0000000 --- a/org.glite.lb.logger/src/perftest_il.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash - -numjobs=$1 - -# XXX - there must be better way to find stage -STAGEDIR=/home/michal/shared/egee/jra1-head/stage -. $STAGEDIR/sbin/perftest_common.sh - -DEBUG=${DEBUG:-0} -# CONSUMER_ARGS= -# PERFTEST_COMPONENT= -# COMPONENT_ARGS= -#LOGJOBS_ARGS="" - -check_test_files || exit 1 - -PERFTEST_CONSUMER=$STAGEDIR/bin/glite-lb-interlogd-perf-empty -CONSUMER_ARGS="-d -v" - -echo -e "\tsmall_job \t big_job \t small_dag \t big_dag" -run_test il $numjobs -j=0 -while [[ $j -lt 4 ]] -do - echo -e -n "\t ${PERFTEST_THROUGHPUT[$j]}" - j=$((j+1)) -done -echo "" -#j=0 -#while [[ $j -lt 4 ]] -#do -# echo -e -n "\t (${PERFTEST_EV_THROUGHPUT[$j]})" -# j=$((j+1)) -#done -#echo "" - - -# -# dst=il -# -## i)1) -# -# glite_lb_interlogd_perf_noparse --nosend -# run_test() -# -# glite_lb_interlogd_perf_nosync --nosend -# run_test() -# -# glite_lb_interlogd_perf_norecover --nosend -# run_test() -# -# glite_lb_interlogd_perf --nosend -# run_test() -# -## ii)1) -# -#glite_lb_bkserverd_perf_empty -# -# glite_lb_interlogd_perf_noparse -# run_test() -# -# glite_lb_interlogd_perf_nosync -# run_test() -# -# glite_lb_interlogd_perf_norecover -# run_test() -# -# glite_lb_interlogd_perf_lazy -# run_test() -# -# glite_lb_interlogd_perf -# run_test() diff --git a/org.glite.lb.logger/src/perftest_ll.sh b/org.glite.lb.logger/src/perftest_ll.sh deleted file mode 100644 index 599867e..0000000 --- a/org.glite.lb.logger/src/perftest_ll.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -numjobs=$1 - -# XXX - there must be better way to find stage -if [ -z "${GLITE_LOCATION}" ]; then - STAGEDIR=/home/michal/shared/egee/jra1-head/stage -else - STAGEDIR=${GLITE_LOCATION} -fi - -. $STAGEDIR/sbin/perftest_common.sh - -DEBUG=${DEBUG:-0} -# CONSUMER_ARGS= -# PERFTEST_COMPONENT= -# COMPONENT_ARGS= -#LOGJOBS_ARGS="" - -check_test_files || exit 1 - -PERFTEST_CONSUMER=$STAGEDIR/bin/glite-lb-logd-perf-nofile -CONSUMER_ARGS="-d -v --noIPC --noParse" - -echo -e "\tsmall_job \t big_job \t small_dag \t big_dag" -run_test ll $numjobs -j=0 -while [[ $j -lt 4 ]] -do - echo -e -n "\t ${PERFTEST_EVENT_THROUGHPUT[$j]}" - j=$((j+1)) -done -echo "" - diff --git a/org.glite.lb.logger/src/send_event.c b/org.glite.lb.logger/src/send_event.c index dc33757..44bb8b4 100644 --- a/org.glite.lb.logger/src/send_event.c +++ b/org.glite.lb.logger/src/send_event.c @@ -168,10 +168,6 @@ event_queue_connect(struct event_queue *eq) assert(eq != NULL); -#ifdef LB_PERF - if(!nosend) { -#endif - if(eq->gss.context == GSS_C_NO_CONTEXT) { tv.tv_sec = TIMEOUT; @@ -196,10 +192,6 @@ event_queue_connect(struct event_queue *eq) } } -#ifdef LB_PERF - } -#endif - return(1); } @@ -209,17 +201,10 @@ event_queue_close(struct event_queue *eq) { assert(eq != NULL); -#ifdef LB_PERF - if(!nosend) { -#endif - if(eq->gss.context != GSS_C_NO_CONTEXT) { edg_wll_gss_close(&eq->gss, NULL); eq->gss.context = GSS_C_NO_CONTEXT; } -#ifdef LB_PERF - } -#endif return(0); } @@ -233,14 +218,8 @@ event_queue_send(struct event_queue *eq) { assert(eq != NULL); -#ifdef LB_PERF - if(!nosend) { -#endif if(eq->gss.context == GSS_C_NO_CONTEXT) return(0); -#ifdef LB_PERF - } -#endif /* feed the server with events */ while (!event_queue_empty(eq)) { @@ -250,6 +229,7 @@ event_queue_send(struct event_queue *eq) size_t bytes_sent; struct timeval tv; edg_wll_GssStatus gss_stat; + int events_sent = 0; clear_error(); @@ -258,29 +238,23 @@ event_queue_send(struct event_queue *eq) il_log(LOG_DEBUG, " trying to deliver event at offset %d for job %s\n", msg->offset, msg->job_id_s); -#ifdef LB_PERF - if(!nosend) { -#endif - tv.tv_sec = TIMEOUT; - tv.tv_usec = 0; - ret = edg_wll_gss_write_full(&eq->gss, msg->msg, msg->len, &tv, &bytes_sent, &gss_stat); - if(ret < 0) { - eq->timeout = TIMEOUT; - return(0); - } - - if((code = get_reply(eq, &rep, &code_min)) < 0) { - /* could not get the reply properly, so try again later */ - il_log(LOG_ERR, " error reading server %s reply:\n %s\n", eq->dest_name, error_get_msg()); - eq->timeout = TIMEOUT; - return(0); - } -#ifdef LB_PERF - } else { - glite_wll_perftest_consumeEventIlMsg(msg->msg+17); - code = LB_OK; + tv.tv_sec = TIMEOUT; + tv.tv_usec = 0; + ret = edg_wll_gss_write_full(&eq->gss, msg->msg, msg->len, &tv, &bytes_sent, &gss_stat); + if(ret < 0) { + if (ret == EDG_WLL_GSS_ERROR_ERRNO && errno == EPIPE && events_sent > 0) + eq->timeout = 0; + else + eq->timeout = TIMEOUT; + return(0); + } + + if((code = get_reply(eq, &rep, &code_min)) < 0) { + /* could not get the reply properly, so try again later */ + il_log(LOG_ERR, " error reading server %s reply:\n %s\n", eq->dest_name, error_get_msg()); + eq->timeout = TIMEOUT; + return(0); } -#endif il_log(LOG_DEBUG, " event sent, server %s replied with %d, %s\n", eq->dest_name, code, rep); free(rep); @@ -318,6 +292,7 @@ event_queue_send(struct event_queue *eq) il_log(LOG_ERR, "send_event: %s\n", error_get_msg()); event_queue_remove(eq); + events_sent++; break; } /* switch */ diff --git a/org.glite.lb.logger/src/server_msg.c b/org.glite.lb.logger/src/server_msg.c index b7a005b..1a90e72 100644 --- a/org.glite.lb.logger/src/server_msg.c +++ b/org.glite.lb.logger/src/server_msg.c @@ -12,11 +12,10 @@ static int -create_msg(il_octet_string_t *ev, char **buffer, long *receipt) +create_msg(char *event, char **buffer, long *receipt) { char *p; int len; - char *event = ev->data; - + *receipt = 0; #if defined(INTERLOGD_EMS) @@ -57,7 +56,7 @@ create_msg(il_octet_string_t *ev, char **buffer, long *receipt) } #endif - len = encode_il_msg(buffer, ev); + len = encode_il_msg(buffer, event); if(len < 0) { set_error(IL_NOMEM, ENOMEM, "create_msg: out of memory allocating message"); return(-1); @@ -67,7 +66,7 @@ create_msg(il_octet_string_t *ev, char **buffer, long *receipt) struct server_msg * -server_msg_create(il_octet_string_t *event, long offset) +server_msg_create(char *event, long offset) { struct server_msg *msg; @@ -122,7 +121,7 @@ server_msg_copy(struct server_msg *src) int -server_msg_init(struct server_msg *msg, il_octet_string_t *event) +server_msg_init(struct server_msg *msg, char *event) { #if defined(IL_NOTIFICATIONS) edg_wll_Context context; @@ -131,7 +130,6 @@ server_msg_init(struct server_msg *msg, il_octet_string_t *event) #endif assert(msg != NULL); - assert(event != NULL); memset(msg, 0, sizeof(*msg)); @@ -166,10 +164,10 @@ server_msg_init(struct server_msg *msg, il_octet_string_t *event) if(msg->len < 0) { return(-1); } - msg->job_id_s = edg_wll_GetJobId(event->data); + msg->job_id_s = edg_wll_GetJobId(event); #endif /* remember to add event separator to the length */ - msg->ev_len = event->len + 1; + msg->ev_len = strlen(event) + 1; if(msg->job_id_s == NULL) { set_error(IL_LBAPI, EDG_WLL_ERROR_PARSE_BROKEN_ULM, "server_msg_init: error getting id"); diff --git a/org.glite.lb.proxy/Makefile b/org.glite.lb.proxy/Makefile index 282052f..e1bc0ff 100644 --- a/org.glite.lb.proxy/Makefile +++ b/org.glite.lb.proxy/Makefile @@ -18,9 +18,7 @@ expat_prefix=/opt/expat gsoap_prefix=/opt/gsoap -include Makefile.inc --include ../project/version.properties - -version=${module.version} +-include ../Makefile.inc CC=gcc YACC=bison -y @@ -28,24 +26,13 @@ YACC=bison -y VPATH=${top_srcdir}/src:${top_srcdir}/test:${top_srcdir}/examples:${top_srcdir}/project AT3=perl -I${top_srcdir}/project ${top_srcdir}/project/at3 -TEST_LIBS:=-L${cppunit_prefix}/lib -lcppunit -TEST_INC:=-I${cppunit_prefix}/include - -ifdef LB_PERF - STATIC_LIB_BK:=${stagedir}/lib/libglite_lb_bkserver_perf.a - LB_PERF_FLAGS:=-DLB_PERF -else - STATIC_LIB_BK:=${stagedir}/lib/libglite_lb_bkserver.a -endif +TEST_LIBS:=-L${cppunit}/lib -lcppunit +TEST_INC:=-I${cppunit}/include SUFFIXES = .T DEBUG:=-g -O0 -Wall -ifdef LB_STANDALONE - LB_STANDALONE_FLAGS:=-DLB_STANDALONE -endif - CFLAGS:= ${DEBUG} \ -DVERSION=\"${version}\" \ -I${stagedir}/include -I${top_srcdir}/src -I. \ @@ -55,7 +42,7 @@ CFLAGS:= ${DEBUG} \ -I${mysql_prefix}/include -I${mysql_prefix}/include/mysql \ -I${globus_prefix}/include/${nothrflavour} \ -I${gridsite_prefix}/include -I${globus_prefix}/include/${nothrflavour}/openssl \ - -D_GNU_SOURCE ${LB_STANDALONE_FLAGS} ${LB_PERF_FLAGS} + -D_GNU_SOURCE LINK:=libtool --mode=link ${CC} ${LDFLAGS} @@ -81,6 +68,9 @@ endif SRVBONES_LIB:= -L${stagedir}/lib -lglite_lb_server_bones +LB_SERVER_SHARE_LIB:=${stagedir}/lib/libglite_lb_bkserver.a +LB_PROXY_COMMON_LIB:= -L${stagedir}/lib -lglite_lb_common_${nothrflavour} +COMMON_LIBS:= -L${stagedir}/lib -lglite_lb_common_${nothrflavour} -lglite_security_gss_${nothrflavour} GRIDSITE_LIBS = -lgridsite_globus `xml2-config --libs` vomsflavour := _${nothrflavour} @@ -91,18 +81,17 @@ ifeq (${nothrflavour},gcc32dbg) vomsflavour := endif -VOMS_LIBS:=-L${voms_prefix}/lib -lvomsc${vomsflavour} EXT_LIBS:= \ ${mysqlib} -lmysqlclient -lz\ ${expatlib} -lexpat \ ${GRIDSITE_LIBS} \ - ${VOMS_LIBS} \ + -lvomsc${vomsflavour} \ ${GLOBUS_LIBS} LB_PROXY_LIBS:= \ - ${STATIC_LIB_BK} \ + ${LB_SERVER_SHARE_LIB} \ ${SRVBONES_LIB} \ -lglite_lb_common_${nothrflavour} \ -lglite_security_gss_${nothrflavour} \ @@ -110,14 +99,11 @@ LB_PROXY_LIBS:= \ -glite_lb_proxy: lbproxy.o fake_write2rgma.o ${STATIC_LIB_BK} +glite_lb_proxy: lbproxy.o fake_write2rgma.o ${LB_SERVER_SHARE_LIB} @echo DEBUG: mysql_version=${mysql_version} mysql_prefix=${mysql_prefix} @echo DEBUG: shell: x$(shell echo ${mysql_version} | cut -d. -f1,2)x ${LINK} -o $@ lbproxy.o fake_write2rgma.o ${LB_PROXY_LIBS} -glite_lb_proxy_perf: lbproxy.o fake_write2rgma.o ${STATIC_LIB_BK} - ${LINK} -o $@ lbproxy.o fake_write2rgma.o ${LB_PROXY_LIBS} - default all: compile compile: glite_lb_proxy diff --git a/org.glite.lb.proxy/examples/test.sh b/org.glite.lb.proxy/examples/test.sh index 7847dc7..31fc184 100755 --- a/org.glite.lb.proxy/examples/test.sh +++ b/org.glite.lb.proxy/examples/test.sh @@ -1,7 +1,7 @@ #!/bin/sh # XXX: add path to the stage area -PATH=/home/michal/shared/egee/jra1-head/stage/bin:/home/michal/shared/egee/jra1-head/stage/examples:$PATH +PATH=.:$PATH #set -x @@ -143,8 +143,8 @@ test_gen_sample_jobs() exit 1; fi if test "$state" != "$proxy_state" ; then - echo -e "ERROR\n\tjob $job (${SAMPLE_JOBS_ARRAY[$job]}) records on lbproxy and bkserver differs!" -# exit 1; + echo -e "ERROR\n\tjob (${SAMPLE_JOBS_ARRAY[$job]}) records on lbproxy and bkserver differs!" + exit 1; fi SAMPLE_JOBS_STATES[$job]=$state diff --git a/org.glite.lb.proxy/examples/test1.sh b/org.glite.lb.proxy/examples/test1.sh deleted file mode 100644 index 485418f..0000000 --- a/org.glite.lb.proxy/examples/test1.sh +++ /dev/null @@ -1,295 +0,0 @@ -#!/bin/sh - -# XXX: add path to the stage area -PATH=/home/michal/shared/egee/jra1/stage/bin:/home/michal/shared/egee/jra1/stage/examples:$PATH - -#set -x - -# Binaries -LOGEV=${LOGEV:-glite-lb-logevent} -JOBLOG=${JOBLOG:-glite-lb-job_log} -JOBREG=${JOBREG:-glite-lb-job_reg} -USERJOBS=${USERJOBS:-glite-lb-user_jobs} -JOBSTAT=${JOBSTAT:-glite-lb-job_status} -PURGE=${PURGE:-glite-lb-purge} - -# -m host -BKSERVER_HOST=${BKSERVER_HOST:-`hostname -f`:9000} -TEST_LBPROXY_STORE_SOCK=${EDG_WL_LBPROXY_STORE_SOCK:-/tmp/lb_proxy_store.sock} -TEST_LBPROXY_SERVE_SOCK=${EDG_WL_LBPROXY_SERVE_SOCK:-/tmp/lb_proxy_serve.sock} - -STATES="aborted cancelled done ready running scheduled waiting" -LBPROXY_PURGE_STATES="cleared done aborted cancelled" -JOBS_ARRAY_SIZE=10 -SAMPLE_JOBS_ARRAY[0]= -SAMPLE_JOBS_STATES[0]= -SAMPLE_JOBS_RESPONSES[0]= - -# some defaults -DEBUG=2 -LOGFD=${LOGFD:-1} -LARGE_STRESS=${LARGE_STRESS:-} - -# timeouts for polling the bkserver -timeout=10 -maxtimeout=300 - -# -# Procedures -# - -# print help message -show_help() -{ - echo "Usage: $0 [OPTIONS] " - echo "Options:" - echo " -h | --help Show this help message." - echo " -x | --proxy-sockpath-pref LBProxy socket path prefix." - echo " -j | --jobs-count Count of test(ed) jobs." - echo " -s | --states List of states in which could tested jobs fall." - echo " -p | --proxy-purge-states List of states in which LBProxy purges the job." - echo " -l | --large-stress 'size' Do a large stress logging ('size' random data added to the messages." - echo " -g | --log 'logfile' Redirect all output to the 'logfile'." - echo "" - echo "For proper operation check your grid-proxy-info" - grid-proxy-info -} - -get_time() -{ - sec=`date +%s` - nsec=`date +%N` - time=`echo "1000000000*$sec + $nsec"|bc` -# time=$sec - return 0 -} - -check_exec() -{ - [ $DEBUG -gt 0 ] && [ -n "$2" ] && echo -n -e "$2\t" || echo -n -e "$1\t" - eval $1 - RV=$? - [ $DEBUG -gt 0 ] && [ $RV -eq 0 ] && echo "OK" || echo "FAILED" - return $RV -} - -# check for existance of needed executable(s) -check_utils() -{ - check_exec 'JOBREG=`which $JOBREG`' "Checkig $JOBREG utility" || exit 1 - check_exec 'JOBLOG=`which $JOBLOG`' "Checkig $JOBLOG utility" || exit 1 - check_exec 'LOGEV=`which $LOGEV`' "Checkig $LOGEV utility" || exit 1 - check_exec 'USERJOBS=`which $USERJOBS`' "Checkig $USERJOBS utility" || exit 1 - check_exec 'JOBSTAT=`which $JOBSTAT`' "Checkig $JOBSTAT utility" || exit 1 -} - -log_ev() -{ -# $LOGEV -j $EDG_JOBID -s NetworkServer -n $1 -e UserTag --name color --value red - [ $DEBUG -gt 2 ] && echo "$LOGEV -j \"$EDG_JOBID\" -s UserInterface -c \"$EDG_WL_SEQUENCE\" $@" - EDG_WL_SEQUENCE=`$LOGEV $LARGE_STRESS -j $EDG_JOBID -s UserInterface -c $EDG_WL_SEQUENCE "$@"` - test $? -ne 0 -o -z "$EDG_WL_SEQUENCE" && echo "missing EDG_WL_SEQUENCE from $LOGEV" -} - -log_ev_proxy() -{ -# $LOGEV -x -j $EDG_JOBID -s NetworkServer -n $1 -e UserTag --name color --value red - - [ $DEBUG -gt 2 ] && echo "$LOGEV -x -j \"$EDG_JOBID\" -s UserInterface -c \"$EDG_WL_SEQUENCE\" $@" - EDG_WL_SEQUENCE=`$LOGEV -x $LARGE_STRESS -j $EDG_JOBID -s UserInterface -c $EDG_WL_SEQUENCE "$@"` - test $? -ne 0 -o -z "$EDG_WL_SEQUENCE" && echo "missing EDG_WL_SEQUENCE from $LOGEV" -} - -purge() -{ - [ $DEBUG -gt 2 ] && echo "$PURGE -a 0 -c 0 -n 0 -o 0 $@" - $PURGE -a 0 -c 0 -n 0 -o 0 "$@" -} - -purge_proxy() -{ - [ $DEBUG -gt 2 ] && echo "$PURGE -x -a 0 -c 0 -n 0 -o 0 $@" - $PURGE -x -a 0 -c 0 -n 0 -o 0 "$@" -} - - -db_clear_jobs() -{ - [ $DEBUG -gt 0 ] && echo -n -e "Purging test jobs from db\t\t" - job=0 - while [ $job -lt $JOBS_ARRAY_SIZE ] ; do - LARGE_STRESS="" - EDG_WL_SEQUENCE="UI=999999:NS=9999999999:WM=999999:BH=9999999999:JSS=999999:LM=999999:LRMS=999999:APP=999999" -# log_ev_proxy -e Clear --reason=PurgingDB -# purge_proxy -# log_ev -e Clear --reason=PurgingDB -# purge - - job=$(($job + 1)) - done - [ $DEBUG -gt 0 ] && echo "OK" -} - -# Test thet registers jobs -# and checks against lbproxy and bkserver -# -test_gen_sample_jobs() -{ - [ $DEBUG -gt 0 ] && echo -n -e "Registering sample jobs\t\t\t" - job=0 - while [ $job -lt $JOBS_ARRAY_SIZE ] ; do -# eval `$JOBREG -x -m $BKSERVER_HOST -s UserInterface 2>&1 | tail -n 2` - TMP=`$JOBREG -x -m $BKSERVER_HOST -s UserInterface 2>&1` - [ $? -ne 0 ] && echo -e "ERROR\n\t$JOBREG error!" - eval `echo "$TMP" | tail -n 2` - if test -z "$EDG_JOBID" ; then - echo "test_gen_sample_jobs: $JOBREG failed" - else - SAMPLE_JOBS_ARRAY[$job]=$EDG_JOBID - fi - -# state=`$JOBSTAT $EDG_JOBID 2>&1 | grep "state :" | cut -d " " -f 3 | tr A-Z a-z` -# proxy_state=`$JOBSTAT -x $TEST_LBPROXY_SERVE_SOCK $EDG_JOBID 2>&1 | grep "state :" | cut -d " " -f 3 | tr A-Z a-z` -# if test "$state" != "submitted" ; then -# echo -e "ERROR\n\tjob ${SAMPLE_JOBS_ARRAY[$job]} not submitted succesfully!" -# fi -# if test "$state" != "$proxy_state" ; then -# echo -e "ERROR\n\tjob (${SAMPLE_JOBS_ARRAY[$job]}) records on lbproxy and bkserver differs!" -# fi -# SAMPLE_JOBS_STATES[$job]=$state - echo -n "." - job=$(($job + 1)) - done - [ $DEBUG -gt 0 ] && echo "OK" -# [ $DEBUG -gt 1 ] && { -# job=0 -# while [ $job -lt $JOBS_ARRAY_SIZE ] ; do -# echo ${SAMPLE_JOBS_ARRAY[$job]} -# job=$(($job + 1)) -# done -# } -} - -# Test that logs random set of events (for registered jobs) to lbproxy -# and checks the state in lbproxy -# and measures the time it takes the state to propagate to bkserver -# -test_logging_events() -{ - [ $DEBUG -gt 0 ] && echo -n -e "Logging events to the lbproxy\t\t" - st_count=`echo $STATES | wc -w` - job=0 - while [ $job -lt $JOBS_ARRAY_SIZE ] ; do - echo -n "." - if test -z "${SAMPLE_JOBS_ARRAY[$job]}" ; then - job=$(($job + 1)) - continue - fi -# tmp=`echo $RANDOM % $st_count + 1 | bc` -# state=`echo $STATES | cut -d " " -f $tmp | tr A-Z a-z` - get_time - start=$time - -# source glite-lb-$state.sh $LARGE_STRESS -X $TEST_LBPROXY_STORE_SOCK -m $BKSERVER_HOST -j ${SAMPLE_JOBS_ARRAY[$job]} 2>&1 1>/dev/null -# [ $? -ne 0 ] && echo -e "ERROR\n\tglite-lb-$state.sh ${SAMPLE_JOBS_ARRAY[$job]} error!" - log_ev_proxy -n 100 -e UserTag --tag=color --value=red - -# proxy_state=`$JOBSTAT -x $TEST_LBPROXY_SERVE_SOCK ${SAMPLE_JOBS_ARRAY[$job]} 2>&1 | grep "state :" | cut -d " " -f 3 | tr A-Z a-z` -# purged=`echo $LBPROXY_PURGE_STATES | grep $state` -# bkserver_state=`$JOBSTAT ${SAMPLE_JOBS_ARRAY[$job]} 2>&1 | grep "state :" | cut -d " " -f 3 | tr A-Z a-z` -# -# if test -n "$purged" ; then -# echo $proxy_state | grep "No such file or directory" -# if test $? -eq 0 ; then -# echo -e "ERROR\n\tJob ${SAMPLE_JOBS_ARRAY[$job]} was not purged out from LBProxy!" -# exit 1; -# fi -# fi -# if test -z "$purged" ; then -# if test "$state" != "$proxy_state" ; then -# echo -e "ERROR\n\tevents for job ${SAMPLE_JOBS_ARRAY[$job]} were not logged succesfully!" -# exit 1; -# fi -# fi - -# response=0 -# while [ "$state" != "$bkserver_state" ] ; do -# bkserver_state=`$JOBSTAT ${SAMPLE_JOBS_ARRAY[$job]} 2>&1 | grep "state :" | cut -d " " -f 3 | tr A-Z a-z` -# [ $DEBUG -gt 0 ] && echo -n "." -# sleep $timeout -# response=$(($response + $timeout )) -# if test $response -gt $maxtimeout ; then -# echo -e "ERROR\n\tstatus of job ${SAMPLE_JOBS_ARRAY[$job]} as queried from bkserver ($bkserver_state) has not become $state for more than $response seconds!" -# exit 1; -# fi -# done -# -# SAMPLE_JOBS_STATES[$job]=$state - get_time - response=`echo "scale=9; ($time - $start)/1000000000"|bc` - SAMPLE_JOBS_RESPONSES[$job]=$response - job=$(($job + 1)) - done - [ $DEBUG -gt 0 ] && echo "OK" - [ $DEBUG -gt 1 ] && { - job=0 - total=0 -# echo "Sending events took for individual jobs the following time" - while [ $job -lt $JOBS_ARRAY_SIZE ] ; do - total=`echo "scale=9; $total + ${SAMPLE_JOBS_RESPONSES[$job]}" |bc` -# echo -e "${SAMPLE_JOBS_ARRAY[$job]} \t${SAMPLE_JOBS_RESPONSES[$job]} seconds" - job=$(($job + 1)) - done - echo -e "Total time for $JOBS_ARRAY_SIZE jobs: \t$total" - echo -e -n "Average time for job: \t" - echo "scale=9; $total / $JOBS_ARRAY_SIZE"|bc - echo -e -n "Job throughput (jobs/sec): \t" - echo "scale=9; $JOBS_ARRAY_SIZE / $total"|bc - - } -} - - -# -# shell starting code - -# without parameters show help message -# test -z "$1" && show_help - -while test -n "$1" -do - case "$1" in - "-h" | "--help") show_help && exit 0 ;; - "-x" | "--proxy-sockpath-pref") - shift - export TEST_LBPROXY_STORE_SOCK=$1store.sock - export TEST_LBPROXY_SERVE_SOCK=$1serve.sock - ;; - "-m" | "--bkserver") shift ; BKSERVER_HOST=$1 ;; - "-j" | "--jobs-count") shift; JOBS_ARRAY_SIZE=$1 ;; - "-s" | "--states") shift; STATES="$1" ;; - "-p" | "--proxy-purge-states") shift; LBPROXY_PURGE_STATES="$1" ;; - "-l" | "--large-stress") shift ; LARGE_STRESS="-l $1" ;; - "-g" | "--log") shift ; logfile=$1 ;; - - *) echo "Unrecognized option $1" ;; - - esac - shift -done - -if test -n "$logfile" ; then - LOGFD=3 - exec 3>$logfile -fi - - -echo "STATES = $STATES" -echo "LBPROXY_PURGE_STATES = $LBPROXY_PURGE_STATES" - -check_utils - -test_gen_sample_jobs -test_logging_events - -db_clear_jobs diff --git a/org.glite.lb.proxy/examples/test2.sh b/org.glite.lb.proxy/examples/test2.sh deleted file mode 100644 index 54b9416..0000000 --- a/org.glite.lb.proxy/examples/test2.sh +++ /dev/null @@ -1,298 +0,0 @@ -#!/bin/sh - -# XXX: add path to the stage area -PATH=/home/michal/shared/egee/jra1/stage/bin:/home/michal/shared/egee/jra1/stage/examples:$PATH - -#set -x - -# Binaries -LOGEV=${LOGEV:-glite-lb-logevent} -JOBLOG=${JOBLOG:-glite-lb-job_log} -JOBREG=${JOBREG:-glite-lb-job_reg} -USERJOBS=${USERJOBS:-glite-lb-user_jobs} -JOBSTAT=${JOBSTAT:-glite-lb-job_status} -PURGE=${PURGE:-glite-lb-purge} - -# -m host -BKSERVER_HOST=${BKSERVER_HOST:-`hostname -f`:9000} -TEST_LBPROXY_STORE_SOCK=${EDG_WL_LBPROXY_STORE_SOCK:-/tmp/lb_proxy_store.sock} -TEST_LBPROXY_SERVE_SOCK=${EDG_WL_LBPROXY_SERVE_SOCK:-/tmp/lb_proxy_serve.sock} - -STATES="aborted cancelled done ready running scheduled waiting" -LBPROXY_PURGE_STATES="cleared done aborted cancelled" -JOBS_ARRAY_SIZE=10 -EVENT_NUMBER=50 -SAMPLE_JOBS_ARRAY[0]= -SAMPLE_JOBS_STATES[0]= -SAMPLE_JOBS_RESPONSES[0]= - -# some defaults -DEBUG=2 -LOGFD=${LOGFD:-1} -LARGE_STRESS=${LARGE_STRESS:-} - -# timeouts for polling the bkserver -timeout=10 -maxtimeout=300 - -# -# Procedures -# - -# print help message -show_help() -{ - echo "Usage: $0 [OPTIONS] " - echo "Options:" - echo " -h | --help Show this help message." - echo " -x | --proxy-sockpath-pref LBProxy socket path prefix." - echo " -j | --jobs-count Count of test(ed) jobs." - echo " -n | --event-count Number of events per job." - echo " -s | --states List of states in which could tested jobs fall." - echo " -p | --proxy-purge-states List of states in which LBProxy purges the job." - echo " -l | --large-stress 'size' Do a large stress logging ('size' random data added to the messages." - echo " -g | --log 'logfile' Redirect all output to the 'logfile'." - echo "" - echo "For proper operation check your grid-proxy-info" - grid-proxy-info -} - -get_time() -{ - sec=`date +%s` - nsec=`date +%N` - time=`echo "1000000000*$sec + $nsec"|bc` -# time=$sec - return 0 -} - -check_exec() -{ - [ $DEBUG -gt 0 ] && [ -n "$2" ] && echo -n -e "$2\t" || echo -n -e "$1\t" - eval $1 - RV=$? - [ $DEBUG -gt 0 ] && [ $RV -eq 0 ] && echo "OK" || echo "FAILED" - return $RV -} - -# check for existance of needed executable(s) -check_utils() -{ - check_exec 'JOBREG=`which $JOBREG`' "Checkig $JOBREG utility" || exit 1 - check_exec 'JOBLOG=`which $JOBLOG`' "Checkig $JOBLOG utility" || exit 1 - check_exec 'LOGEV=`which $LOGEV`' "Checkig $LOGEV utility" || exit 1 - check_exec 'USERJOBS=`which $USERJOBS`' "Checkig $USERJOBS utility" || exit 1 - check_exec 'JOBSTAT=`which $JOBSTAT`' "Checkig $JOBSTAT utility" || exit 1 -} - -log_ev() -{ -# $LOGEV -j $EDG_JOBID -s NetworkServer -n $1 -e UserTag --name color --value red - [ $DEBUG -gt 2 ] && echo "$LOGEV -j \"$EDG_JOBID\" -s UserInterface -c \"$EDG_WL_SEQUENCE\" $@" - EDG_WL_SEQUENCE=`$LOGEV $LARGE_STRESS -j $EDG_JOBID -s UserInterface -c $EDG_WL_SEQUENCE "$@"` - test $? -ne 0 -o -z "$EDG_WL_SEQUENCE" && echo "missing EDG_WL_SEQUENCE from $LOGEV" -} - -log_ev_proxy() -{ -# $LOGEV -x -j $EDG_JOBID -s NetworkServer -n $1 -e UserTag --name color --value red - - [ $DEBUG -gt 2 ] && echo "$LOGEV -x -j \"$EDG_JOBID\" -s UserInterface -c \"$EDG_WL_SEQUENCE\" $@" - EDG_WL_SEQUENCE=`$LOGEV -x $LARGE_STRESS -j $EDG_JOBID -s UserInterface -c $EDG_WL_SEQUENCE "$@"` - test $? -ne 0 -o -z "$EDG_WL_SEQUENCE" && echo "missing EDG_WL_SEQUENCE from $LOGEV" -} - -purge() -{ - [ $DEBUG -gt 2 ] && echo "$PURGE -a 0 -c 0 -n 0 -o 0 $@" - $PURGE -a 0 -c 0 -n 0 -o 0 "$@" -} - -purge_proxy() -{ - [ $DEBUG -gt 2 ] && echo "$PURGE -x -a 0 -c 0 -n 0 -o 0 $@" - $PURGE -x -a 0 -c 0 -n 0 -o 0 "$@" -} - - -db_clear_jobs() -{ - [ $DEBUG -gt 0 ] && echo -n -e "Purging test jobs from db\t\t" - job=0 - while [ $job -lt $JOBS_ARRAY_SIZE ] ; do - LARGE_STRESS="" - EDG_WL_SEQUENCE="UI=999999:NS=9999999999:WM=999999:BH=9999999999:JSS=999999:LM=999999:LRMS=999999:APP=999999" -# log_ev_proxy -e Clear --reason=PurgingDB -# purge_proxy -# log_ev -e Clear --reason=PurgingDB -# purge - - job=$(($job + 1)) - done - [ $DEBUG -gt 0 ] && echo "OK" -} - -# Test thet registers jobs -# and checks against lbproxy and bkserver -# -test_gen_sample_jobs() -{ - [ $DEBUG -gt 0 ] && echo -n -e "Registering sample jobs\t\t\t" - job=0 - while [ $job -lt $JOBS_ARRAY_SIZE ] ; do -# eval `$JOBREG -x -m $BKSERVER_HOST -s UserInterface 2>&1 | tail -n 2` - TMP=`$JOBREG -x -m $BKSERVER_HOST -s UserInterface 2>&1` - [ $? -ne 0 ] && echo -e "ERROR\n\t$JOBREG error!" - eval `echo "$TMP" | tail -n 2` - if test -z "$EDG_JOBID" ; then - echo "test_gen_sample_jobs: $JOBREG failed" - else - SAMPLE_JOBS_ARRAY[$job]=$EDG_JOBID - fi - -# state=`$JOBSTAT $EDG_JOBID 2>&1 | grep "state :" | cut -d " " -f 3 | tr A-Z a-z` -# proxy_state=`$JOBSTAT -x $TEST_LBPROXY_SERVE_SOCK $EDG_JOBID 2>&1 | grep "state :" | cut -d " " -f 3 | tr A-Z a-z` -# if test "$state" != "submitted" ; then -# echo -e "ERROR\n\tjob ${SAMPLE_JOBS_ARRAY[$job]} not submitted succesfully!" -# fi -# if test "$state" != "$proxy_state" ; then -# echo -e "ERROR\n\tjob (${SAMPLE_JOBS_ARRAY[$job]}) records on lbproxy and bkserver differs!" -# fi -# SAMPLE_JOBS_STATES[$job]=$state - echo -n "." - job=$(($job + 1)) - done - [ $DEBUG -gt 0 ] && echo "OK" -# [ $DEBUG -gt 1 ] && { -# job=0 -# while [ $job -lt $JOBS_ARRAY_SIZE ] ; do -# echo ${SAMPLE_JOBS_ARRAY[$job]} -# job=$(($job + 1)) -# done -# } -} - -# Test that logs random set of events (for registered jobs) to lbproxy -# and checks the state in lbproxy -# and measures the time it takes the state to propagate to bkserver -# -test_logging_events() -{ - [ $DEBUG -gt 0 ] && echo -n -e "Logging events to the lbproxy\t\t" - st_count=`echo $STATES | wc -w` - job=0 - while [ $job -lt $JOBS_ARRAY_SIZE ] ; do - echo -n "." - if test -z "${SAMPLE_JOBS_ARRAY[$job]}" ; then - job=$(($job + 1)) - continue - fi -# tmp=`echo $RANDOM % $st_count + 1 | bc` -# state=`echo $STATES | cut -d " " -f $tmp | tr A-Z a-z` - get_time - start=$time - -# source glite-lb-$state.sh $LARGE_STRESS -X $TEST_LBPROXY_STORE_SOCK -m $BKSERVER_HOST -j ${SAMPLE_JOBS_ARRAY[$job]} 2>&1 1>/dev/null -# [ $? -ne 0 ] && echo -e "ERROR\n\tglite-lb-$state.sh ${SAMPLE_JOBS_ARRAY[$job]} error!" - log_ev_proxy -n $EVENT_NUMBER -e UserTag --tag=color --value=red - -# proxy_state=`$JOBSTAT -x $TEST_LBPROXY_SERVE_SOCK ${SAMPLE_JOBS_ARRAY[$job]} 2>&1 | grep "state :" | cut -d " " -f 3 | tr A-Z a-z` -# purged=`echo $LBPROXY_PURGE_STATES | grep $state` -# bkserver_state=`$JOBSTAT ${SAMPLE_JOBS_ARRAY[$job]} 2>&1 | grep "state :" | cut -d " " -f 3 | tr A-Z a-z` -# -# if test -n "$purged" ; then -# echo $proxy_state | grep "No such file or directory" -# if test $? -eq 0 ; then -# echo -e "ERROR\n\tJob ${SAMPLE_JOBS_ARRAY[$job]} was not purged out from LBProxy!" -# exit 1; -# fi -# fi -# if test -z "$purged" ; then -# if test "$state" != "$proxy_state" ; then -# echo -e "ERROR\n\tevents for job ${SAMPLE_JOBS_ARRAY[$job]} were not logged succesfully!" -# exit 1; -# fi -# fi - -# response=0 -# while [ "$state" != "$bkserver_state" ] ; do -# bkserver_state=`$JOBSTAT ${SAMPLE_JOBS_ARRAY[$job]} 2>&1 | grep "state :" | cut -d " " -f 3 | tr A-Z a-z` -# [ $DEBUG -gt 0 ] && echo -n "." -# sleep $timeout -# response=$(($response + $timeout )) -# if test $response -gt $maxtimeout ; then -# echo -e "ERROR\n\tstatus of job ${SAMPLE_JOBS_ARRAY[$job]} as queried from bkserver ($bkserver_state) has not become $state for more than $response seconds!" -# exit 1; -# fi -# done -# -# SAMPLE_JOBS_STATES[$job]=$state - get_time - response=`echo "scale=9; ($time - $start)/1000000000"|bc` - SAMPLE_JOBS_RESPONSES[$job]=$response - job=$(($job + 1)) - done - [ $DEBUG -gt 0 ] && echo "OK" - [ $DEBUG -gt 1 ] && { - job=0 - total=0 -# echo "Sending events took for individual jobs the following time" - while [ $job -lt $JOBS_ARRAY_SIZE ] ; do - total=`echo "scale=9; $total + ${SAMPLE_JOBS_RESPONSES[$job]}" |bc` -# echo -e "${SAMPLE_JOBS_ARRAY[$job]} \t${SAMPLE_JOBS_RESPONSES[$job]} seconds" - job=$(($job + 1)) - done - echo -e "Total time for $JOBS_ARRAY_SIZE jobs: \t$total" - echo -e -n "Average time for event: \t" - echo "scale=9; $total / $JOBS_ARRAY_SIZE / $EVENT_NUMBER"|bc - echo -e -n "Event throughput (events/sec): \t" - echo "scale=9; $EVENT_NUMBER * $JOBS_ARRAY_SIZE / $total"|bc - - } -} - - -# -# shell starting code - -# without parameters show help message -# test -z "$1" && show_help - -while test -n "$1" -do - case "$1" in - "-h" | "--help") show_help && exit 0 ;; - "-x" | "--proxy-sockpath-pref") - shift - export TEST_LBPROXY_STORE_SOCK=$1store.sock - export TEST_LBPROXY_SERVE_SOCK=$1serve.sock - ;; - "-m" | "--bkserver") shift ; BKSERVER_HOST=$1 ;; - "-j" | "--jobs-count") shift; JOBS_ARRAY_SIZE=$1 ;; - "-n" | "--event-count") shift; EVENT_NUMBER=$1 ;; - "-s" | "--states") shift; STATES="$1" ;; - "-p" | "--proxy-purge-states") shift; LBPROXY_PURGE_STATES="$1" ;; - "-l" | "--large-stress") shift ; LARGE_STRESS="-l $1" ;; - "-g" | "--log") shift ; logfile=$1 ;; - - *) echo "Unrecognized option $1" ;; - - esac - shift -done - -if test -n "$logfile" ; then - LOGFD=3 - exec 3>$logfile -fi - - -echo "STATES = $STATES" -echo "LBPROXY_PURGE_STATES = $LBPROXY_PURGE_STATES" - -check_utils - -test_gen_sample_jobs -test_logging_events - -db_clear_jobs diff --git a/org.glite.lb.proxy/examples/test3.sh b/org.glite.lb.proxy/examples/test3.sh deleted file mode 100755 index d8856d9..0000000 --- a/org.glite.lb.proxy/examples/test3.sh +++ /dev/null @@ -1,326 +0,0 @@ -#!/bin/sh - -# XXX: add path to the stage area -PATH=/home/michal/shared/egee/jra1/stage/bin:/home/michal/shared/egee/jra1/stage/examples:$PATH - -#set -x - -# Binaries -LOGEV=${LOGEV:-glite-lb-logevent} -JOBLOG=${JOBLOG:-glite-lb-job_log} -JOBREG=${JOBREG:-glite-lb-job_reg} -USERJOBS=${USERJOBS:-glite-lb-user_jobs} -JOBSTAT=${JOBSTAT:-glite-lb-job_status} -PURGE=${PURGE:-glite-lb-purge} - -# -m host -BKSERVER_HOST=${BKSERVER_HOST:-`hostname -f`:9000} -TEST_LBPROXY_STORE_SOCK=${EDG_WL_LBPROXY_STORE_SOCK:-/tmp/lb_proxy_store.sock} -TEST_LBPROXY_SERVE_SOCK=${EDG_WL_LBPROXY_SERVE_SOCK:-/tmp/lb_proxy_serve.sock} - -STATES="aborted cancelled done ready running scheduled waiting" -LBPROXY_PURGE_STATES="cleared done aborted cancelled" -JOBS_ARRAY_SIZE=10 -SAMPLE_JOBS_ARRAY[0]= -SAMPLE_JOBS_STATES[0]= -SAMPLE_JOBS_RESPONSES[0]= - -# some defaults -DEBUG=2 -LOGFD=${LOGFD:-1} -LARGE_STRESS=${LARGE_STRESS:-} - -# timeouts for polling the bkserver -timeout=10 -maxtimeout=300 - -# -# Procedures -# - -# print help message -show_help() -{ - echo "Usage: $0 [OPTIONS] " - echo "Options:" - echo " -h | --help Show this help message." - echo " -x | --proxy-sockpath-pref LBProxy socket path prefix." - echo " -j | --jobs-count Count of test(ed) jobs." - echo " -n | --subjobs Number of subjobs." - echo " -s | --states List of states in which could tested jobs fall." - echo " -p | --proxy-purge-states List of states in which LBProxy purges the job." - echo " -l | --large-stress 'size' Do a large stress logging ('size' random data added to the messages." - echo " -g | --log 'logfile' Redirect all output to the 'logfile'." - echo "" - echo "For proper operation check your grid-proxy-info" - grid-proxy-info -} - -get_time() -{ - sec=`date +%s` - nsec=`date +%N` - time=`echo "1000000000*$sec + $nsec"|bc` -# time=$sec - return 0 -} - -check_exec() -{ - [ $DEBUG -gt 0 ] && [ -n "$2" ] && echo -n -e "$2\t" || echo -n -e "$1\t" - eval $1 - RV=$? - [ $DEBUG -gt 0 ] && [ $RV -eq 0 ] && echo "OK" || echo "FAILED" - return $RV -} - -# check for existance of needed executable(s) -check_utils() -{ - check_exec 'JOBREG=`which $JOBREG`' "Checkig $JOBREG utility" || exit 1 - check_exec 'JOBLOG=`which $JOBLOG`' "Checkig $JOBLOG utility" || exit 1 - check_exec 'LOGEV=`which $LOGEV`' "Checkig $LOGEV utility" || exit 1 - check_exec 'USERJOBS=`which $USERJOBS`' "Checkig $USERJOBS utility" || exit 1 - check_exec 'JOBSTAT=`which $JOBSTAT`' "Checkig $JOBSTAT utility" || exit 1 -} - -log_ev() -{ -# $LOGEV -j $EDG_JOBID -s NetworkServer -n $1 -e UserTag --name color --value red - [ $DEBUG -gt 2 ] && echo "$LOGEV -j \"$EDG_JOBID\" -s UserInterface -c \"$EDG_WL_SEQUENCE\" $@" - EDG_WL_SEQUENCE=`$LOGEV $LARGE_STRESS -j $EDG_JOBID -s UserInterface -c $EDG_WL_SEQUENCE "$@"` - test $? -ne 0 -o -z "$EDG_WL_SEQUENCE" && echo "missing EDG_WL_SEQUENCE from $LOGEV" -} - -log_ev_proxy() -{ -# $LOGEV -x -j $EDG_JOBID -s NetworkServer -n $1 -e UserTag --name color --value red - - [ $DEBUG -gt 2 ] && echo "$LOGEV -x -j \"$EDG_JOBID\" -s UserInterface -c \"$EDG_WL_SEQUENCE\" $@" - EDG_WL_SEQUENCE=`$LOGEV -x $LARGE_STRESS -j $EDG_JOBID -s UserInterface -c $EDG_WL_SEQUENCE "$@"` - test $? -ne 0 -o -z "$EDG_WL_SEQUENCE" && echo "missing EDG_WL_SEQUENCE from $LOGEV" -} - -purge() -{ - [ $DEBUG -gt 2 ] && echo "$PURGE -a 0 -c 0 -n 0 -o 0 $@" - $PURGE -a 0 -c 0 -n 0 -o 0 "$@" -} - -purge_proxy() -{ - [ $DEBUG -gt 2 ] && echo "$PURGE -x -a 0 -c 0 -n 0 -o 0 $@" - $PURGE -x -a 0 -c 0 -n 0 -o 0 "$@" -} - - -db_clear_jobs() -{ - [ $DEBUG -gt 0 ] && echo -n -e "Purging test jobs from db\t\t" - job=0 - while [ $job -lt $JOBS_ARRAY_SIZE ] ; do - LARGE_STRESS="" - EDG_WL_SEQUENCE="UI=999999:NS=9999999999:WM=999999:BH=9999999999:JSS=999999:LM=999999:LRMS=999999:APP=999999" -# log_ev_proxy -e Clear --reason=PurgingDB -# purge_proxy -# log_ev -e Clear --reason=PurgingDB -# purge - - job=$(($job + 1)) - done - [ $DEBUG -gt 0 ] && echo "OK" -} - -# Test thet registers jobs -# and checks against lbproxy and bkserver -# -test_gen_sample_jobs() -{ - [ $DEBUG -gt 0 ] && echo -n -e "Registering sample jobs\t\t\t" - job=0 - while [ $job -lt $JOBS_ARRAY_SIZE ] ; do -# eval `$JOBREG -x -m $BKSERVER_HOST -s UserInterface 2>&1 | tail -n 2` - get_time - start=$time - [ $? -ne 0 ] && echo -e "ERROR\n\t$JOBREG error!" - if [[ -z $SUBJOBS ]] ; then - TMP=`$JOBREG -x -m $BKSERVER_HOST -s UserInterface 2>&1` - get_time - eval `echo "$TMP" | tail -n 2` - else - TMP=`$JOBREG -x -m $BKSERVER_HOST -s UserInterface -n $SUBJOBS 2>&1` - get_time - eval `echo "$TMP" | grep DAG_JOBID` - EDG_JOBID=$EDG_WL_DAG_JOBID - fi - if test -z "$EDG_JOBID" ; then - echo "test_gen_sample_jobs: $JOBREG failed" - else - SAMPLE_JOBS_ARRAY[$job]=$EDG_JOBID - response=`echo "scale=9; ($time - $start)/1000000000"|bc` - SAMPLE_JOBS_RESPONSES[$job]=$response - fi - -# state=`$JOBSTAT $EDG_JOBID 2>&1 | grep "state :" | cut -d " " -f 3 | tr A-Z a-z` -# proxy_state=`$JOBSTAT -x $TEST_LBPROXY_SERVE_SOCK $EDG_JOBID 2>&1 | grep "state :" | cut -d " " -f 3 | tr A-Z a-z` -# if test "$state" != "submitted" ; then -# echo -e "ERROR\n\tjob ${SAMPLE_JOBS_ARRAY[$job]} not submitted succesfully!" -# fi -# if test "$state" != "$proxy_state" ; then -# echo -e "ERROR\n\tjob (${SAMPLE_JOBS_ARRAY[$job]}) records on lbproxy and bkserver differs!" -# fi -# SAMPLE_JOBS_STATES[$job]=$state - echo -n "." - job=$(($job + 1)) - done - [ $DEBUG -gt 0 ] && echo "OK" - [ $DEBUG -gt 1 ] && { - job=0 - total=0 -# echo "Registration took for individual jobs the following time" - while [ $job -lt $JOBS_ARRAY_SIZE ] ; do - total=`echo "scale=9; $total + ${SAMPLE_JOBS_RESPONSES[$job]}" |bc` -# echo -e "${SAMPLE_JOBS_ARRAY[$job]} \t${SAMPLE_JOBS_RESPONSES[$job]} seconds" - job=$(($job + 1)) - done - echo "Registration results:" - echo -e "Total time for $JOBS_ARRAY_SIZE jobs with $SUBJOBS subjobs: \t$total" - echo -e -n "Average time for registration: \t" - echo "scale=9; $total / $JOBS_ARRAY_SIZE / $SUBJOBS"|bc - echo -e -n "Registration throughput (jobs/sec): \t" - echo "scale=9; $SUBJOBS * $JOBS_ARRAY_SIZE / $total"|bc - - } -# [ $DEBUG -gt 1 ] && { -# job=0 -# while [ $job -lt $JOBS_ARRAY_SIZE ] ; do -# echo ${SAMPLE_JOBS_ARRAY[$job]} -# job=$(($job + 1)) -# done -# } -} - -# Test that logs random set of events (for registered jobs) to lbproxy -# and checks the state in lbproxy -# and measures the time it takes the state to propagate to bkserver -# -test_logging_events() -{ - [ $DEBUG -gt 0 ] && echo -n -e "Logging events to the lbproxy\t\t" - st_count=`echo $STATES | wc -w` - job=0 - while [ $job -lt $JOBS_ARRAY_SIZE ] ; do - echo -n "." - if test -z "${SAMPLE_JOBS_ARRAY[$job]}" ; then - job=$(($job + 1)) - continue - fi -# tmp=`echo $RANDOM % $st_count + 1 | bc` -# state=`echo $STATES | cut -d " " -f $tmp | tr A-Z a-z` - get_time - start=$time - -# source glite-lb-$state.sh $LARGE_STRESS -X $TEST_LBPROXY_STORE_SOCK -m $BKSERVER_HOST -j ${SAMPLE_JOBS_ARRAY[$job]} 2>&1 1>/dev/null -# [ $? -ne 0 ] && echo -e "ERROR\n\tglite-lb-$state.sh ${SAMPLE_JOBS_ARRAY[$job]} error!" - log_ev_proxy -n 100 -e UserTag --tag=color --value=red - -# proxy_state=`$JOBSTAT -x $TEST_LBPROXY_SERVE_SOCK ${SAMPLE_JOBS_ARRAY[$job]} 2>&1 | grep "state :" | cut -d " " -f 3 | tr A-Z a-z` -# purged=`echo $LBPROXY_PURGE_STATES | grep $state` -# bkserver_state=`$JOBSTAT ${SAMPLE_JOBS_ARRAY[$job]} 2>&1 | grep "state :" | cut -d " " -f 3 | tr A-Z a-z` -# -# if test -n "$purged" ; then -# echo $proxy_state | grep "No such file or directory" -# if test $? -eq 0 ; then -# echo -e "ERROR\n\tJob ${SAMPLE_JOBS_ARRAY[$job]} was not purged out from LBProxy!" -# exit 1; -# fi -# fi -# if test -z "$purged" ; then -# if test "$state" != "$proxy_state" ; then -# echo -e "ERROR\n\tevents for job ${SAMPLE_JOBS_ARRAY[$job]} were not logged succesfully!" -# exit 1; -# fi -# fi - -# response=0 -# while [ "$state" != "$bkserver_state" ] ; do -# bkserver_state=`$JOBSTAT ${SAMPLE_JOBS_ARRAY[$job]} 2>&1 | grep "state :" | cut -d " " -f 3 | tr A-Z a-z` -# [ $DEBUG -gt 0 ] && echo -n "." -# sleep $timeout -# response=$(($response + $timeout )) -# if test $response -gt $maxtimeout ; then -# echo -e "ERROR\n\tstatus of job ${SAMPLE_JOBS_ARRAY[$job]} as queried from bkserver ($bkserver_state) has not become $state for more than $response seconds!" -# exit 1; -# fi -# done -# -# SAMPLE_JOBS_STATES[$job]=$state - get_time - response=`echo "scale=9; ($time - $start)/1000000000"|bc` - SAMPLE_JOBS_RESPONSES[$job]=$response - job=$(($job + 1)) - done - [ $DEBUG -gt 0 ] && echo "OK" - [ $DEBUG -gt 1 ] && { - job=0 - total=0 -# echo "Sending events took for individual jobs the following time" - while [ $job -lt $JOBS_ARRAY_SIZE ] ; do - total=`echo "scale=9; $total + ${SAMPLE_JOBS_RESPONSES[$job]}" |bc` -# echo -e "${SAMPLE_JOBS_ARRAY[$job]} \t${SAMPLE_JOBS_RESPONSES[$job]} seconds" - job=$(($job + 1)) - done - echo -e "Total time for $JOBS_ARRAY_SIZE jobs: \t$total" - echo -e -n "Average time for job: \t" - echo "scale=9; $total / $JOBS_ARRAY_SIZE"|bc - echo -e -n "Job throughput (jobs/sec): \t" - echo "scale=9; $JOBS_ARRAY_SIZE / $total"|bc - - } -} - - -# -# shell starting code - -# without parameters show help message -# test -z "$1" && show_help - -while test -n "$1" -do - case "$1" in - "-h" | "--help") show_help && exit 0 ;; - "-x" | "--proxy-sockpath-pref") - shift - export TEST_LBPROXY_STORE_SOCK=$1store.sock - export TEST_LBPROXY_SERVE_SOCK=$1serve.sock - ;; - "-m" | "--bkserver") shift ; BKSERVER_HOST=$1 ;; - "-j" | "--jobs-count") shift; JOBS_ARRAY_SIZE=$1 ;; - "-n" | "--subjobs") shift; SUBJOBS="$1" ;; - "-s" | "--states") shift; STATES="$1" ;; - "-p" | "--proxy-purge-states") shift; LBPROXY_PURGE_STATES="$1" ;; - "-l" | "--large-stress") shift ; LARGE_STRESS="-l $1" ;; - "-g" | "--log") shift ; logfile=$1 ;; - - *) echo "Unrecognized option $1" ;; - - esac - shift -done - -if test -n "$logfile" ; then - LOGFD=3 - exec 3>$logfile -fi - - -echo "STATES = $STATES" -echo "LBPROXY_PURGE_STATES = $LBPROXY_PURGE_STATES" - -check_utils - -test_gen_sample_jobs -#test_logging_events - -db_clear_jobs diff --git a/org.glite.lb.proxy/project/build.number b/org.glite.lb.proxy/project/build.number index 5c2e618..14f964b 100644 --- a/org.glite.lb.proxy/project/build.number +++ b/org.glite.lb.proxy/project/build.number @@ -1,2 +1,2 @@ -#Mon Apr 03 07:51:54 CEST 2006 -module.build=0099 +#Sun Apr 02 07:32:00 CEST 2006 +module.build=0098 diff --git a/org.glite.lb.proxy/project/configure.properties.xml b/org.glite.lb.proxy/project/configure.properties.xml index dec83a3..42628fe 100644 --- a/org.glite.lb.proxy/project/configure.properties.xml +++ b/org.glite.lb.proxy/project/configure.properties.xml @@ -42,14 +42,14 @@ PREFIX=${install.dir} version=${module.version} glite_location=${with.glite.location} globus_prefix=${with.globus.prefix} +thrflavour=${with.globus.thr.flavor} +nothrflavour=${with.globus.nothr.flavor} expat_prefix=${with.expat.prefix} mysql_prefix=${with.mysql.prefix} mysql_version=${ext.mysql.version} +cppunit=${with.cppunit.prefix} gridsite_prefix=${with.gridsite.prefix} gsoap_prefix=${with.gsoap.prefix} -cppunit_prefix=${with.cppunit.prefix} -thrflavour=${with.globus.thr.flavor} -nothrflavour=${with.globus.nothr.flavor} diff --git a/org.glite.lb.proxy/project/version.properties b/org.glite.lb.proxy/project/version.properties index 11584ea..0904578 100644 --- a/org.glite.lb.proxy/project/version.properties +++ b/org.glite.lb.proxy/project/version.properties @@ -1,3 +1,3 @@ #Fri Sep 02 14:18:53 CEST 2005 -module.version=1.3.0 +module.version=1.3.2 module.age=0 diff --git a/org.glite.lb.proxy/src/lbproxy.c b/org.glite.lb.proxy/src/lbproxy.c index 892b305..0ea0e33 100644 --- a/org.glite.lb.proxy/src/lbproxy.c +++ b/org.glite.lb.proxy/src/lbproxy.c @@ -27,12 +27,6 @@ #include "glite/lb/srvbones.h" #include "glite/lb/context.h" #include "glite/lb/context-int.h" -#ifdef LB_PERF -#include "glite/lb/lb_perftest.h" -#include "glite/lb/srv_perf.h" - -enum lb_srv_perf_sink sink_mode; -#endif extern int edg_wll_DBCheckVersion(edg_wll_Context); extern edg_wll_ErrorCode edg_wll_Open(edg_wll_Context ctx, char *cs); @@ -86,24 +80,16 @@ static struct option opts[] = { {"port", 1, NULL, 'p'}, {"con-queue", 1, NULL, 'c'}, {"debug", 0, NULL, 'd'}, - {"silent", 0, NULL, 'z'}, {"mysql", 1, NULL, 'm'}, {"slaves", 1, NULL, 's'}, {"semaphores", 1, NULL, 'l'}, {"pidfile", 1, NULL, 'i'}, {"proxy-il-sock", 1, NULL, 'X'}, {"proxy-il-fprefix", 1, NULL, 'Y'}, -#ifdef LB_PERF - {"perf-sink", 1, NULL, 'K'}, -#endif {NULL,0,NULL,0} }; -static const char *get_opt_string = "p:c:dm:s:l:i:X:Y:z" -#ifdef LB_PERF - "K:" -#endif -; +static const char *get_opt_string = "p:c:dm:s:l:i:X:Y:"; static void usage(char *me) { @@ -117,10 +103,6 @@ static void usage(char *me) "\t-i, --pidfile\t file to store master pid\n" "\t--proxy-il-sock\t socket to send events to\n" "\t--proxy-il-fprefix\t file prefix for events\n" - "\t--silent\t don't print diagnostic, even if -d is on\n" -#ifdef LB_PERF - "\t--perf-sink\t where to sink events\n" -#endif ,me); } @@ -169,7 +151,6 @@ int main(int argc, char *argv[]) key_t semkey; edg_wll_Context ctx; struct timeval to; - int silent = 0; @@ -182,16 +163,12 @@ int main(int argc, char *argv[]) case 'p': strcpy(socket_path_prefix, optarg); break; case 'c': con_queue = atoi(optarg); break; case 'd': debug = 1; break; - case 'z': silent = 1; break; case 'm': dbstring = optarg; break; case 's': slaves = atoi(optarg); break; case 'l': semaphores = atoi(optarg); break; case 'X': lbproxy_ilog_socket_path = strdup(optarg); break; case 'Y': lbproxy_ilog_file_prefix = strdup(optarg); break; case 'i': strcpy(pidfile, optarg); break; -#ifdef LB_PERF - case 'K': sink_mode = atoi(optarg); break; -#endif case '?': usage(name); return 1; } @@ -216,8 +193,8 @@ int main(int argc, char *argv[]) fpid = fopen(pidfile, "w"); if ( !fpid ) { perror(pidfile); return 1; } - fprintf(fpid, "%d", getpid()); - fclose(fpid); + if (fprintf(fpid, "%d", getpid()) <= 0) { perror(pidfile); return 1; } + if (fclose(fpid) != 0) { perror(pidfile); return 1; } semkey = ftok(pidfile,0); @@ -323,7 +300,6 @@ int main(int argc, char *argv[]) openlog(name, LOG_PID, LOG_DAEMON); } else { setpgid(0, getpid()); } - if (silent) debug = 0; glite_srvbones_set_param(GLITE_SBPARAM_SLAVES_COUNT, slaves); glite_srvbones_set_param(GLITE_SBPARAM_SLAVE_OVERLOAD, SLAVE_OVERLOAD); @@ -364,10 +340,6 @@ int clnt_data_init(void **data) cdata->mysql = ctx->mysql; edg_wll_FreeContext(ctx); -#ifdef LB_PERF - glite_wll_perftest_init(NULL, NULL, NULL, NULL, 0); -#endif - *data = cdata; return 0; } @@ -379,8 +351,8 @@ int handle_conn(int conn, struct timeval *timeout, void *data) edg_wll_Context ctx; struct timeval conn_start, now; - if ( !(ctx = (edg_wll_Context) calloc(1, sizeof(*ctx))) ) { - dprintf(("Couldn't create context")); + if ( edg_wll_InitContext(&ctx) ) { + fprintf(stderr, "Couldn't create context"); return -1; } cdata->ctx = ctx; diff --git a/org.glite.lb.proxy/src/perftest_proxy.sh b/org.glite.lb.proxy/src/perftest_proxy.sh deleted file mode 100755 index 9421fb5..0000000 --- a/org.glite.lb.proxy/src/perftest_proxy.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -numjobs=$1 - -# XXX - there must be better way to find stage -STAGEDIR=/home/michal/shared/egee/jra1-head/stage -. $STAGEDIR/sbin/perftest_common.sh - -DEBUG=${DEBUG:-0} -PERFTEST_CONSUMER=./glite_lb_proxy_perf -# CONSUMER_ARGS= -# PERFTEST_COMPONENT= -# COMPONENT_ARGS= -#LOGJOBS_ARGS="" - -check_test_files || exit 1 - -echo -e "\tsmall_job \t big_job \t small_dag \t big_dag" -i=1 -while [[ $i -lt 5 ]] -do - CONSUMER_ARGS="-d --perf-sink $i" - echo Running test $i - run_test proxy $numjobs - j=0 - while [[ $j -lt 4 ]] - do - echo -e -n "\t ${PERFTEST_THROUGHPUT[$j]}" - j=$((j+1)) - done - echo "" - # purge jobs from database - $LOGJOBS -n $numjobs > /tmp/perftest.jobids - i=$((i+1)) -done - diff --git a/org.glite.lb.server-bones/Makefile b/org.glite.lb.server-bones/Makefile index 321765d..7b01dee 100644 --- a/org.glite.lb.server-bones/Makefile +++ b/org.glite.lb.server-bones/Makefile @@ -15,14 +15,11 @@ globus_prefix=/opt/globus nothrflavour=gcc32 thrflavour=gcc32pthr expat_prefix=/opt/expat -cares_prefix=/opt/c-ares +ares_prefix=/opt/ares CC=gcc -include Makefile.inc --include ../project/version.properties - -version=${module.version} VPATH=${top_srcdir}/src:${top_srcdir}/examples diff --git a/org.glite.lb.server-bones/project/build.number b/org.glite.lb.server-bones/project/build.number index 0efdeda..50ac1a0 100644 --- a/org.glite.lb.server-bones/project/build.number +++ b/org.glite.lb.server-bones/project/build.number @@ -1,2 +1,2 @@ -#Mon Apr 03 07:39:17 CEST 2006 -module.build=0200 +#Sun Apr 02 07:19:25 CEST 2006 +module.build=0199 diff --git a/org.glite.lb.server-bones/project/version.properties b/org.glite.lb.server-bones/project/version.properties index ea0d402..0d621b6 100644 --- a/org.glite.lb.server-bones/project/version.properties +++ b/org.glite.lb.server-bones/project/version.properties @@ -1,3 +1,3 @@ #Fri Sep 02 14:17:59 CEST 2005 -module.version=2.2.0 +module.version=2.2.1 module.age=0 diff --git a/org.glite.lb.server-bones/src/srvbones.c b/org.glite.lb.server-bones/src/srvbones.c index b4b8b3f..7412e56 100644 --- a/org.glite.lb.server-bones/src/srvbones.c +++ b/org.glite.lb.server-bones/src/srvbones.c @@ -326,7 +326,7 @@ static int slave(slave_data_init_hnd data_init_hnd, int sock) */ exit(1); - while ( !die && req_cnt < set_slave_reqs_max) + while ( !die && (req_cnt < set_slave_reqs_max || (conn >= 0 && first_request))) { fd_set fds; int max = sock, @@ -451,7 +451,7 @@ static int slave(slave_data_init_hnd data_init_hnd, int sock) kick_client = KICK_LOAD; } - if (req_cnt >= set_slave_reqs_max) kick_client = KICK_COUNT; + if (req_cnt >= set_slave_reqs_max && !first_request) kick_client = KICK_COUNT; if ( kick_client && conn >= 0 ) { @@ -468,8 +468,6 @@ static int slave(slave_data_init_hnd data_init_hnd, int sock) conn = newconn; srv = newsrv; gettimeofday(&client_start, NULL); - client_done.tv_sec = client_start.tv_sec; - client_done.tv_usec = client_start.tv_usec; switch ( send(sock, &seq, sizeof(seq), 0) ) { @@ -509,6 +507,7 @@ static int slave(slave_data_init_hnd data_init_hnd, int sock) conn = srv = -1; continue; } + gettimeofday(&client_done, NULL); first_request = 1; } } diff --git a/org.glite.lb.server/Makefile b/org.glite.lb.server/Makefile index cb46f41..f8b1613 100644 --- a/org.glite.lb.server/Makefile +++ b/org.glite.lb.server/Makefile @@ -18,29 +18,13 @@ expat_prefix=/opt/expat cares_prefix=/opt/c-ares gsoap_prefix=/opt/gsoap classads_prefix=/opt/classads -voms_prefix=/opt/voms -include Makefile.inc --include ../project/version.properties - -version=${module.version} default all: compile GLITE_LB_SERVER_WITH_WS=yes -ifdef LB_STANDALONE - LB_STANDALONE_FLAGS:=-DLB_STANDALONE -# GLITE_LB_SERVER_WITH_WS=no -endif - -ifdef LB_PERF - STATIC_LIB_BK:=libglite_lb_bkserver_perf.a - LB_PERF_FLAGS:=-DLB_PERF -else - STATIC_LIB_BK:=libglite_lb_bkserver.a -endif - ifeq ($(GLITE_LB_SERVER_WITH_WS),yes) WS_CFLAGS=-DGLITE_LB_SERVER_WITH_WS NSMAP=LoggingAndBookkeeping.nsmap @@ -60,6 +44,9 @@ else endif AT3=perl -I${top_srcdir}/project ${top_srcdir}/project/at3 +TEST_LIBS:=-L${cppunit}/lib -lcppunit +TEST_INC:=-I${cppunit}/include + SUFFIXES = .T DEBUG:=-g -O0 -Wall @@ -76,15 +63,14 @@ CFLAGS:= \ -I${cares_prefix}/include \ -I${gsoap_prefix}/include -I${gsoap_prefix}/ \ -I${classads_prefix}/include \ - -I${voms_prefix}/include \ ${COVERAGE_FLAGS} \ -I${mysql_prefix}/include -I${mysql_prefix}/include/mysql \ -I${globus_prefix}/include/${nothrflavour} \ $(GRIDSITE_CFLAGS) \ - -D_GNU_SOURCE ${LB_STANDALONE_FLAGS} ${LB_PERF_FLAGS} + -D_GNU_SOURCE -TEST_LIBS:=-L${cppunit_prefix}/lib -lcppunit -TEST_INC:=-I${cppunit_prefix}/include +TEST_LIBS:=-L${cppunit}/lib -lcppunit +TEST_INC:=-I${cppunit}/include COMPILE:=libtool --mode=compile ${CC} ${CFLAGS} LINK:=libtool --mode=link ${CC} -rpath ${stagedir}/lib ${LDFLAGS} @@ -92,7 +78,7 @@ SOLINK:=libtool --mode=link ${CC} -module ${LDFLAGS} -rpath ${stagedir}/lib LINKXX:=libtool --mode=link ${CXX} ${LDFLAGS} INSTALL:=libtool --mode=install install LINKXX:=libtool --mode=link ${CXX} -rpath ${stagedir}/lib ${LDFLAGS} -XSLTPROC:=xsltproc +XSLTPROC:=xsltproc --novalid GLOBUS_LIBS:= -L${globus_prefix}/lib \ -lglobus_common_${nothrflavour} \ @@ -125,7 +111,6 @@ endif ifeq (${nothrflavour},gcc32dbg) vomsflavour := endif -VOMS_LIBS:=-L${voms_prefix}/lib -lvomsc${vomsflavour} #EXT_LIBS:= \ # ${mysqlib} -lmysqlclient -lz\ @@ -142,12 +127,12 @@ EXT_LIBS:= \ ${mysqlib} -lmysqlclient -lz\ ${GRIDSITE_LIBS} \ ${classadslib} \ - ${VOMS_LIBS} + -lvomsc${vomsflavour} SRVBONES_LIB:= -L${stagedir}/lib -lglite_lb_server_bones COMMON_LIBS:= -L${stagedir}/lib -lglite_lb_common_${nothrflavour} -lglite_security_gss_${nothrflavour} PLUGIN_LIBS:= -L${stagedir}/lib -lglite_lb_common_${nothrflavour}\ - ${classadslib} ${expatlib} -lexpat\ + ${classadslib} -lstdc++ ${expatlib} -lexpat\ PLUGIN_LOBJS:= lb_plugin.lo jobstat_supp.lo process_event.lo lbs_db_supp.lo @@ -210,6 +195,7 @@ LIB_OBJS_BK:= \ lock.o openserver.o query.o userjobs.o db_store.o request.o store.o \ stored_master.o srv_purge.o server_state.o dump.o lb_authz.o load.o \ notification.o il_notification.o notif_match.o stats.o +STATIC_LIB_BK:=libglite_lb_bkserver.a glite_lb_bkserverd: ${NSMAP} ${BKSERVER_OBJS} ${LINKXX} -o $@ ${BKSERVER_OBJS} ${BKSERVER_LIBS} @@ -222,14 +208,7 @@ glite_lb_plugin.la: ${PLUGIN_LOBJS} default all: compile -ifdef LB_STANDALONE - PLUGIN_LIB= -else - PLUGIN_LIB=glite_lb_plugin.la -endif - -compile: glite_lb_bkserverd glite_lb_bkindex ${STATIC_LIB_BK} ${PLUGIN_LIB} - +compile: glite_lb_bkserverd glite_lb_bkindex ${STATIC_LIB_BK} glite_lb_plugin.la check: compile test.xml test.query -echo check.query not complete yet @@ -261,7 +240,7 @@ LB.xh: ws_typemap.dat ${stagedir}/interface/LB.wsdl rm -f LBTypes.wsdl test.xml: test_xml -# ./test_xml + ./test_xml test_xml: test_xml.cpp ${CXX} -c ${CFLAGS} ${TEST_INC} $< @@ -352,10 +331,7 @@ install: mkdir -p ${PREFIX}/include/${globalprefix}/${lbprefix} ; \ (cd ${top_srcdir}/interface && install -m 644 ${HDRS} ${PREFIX}/include/${globalprefix}/${lbprefix}) ; \ install -m 644 ${STATIC_LIB_BK} ${PREFIX}/lib; \ - if [ x${LB_STANDALONE} = x ]; then \ - ${INSTALL} -m 755 ${PLUGIN_LIB} ${PREFIX}/lib; \ - fi; \ - ${INSTALL} -m 644 ${top_srcdir}/interface/srv_perf.h ${PREFIX}/include/${globalprefix}/${lbprefix}; \ + ${INSTALL} -m 755 glite_lb_plugin.la ${PREFIX}/lib; \ fi clean: diff --git a/org.glite.lb.server/config/startup b/org.glite.lb.server/config/startup index fc3b0a5..d712223 100755 --- a/org.glite.lb.server/config/startup +++ b/org.glite.lb.server/config/startup @@ -36,30 +36,26 @@ start() [ -z "$GLITE_LB_EXPORT_DUMPDIR" ] && GLITE_LB_EXPORT_DUMPDIR=/tmp/dump purgedir="--dump-prefix $GLITE_LB_EXPORT_DUMPDIR" - [ -d "$GLITE_LB_EXPORT_DUMPDIR" ] || mkdir -p "$GLITE_LB_EXPORT_DUMPDIR" && chown $GLITE_USER:$GLITE_GROUP -R "$GLITE_LB_EXPORT_DUMPDIR" + [ -d "$GLITE_LB_EXPORT_DUMPDIR" ] || mkdir "$GLITE_LB_EXPORT_DUMPDIR" && chown $GLITE_USER:$GLITE_GROUP "$GLITE_LB_EXPORT_DUMPDIR" [ -z "$GLITE_LB_EXPORT_JPREG_MAILDIR" ] && GLITE_LB_EXPORT_JPREG_MAILDIR=/tmp/jpreg maildir="--jpreg-dir $GLITE_LB_EXPORT_JPREG_MAILDIR" - [ -d "$GLITE_LB_EXPORT_JPREG_MAILDIR" ] || mkdir -p "$GLITE_LB_EXPORT_JPREG_MAILDIR" && chown $GLITE_USER:$GLITE_GROUP -R "$GLITE_LB_EXPORT_JPREG_MAILDIR" + [ -d "$GLITE_LB_EXPORT_JPREG_MAILDIR" ] || mkdir "$GLITE_LB_EXPORT_JPREG_MAILDIR" && chown $GLITE_USER:$GLITE_GROUP "$GLITE_LB_EXPORT_JPREG_MAILDIR" [ -z "$creds" ] && echo $0: WARNING: No credentials specified. Using default lookup which is dangerous. >&2 [ -n "$GLITE_LB_SERVER_PORT" ] && port="-p $GLITE_LB_SERVER_PORT" - [ -n "$GLITE_LB_SERVER_WPORT" ] && wport="-w $GLITE_LB_SERVER_WPORT" - - [ -z "$GLITE_LB_NOTIF_SOCK" ] && GLITE_LB_NOTIF_SOCK="/tmp/glite-lb-notif.sock" - [ -z "$GLITE_LB_NOTIF_FPREFIX" ] && GLITE_LB_NOTIF_FPREFIX="/var/tmp/glite-lb-notif" echo -n Starting glite-lb-bkserver ... su - $GLITE_USER -c "$GLITE_LOCATION/bin/glite-lb-bkserverd \ - --notif-il-sock=$GLITE_LB_NOTIF_SOCK \ - --notif-il-fprefix=$GLITE_LB_NOTIF_FPREFIX \ - $creds -i $pidfile $port $wport $purgedir $maildir" \ + --notif-il-sock=/tmp/glite-lb-notif.sock \ + --notif-il-fprefix=/var/tmp/glite-lb-notif \ + $creds -i $pidfile $port $purgedir $maildir" \ && echo " done" || echo " FAILED" echo -n Starting glite-lb-notif-interlogd ... su - $GLITE_USER -c "$GLITE_LOCATION/bin/glite-lb-notif-interlogd \ - -f $GLITE_LB_NOTIF_FPREFIX -s $GLITE_LB_NOTIF_SOCK \ + -f /var/tmp/glite-lb-notif -s /tmp/glite-lb-notif.sock \ $creds" && echo " done" || echo " FAILED" } @@ -93,7 +89,7 @@ status() { retval=0 - if netstat -an --unix | grep "^unix .* LISTEN.* ${GLITE_LB_NOTIF_SOCK}$" >/dev/null 2>&1 ;then + if netstat -an --unix | grep "^unix .* LISTEN.* /tmp/glite-lb-notif.sock$" >/dev/null 2>&1 ;then echo glite-lb-notif-interlogd running else echo glite-lb-notif-interlogd not running diff --git a/org.glite.lb.server/interface/job-attrs.xsd b/org.glite.lb.server/interface/job-attrs.xsd index c457c25..7d08482 100644 --- a/org.glite.lb.server/interface/job-attrs.xsd +++ b/org.glite.lb.server/interface/job-attrs.xsd @@ -35,11 +35,13 @@ - - - - - + + + + + + + @@ -55,15 +57,23 @@ + + + + + - Job owner according to LB + Job owner according to LB + + + @@ -96,6 +106,7 @@ + + + @@ -51,6 +52,7 @@ + + +