From 7699cc4cb213bf51dc1ef62d35c383b2427279eb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Posp=C3=AD=C5=A1il?= Date: Fri, 3 Dec 2004 18:08:17 +0000 Subject: [PATCH] L&B Proxy logging now possible via logevent --- .../interface/producer.h.T | 33 ++++++-- org.glite.lb.client/src/logevent.c.T | 46 +++++++---- org.glite.lb.client/src/producer.c | 89 ++++++++++++++++++---- 3 files changed, 133 insertions(+), 35 deletions(-) diff --git a/org.glite.lb.client-interface/interface/producer.h.T b/org.glite.lb.client-interface/interface/producer.h.T index a37ab3c..188f25c 100644 --- a/org.glite.lb.client-interface/interface/producer.h.T +++ b/org.glite.lb.client-interface/interface/producer.h.T @@ -281,7 +281,7 @@ extern int edg_wll_SetLoggingJob( * \param context INOUT context to work with * \param job IN further logging calls are related to this job * \param code IN sequence code as obtained from previous component - * \param user IN user ceredentials + * \param user IN user credentials * \param flags IN flags on code handling (\see API documentation) */ extern int edg_wll_SetLoggingJobProxy( @@ -302,13 +302,13 @@ extern int edg_wll_SetLoggingJobProxy( * Partitionable jobs should set num_subjobs=0 initially, * and re-register when number of subjobs becomes known. * - * \param type EDG_WLL_JOB_SIMPLE, EDG_WLL_JOB_DAG, or EDG_WLL_JOB_PARTITIONABLE - * \param jdl user-specified JDL - * \param ns network server contact - * \param num_subjobs number of subjobs to create - * \param seed seed used for subjob id's generator. + * \param type IN EDG_WLL_JOB_SIMPLE, EDG_WLL_JOB_DAG, or EDG_WLL_JOB_PARTITIONABLE + * \param jdl IN user-specified JDL + * \param ns IN network server contact + * \param num_subjobs IN number of subjobs to create + * \param seed IN seed used for subjob id's generator. * Use non-NULL value to be able to regenerate the set of jobid's - * \param subjobs returned subjob id's + * \param subjobs OUT returned subjob id's */ /* backward compatibility */ @@ -341,12 +341,29 @@ extern int edg_wll_RegisterJobSync( ); /** - * Register alternative for L&B Proxy + * Register job with L&B Proxy service. + * Done via logging REGJOB event, may generate subjob id's and create + * the parent-children associations. + * Set the job as current for the context and initialize sequence code. + * + * Partitionable jobs should set num_subjobs=0 initially, + * and re-register when number of subjobs becomes known. + * + * \param type IN EDG_WLL_JOB_SIMPLE, EDG_WLL_JOB_DAG, or EDG_WLL_JOB_PARTITIONABLE + * \param user IN user credentials + * \param jdl IN user-specified JDL + * \param ns IN network server contact + * \param num_subjobs IN number of subjobs to create + * \param seed IN seed used for subjob id's generator. + * Use non-NULL value to be able to regenerate the set of jobid's + * \param subjobs OUT returned subjob id's */ + extern int edg_wll_RegisterJobProxy( edg_wll_Context context, const edg_wlc_JobId job, enum edg_wll_RegJobJobtype type, + const char * user, const char * jdl, const char * ns, int num_subjobs, diff --git a/org.glite.lb.client/src/logevent.c.T b/org.glite.lb.client/src/logevent.c.T index df0a2f3..65133fa 100644 --- a/org.glite.lb.client/src/logevent.c.T +++ b/org.glite.lb.client/src/logevent.c.T @@ -1,10 +1,10 @@ +#ident "$Header$" + +@@@LANG: C /* @@@AUTO */ -@@@LANG: C - -#ident "$Header$" #include #include #include @@ -30,12 +30,13 @@ int main(int argc, char *argv[]) { char /* *fmt,*fname = NULL,*/ *fmt_arg=NULL; - char* server = NULL,*code = NULL; - char* ff = NULL,*jobid_s = NULL; + char *server = NULL, *code = NULL; + char *ff = NULL, *jobid_s = NULL; char *src_instance = NULL; int err = 0/*,i,done = 0,fmtlen*/; int pri = 0; - int deb = 0; + char *lbproxy = NULL; + int deb = 0; #ifdef ENABLE_REASON_LENGTH int elength = 0; #endif @@ -47,6 +48,7 @@ int main(int argc, char *argv[]) edg_wll_EventCode event, char *fmt, ...); + /* all possible variables */ @@@{ my %vars = (); for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } @@ -70,9 +72,11 @@ int main(int argc, char *argv[]) } @@@} + /* all possible arguments */ edg_wll_Args parray[] = { { EDG_WLL_ARGS_EVENT, "e", "event", "select event type (see -e help)", &event }, { EDG_WLL_ARGS_BOOL, "p", "priority", "send as priority event", &pri }, + { EDG_WLL_ARGS_STRING, "x", "lbproxy", "send directly to L&B Proxy (not locallogger) with given credentials", &lbproxy }, { EDG_WLL_ARGS_STRING, "m", "machine", 0, &server }, { EDG_WLL_ARGS_SOURCE, "s", "source", "event source (see -s help)", &src }, { EDG_WLL_ARGS_STRING, "i", "source-instance", "event source instance", &src_instance }, @@ -115,20 +119,23 @@ int main(int argc, char *argv[]) { EDG_WLL_ARGS_NONE }, }; edg_wll_ParseArgs(&argc, argv, parray, - "Usage: %s [-d] [-p] [-l eventlen] [-j dg_jobid]" + "Usage: %s [-d] [-p] [-x] [-l eventlen] [-j dg_jobid]" "[-s source_id] -e event [key=value ...]"); +/* XXX: Obsolete? if (globus_module_activate(GLOBUS_COMMON_MODULE) != GLOBUS_SUCCESS) { fprintf(stderr, "Cannot initialize Globus common module\n"); exit(1); } +*/ edg_wll_InitContext(&ctx); - /* log the event - priority/normal */ + /* log the event - priority/normal/proxy */ logev = (pri) ? edg_wll_LogEventSync : edg_wll_LogEvent; + logev = (lbproxy) ? edg_wll_LogEventProxy : logev; - /* if no job gived - generate some */ + /* if no job given - generate some */ if (jobid_s == 0) { const char* s; if (!server) { @@ -154,11 +161,22 @@ int main(int argc, char *argv[]) edg_wll_SetParam(ctx, EDG_WLL_PARAM_LEVEL, (deb) ? EDG_WLL_LEVEL_DEBUG : EDG_WLL_LEVEL_SYSTEM); - if (edg_wll_SetLoggingJob(ctx,jobid,code,EDG_WLL_SEQ_NORMAL)) { - char *et,*ed; - edg_wll_Error(ctx,&et,&ed); - fprintf(stderr,"SetLoggingJob(%s,%s): %s (%s)\n",jobid_s,code,et,ed); - exit(1); + if (lbproxy) { + edg_wll_SetParam(ctx, EDG_WLL_PARAM_LBPROXY_STORE_SOCK, "/tmp/lb_proxy_store.sock"); + edg_wll_SetParam(ctx, EDG_WLL_PARAM_LBPROXY_SERVE_SOCK, "/tmp/lb_proxy_serve.sock"); + if (edg_wll_SetLoggingJobProxy(ctx,jobid,code,lbproxy,EDG_WLL_SEQ_NORMAL)) { + char *et,*ed; + edg_wll_Error(ctx,&et,&ed); + fprintf(stderr,"SetLoggingJobProxy(%s,%s,%s): %s (%s)\n",jobid_s,code,lbproxy,et,ed); + exit(1); + } + } else { + if (edg_wll_SetLoggingJob(ctx,jobid,code,EDG_WLL_SEQ_NORMAL)) { + char *et,*ed; + edg_wll_Error(ctx,&et,&ed); + fprintf(stderr,"SetLoggingJob(%s,%s): %s (%s)\n",jobid_s,code,et,ed); + exit(1); + } } #ifdef ENABLE_REASON_LENGTH diff --git a/org.glite.lb.client/src/producer.c b/org.glite.lb.client/src/producer.c index a264360..7e0ee5d 100644 --- a/org.glite.lb.client/src/producer.c +++ b/org.glite.lb.client/src/producer.c @@ -21,6 +21,7 @@ #include "glite/lb/ulm_parse.h" #include "glite/lb/trio.h" #include "glite/lb/lb_gss.h" +#include "glite/lb/lb_plain_io.h" #include "glite/lb/escape.h" #include "prod_proto.h" @@ -180,7 +181,6 @@ static int edg_wll_DoLogEventProxy( fprintf(stderr,"Logging to L&B Proxy at socket %s\n", context->p_lbproxy_store_sock? context->p_lbproxy_store_sock: socket_path); #endif - memset(&conn, 0, sizeof(conn)); conn.sock = socket(PF_UNIX, SOCK_STREAM, 0); if (conn.sock < 0) { edg_wll_SetError(context,answer = errno,"socket() error"); @@ -713,35 +713,36 @@ int edg_wll_SetLoggingJobProxy( int flags) { int err; - char *code_loc; + char *code_loc = NULL; edg_wll_ResetError(context); -/* XXX: add user credentials somewhere - to context? */ - edg_wll_SetParamString(context, EDG_WLL_PARAM_LBPROXY_USER, user); - if (!job) return edg_wll_SetError(context,EINVAL,"jobid is null"); edg_wlc_JobIdFree(context->p_jobid); if ((err = edg_wlc_JobIdDup(job,&context->p_jobid))) { edg_wll_SetError(context,err,"edg_wll_SetLoggingJob(): edg_wlc_JobIdDup() error"); - goto err; + goto edg_wll_setloggingjobproxy_end; } + /* add user credentials to context */ + 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 err; - } - else + goto edg_wll_setloggingjobproxy_end; + } else { code_loc = strdup(code); + } - if (!edg_wll_SetSequenceCode(context,code_loc,flags)) -/* XXX: ask proxy for last known sequence code */ + if (!edg_wll_SetSequenceCode(context,code_loc,flags)) */ { edg_wll_IncSequenceCode(context); - free(code_loc); + } -err: +edg_wll_setloggingjobproxy_end: + if (code_loc) free(code_loc); return edg_wll_Error(context,NULL,NULL); } @@ -793,6 +794,54 @@ static int edg_wll_RegisterJobMaster( return edg_wll_Error(context,NULL,NULL); } +/** + *----------------------------------------------------------------------- + * Register job with L&B Proxy service. + *----------------------------------------------------------------------- + */ +static int edg_wll_RegisterJobMasterProxy( + edg_wll_Context context, + const edg_wlc_JobId job, + enum edg_wll_RegJobJobtype type, + const char * user, + const char * jdl, + const char * ns, + edg_wlc_JobId parent, + int num_subjobs, + const char * seed, + edg_wlc_JobId ** subjobs) +{ + char *type_s = NULL,*intseed = NULL, *seq = NULL; + char *parent_s = NULL; + int err = 0; + + edg_wll_ResetError(context); + + intseed = seed ? strdup(seed) : + str2md5base64(seq = edg_wll_GetSequenceCode(context)); + + free(seq); + + type_s = edg_wll_RegJobJobtypeToString(type); + if (!type_s) return edg_wll_SetError(context,EINVAL,"edg_wll_RegisterJobMaster(): no jobtype specified"); + + if ((type == EDG_WLL_REGJOB_DAG || type == EDG_WLL_REGJOB_PARTITIONED) + && num_subjobs > 0) + err = edg_wll_GenerateSubjobIds(context,job, + num_subjobs,intseed,subjobs); + + parent_s = parent ? edg_wlc_JobIdUnparse(parent) : strdup(""); + + if (err == 0 && + edg_wll_SetLoggingJobProxy(context,job,NULL,user,EDG_WLL_SEQ_NORMAL) == 0) + edg_wll_LogEventMasterProxy(context, + EDG_WLL_EVENT_REGJOB,EDG_WLL_FORMAT_REGJOB, + (char *)jdl,ns,parent_s,type_s,num_subjobs,intseed); + + free(type_s); free(intseed); free(parent_s); + return edg_wll_Error(context,NULL,NULL); +} + int edg_wll_RegisterJobSync( edg_wll_Context context, const edg_wlc_JobId job, @@ -858,6 +907,20 @@ int edg_wll_RegisterSubjobs(edg_wll_Context ctx,const edg_wlc_JobId parent, return edg_wll_Error(ctx, NULL, NULL); } +int edg_wll_RegisterJobProxy( + edg_wll_Context context, + const edg_wlc_JobId job, + enum edg_wll_RegJobJobtype type, + const char * user, + const char * jdl, + const char * ns, + int num_subjobs, + const char * seed, + edg_wlc_JobId ** subjobs) +{ + return edg_wll_RegisterJobMasterProxy(context,job,type,user,jdl,ns, NULL, num_subjobs,seed,subjobs); +} + int edg_wll_ChangeACL( edg_wll_Context ctx, const edg_wlc_JobId jobid, -- 1.8.2.3