From 0a9cdce08e0ba1ea4abfd4c268b6993a098449c3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Posp=C3=AD=C5=A1il?= Date: Mon, 3 Apr 2006 07:15:31 +0000 Subject: [PATCH] lb_plugin now reads attributes from JDL.. --- org.glite.lb.server/Makefile | 2 +- org.glite.lb.server/src/lb_plugin.c | 96 +++++++++++++++++++++++++++++++++++-- 2 files changed, 92 insertions(+), 6 deletions(-) diff --git a/org.glite.lb.server/Makefile b/org.glite.lb.server/Makefile index 110d9ec..af17563 100644 --- a/org.glite.lb.server/Makefile +++ b/org.glite.lb.server/Makefile @@ -132,7 +132,7 @@ EXT_LIBS:= \ SRVBONES_LIB:= -L${stagedir}/lib -lglite_lb_server_bones COMMON_LIBS:= -L${stagedir}/lib -lglite_lb_common_${nothrflavour} -lglite_security_gss_${nothrflavour} PLUGIN_LIBS:= -L${stagedir}/lib -lglite_lb_common_${nothrflavour}\ - ${expatlib} -lexpat\ + ${classadslib} ${expatlib} -lexpat\ PLUGIN_LOBJS:= lb_plugin.lo jobstat_supp.lo process_event.lo lbs_db_supp.lo diff --git a/org.glite.lb.server/src/lb_plugin.c b/org.glite.lb.server/src/lb_plugin.c index d5925f7..546212c 100644 --- a/org.glite.lb.server/src/lb_plugin.c +++ b/org.glite.lb.server/src/lb_plugin.c @@ -7,6 +7,8 @@ #include #include +#include + #include "glite/lb/context.h" #include "glite/lb/jobstat.h" @@ -221,12 +223,96 @@ static int lb_query(void *fpctx,void *handle,const char *attr,glite_jp_attrval_t av[0].value = edg_wlc_JobIdUnparse(h->status.jobId); av[0].size = -1; av[0].timestamp = h->status.lastUpdateTime.tv_sec; - } else if (strcmp(attr, GLITE_JP_LB_VO) == 0 || - strcmp(attr, GLITE_JP_LB_aTag) == 0 || + } else if (strcmp(attr, GLITE_JP_LB_VO) == 0) { + av = calloc(2, sizeof(glite_jp_attrval_t)); + av[0].name = strdup(attr); + if (h->events) { + i = 0; + while (h->events[i]) { + if (h->events[i]->type == EDG_WLL_EVENT_REGJOB) { + struct cclassad *ad; + char *string_vo = NULL; + + ad = cclassad_create(h->events[i]->regJob.jdl); + if (ad) { + if (!cclassad_evaluate_to_string(ad, "VirtualOrganisation", &string_vo)) + string_vo = NULL; + + av[0].value = check_strdup(string_vo); + cclassad_delete(ad); + if (string_vo) free(string_vo); + } + av[0].timestamp = h->events[i]->any.timestamp.tv_sec; + break; + } + i++; + } + } + if (!av[0].value) { + av[0].value = "UNKNOWN"; + av[0].timestamp = h->status.lastUpdateTime.tv_sec; + } + } else if (strcmp(attr, GLITE_JP_LB_eNodes) == 0) { + av = calloc(2, sizeof(glite_jp_attrval_t)); + av[0].name = strdup(attr); + if (h->events) { + i = 0; + while (h->events[i]) { + if (h->events[i]->type == EDG_WLL_EVENT_REGJOB) { + struct cclassad *ad; + char *string_nodes = NULL; + + ad = cclassad_create(h->events[i]->regJob.jdl); + if (ad) { + if (!cclassad_evaluate_to_string(ad, "max_nodes_running", &string_nodes)) + string_nodes = NULL; + + av[0].value = check_strdup(string_nodes); + cclassad_delete(ad); + if (string_nodes) free(string_nodes); + } + av[0].timestamp = h->events[i]->any.timestamp.tv_sec; + break; + } + i++; + } + } + if (!av[0].value) { + av[0].value = "UNKNOWN"; + av[0].timestamp = h->status.lastUpdateTime.tv_sec; + } + } else if (strcmp(attr, GLITE_JP_LB_eProc) == 0) { + av = calloc(2, sizeof(glite_jp_attrval_t)); + av[0].name = strdup(attr); + if (h->events) { + i = 0; + while (h->events[i]) { + if (h->events[i]->type == EDG_WLL_EVENT_REGJOB) { + struct cclassad *ad; + char *string_nodes = NULL; + + ad = cclassad_create(h->events[i]->regJob.jdl); + if (ad) { + if (!cclassad_evaluate_to_string(ad, "NodeNumber", &string_nodes)) + string_nodes = NULL; + + av[0].value = check_strdup(string_nodes); + cclassad_delete(ad); + if (string_nodes) free(string_nodes); + } + av[0].timestamp = h->events[i]->any.timestamp.tv_sec; + break; + } + i++; + } + } + if (!av[0].value) { + av[0].value = "UNKNOWN"; + av[0].timestamp = h->status.lastUpdateTime.tv_sec; + } + } else if (strcmp(attr, GLITE_JP_LB_aTag) == 0 || strcmp(attr, GLITE_JP_LB_rQType) == 0 || - strcmp(attr, GLITE_JP_LB_eDuration) == 0 || - strcmp(attr, GLITE_JP_LB_eNodes) == 0 || - strcmp(attr, GLITE_JP_LB_eProc) == 0) { + strcmp(attr, GLITE_JP_LB_eDuration) == 0) { /* have to be retrieved from JDL */ /* av = calloc(2, sizeof(glite_jp_attrval_t)); -- 1.8.2.3