From e8eb0806a15191917e25e61ca36cc54173b64d81 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Voc=C5=AF?= Date: Wed, 16 May 2012 07:55:21 +0000 Subject: [PATCH] merge of branch michal_Torque --- org.glite.lb.client/examples/job_status.c | 2 +- org.glite.lb.client/interface/Event.h.T | 1 + org.glite.lb.client/src/EventAttrNames.pl | 5 ++ org.glite.lb.client/src/StatusAttrNames.pl | 2 + org.glite.lb.client/src/args.c.T | 15 +++++ org.glite.lb.client/src/args.h | 1 + org.glite.lb.client/src/logevent.c.T | 3 +- org.glite.lb.client/src/prod_proto.c | 4 +- org.glite.lb.client/src/producer.c | 1 - org.glite.lb.common/interface/context-int.h | 13 ++--- org.glite.lb.common/interface/context.h | 5 ++ org.glite.lb.common/interface/events.h.T | 11 ++++ org.glite.lb.common/interface/events_parse.h | 1 + org.glite.lb.common/interface/jobstat.h.T | 10 +--- org.glite.lb.common/interface/xml_conversions.h | 4 +- org.glite.lb.common/src/context.c | 33 ++++++++++- org.glite.lb.common/src/events.c.T | 34 +++++++++++ org.glite.lb.common/src/events_parse.c.T | 77 ++++++++++++++++++++++++- org.glite.lb.common/src/status.c.T | 22 +++---- org.glite.lb.common/src/xml_conversions.c | 24 +++++++- org.glite.lb.logger/src/interlogd.c | 16 ++++- org.glite.lb.types/Makefile | 4 ++ org.glite.lb.types/events.T | 53 +++++++++++++++-- org.glite.lb.types/interface/lb_types.h | 48 +++++++++++++++ org.glite.lb.types/status.T | 4 +- org.glite.lb.types/types.T | 7 ++- org.glite.lb.ws-interface/src/LBTypes.xml.T | 8 ++- 27 files changed, 354 insertions(+), 54 deletions(-) create mode 100644 org.glite.lb.types/interface/lb_types.h diff --git a/org.glite.lb.client/examples/job_status.c b/org.glite.lb.client/examples/job_status.c index c3e7a2d..8a9f526 100644 --- a/org.glite.lb.client/examples/job_status.c +++ b/org.glite.lb.client/examples/job_status.c @@ -343,7 +343,7 @@ static void printstat(edg_wll_JobStat stat, int level) printf("%spbs_dest_host : %s\n", ind, stat.pbs_dest_host); printf("%spbs_pid : %d\n", ind, stat.pbs_pid); printf("%spbs_resource_usage : %s%s\n", ind, - (stat.pbs_resource_usage) ? "\n" : "", stat.pbs_resource_usage); + (stat.pbs_resource_usage) ? "\n" : "", edg_wll_TagListToString(stat.pbs_resource_usage)); printf("%spbs_exit_status : %d\n", ind, stat.pbs_exit_status); printf("%spbs_error_desc : %s%s\n", ind, (stat.pbs_error_desc) ? "\n" : "", stat.pbs_error_desc); diff --git a/org.glite.lb.client/interface/Event.h.T b/org.glite.lb.client/interface/Event.h.T index 1a198b6..1aa05b3 100644 --- a/org.glite.lb.client/interface/Event.h.T +++ b/org.glite.lb.client/interface/Event.h.T @@ -181,6 +181,7 @@ public: NOTIFID_T, /**< NotifId value. */ FLOAT_T, /**< Float value. */ DOUBLE_T, /**< Double value. */ + TAGLIST_T, /**< List of user tags (name = value pairs). */ }; Type type; /**< Type of the event as defined by Type. */ diff --git a/org.glite.lb.client/src/EventAttrNames.pl b/org.glite.lb.client/src/EventAttrNames.pl index 8963265..9b24a03 100644 --- a/org.glite.lb.client/src/EventAttrNames.pl +++ b/org.glite.lb.client/src/EventAttrNames.pl @@ -115,4 +115,9 @@ FAILURE_REASON WMS_DN PAYLOAD_OWNER + OLDSTATE + OLDSUBSTATE + NEWSTATE + NEWSUBSTATE + RESOURCES /; diff --git a/org.glite.lb.client/src/StatusAttrNames.pl b/org.glite.lb.client/src/StatusAttrNames.pl index db266d0..413aefd 100644 --- a/org.glite.lb.client/src/StatusAttrNames.pl +++ b/org.glite.lb.client/src/StatusAttrNames.pl @@ -68,6 +68,8 @@ PBS_PID PBS_QUEUE PBS_REASON + PBS_RESOURCE_REQUESTED + PBS_SUBSTATE PBS_RESOURCE_USAGE PBS_SCHEDULER PBS_STATE diff --git a/org.glite.lb.client/src/args.c.T b/org.glite.lb.client/src/args.c.T index 88eddcf..df5af9e 100644 --- a/org.glite.lb.client/src/args.c.T +++ b/org.glite.lb.client/src/args.c.T @@ -333,6 +333,18 @@ static void read_jobid(const edg_wll_Args* o, char* arg, char* par) else glite_jobid_free(jobid); } +static void read_taglist(const edg_wll_Args* o, char* arg, char* par) +{ + edg_wll_TagValue *list = NULL; + + if(edg_wll_TagListParse(par, &list) != 0) { + fprintf(stderr, "ERROR %s can't parse %s: %s\n", arg, par, strerror(errno)); + exit(1); + } + if(o->value) *(edg_wll_TagValue **)o->value = list; + else /* FIXME: free it properly */ free(list); +} + static void show_help(const edg_wll_Args* o, int prefix) { unsigned max = 0; @@ -557,6 +569,9 @@ static int findOpt(opt_ctx_t* ctx, int olong) case EDG_WLL_ARGS_JOBID: read_jobid(o, arg, par); break; + case EDG_WLL_ARGS_TAGLIST: + read_taglist(o, arg, par); + break; default: printf("FIXME: unhandle option type %d\n", o->type); break; diff --git a/org.glite.lb.client/src/args.h b/org.glite.lb.client/src/args.h index 4e894b1..1118239 100644 --- a/org.glite.lb.client/src/args.h +++ b/org.glite.lb.client/src/args.h @@ -34,6 +34,7 @@ typedef enum { EDG_WLL_ARGS_SUBOPTIONS, EDG_WLL_ARGS_SELECTSTRING, EDG_WLL_ARGS_TIMEVAL, + EDG_WLL_ARGS_TAGLIST, } edg_wll_ArgsCode; typedef struct { diff --git a/org.glite.lb.client/src/logevent.c.T b/org.glite.lb.client/src/logevent.c.T index ed7c22c..2cf2a47 100644 --- a/org.glite.lb.client/src/logevent.c.T +++ b/org.glite.lb.client/src/logevent.c.T @@ -126,7 +126,8 @@ int main(int argc, char *argv[]) "edg_wll_NotifId", "EDG_WLL_ARGS_NOTIFID", "edg_wll_Source", "EDG_WLL_ARGS_SOURCE", "uint16_t", "EDG_WLL_ARGS_UINT16", - "struct timeval", "EDG_WLL_ARGS_TIMEVAL" + "struct timeval", "EDG_WLL_ARGS_TIMEVAL", + "edg_wll_TagValue *", "EDG_WLL_ARGS_TAGLIST", ); my %vars = (); for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } diff --git a/org.glite.lb.client/src/prod_proto.c b/org.glite.lb.client/src/prod_proto.c index 4bba21b..ce8142a 100644 --- a/org.glite.lb.client/src/prod_proto.c +++ b/org.glite.lb.client/src/prod_proto.c @@ -274,7 +274,6 @@ int edg_wll_log_connect(edg_wll_Context ctx, int *conn) edg_wll_connectionTryLock(ctx, index); edg_wll_poolUnlock(); -#if 0 /* acquire gss credentials */ ret = edg_wll_gss_acquire_cred_gsi( ctx->p_proxy_filename ? ctx->p_proxy_filename : ctx->p_cert_filename, @@ -295,7 +294,7 @@ int edg_wll_log_connect(edg_wll_Context ctx, int *conn) fprintf(stderr,"edg_wll_log_connect: going on anonymously!\n"); } #endif -#endif + #ifdef EDG_WLL_LOG_STUB fprintf(stderr,"edg_wll_log_connect: opening connection to local-logger %s:%d\n", ctx->connections->connPool[index].peerName, @@ -310,6 +309,7 @@ int edg_wll_log_connect(edg_wll_Context ctx, int *conn) ctx->p_proxy_filename ? ctx->p_proxy_filename : ctx->p_cert_filename, ctx->p_proxy_filename ? ctx->p_proxy_filename : ctx->p_key_filename, &ctx->connections->connPool[index].gsiCred, &gss_stat); + /* give up if unable to acquire prescribed credentials, otherwise go on anonymously */ if (ret && ctx->p_proxy_filename) { answer = edg_wll_SetErrorGss(ctx, "edg_wll_gss_acquire_cred_gsi(): failed to load GSI credentials", &gss_stat); diff --git a/org.glite.lb.client/src/producer.c b/org.glite.lb.client/src/producer.c index 1f09a71..b8a62e2 100644 --- a/org.glite.lb.client/src/producer.c +++ b/org.glite.lb.client/src/producer.c @@ -728,7 +728,6 @@ static int edg_wll_SetLoggingJobMaster( } else { edg_wll_SetParamString(ctx, EDG_WLL_PARAM_LBPROXY_USER, cred->name); } - if (cred != NULL) edg_wll_gss_release_cred(&cred, NULL); } diff --git a/org.glite.lb.common/interface/context-int.h b/org.glite.lb.common/interface/context-int.h index caa9602..265fe51 100644 --- a/org.glite.lb.common/interface/context-int.h +++ b/org.glite.lb.common/interface/context-int.h @@ -43,23 +43,22 @@ extern "C" { #endif #define EDG_WLL_SEQ_NULL "UI=000000:NS=0000000000:WM=000000:BH=0000000000:JSS=000000:LM=000000:LRMS=000000:APP=000000:LBS=000000" -#define EDG_WLL_SEQ_PBS_NULL "TIMESTAMP=00000000000000:POS=0000000000:EV.CODE=000:SRC=?" +#define EDG_WLL_SEQ_PBS_NULL "CLIENT=000000:SERVER=0000000000:SCHED=000000:SMOM=000000:MOM=000000" #define EDG_WLL_SEQ_CONDOR_NULL EDG_WLL_SEQ_PBS_NULL #define EDG_WLL_SEQ_SIZE (sizeof(EDG_WLL_SEQ_NULL)) #define EDG_WLL_SEQ_PBS_SIZE (sizeof(EDG_WLL_SEQ_PBS_NULL)) #define EDG_WLL_SEQ_CONDOR_SIZE EDG_WLL_SEQ_PBS_SIZE #define EDG_WLL_SEQ_FORMAT_PRINTF "UI=%06d:NS=%010d:WM=%06d:BH=%010d:JSS=%06d:LM=%06d:LRMS=%06d:APP=%06d:LBS=%06d" #define EDG_WLL_SEQ_FORMAT_SCANF "UI=%d:NS=%d:WM=%d:BH=%d:JSS=%d:LM=%d:LRMS=%d:APP=%d:LBS=%d" -#define EDG_WLL_SEQ_FORMAT_NUMBER 9 +#define EDG_WLL_SEQ_FORMAT_NUMBER 9 +#define EDG_WLL_SEQ_PBS_FORMAT_PRINTF "CLIENT=%06d:SERVER=%010d:SCHED=%06d:SMOM=%06d:MOM=%06d" +#define EDG_WLL_SEQ_PBS_FORMAT_SCANF "CLIENT=%d:SERVER=%d:SCHED=%d:SMOM=%d:MOM=%d" +#define EDG_WLL_SEQ_PBS_FORMAT_NUMBER 5 typedef struct _edg_wll_SeqCode { unsigned int type; /* seq code type */ - unsigned int c[EDG_WLL_SOURCE__LAST]; /* glite seq. code */ + unsigned int c[EDG_WLL_SOURCE__LAST]; /* glite and PBS seq. code */ char pbs[EDG_WLL_SEQ_PBS_SIZE]; /* PBS seq. code */ - /* 0-24 TIMESTAMP=YYYYMMDDHHMMSS: */ - /* 25-39 POS=%010u: */ - /* 40-51 EV.CODE=%03d: */ - /* 53-56 SRC=%c */ char condor[EDG_WLL_SEQ_CONDOR_SIZE]; } edg_wll_SeqCode; diff --git a/org.glite.lb.common/interface/context.h b/org.glite.lb.common/interface/context.h index ad5953d..94dbf5d 100644 --- a/org.glite.lb.common/interface/context.h +++ b/org.glite.lb.common/interface/context.h @@ -99,6 +99,11 @@ typedef enum _edg_wll_Source { EDG_WLL_SOURCE_LB_SERVER, EDG_WLL_SOURCE_CREAM_INTERFACE, EDG_WLL_SOURCE_CREAM_EXECUTOR, + EDG_WLL_SOURCE_PBS_CLIENT, + EDG_WLL_SOURCE_PBS_SERVER, + EDG_WLL_SOURCE_PBS_SMOM, + EDG_WLL_SOURCE_PBS_MOM, + EDG_WLL_SOURCE_PBS_SCHEDULER, EDG_WLL_SOURCE__LAST /* marker, for internal use only */ } edg_wll_Source; diff --git a/org.glite.lb.common/interface/events.h.T b/org.glite.lb.common/interface/events.h.T index dc94115..315f735 100644 --- a/org.glite.lb.common/interface/events.h.T +++ b/org.glite.lb.common/interface/events.h.T @@ -33,6 +33,8 @@ limitations under the License. #include #include "glite/jobid/cjobid.h" +#include "glite/lb/lb_types.h" + #ifdef BUILDING_LB_COMMON #include "context.h" @@ -118,6 +120,15 @@ extern char *edg_wll_EventToString(edg_wll_EventCode event); /** + * Free allocated edg_wll_TagValue * list + * \param list IN: list to free + */ +extern void edg_wll_FreeTagList( + edg_wll_TagValue *list +); + + +/** * \typedef edg_wll_KeyNameCode * Predefined ULM key types */ diff --git a/org.glite.lb.common/interface/events_parse.h b/org.glite.lb.common/interface/events_parse.h index 0f31cbb..b8b7139 100644 --- a/org.glite.lb.common/interface/events_parse.h +++ b/org.glite.lb.common/interface/events_parse.h @@ -110,6 +110,7 @@ extern edg_wll_LogLine edg_wll_UnparseNotifEvent( edg_wll_Event * event ); + #ifdef __cplusplus } #endif diff --git a/org.glite.lb.common/interface/jobstat.h.T b/org.glite.lb.common/interface/jobstat.h.T index 9a98e26..9220f75 100644 --- a/org.glite.lb.common/interface/jobstat.h.T +++ b/org.glite.lb.common/interface/jobstat.h.T @@ -32,6 +32,7 @@ limitations under the License. #include #include "glite/jobid/cjobid.h" +#include "glite/lb/lb_types.h" #ifdef __cplusplus extern "C" { @@ -97,15 +98,6 @@ typedef enum _edg_wll_JobStatCode { extern const int EDG_WLL_JOB_TERMINAL_STATE[EDG_WLL_NUMBER_OF_STATCODES]; -/*! - * - * Pair tag = value. - */ -typedef struct _edg_wll_TagValue { - char * tag; /**< User-specified information tag */ - char * value; /**< Value assigned to user-specified information tag */ -} edg_wll_TagValue; - /*! * diff --git a/org.glite.lb.common/interface/xml_conversions.h b/org.glite.lb.common/interface/xml_conversions.h index 6f57c35..576bbc2 100644 --- a/org.glite.lb.common/interface/xml_conversions.h +++ b/org.glite.lb.common/interface/xml_conversions.h @@ -138,7 +138,8 @@ void edg_wll_add_uint16_t_to_XMLBody(char **body, const uint16_t toAdd, const ch void edg_wll_add_logsrc_to_XMLBody(char **body, const edg_wll_Source toAdd, const char *tag, const edg_wll_Source null); void edg_wll_add_intlist_to_XMLBody(char **body, const int *toAdd, const char *tag, char *(*indexToTag)(), const char *indent, const int from, const int to); void edg_wll_add_strlist_to_XMLBody(char **body, char * const *toAdd, const char *tag, const char *subTag, const char *indent, const char *null); -void edg_wll_add_taglist_to_XMLBody(char **body, const edg_wll_TagValue *toAdd, const char *tag, const char *subTag, const char *indent, const char *subTag2, const char *null); +void edg_wll_add_taglist_to_XMLBody(char **body, const edg_wll_TagValue *toAdd, const char *tag, const edg_wll_TagValue *null); +void edg_wll_add_usertag_to_XMLBody(char **body, const edg_wll_TagValue *toAdd, const char *tag, const char *subTag, const char *indent, const char *subTag2, const char *null); void edg_wll_add_time_t_list_to_XMLBody(char **body, const time_t *toAdd, const char *tag, char *(*indexToTag)(), const char *indent, const int from, const int to); void edg_wll_add_cclassad_to_XMLBody(char **body, void *toAdd, const char *tag, const char *null); char *edg_wll_from_string_to_string(edg_wll_XML_ctx *XMLCtx); @@ -154,6 +155,7 @@ struct timeval edg_wll_from_string_to_timeval(edg_wll_XML_ctx *XMLCtx); time_t edg_wll_from_string_to_time_t(edg_wll_XML_ctx *XMLCtx); edg_wll_Source edg_wll_from_string_to_logsrc(edg_wll_XML_ctx *XMLCtx); void *edg_wll_from_string_to_cclassad(edg_wll_XML_ctx *XMLCtx); +edg_wll_TagValue *edg_wll_from_string_to_taglist(edg_wll_XML_ctx *XMLCtx); char *edg_wll_stat_flags_to_string(int flags); int edg_wll_string_to_stat_flags(char *cflags); diff --git a/org.glite.lb.common/src/context.c b/org.glite.lb.common/src/context.c index b6ed8ab..78c907d 100644 --- a/org.glite.lb.common/src/context.c +++ b/org.glite.lb.common/src/context.c @@ -346,6 +346,11 @@ static const char* const srcNames[] = { "LBServer", "CREAMInterface", "CREAMExecutor", + "PBSClient", + "PBSServer", + "PBSMomSuperior", + "PBSMom", + "PBSScheduler" }; edg_wll_Source edg_wll_StringToSource(const char *name) @@ -412,7 +417,14 @@ char *edg_wll_GetSequenceCode(const edg_wll_Context ctx) c[EDG_WLL_SOURCE_LB_SERVER]); break; case EDG_WLL_SEQ_PBS: - ret = strdup(ctx->p_seqcode.pbs); + c = &ctx->p_seqcode.c[0]; + asprintf(&ret, EDG_WLL_SEQ_PBS_FORMAT_PRINTF, + c[EDG_WLL_SOURCE_PBS_CLIENT], + c[EDG_WLL_SOURCE_PBS_SERVER], + c[EDG_WLL_SOURCE_PBS_SCHEDULER], + c[EDG_WLL_SOURCE_PBS_SMOM], + c[EDG_WLL_SOURCE_PBS_MOM]); + /* ret = strdup(ctx->p_seqcode.pbs); */ break; case EDG_WLL_SEQ_CONDOR: ret = strdup(ctx->p_seqcode.condor); @@ -480,10 +492,27 @@ int edg_wll_SetSequenceCode(edg_wll_Context ctx, } break; case EDG_WLL_SEQ_PBS: + /* original version if (!seqcode_str) memset(&ctx->p_seqcode.pbs, 0, sizeof ctx->p_seqcode.pbs); else strncpy(ctx->p_seqcode.pbs, seqcode_str, sizeof(ctx->p_seqcode.pbs)); + */ + if (!seqcode_str) { + memset(&ctx->p_seqcode.c, 0, sizeof(ctx->p_seqcode.c)); + return 0; + } + c = ctx->p_seqcode.c; + res = sscanf(seqcode_str, EDG_WLL_SEQ_PBS_FORMAT_SCANF, + &c[EDG_WLL_SOURCE_PBS_CLIENT], + &c[EDG_WLL_SOURCE_PBS_SERVER], + &c[EDG_WLL_SOURCE_PBS_SCHEDULER], + &c[EDG_WLL_SOURCE_PBS_SMOM], + &c[EDG_WLL_SOURCE_PBS_MOM]); + if(res != EDG_WLL_SEQ_PBS_FORMAT_NUMBER) { + return edg_wll_SetError(ctx, EINVAL, + "edg_wll_SetSequenceCode(): syntax error in sequence code"); + } break; case EDG_WLL_SEQ_CONDOR: if (!seqcode_str) @@ -508,6 +537,7 @@ int edg_wll_IncSequenceCode(edg_wll_Context ctx) switch (ctx->p_seqcode.type) { case EDG_WLL_SEQ_DUPLICATE: /* fall through */ + case EDG_WLL_SEQ_PBS: case EDG_WLL_SEQ_NORMAL: if (ctx->p_source <= EDG_WLL_SOURCE_NONE || ctx->p_source >= EDG_WLL_SOURCE__LAST) @@ -518,7 +548,6 @@ int edg_wll_IncSequenceCode(edg_wll_Context ctx) ctx->p_seqcode.c[ctx->p_source]++; break; - case EDG_WLL_SEQ_PBS: case EDG_WLL_SEQ_CREAM: /* no action */ break; diff --git a/org.glite.lb.common/src/events.c.T b/org.glite.lb.common/src/events.c.T index 5173199..002c2c8 100644 --- a/org.glite.lb.common/src/events.c.T +++ b/org.glite.lb.common/src/events.c.T @@ -66,6 +66,37 @@ for my $e (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } "SysClStat", }; +/* Free the tags and values from list */ +void edg_wll_FreeTagList(edg_wll_TagValue *list) { + edg_wll_TagValue *tag; + + if(NULL == list) return; + + for(tag = list; tag->tag; tag++) { + free(tag->tag); + if(tag->value) free(tag->value); + } +} + +/* Deep copy the tag list */ +edg_wll_TagValue *edg_wll_CopyTagList(edg_wll_TagValue *src) { + edg_wll_TagValue *dst, *tag, *dtag; + int count; + + if(NULL == src) return NULL; + + for(tag = src, count = 0; tag->tag; tag++, count++); + + dst = (edg_wll_TagValue*)calloc(count + 1, sizeof(edg_wll_TagValue)); + for(tag = src, dtag = dst; tag->tag; tag++, dtag++) { + dtag->tag = strdup(tag->tag); + dtag->value = strdup(tag->value); + } + + return dst; +} + + /** * \fn edg_wll_EventCode edg_wll_StringToEvent(const char *name) * \param name a string event name (e.g. "JobTransfer") @@ -392,6 +423,9 @@ for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } if ($ft eq 'notifid') { gen $indent."\tif (event->$tl.$fn) edg_wll_NotifIdFree(event->$tl.$fn);\n" } + if ($ft eq 'taglist') { + gen $intent."\tif (event->$tl.$fn) { edg_wll_FreeTagList(event->$tl.$fn); free(event->$tl.$fn); }\n" + } } gen $indent.$indent."break;\n" } diff --git a/org.glite.lb.common/src/events_parse.c.T b/org.glite.lb.common/src/events_parse.c.T index e95070d..34323e4 100644 --- a/org.glite.lb.common/src/events_parse.c.T +++ b/org.glite.lb.common/src/events_parse.c.T @@ -39,8 +39,80 @@ static const struct timeval null_timeval = {0,0}; /* -- Internal function prototype -- */ char *my_edg_wll_ULMGetValueAt( p_edg_wll_ULMFields, int ); +/* Function for parsing name=value tag lists */ +int edg_wll_TagListParse(const char *src, edg_wll_TagValue **list) { + int n = 0; + char *p; + edg_wll_TagValue *tag; + + if(NULL == src) + return -1; + + /* count tag=value pairs */ + for(p = (char*)src; *p; p++) { + if(',' == *p) n++; /* counts empty tokens as well... */ + } + /* one more for last empty struct */ + n += 2; + + *list = (edg_wll_TagValue*)malloc(n*sizeof(edg_wll_TagValue)); + if(NULL == *list) + return -1; + + for(p = strtok(src, ","), tag = *list; p; p = strtok(NULL, ","), tag++) { + char *s = strchr(p, '='); + + if(NULL == s || '\0' == *(s+1)) + continue; + + *s = 0; + tag->tag = strdup(p); + *s = '='; + tag->value = strdup(s+1); + } + tag->tag = NULL; + tag->value = NULL; + + return 0; +} + + +/* Function for stringifying name=value tag lists */ +char * edg_wll_TagListToString(edg_wll_TagValue *list) { + int len = 0; + edg_wll_TagValue *tag; + char *out, *p; + + if(NULL == list) return NULL; + + for(tag = list; tag->tag; tag++) { + len += strlen(tag->tag); + len += strlen(tag->value); + len += 2; + } + + out = malloc(len*sizeof(char) + 1); + if(NULL == out) return NULL; + + *out = '\0'; + p = out; + for(tag = list; tag->tag; tag++) { + if(p != out) { + strcat(p++, ","); + } + strcat(p, tag->tag); + p += strlen(tag->tag); + strcat(p++, "="); + strcat(p, tag->value); + p += strlen(tag->value); + } + + return out; +} + + /** - * edg_wll_ParseEvent - parse ULM message to internal structures + * Edg_wll_ParseEvent - parse ULM message to internal structures * Calls: calloc, free, sprintf, strdup * edg_wll_ULMNewParseTable, edg_wll_ULMFreeParseTable, edg_wll_ULMProcessParseTable, * edg_wll_ULMGetNameAt, my_edg_wll_ULMGetValueAt, edg_wll_ULMDateToTimeval (edg_wll_ULMDateToDouble), @@ -304,7 +376,8 @@ for my $t (sort { $event->{order}->{$a} <=> $event->{order}->{$b} } gen "\t\t".toString $f "event->$tl.$fn", "$fn\_str"; gen "\n"; } elsif ($ULMasString{$f->{type}}) { - gen "\t\tchar \*$fn\_str = ".$f->getType()."ToString(event->$tl.$fn);\n"; + #gen "\t\tchar \*$fn\_str = ".$f->getType()."ToString(event->$tl.$fn);\n"; + gen "\t\t". $f->toString("event->$tl.$fn","char \*$fn\_str",)."\n"; $free .= "free($fn\_str); "; } } diff --git a/org.glite.lb.common/src/status.c.T b/org.glite.lb.common/src/status.c.T index b412633..3a59a82 100644 --- a/org.glite.lb.common/src/status.c.T +++ b/org.glite.lb.common/src/status.c.T @@ -36,6 +36,7 @@ static const struct timeval null_timeval = {0,0}; gen qq{$sep}; @@@} +extern void edg_wll_FreeTagList(edg_wll_TagValue *); void edg_wll_FreeStatus(edg_wll_JobStat *stat) { @@ -65,10 +66,11 @@ void edg_wll_FreeStatus(edg_wll_JobStat *stat) } if ($ft eq 'taglist') { gen "\tif (stat->$_ != NULL ) {\n"; - gen "\t\tfor (i=0; stat->$_\[i].tag; i++) {\n"; - gen "\t\t\tfree(stat->$_\[i].tag);\n"; - gen "\t\t\tfree(stat->$_\[i].value);\n"; - gen "\t\t}\n"; + #gen "\t\tfor (i=0; stat->$_\[i].tag; i++) {\n"; + #gen "\t\t\tfree(stat->$_\[i].tag);\n"; + #gen "\t\t\tfree(stat->$_\[i].value);\n"; + #gen "\t\t}\n"; + gen "\t\tedg_wll_FreeTagList(stat->$_);\n"; gen "\t\tfree(stat->$_);\n"; gen "\t}\n"; } @@ -136,17 +138,7 @@ edg_wll_JobStat *edg_wll_CpyStatus(const edg_wll_JobStat *src, edg_wll_JobStat * gen "\tdest->$_ = src->$_;\n"; } elsif ($ft eq 'taglist') { - gen qq{ -! if (src->$_ != NULL) \{ -! for (i=0; src->$_\[i].tag; i++); -! dest->$_ = malloc(sizeof(*src->$_)*(i+1)); -! for (i=0; src->$_\[i].tag; i++) \{ -! dest->$_\[i].tag = strdup(src->$_\[i].tag); -! dest->$_\[i].value = strdup(src->$_\[i].value); -! \} -! dest->$_\[i].tag = NULL; -! \} - }; + gen "\tdest->$_ = edg_wll_CopyTagList(src->$_);\n"; } elsif ($ft eq 'cclassad') { gen "\tif ( src->$_ != NULL )\n"; diff --git a/org.glite.lb.common/src/xml_conversions.c b/org.glite.lb.common/src/xml_conversions.c index 0c022cb..fec92e6 100644 --- a/org.glite.lb.common/src/xml_conversions.c +++ b/org.glite.lb.common/src/xml_conversions.c @@ -28,6 +28,7 @@ limitations under the License. #include "jobstat.h" +extern char *edg_wll_TagListToString(edg_wll_TagValue *); static const struct timeval null_timeval = {0,0}; @@ -448,7 +449,17 @@ void edg_wll_add_intlist_to_XMLBody(char **body, const int *toAdd, const char *t } -void edg_wll_add_taglist_to_XMLBody(char **body, const edg_wll_TagValue *toAdd, const char *tag, const char *subTag, const char *subTag2, const char *indent, const char *null) +void edg_wll_add_taglist_to_XMLBody(char **body, const edg_wll_TagValue *toAdd, const char *tag, const edg_wll_TagValue *null) +{ + char *s_taglist; + + s_taglist = edg_wll_TagListToString(toAdd); + edg_wll_add_string_to_XMLBody(body, s_taglist, tag, NULL); + free(s_taglist); +} + + +void edg_wll_add_usertag_to_XMLBody(char **body, const edg_wll_TagValue *toAdd, const char *tag, const char *subTag, const char *subTag2, const char *indent, const char *null) { char *pomA, *pomB, *newBody; char **list = NULL; @@ -746,6 +757,17 @@ void *edg_wll_from_string_to_cclassad(edg_wll_XML_ctx *XMLCtx) return (NULL); } +edg_wll_TagValue *edg_wll_from_string_to_taglist(edg_wll_XML_ctx *XMLCtx) +{ + char *s, *out = NULL; + + s = glite_lbu_UnescapeXML((const char*) XMLCtx->char_buf); + if(s) { + edg_wll_TagListParse(s, &out); + } + + return out; +} /************************************************************************/ /* various conversion functions */ diff --git a/org.glite.lb.logger/src/interlogd.c b/org.glite.lb.logger/src/interlogd.c index 17d1046..9ffeed6 100644 --- a/org.glite.lb.logger/src/interlogd.c +++ b/org.glite.lb.logger/src/interlogd.c @@ -512,6 +512,10 @@ main (int argc, char **argv) /* get credentials */ if (CAcert_dir) setenv("X509_CERT_DIR", CAcert_dir, 1); + if(edg_wll_gss_initialize()) { + glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_FATAL, "Failed to initialize GSS."); + exit(EXIT_FAILURE); + } ret = edg_wll_gss_watch_creds(cert_file,&cert_mtime); if (ret < 0) glite_common_log(LOG_CATEGORY_SECURITY,LOG_PRIORITY_WARN,"edg_wll_gss_watch_creds failed, unable to access credentials\n"); @@ -528,13 +532,19 @@ main (int argc, char **argv) if (ret == EDG_WLL_GSS_ERROR_GSS) edg_wll_gss_get_error(&gss_stat, "edg_wll_gss_acquire_cred_gsi()", &gss_err); - glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_FATAL, "Failed to load GSI credential: %s, exiting.", + glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_FATAL, "Failed to load GSI credential: %s", (gss_err) ? gss_err : "edg_wll_gss_acquire_cred_gsi() failed"); if (gss_err) free(gss_err); - exit(EXIT_FAILURE); + if(gss_stat.minor_status != 0) { + exit(EXIT_FAILURE); + } else { + glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_WARN, "Continuing unauthenticated (yet)."); + } + } + if(cred_handle && cred_handle->creds) { + glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_INFO, "Using certificate %s", cred_handle->creds->name); } - glite_common_log(LOG_CATEGORY_SECURITY, LOG_PRIORITY_INFO, "Using certificate %s", cred_handle->creds->name); /* parse config, initialize plugins */ glite_common_log(LOG_CATEGORY_CONTROL, LOG_PRIORITY_INFO, "Initializing plugins:\n"); diff --git a/org.glite.lb.types/Makefile b/org.glite.lb.types/Makefile index 7f42572..6b94101 100644 --- a/org.glite.lb.types/Makefile +++ b/org.glite.lb.types/Makefile @@ -3,10 +3,13 @@ top_srcdir=. -include Makefile.inc +globalprefix=glite +lbprefix=lb PM=StructField.pm MultiStruct.pm T=events.T status.T types.T SCRIPTS=at3 check_version.pl +HDRS=lb_types.h default: compile @@ -25,6 +28,7 @@ install: compile done install -m 755 ${top_srcdir}/at3.in ${DESTDIR}${PREFIX}${prefix}/sbin/glite-lb-at3 install -m 755 ${top_srcdir}/check_version.pl ${DESTDIR}${PREFIX}${prefix}/sbin/glite-lb-check_version.pl + (cd ${top_srcdir}/interface && install -m 644 ${HDRS} ${DESTDIR}${PREFIX}${prefix}/include/${globalprefix}/${lbprefix}) clean: diff --git a/org.glite.lb.types/events.T b/org.glite.lb.types/events.T index 4c5d6f0..fc9ad19 100644 --- a/org.glite.lb.types/events.T +++ b/org.glite.lb.types/events.T @@ -251,10 +251,51 @@ @flesh PBS +@type PBSInternalStateChange Change of internal PBS job state + int oldstate + _null_ -1 + int oldsubstate + _null_ -1 + int newstate + _null_ -1 + int newsubstate + _null_ -1 + + +@type PBSTransfer Start, success, or failure of job transfer to another component. + logsrc destination Destination where the job is being transfered to. + string dest_instance Service (instance) that takes over control of the job. + _optional_ + int result Result code of the transfer attempt (START, OK, REFUSED or FAIL). + _code_ START The sending component has started or is about to start the transfer. + _code_ OK The job was sent successfully. + _code_ REFUSED The job was refused by the other component. + _code_ FAIL The transfer failed for other reason than explicit refusal (eg. network timeout). + string reason Detailed description of the transfer, especially reason of failure. + _optional_ + string dest_jobid Job id as assigned by the receiving software component. + _optional_ + +@type PBSAccepted Accepting job (successful counterpart to Transfer). + logsrc from The software component the job was received from. + string from_instance Instance of the component the job was received from. + _optional_ + string local_jobid New job id as assigned by the receiving component. + _optional_ + +@type PBSRefused Refusing job (unsuccessful counterpart to Transfer). + logsrc from The software component that tried to send the job. + string from_instance Instance of the component that tried to send the job. + _optional_ + string reason Description of the reason why the job was refused. + _optional_ + @type PBSQueued Job enqued string queue Queue name - string owner Job owner string name Job name + string owner Job owner + +@type PBSDequeued Job dequeued @type PBSMatch Scheduler created exec host string dest_host Aka exec host @@ -262,6 +303,8 @@ @type PBSPending Scheduler is not able to find exec host, or some error occured string reason Reasons of job pendation or errors +@type PBSWaiting Job is waiting for some condition + @type PBSRun Job attempted to be run by the logging component string scheduler Scheduler ID _optional_ @@ -272,20 +315,18 @@ @type PBSRerun Job rerun requested +@type PBSAbort Job aborted + @type PBSDone Job terminated int exit_status Exit status _optional_ Bypass need of 'null value' -@type PBSDequeued Job dequeued @type PBSResourceUsage Resources requested/consumed int usage Type of record _code_ REQUESTED Requested value _code_ USED Consumed quantity - string name Name of resource - double quantity The quantity - _optional_ Bypass need of 'null value' - string unit Units (sec, kB, etc.) + taglist resources List of resources @type PBSError Any error occured string error_desc Error reason diff --git a/org.glite.lb.types/interface/lb_types.h b/org.glite.lb.types/interface/lb_types.h new file mode 100644 index 0000000..07e433b --- /dev/null +++ b/org.glite.lb.types/interface/lb_types.h @@ -0,0 +1,48 @@ +#ifndef GLITE_LB_TYPES_H +#define GLITE_LB_TYPES_H + +/** + * \file lb_types.h + * \brief L&B API common types and related definitions + */ + + +#ident "$Header$" +/* +Copyright (c) Members of the EGEE Collaboration. 2004-2010. +See http://www.eu-egee.org/partners for details on the copyright holders. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + + + +#ifdef __cplusplus +extern "C" { +#endif + +/*! + * + * Pair tag = value. + */ +typedef struct _edg_wll_TagValue { + char * tag; /**< User-specified information tag */ + char * value; /**< Value assigned to user-specified information tag */ +} edg_wll_TagValue; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/org.glite.lb.types/status.T b/org.glite.lb.types/status.T index 640b1bb..f774008 100644 --- a/org.glite.lb.types/status.T +++ b/org.glite.lb.types/status.T @@ -110,6 +110,7 @@ string history Job history. _pad_ 55 string pbs_state Job state which would probably return PBS qstat (Q/R/C/....) +int pbs_substate Job substate string pbs_queue Name of queue in which is job queued string pbs_owner Owner of job string pbs_name Name of job @@ -117,7 +118,8 @@ string pbs_reason Glued reasons/errors leading to pending events string pbs_scheduler Name of pbs scheduler string pbs_dest_host Hostname of node where job is running int pbs_pid PID of running job -string pbs_resource_usage Glued resource usage +taglist pbs_resource_requested Resources requested +taglist pbs_resource_usage Resource usage int pbs_exit_status Job exit status string pbs_error_desc Glued error descriptions from error events diff --git a/org.glite.lb.types/types.T b/org.glite.lb.types/types.T index 7b727f5..eecdb3c 100644 --- a/org.glite.lb.types/types.T +++ b/org.glite.lb.types/types.T @@ -90,11 +90,13 @@ logsrc=>'qq{$dst = edg_wll_SourceToString($src);}', cclassad=>'qq{$dst = NULL;}', # strlist, intlist, stslist are used only in consumer API, they don't need toString method + taglist=>'qq{$dst = edg_wll_TagListToString($src);}', } ); %ULMasString = ( - logsrc=>1 + logsrc=>1, + taglist=>1 ); %fromString = ( @@ -111,6 +113,7 @@ # level=>'qq{$dst = edg_wll_StringToLevel($src);}', logsrc=>'qq{$dst = edg_wll_StringToSource($src);}', # strlist, intlist, stslist are used only in consumer API, they don't need fromString method + taglist=>'qq{edg_wll_TagListParse($src, &$dst);}', } ); @@ -150,6 +153,7 @@ logsrc=>'"($a) == ($b)"', timeval=>'"($a).tv_sec == ($b).tv_sec && ($a).tv_usec == ($b).tv_usec"', cclassad=>'"($a == $b)"', + taglist=>'"($a == $b)"', } ); @@ -166,5 +170,6 @@ notifid=>'"%s"', logsrc=>'"%s"', timeval=>'"%s"', + taglist=>'"%s"', } ); diff --git a/org.glite.lb.ws-interface/src/LBTypes.xml.T b/org.glite.lb.ws-interface/src/LBTypes.xml.T index 610e123..7df25c7 100644 --- a/org.glite.lb.ws-interface/src/LBTypes.xml.T +++ b/org.glite.lb.ws-interface/src/LBTypes.xml.T @@ -184,7 +184,13 @@ my $f = selectField $event $_; my $fn = $f->{name}; my $ftn = $f->getType; + my $type = $f->{type}; + my $list = 'no'; + if ($main::baseTypes{$type}) { + $ftn = eval $main::types{wsdl}->{$main::baseTypes{$type}}; + $list = 'yes' + } $fn = $1.ucfirst $2 while $fn =~ /([[:alpha:]]*)_([[:alpha:]_]*)/; $ftn = $tn . '_' . $fn if ($f->{codes}); @@ -193,7 +199,7 @@ my $comment = getComment $f; my $opt = $f->{optional} ? 'yes' : 'no'; - gen qq{\t\t\t\t$comment + gen qq{\t\t\t\t$comment }; } gen "\n\n"; -- 1.8.2.3