From 9454b3506b07fa96959631ef9c6dd464ebb526f8 Mon Sep 17 00:00:00 2001 From: cvs2svn Date: Mon, 17 Jan 2005 13:13:00 +0000 Subject: [PATCH] This commit was manufactured by cvs2svn to create branch 'glite-lb- client_branch_1_0_0'. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Cherrypick from master 2005-01-17 13:12:59 UTC Miloš Mulač 'Brief documentation to notifications': org.glite.lb.client/doc/README-notify org.glite.lb.client/examples/abort_job.c --- org.glite.lb.client/doc/README-notify | 72 +++++++++++++++++ org.glite.lb.client/examples/abort_job.c | 128 +++++++++++++++++++++++++++++++ 2 files changed, 200 insertions(+) create mode 100644 org.glite.lb.client/doc/README-notify create mode 100644 org.glite.lb.client/examples/abort_job.c diff --git a/org.glite.lb.client/doc/README-notify b/org.glite.lb.client/doc/README-notify new file mode 100644 index 0000000..c7feb9e --- /dev/null +++ b/org.glite.lb.client/doc/README-notify @@ -0,0 +1,72 @@ +LB notifications +---------------- + +LB infrastructure enables its users to be notified when something interesting happens on a bookkeeping server. + +User registers to infrastructure via client API (notification.h) or he/she can use example program glite-lb-notify (see bellow). He/she must specify a condition under which the notification is sent. The condition(s) is(are) stored in edg_wll_QueryRec data structure. Currently one or more JOBID's are required in it and only a single occurence of a specific attribute is allowed among ANDed conditions. + +The request for notification is then delivered to a bookkeeping server. Whenever a new event arrives to the bookkeeping server, the notification condition is tested. Always when it is true, the notification is sent to the user. Notifications are incomming until the user cancels notification registration on the server. + +For a notification deliveriy, a special deamon, notification interlogger is used. It stores registrations in files until they are delivered. + + + +Notification example +-------------------- + +In next steps, you will be instucted how to register for a notification and how to triger this registration on the bookkeeping server in order to receive registration. Our example program 'glite-lb-notify' is used for this purpose. It uses mentioned client API calls to manipulate with registrations. + + +1) Set up LB environment + + a) Download, compile and install LB module from SCM CVS + b) Install it from RPMs + + See instructions at section 'Installation & Configuration' + from EGEE JRA1 web site. It was located at (Jan 2005) : + + http://egee-jra1-wm.mi.infn.it/egee-jra1-wm/lb_install.shtml + + +2) Get globus proxy certificate + ./grid-proxy-init -key PATH_TO_YOUR_KEY -cert PATH_TO_YOUR_CERT + + +3) Start LB deamons + + Substitute KEY with location server private key, CERT with location + of server certificate, and CERTS_DIR directory containing CA + certificates. + + ./glite-lb-logd -k KEY -c CERT -C CERTS_DIR -d -v + + ./glite-lb-interlogd -k KEY -c CERT -C CERTS_DIR -b -d -v + + ./glite-lb-bkserverd -d -k KEY -c CERT -C CERTS_DIR + + ./glite-lb-notif-interlogd -k KEY -c CERT -C CERTS_DIR -d -v + + +4) Register a job + export EDG_WL_LOG_DESTINATION=HOSTNAME:9002 + ./glite-lb-job_reg -m HOSTNAME:9000 -s UserInterface + + -> returns JOBID - used in the next steps + + +5) Register notification + export EDG_WL_NOTIF_SERVER=HOSTNAME:9000 + ./glite-lb-notify test JOBID + + +6) Change status of your job + export EDG_WL_LOG_DESTINATION=HOSTNAME:9002 + ./glite-lb-running.sh -j JOBID + + +7) Watch incomming notifications + + +Warning: Try to destroy all your registrations when you finish, otherwise the system will still try to deliver you your notifications to nonexistent destinations (ports which nobody listens at). + +TIP: If you are stucked, try to clean up notif-interlogger's cache files. They are by default stored at /tmp/notif_events*, or wherever you set by -f option. diff --git a/org.glite.lb.client/examples/abort_job.c b/org.glite.lb.client/examples/abort_job.c new file mode 100644 index 0000000..784e6d5 --- /dev/null +++ b/org.glite.lb.client/examples/abort_job.c @@ -0,0 +1,128 @@ +#ident "$Header$" + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif + +#include +#include +#include +#include + +#include "glite/lb/events_parse.h" +#include "glite/lb/consumer.h" +#include "glite/wmsutils/jobid/cjobid.h" + +static void free_events(edg_wll_Event *); + +static void help(const char* n) +{ + fprintf(stderr,"usage: %s \n", n); + exit(1); +} + +int main(int argc,char **argv) +{ + edg_wll_Context ctx; + char *errt,*errd,*e,a; + edg_wll_Event *events; + int i; + edg_wll_QueryRec jq[2],eq[2]; + edg_wlc_JobId job; + edg_wll_Source src; + + if (argc != 3) help(argv[0]); + + puts( +"*\n" +"* USE WITH CARE, AT YOUR OWN RISK, UNDER ABNORMAL CONDITIONS ONLY,\n" +"* AND BE ALWAYS SURE WHAT YOU ARE DOING.\n" +"* \n" +"* THIS PROGRAM IS A PERFECT EXAMPLE HOW L&B SEQENCE CODES SHOULD NOT BE USED\n" +"* IN NORMAL OPERATION.\n" +"\n" +"Do you want to proceed?" + ); + + scanf("%c",&a); + if (a != 'y' && a != 'Y') return 1; + + edg_wll_InitContext(&ctx); + + if (edg_wlc_JobIdParse(argv[1],&job)) { + fprintf(stderr,"%s: can't parse job ID\n",argv[1]); + return 1; + } + + if (( src = edg_wll_StringToSource(argv[2])) == EDG_WLL_SOURCE_NONE) { + fprintf(stderr,"%s: unknown event source\n",argv[2]); + return 1; + } + + jq[0].attr = EDG_WLL_QUERY_ATTR_JOBID; + jq[0].op = EDG_WLL_QUERY_OP_EQUAL; + jq[0].value.j = job; + jq[1].attr = EDG_WLL_QUERY_ATTR_UNDEF; + + eq[0].attr = EDG_WLL_QUERY_ATTR_SOURCE; + eq[0].op = EDG_WLL_QUERY_OP_EQUAL; + eq[0].value.i = src; + eq[1].attr = EDG_WLL_QUERY_ATTR_UNDEF; + + if ( edg_wll_QueryEvents(ctx,jq,eq,&events) ) + { + if ( edg_wll_Error(ctx, &errt, &errd) != E2BIG ) + goto err; + + fprintf(stderr,"%s: %s (%s)\n",argv[0],errt,errd); + } + + for ( i = 0; events[i].type != EDG_WLL_EVENT_UNDEF; i++ ); + + e = edg_wll_UnparseEvent(ctx,events+i-1); + + fputs(e,stdout); + fputs("\n",stdout); + + if (edg_wll_SetParam(ctx,EDG_WLL_PARAM_SOURCE,src) || + edg_wll_SetLoggingJob(ctx,job,events[i-1].any.seqcode,EDG_WLL_SEQ_NORMAL) || + edg_wll_IncSequenceCode(ctx) || /* necessary to simulate this + * call in last event logging + * _after_ current seq. was used */ + edg_wll_LogAbort(ctx,"manual abort")) goto err; + + + free(e); + free_events(events); + + edg_wll_FreeContext(ctx); + + return 0; + +err: + switch (edg_wll_Error(ctx,&errt,&errd)) { + case 0: break; + case ENOENT: + puts("No events found"); + break; + default: + fprintf(stderr,"%s: %s (%s)\n",argv[0],errt,errd); + return 1; + } + + edg_wll_FreeContext(ctx); + + return 0; +} + +static void free_events(edg_wll_Event *events) +{ + int i; + + if (events) { + for (i=0; events[i].type != EDG_WLL_EVENT_UNDEF; i++) edg_wll_FreeEvent(&(events[i])); + edg_wll_FreeEvent(&(events[i])); /* free last line */ + free(events); + events = NULL; + } +} -- 1.8.2.3