From 4e8a690f1e2264b074cc24a6ef415f79dcaf5d94 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Posp=C3=AD=C5=A1il?= Date: Thu, 11 Mar 2010 07:41:04 +0000 Subject: [PATCH] RegisterJobACL (new feature, see https://rt3.cesnet.cz/rt/Ticket/Display.html?id=24010) - added wms_dn as an optional parameter to RegJob event - added RegisterJobACL and RegisterJobProxyACL functions - internally wms_dn is a \n separated char * of all possible DNs - server side still needs to be done (Dan?) --- org.glite.lb.client/interface/producer.h.T | 61 ++++++++++--- org.glite.lb.client/src/EventAttrNames.pl | 1 + org.glite.lb.client/src/producer.c | 141 ++++++++++++++++++++++++----- org.glite.lb.server/src/store.c.T | 1 + org.glite.lb.types/events.T | 2 + 5 files changed, 171 insertions(+), 35 deletions(-) diff --git a/org.glite.lb.client/interface/producer.h.T b/org.glite.lb.client/interface/producer.h.T index 5283980..5586890 100644 --- a/org.glite.lb.client/interface/producer.h.T +++ b/org.glite.lb.client/interface/producer.h.T @@ -48,6 +48,7 @@ require '../src/uiwrap.T'; /** * Formats a logging message and sends it asynchronously to local-logger + * (the connection is through GSS) * \brief generic asynchronous logging function * \param[in,out] context context to work with, * \param[in] event type of the event, @@ -68,6 +69,7 @@ extern int edg_wll_LogEvent( /** * Formats a logging message and sends it synchronously to local-logger + * (the connection is through GSS) * \brief generic synchronous logging function * \param[in,out] context context to work with, * \param[in] event type of the event, @@ -90,6 +92,7 @@ extern int edg_wll_LogEventSync( /** * Formats a logging message and sends it synchronously to L&B Proxy + * (the connection is through UNIX socket) * \brief generic synchronous logging function * \param[in,out] context context to work with, * \param[in] event type of the event, @@ -168,13 +171,13 @@ extern int edg_wll_SetLoggingJobProxy( /** * Register job with L&B 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. + * Done via logging REGJOB event directly to LB server (the connection is asynchronous through GSS) + * - 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 the number of subjobs becomes known. * + * \brief asynchronous job registration * \param[in,out] context context to work with * \param[in] job jobId * \param[in] type EDG_WLL_JOB_SIMPLE, EDG_WLL_JOB_DAG, or EDG_WLL_JOB_PARTITIONABLE @@ -188,7 +191,8 @@ extern int edg_wll_SetLoggingJobProxy( /* backward compatibility */ #define EDG_WLL_JOB_SIMPLE EDG_WLL_REGJOB_SIMPLE - +#define edg_wll_RegisterJobAsync edg_wll_RegisterJob + extern int edg_wll_RegisterJob( edg_wll_Context context, glite_jobid_const_t job, @@ -217,12 +221,13 @@ extern int edg_wll_RegisterJobSync( /** * 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. + * Done via logging REGJOB event in parallel both + * to LB proxy (through UNIX socket) and + * to LB server (through GSS) + * - 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[in,out] context context to work with * \param[in] job jobId @@ -246,6 +251,36 @@ extern int edg_wll_RegisterJobProxy( glite_jobid_t ** subjobs ); +/** + * Job registration with an extra ACL specifying WMS to acces the job + * (the connection to LB server is asynchronous through GSS) + * \param[in] wms_dn DN of WMS handling the job + */ + +extern int edg_wll_RegisterJobACL( + edg_wll_Context context, + glite_jobid_const_t job, + enum edg_wll_RegJobJobtype type, + const char * jdl, + const char * ns, + int num_subjobs, + const char * seed, + glite_jobid_t ** subjobs, + char ** wms_dn +); + +extern int edg_wll_RegisterJobProxyACL( + edg_wll_Context context, + glite_jobid_const_t job, + enum edg_wll_RegJobJobtype type, + const char * jdl, + const char * ns, + int num_subjobs, + const char * seed, + glite_jobid_t ** subjobs, + char ** wms_dn +); + #ifdef LB_PERF /* original register to LBProxy */ extern int edg_wll_RegisterJobProxyOld( diff --git a/org.glite.lb.client/src/EventAttrNames.pl b/org.glite.lb.client/src/EventAttrNames.pl index 2bd5593..e559f78 100644 --- a/org.glite.lb.client/src/EventAttrNames.pl +++ b/org.glite.lb.client/src/EventAttrNames.pl @@ -97,4 +97,5 @@ LRMS_JOBID WORKER_NODE FAILURE_REASON + WMS_DN /; diff --git a/org.glite.lb.client/src/producer.c b/org.glite.lb.client/src/producer.c index 0cd4e92..cbae9aa 100644 --- a/org.glite.lb.client/src/producer.c +++ b/org.glite.lb.client/src/producer.c @@ -387,7 +387,7 @@ static int edg_wll_LogEventMaster( if (ret) goto edg_wll_logeventmaster_end; } - if (flags & (EDG_WLL_LOGFLAG_LOCAL|EDG_WLL_LOGFLAG_PROXY|EDG_WLL_LOGFLAG_DIRECT) == 0) { + if ((flags & (EDG_WLL_LOGFLAG_LOCAL|EDG_WLL_LOGFLAG_PROXY|EDG_WLL_LOGFLAG_DIRECT)) == 0) { edg_wll_SetError(ctx,ret = EINVAL,"edg_wll_LogEventMaster(): no known flag specified"); } #endif @@ -752,13 +752,14 @@ static int edg_wll_RegisterJobMaster( glite_jobid_const_t parent, int num_subjobs, const char * seed, - edg_wlc_JobId ** subjobs) + edg_wlc_JobId ** subjobs, + char ** wms_dn) { - char *seq,*type_s,*parent_s; - int err = 0; + char *seq,*type_s,*parent_s,*wms_dn_s; + int err = 0,i; struct timeval sync_to; - seq = type_s = parent_s = NULL; + seq = type_s = parent_s = wms_dn_s = NULL; edg_wll_ResetError(ctx); memcpy(&sync_to, &ctx->p_sync_timeout, sizeof sync_to); @@ -783,6 +784,16 @@ static int edg_wll_RegisterJobMaster( goto edg_wll_registerjobmaster_end; } parent_s = parent ? edg_wlc_JobIdUnparse(parent) : strdup(""); + if (wms_dn) { + char *aux,*aux2; + aux2 = strdup(""); + for (i=0; wms_dn[i]; i++) { + asprintf(&aux,"%s\n%s",aux2,wms_dn[i]); + free(aux2); aux2 = aux; aux = NULL; + } + wms_dn_s = strdup(aux2); + free(aux2); aux2 = NULL; + } if ( ((flags & (EDG_WLL_LOGFLAG_DIRECT | EDG_WLL_LOGFLAG_LOCAL)) == (EDG_WLL_LOGFLAG_DIRECT | EDG_WLL_LOGFLAG_LOCAL)) || @@ -796,7 +807,7 @@ static int edg_wll_RegisterJobMaster( if (edg_wll_SetLoggingJob(ctx,job,NULL,EDG_WLL_SEQ_NORMAL) == 0) { err = edg_wll_LogEventMaster(ctx, flags, EDG_WLL_EVENT_REGJOB, EDG_WLL_FORMAT_REGJOB, - (char *)jdl, ns, parent_s, type_s, num_subjobs, seed); + (char *)jdl, ns, parent_s, type_s, num_subjobs, seed, wms_dn_s); if (err) { edg_wll_UpdateError(ctx,0,"edg_wll_RegisterJobMaster(): unable to register with bkserver"); goto edg_wll_registerjobmaster_end; @@ -830,7 +841,7 @@ int edg_wll_RegisterJobSync( const char * seed, edg_wlc_JobId ** subjobs) { - return edg_wll_RegisterJobMaster(ctx,EDG_WLL_LOGFLAG_DIRECT | EDG_WLL_LOGFLAG_SYNC,job,type,jdl,ns,NULL,num_subjobs,seed,subjobs); + return edg_wll_RegisterJobMaster(ctx,EDG_WLL_LOGFLAG_DIRECT | EDG_WLL_LOGFLAG_SYNC,job,type,jdl,ns,NULL,num_subjobs,seed,subjobs,NULL); } /** @@ -849,19 +860,39 @@ int edg_wll_RegisterJob( const char * seed, edg_wlc_JobId ** subjobs) { - return edg_wll_RegisterJobMaster(ctx,EDG_WLL_LOGFLAG_DIRECT | EDG_WLL_LOGFLAG_ASYNC,job,type,jdl,ns,NULL,num_subjobs,seed,subjobs); + return edg_wll_RegisterJobMaster(ctx,EDG_WLL_LOGFLAG_DIRECT | EDG_WLL_LOGFLAG_ASYNC,job,type,jdl,ns,NULL,num_subjobs,seed,subjobs,NULL); +} + +/** + *----------------------------------------------------------------------- + * Asynchronous job registration with an extra ACL specifying WMS to acces the job + * \note simple wrapper around edg_wll_RegisterJobMaster() + *----------------------------------------------------------------------- + */ +int edg_wll_RegisterJobACL( + edg_wll_Context ctx, + glite_jobid_const_t job, + enum edg_wll_RegJobJobtype type, + const char * jdl, + const char * ns, + int num_subjobs, + const char * seed, + edg_wlc_JobId ** subjobs, + char ** wms_dn) +{ + return edg_wll_RegisterJobMaster(ctx,EDG_WLL_LOGFLAG_DIRECT | EDG_WLL_LOGFLAG_ASYNC,job,type,jdl,ns,NULL,num_subjobs,seed,subjobs,wms_dn); } + #ifndef LB_SERIAL_REG /** *----------------------------------------------------------------------- - * Register one job with L&B Proxy service - * \note simple wrapper around edg_wll_RegisterJobMaster() - * this is new (!LB_SERIAL_REG) edg_wll_RegisterJobProxy + * Register job with L&B Proxy service. *----------------------------------------------------------------------- */ -int edg_wll_RegisterJobProxy( + +int edg_wll_RegisterJobProxyMaster( edg_wll_Context ctx, glite_jobid_const_t job, enum edg_wll_RegJobJobtype type, @@ -869,17 +900,18 @@ int edg_wll_RegisterJobProxy( const char * ns, int num_subjobs, const char * seed, - edg_wlc_JobId ** subjobs) + edg_wlc_JobId ** subjobs, + char ** wms_dn) { - char *seq,*type_s; + char *seq,*type_s,*wms_dn_s; edg_wll_LogLine logline = NULL; - int ret = 0,n,count,fd; + int ret = 0,n,count,fd,i; struct timeval sync_to; edg_wll_GssConnection con_bkserver; edg_wll_PlainConnection con_lbproxy; fd_set fdset; - seq = type_s = NULL; + seq = type_s = wms_dn_s = NULL; edg_wll_ResetError(ctx); memcpy(&sync_to, &ctx->p_sync_timeout, sizeof sync_to); @@ -894,6 +926,16 @@ int edg_wll_RegisterJobProxy( edg_wll_SetError(ctx,EINVAL,"edg_wll_RegisterJobProxy(): no jobtype specified"); goto edg_wll_registerjobproxy_end; } + if (wms_dn) { + char *aux,*aux2; + aux2 = strdup(""); + for (i=0; wms_dn[i]; i++) { + asprintf(&aux,"%s\n%s",aux2,wms_dn[i]); + free(aux2); aux2 = aux; aux = NULL; + } + wms_dn_s = strdup(aux2); + free(aux2); aux2 = NULL; + } if ((type == EDG_WLL_REGJOB_DAG || type == EDG_WLL_REGJOB_PARTITIONED || type == EDG_WLL_REGJOB_COLLECTION) @@ -918,7 +960,7 @@ int edg_wll_RegisterJobProxy( /* format the RegJob event message */ if (edg_wll_FormatLogLine(ctx,EDG_WLL_LOGFLAG_DIRECT | EDG_WLL_LOGFLAG_PROXY, EDG_WLL_EVENT_REGJOB,&logline, - EDG_WLL_FORMAT_REGJOB,(char *)jdl,ns,"",type_s,num_subjobs,seed) != 0 ) { + EDG_WLL_FORMAT_REGJOB,(char *)jdl,ns,"",type_s,num_subjobs,seed,wms_dn_s) != 0 ) { edg_wll_UpdateError(ctx,EINVAL,"edg_wll_RegisterJobProxy(): edg_wll_FormatLogLine() error"); goto edg_wll_registerjobproxy_end; } @@ -1022,6 +1064,46 @@ edg_wll_registerjobproxy_end: /** *----------------------------------------------------------------------- * Register one job with L&B Proxy service + * \note simple wrapper around edg_wll_RegisterJobProxyMaster() + * this is new (!LB_SERIAL_REG) edg_wll_RegisterJobProxy + *----------------------------------------------------------------------- + */ +int edg_wll_RegisterJobProxy( + edg_wll_Context ctx, + glite_jobid_const_t job, + enum edg_wll_RegJobJobtype type, + const char * jdl, + const char * ns, + int num_subjobs, + const char * seed, + edg_wlc_JobId ** subjobs) +{ + return edg_wll_RegisterJobProxyMaster(ctx,job,type,jdl,ns,num_subjobs,seed,subjobs,NULL); +} + +/** + *----------------------------------------------------------------------- + * Proxy job registration with an extra ACL specifying WMS to acces the job + * \note simple wrapper around edg_wll_RegisterJobProxyMaster() + *----------------------------------------------------------------------- + */ +int edg_wll_RegisterJobProxyACL( + edg_wll_Context ctx, + glite_jobid_const_t job, + enum edg_wll_RegJobJobtype type, + const char * jdl, + const char * ns, + int num_subjobs, + const char * seed, + edg_wlc_JobId ** subjobs, + char ** wms_dn) +{ + return edg_wll_RegisterJobProxyMaster(ctx,job,type,jdl,ns,num_subjobs,seed,subjobs,wms_dn); +} + +/** + *----------------------------------------------------------------------- + * Register one job with L&B Proxy service * \note simple wrapper around edg_wll_RegisterJobMaster() * this is original edg_wll_RegisterJobProxy *----------------------------------------------------------------------- @@ -1037,7 +1119,7 @@ int edg_wll_RegisterJobProxyOld( edg_wlc_JobId ** subjobs) { /* first register with bkserver and then with L&B Proxy */ - return edg_wll_RegisterJobMaster(ctx,EDG_WLL_LOGFLAG_DIRECT | EDG_WLL_LOGFLAG_PROXY,job,type,jdl,ns,NULL,num_subjobs,seed,subjobs); + return edg_wll_RegisterJobMaster(ctx,EDG_WLL_LOGFLAG_DIRECT | EDG_WLL_LOGFLAG_PROXY,job,type,jdl,ns,NULL,num_subjobs,seed,subjobs,NULL); } #else /* LB_SERIAL_REG */ @@ -1060,7 +1142,22 @@ int edg_wll_RegisterJobProxy( edg_wlc_JobId ** subjobs) { /* first register with bkserver and then with L&B Proxy */ - return edg_wll_RegisterJobMaster(ctx,EDG_WLL_LOGFLAG_DIRECT | EDG_WLL_LOGFLAG_PROXY,job,type,jdl,ns,NULL,num_subjobs,seed,subjobs); + return edg_wll_RegisterJobMaster(ctx,EDG_WLL_LOGFLAG_DIRECT | EDG_WLL_LOGFLAG_PROXY,job,type,jdl,ns,NULL,num_subjobs,seed,subjobs,NULL); +} + +int edg_wll_RegisterJobProxyACL( + edg_wll_Context ctx, + glite_jobid_const_t job, + enum edg_wll_RegJobJobtype type, + const char * jdl, + const char * ns, + int num_subjobs, + const char * seed, + edg_wlc_JobId ** subjobs, + char ** wms_dn) +{ + /* first register with bkserver and then with L&B Proxy */ + return edg_wll_RegisterJobMaster(ctx,EDG_WLL_LOGFLAG_DIRECT | EDG_WLL_LOGFLAG_PROXY,job,type,jdl,ns,NULL,num_subjobs,seed,subjobs,wms_dn); } #endif /* LB_SERIAL_REG */ @@ -1082,7 +1179,7 @@ int edg_wll_RegisterJobProxyOnly( const char * seed, edg_wlc_JobId ** subjobs) { - return edg_wll_RegisterJobMaster(ctx,EDG_WLL_LOGFLAG_PROXY,job,type,jdl,ns,NULL,num_subjobs,seed,subjobs); + return edg_wll_RegisterJobMaster(ctx,EDG_WLL_LOGFLAG_PROXY,job,type,jdl,ns,NULL,num_subjobs,seed,subjobs,NULL); } /** @@ -1103,7 +1200,7 @@ int edg_wll_RegisterSubjob( const char * seed, edg_wlc_JobId ** subjobs) { - return edg_wll_RegisterJobMaster(ctx,EDG_WLL_LOGFLAG_LOCAL,job,type,jdl,ns,parent,num_subjobs,seed,subjobs); + return edg_wll_RegisterJobMaster(ctx,EDG_WLL_LOGFLAG_LOCAL,job,type,jdl,ns,parent,num_subjobs,seed,subjobs,NULL); } /** @@ -1124,7 +1221,7 @@ int edg_wll_RegisterSubjobProxy( const char * seed, edg_wlc_JobId ** subjobs) { - return edg_wll_RegisterJobMaster(ctx,EDG_WLL_LOGFLAG_PROXY,job,type,jdl,ns,parent,num_subjobs,seed,subjobs); + return edg_wll_RegisterJobMaster(ctx,EDG_WLL_LOGFLAG_PROXY,job,type,jdl,ns,parent,num_subjobs,seed,subjobs,NULL); } /** diff --git a/org.glite.lb.server/src/store.c.T b/org.glite.lb.server/src/store.c.T index 5abfc98..0e9b66b 100644 --- a/org.glite.lb.server/src/store.c.T +++ b/org.glite.lb.server/src/store.c.T @@ -624,6 +624,7 @@ edg_wll_ErrorCode intJobStat_embryonic( stat->pub.jobtype = EDG_WLL_STAT_SIMPLE; stat->pub.stateEnterTimes[1 + EDG_WLL_JOB_SUBMITTED] = (int)e->timestamp.tv_sec; stat->pub.lastUpdateTime = e->timestamp; + // TODO: update job ACL according to e->wms_dn err: return edg_wll_Error(ctx,NULL,NULL); diff --git a/org.glite.lb.types/events.T b/org.glite.lb.types/events.T index 5371865..b4d4dc8 100644 --- a/org.glite.lb.types/events.T +++ b/org.glite.lb.types/events.T @@ -168,6 +168,8 @@ _optional_ string seed Seed for subjob id generation. _optional_ + string wms_dn DN of WMS handling the job + _optional_ @type Chkpt Application-specific checkpoint record. string tag Application specific checkpoint tag. -- 1.8.2.3