From 4cb7c2f3d17a081a6e9cd9d749ef74b7cf2bfe68 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Voc=C5=AF?= Date: Fri, 5 May 2006 21:22:39 +0000 Subject: [PATCH] * added some implementation --- org.glite.lb.common/src/lb_perftest.c | 101 ++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/org.glite.lb.common/src/lb_perftest.c b/org.glite.lb.common/src/lb_perftest.c index e69de29..55b39cd 100644 --- a/org.glite.lb.common/src/lb_perftest.c +++ b/org.glite.lb.common/src/lb_perftest.c @@ -0,0 +1,101 @@ +#include +#include +#include +#include +#include +#include +#include + +#include "lb_perftest.h" +#include "glite/lb/producer.h" +#include "glite/lb/trio.h" + +#ident "$Header$" + +static pthread_mutex_t perftest_lock = PTHREAD_MUTEX_INITIALIZER; +static struct timeval endtime; +static char *termination_string; + +int +glite_wll_perftest_init() +{ + if(trio_asprintf(&termination_string, EDG_WLL_FORMAT_USERTAG, + PERFTEST_END_TAG_NAME, PERFTEST_END_TAG_VALUE) < 0) + return(-1); + + return(0); +} + + +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: %ld\n", + endtime.tv_sec + 1000000L*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(strstr(event_string, termination_string) != NULL) { + /* print the timestamp */ + fprintf(stderr, "PERFTEST_END_TIMESTAMP: %ld\n", + endtime.tv_sec + 1000000L*endtime.tv_usec); + ret = 1; + } + + if(pthread_mutex_unlock(&perftest_lock) < 0) + abort(); + + return(ret); +} + + +int +glite_wll_perftest_createJobId(const char *bkserver, + int port, + const char *test_user, + int test_num, + int job_num, + edg_wlc_JobId *jobid) +{ + char unique[256]; + + if(snprintf(unique, sizeof(unique), "%s_%d_%d", + test_user, test_num, job_num) >= sizeof(unique)) + return(E2BIG); + + return(edg_wlc_JobIdRecreate(bkserver, port, unique, jobid)); +} -- 1.8.2.3