case EDG_WLL_QUERY_ATTR_LOCATION:
case EDG_WLL_QUERY_ATTR_DESTINATION:
case EDG_WLL_QUERY_ATTR_USERTAG:
+ if ( !(cond->value.c = strdup(tmps)) )
+ return 0;
+ break;
+
case EDG_WLL_QUERY_ATTR_JDL_ATTR:
if ( !(cond->value.c = strdup(tmps)) )
return 0;
+ if ( !(s = get_attr_value(s, tmps, 500)) ) return NULL;
+ if ( tmps[0] == '\0' )
+ {
+ fprintf(stderr,"%s: you need to specify attribute name\n", myname);
+ return NULL;
+ }
+ if ( !(cond->attr_id.tag = strdup(tmps)) )
+ return 0;
break;
case EDG_WLL_QUERY_ATTR_STATUS:
}
switch (prec->attr) {
case EDG_WLL_QUERY_ATTR_USERTAG:
+ case EDG_WLL_QUERY_ATTR_JDL_ATTR:
free(prec->attr_id.tag);
case EDG_WLL_QUERY_ATTR_OWNER:
case EDG_WLL_QUERY_ATTR_LOCATION:
case EDG_WLL_QUERY_ATTR_DESTINATION:
case EDG_WLL_QUERY_ATTR_HOST:
case EDG_WLL_QUERY_ATTR_INSTANCE:
- case EDG_WLL_QUERY_ATTR_JDL_ATTR:
if ( prec->value.c ) free(prec->value.c);
break;
case EDG_WLL_QUERY_ATTR_JOBID:
edg_wll_add_tagged_string_to_XMLBody(&pomValue, conditions[row][i].value.c, "usertag", conditions[row][i].attr_id.tag, "name", NULL);
break;
case EDG_WLL_QUERY_ATTR_JDL_ATTR:
- edg_wll_add_string_to_XMLBody(&pomValue, conditions[row][i].value.c, "jdl", NULL);
+ edg_wll_add_tagged_string_to_XMLBody(&pomValue, conditions[row][i].value.c, "jdl", conditions[row][i].attr_id.tag, "name", NULL);
break;
case EDG_WLL_QUERY_ATTR_STATEENTERTIME:
if (conditions[row][i].op == EDG_WLL_QUERY_OP_WITHIN) {
case EDG_WLL_QUERY_ATTR_USERTAG:
edg_wll_add_tagged_string_to_XMLBody(&pomValue, event_conditions[row][i].value.c, "usertag", event_conditions[row][i].attr_id.tag, "name", NULL);
break;
+ case EDG_WLL_QUERY_ATTR_JDL_ATTR:
+ edg_wll_add_tagged_string_to_XMLBody(&pomValue, event_conditions[row][i].value.c, "jdl", event_conditions[row][i].attr_id.tag, "name", NULL);
+ break;
default:
free(pomValue);
return -1;
${LB_COMMON_LIB} \
${LB_UTILS_DB_LIB} \
${GSOAP_LIB} \
- ${EXT_LIBS}
+ ${EXT_LIBS} \
+ ${classadslib}
else
BKSERVER_OBJS:= ${BKSERVER_BASE_OBJS}
${LB_COMMON_LIB} \
${LB_UTILS_DB_LIB} \
-lglite_security_gss_${nothrflavour} \
- ${EXT_LIBS}
+ ${EXT_LIBS} \
+ ${classadslib}
endif
INDEX_OBJS:= index.o index_parse.o jobstat_supp.o openserver.o \
test_query_events: ${query_events_objs}
${LINKXX} -o $@ ${query_events_objs} \
- ${TEST_LIBS} ${LB_COMMON_LIB}
+ ${TEST_LIBS} ${LB_COMMON_LIB} ${classadslib}
# ${TEST_LIBS} ${COMMON_LIBS} ${EXT_LIBS}
test.soapconv: test_soap_conv
switch (r1->attr) {
case EDG_WLL_QUERY_ATTR_USERTAG:
return strcasecmp(r1->attr_id.tag,r2->attr_id.tag);
+ case EDG_WLL_QUERY_ATTR_JDL_ATTR:
+ return strcasecmp(r1->attr_id.tag,r2->attr_id.tag);
case EDG_WLL_QUERY_ATTR_TIME:
return r1->attr_id.state != r2->attr_id.state;
default:
case EDG_WLL_QUERY_ATTR_LASTUPDATETIME:
glite_lbu_TimeToDB(stat->lastUpdateTime.tv_sec, &data);
break;
- case EDG_WLL_QUERY_ATTR_JDL_ATTR: // XXX: It's not clear how this is supposed to work
+ case EDG_WLL_QUERY_ATTR_JDL_ATTR: // This is not the correct way to handle jdl searches.
+ /* There's no way to index individual JDL attributes */
if (stat->jdl)
- trio_asprintf(&data, "'%|Ss'", stat->destination);
+ trio_asprintf(&data, "'%|Ss'", stat->jdl);
else data = strdup("''");
break;
/* case EDG_WLL_QUERY_ATTR_STATEENTERTIME: /// XXX: Which way of handling this is correct?
if (attr[0] && strcmp(attr[0],"state")) { unexp() break;}
XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr_id.state = edg_wll_StringToStat(attr[1]);
}
+ if ( (i+1) == EDG_WLL_QUERY_ATTR_JDL_ATTR) {
+ if (!attr[0] || !attr[1]) { unexp() break;}
+ if (strcmp(attr[0],"name")) { unexp() break;}
+ XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr_id.tag = strdup(attr[1]);
+ }
XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].attr = i+1;
}
break;
case EDG_WLL_QUERY_ATTR_LOCATION:
case EDG_WLL_QUERY_ATTR_DESTINATION:
case EDG_WLL_QUERY_ATTR_USERTAG:
+ case EDG_WLL_QUERY_ATTR_JDL_ATTR:
XMLCtx->job_conditions[XMLCtx->row][XMLCtx->position].value.c =
edg_wll_from_string_to_string(XMLCtx);
break;
case EDG_WLL_QUERY_ATTR_HOST:
case EDG_WLL_QUERY_ATTR_INSTANCE:
case EDG_WLL_QUERY_ATTR_USERTAG:
+ case EDG_WLL_QUERY_ATTR_JDL_ATTR:
XMLCtx->event_conditions[XMLCtx->row2][XMLCtx->position2].value.c =
edg_wll_from_string_to_string(XMLCtx);
break;
ctx->job_index[i][j].attr_id.tag,
"name", NULL);
+ if (ctx->job_index[i][j].attr == EDG_WLL_QUERY_ATTR_JDL_ATTR)
+ edg_wll_add_string_to_XMLBody(&pomA,
+ ctx->job_index[i][j].attr_id.tag,
+ "name", NULL);
+
asprintf(&pomB, "%s\t\t%s\r\n",pomA,"</QueryRec>");
free(pomA);
pomA = pomB;
#include <expat.h>
+#include <cclassad.h>
+
#include "glite/jobid/strmd5.h"
#include "glite/lbu/trio.h"
#define FL_SEL_TAGS (1<<1)
#define FL_SEL_JOB (1<<2)
#define FL_FILTER (1<<3) // DB query result needs further filtering
+#define FL_SEL_JDL (1<<4) // Retrieve classads while filtering
static int check_event_query_index(edg_wll_Context,const edg_wll_QueryRec **,const edg_wll_QueryRec **);
}
// if some condition hits unindexed column or states of matching jobs wanted
+
if ((where_flags & FL_FILTER) || !(flags & EDG_WLL_STAT_NO_STATES)) {
- if ( edg_wll_JobStatus(ctx, jobs_out[i], flags, &states_out[i]) )
+ if ( edg_wll_JobStatus(ctx, jobs_out[i], (where_flags & FL_SEL_JDL)?(flags|EDG_WLL_STAT_CLASSADS):flags, &states_out[i]) )
{
edg_wlc_JobIdFree(jobs_out[i]);
if (edg_wll_Error(ctx,NULL,NULL) == EPERM) eperm = 1;
if ( !is_indexed(&(jc[m][n]), ctx)
|| !(cname = edg_wll_QueryRecToColumn(&(jc[m][n]))) )
{
- *where_flags |= FL_FILTER;
+ *where_flags |= FL_FILTER | FL_SEL_JDL;
break;
}
}
break;
case EDG_WLL_QUERY_ATTR_JDL_ATTR:
- if ( stat->destination )
- {
- if ( !strcmp(conds[i][j].value.c, stat->jdl) ) { // XXX: actually interested in one attribute only.
- if ( conds[i][j].op == EDG_WLL_QUERY_OP_EQUAL ) goto or_satisfied;
- } else if ( conds[i][j].op == EDG_WLL_QUERY_OP_UNEQUAL ) goto or_satisfied;
+
+ if (stat->jdl != NULL) {
+ struct cclassad *ad = NULL;
+ char *extr_val = NULL;
+
+ // Jobs that do not have a JDL come with blabla:
+ if (!strcmp(stat->jdl,"blabla")) break;
+
+ ad = cclassad_create(stat->jdl);
+ if (ad) {
+ if (!cclassad_evaluate_to_string(ad, conds[i][j].attr_id.tag, &extr_val)) // Extract attribute value
+ extr_val = NULL;
+ cclassad_delete(ad);
+ }
+ if (extr_val) {
+
+ if ( !strcmp(conds[i][j].value.c, extr_val) ) {
+ if ( conds[i][j].op == EDG_WLL_QUERY_OP_EQUAL ) goto or_satisfied;
+ else if ( conds[i][j].op == EDG_WLL_QUERY_OP_UNEQUAL ) goto or_satisfied;
+ }
+ }
}
break;
case EDG_WLL_QUERY_ATTR_STATEENTERTIME: