From 691156ae73bbfe19195ca0d91a374603a6ea4b93 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Milo=C5=A1=20Mula=C4=8D?= Date: Mon, 3 Nov 2008 14:50:44 +0000 Subject: [PATCH] implementation of change operator for notification - working for status change only --- org.glite.lb.common/src/xml_parse.c.T | 11 ++++- org.glite.lb.server/interface/query.h | 2 +- org.glite.lb.server/src/lb_xml_parse.c.T | 2 +- org.glite.lb.server/src/notif_match.c | 8 ++-- org.glite.lb.server/src/query.c | 74 +------------------------------- 5 files changed, 17 insertions(+), 80 deletions(-) diff --git a/org.glite.lb.common/src/xml_parse.c.T b/org.glite.lb.common/src/xml_parse.c.T index 6a3dddc..7c8e674 100644 --- a/org.glite.lb.common/src/xml_parse.c.T +++ b/org.glite.lb.common/src/xml_parse.c.T @@ -2462,7 +2462,15 @@ int edg_wll_JobQueryRecToXML( "NULL", "owner", NULL); break; case EDG_WLL_QUERY_ATTR_STATUS: - edg_wll_add_edg_wll_JobStatCode_to_XMLBody(&pomValue, conditions[row][i].value.i, "status", EDG_WLL_JOB_UNDEF); + if (conditions[row][i].op != EDG_WLL_QUERY_OP_CHANGED) + edg_wll_add_edg_wll_JobStatCode_to_XMLBody(&pomValue, conditions[row][i].value.i, "status", EDG_WLL_JOB_UNDEF); + else { + char *newBody; + + asprintf(&newBody,"%s\t\t\t\r\n", pomValue); + free(pomValue); + pomValue = newBody; + } if (conditions[row][i].op == EDG_WLL_QUERY_OP_WITHIN) edg_wll_add_edg_wll_JobStatCode_to_XMLBody(&pomValue, conditions[row][i].value2.i, "status", EDG_WLL_JOB_UNDEF); break; @@ -2524,6 +2532,7 @@ int edg_wll_JobQueryRecToXML( case EDG_WLL_QUERY_OP_GREATER: pomOp = "greater"; break; case EDG_WLL_QUERY_OP_WITHIN: pomOp = "within"; break; case EDG_WLL_QUERY_OP_UNEQUAL: pomOp = "unequal"; break; + case EDG_WLL_QUERY_OP_CHANGED: pomOp = "changed"; break; default: return -1; } diff --git a/org.glite.lb.server/interface/query.h b/org.glite.lb.server/interface/query.h index 3b0e1b8..e93a4a2 100644 --- a/org.glite.lb.server/interface/query.h +++ b/org.glite.lb.server/interface/query.h @@ -11,7 +11,7 @@ int convert_event_head(edg_wll_Context,char **,edg_wll_Event *); int check_strict_jobid(edg_wll_Context, glite_jobid_const_t); -int match_status(edg_wll_Context, const edg_wll_JobStat *stat,const edg_wll_QueryRec **conditions); +int match_status(edg_wll_Context, const edg_wll_JobStat *oldstat, const edg_wll_JobStat *stat,const edg_wll_QueryRec **conditions); int check_job_query_index(edg_wll_Context, const edg_wll_QueryRec **); #define NOTIF_ALL_JOBS "all_jobs" diff --git a/org.glite.lb.server/src/lb_xml_parse.c.T b/org.glite.lb.server/src/lb_xml_parse.c.T index 6eabd2d..2be2079 100644 --- a/org.glite.lb.server/src/lb_xml_parse.c.T +++ b/org.glite.lb.server/src/lb_xml_parse.c.T @@ -47,7 +47,7 @@ #define USERJOBS_END "\r\n" -static char *ops[] = { "equal","less","greater","within","unequal" }, +static char *ops[] = { "equal","less","greater","within","unequal","changed" }, *attrs[] = { "jobid","owner","status","location","destination", "donecode","usertag","time","level","host","source", "instance","type","chkpt_tag", "resubmitted", "parent_job", diff --git a/org.glite.lb.server/src/notif_match.c b/org.glite.lb.server/src/notif_match.c index 4ab6a6a..192b6b3 100644 --- a/org.glite.lb.server/src/notif_match.c +++ b/org.glite.lb.server/src/notif_match.c @@ -19,7 +19,7 @@ #include "db_supp.h" #include "index.h" -static int notif_match_conditions(edg_wll_Context,const edg_wll_JobStat *,const char *); +static int notif_match_conditions(edg_wll_Context,const edg_wll_JobStat *,const edg_wll_JobStat *,const char *); static int notif_check_acl(edg_wll_Context,const edg_wll_JobStat *,const char *); extern int debug; @@ -97,7 +97,7 @@ int edg_wll_NotifMatch(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, cons if (debug) fprintf(stderr,"[%d] NOTIFY:%s expired at %s UTC\n", getpid(),jobc[0],asctime(gmtime(&expires))); } - else if (notif_match_conditions(ctx,stat,jobc[4]) && + else if (notif_match_conditions(ctx,oldstat,stat,jobc[4]) && notif_check_acl(ctx,stat,jobc[3])) { char *dest, *aux; @@ -171,7 +171,7 @@ int edg_wll_NotifExpired(edg_wll_Context ctx,const char *notif) } -static int notif_match_conditions(edg_wll_Context ctx,const edg_wll_JobStat *stat,const char *cond) +static int notif_match_conditions(edg_wll_Context ctx,const edg_wll_JobStat *oldstat, const edg_wll_JobStat *stat,const char *cond) { edg_wll_QueryRec **c,**p; int match,i; @@ -184,7 +184,7 @@ static int notif_match_conditions(edg_wll_Context ctx,const edg_wll_JobStat *sta return 1; } - match = match_status(ctx,stat,(const edg_wll_QueryRec **) c); + match = match_status(ctx,oldstat,stat,(const edg_wll_QueryRec **) c); if ( c ) { for (p = c; *p; p++) { diff --git a/org.glite.lb.server/src/query.c b/org.glite.lb.server/src/query.c index 0ecf9ae..6459c02 100644 --- a/org.glite.lb.server/src/query.c +++ b/org.glite.lb.server/src/query.c @@ -1440,8 +1440,6 @@ int match_status(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, const edg_ if ( conds[i][j].value.i == stat->resubmitted ) goto or_satisfied; } else if ( conds[i][j].op == EDG_WLL_QUERY_OP_UNEQUAL ) { if ( conds[i][j].value.i != stat->resubmitted ) goto or_satisfied; - } else if ( conds[i][j].op == EDG_WLL_QUERY_OP_CHANGED ) { - if ( oldstat->resubmitted != stat->resubmitted ) goto or_satisfied; } break; case EDG_WLL_QUERY_ATTR_DONECODE: @@ -1463,9 +1461,6 @@ int match_status(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, const edg_ if ( conds[i][j].value.i <= stat->done_code && conds[i][j].value2.i >= stat->done_code ) goto or_satisfied; break; - case EDG_WLL_QUERY_OP_CHANGED: - if ( oldstat->done_code != stat->done_code ) goto or_satisfied; - break; } break; case EDG_WLL_QUERY_ATTR_EXITCODE: @@ -1487,9 +1482,6 @@ int match_status(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, const edg_ if ( conds[i][j].value.i <= stat->exit_code && conds[i][j].value2.i >= stat->exit_code ) goto or_satisfied; break; - case EDG_WLL_QUERY_OP_CHANGED: - if ( oldstat->exit_code != stat->exit_code ) goto or_satisfied; - break; } break; case EDG_WLL_QUERY_ATTR_OWNER: @@ -1502,8 +1494,6 @@ int match_status(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, const edg_ if (edg_wll_gss_equal_subj(ctx->peerName, stat->owner) ) { 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; - } else if ( conds[i][j].op == EDG_WLL_QUERY_OP_CHANGED ) { - if (!edg_wll_gss_equal_subj(oldstat->owner, stat->owner) ) goto or_satisfied; } } break; @@ -1514,12 +1504,6 @@ int match_status(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, const edg_ 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 ( conds[i][j].op == EDG_WLL_QUERY_OP_CHANGED ) { - if ( (oldstat->location && !stat->location) || - (!oldstat->location && stat->location) ) goto or_satisfied; - if ( oldstat->location && stat->location && - strcmp(oldstat->location,stat->location) ) goto or_satisfied; - } break; case EDG_WLL_QUERY_ATTR_DESTINATION: if ( stat->destination ) @@ -1528,12 +1512,6 @@ int match_status(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, const edg_ 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 ( conds[i][j].op == EDG_WLL_QUERY_OP_CHANGED ) { - if ( (oldstat->destination && !stat->destination) || - (!oldstat->destination && stat->destination) ) goto or_satisfied; - if ( oldstat->destination && stat->destination && - strcmp(oldstat->destination,stat->destination) ) goto or_satisfied; - } case EDG_WLL_QUERY_ATTR_NETWORK_SERVER: if ( stat->network_server ) { @@ -1542,12 +1520,6 @@ int match_status(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, const edg_ } else if ( conds[i][j].op == EDG_WLL_QUERY_OP_UNEQUAL ) goto or_satisfied; } break; - if ( conds[i][j].op == EDG_WLL_QUERY_OP_CHANGED ) { - if ( (oldstat->network_server && !stat->network_server) || - (!oldstat->network_server && stat->network_server) ) goto or_satisfied; - if ( oldstat->network_server && stat->network_server && - strcmp(oldstat->network_server,stat->network_server) ) goto or_satisfied; - } case EDG_WLL_QUERY_ATTR_JOBID: if ( !stat->jobId ) break; @@ -1595,19 +1567,6 @@ int match_status(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, const edg_ } if ( !stat->user_tags[n].tag && conds[i][j].op == EDG_WLL_QUERY_OP_UNEQUAL ) goto or_satisfied; - if ( conds[i][j].op == EDG_WLL_QUERY_OP_CHANGED ) { - if ( (oldstat->user_tags && !stat->user_tags) || - (!oldstat->user_tags && stat->user_tags) ) goto or_satisfied; - if ( oldstat->user_tags && stat->user_tags ) { - for ( n = 0; stat->user_tags[n].tag; n++ ) - if ( !oldstat->user_tags[n].tag ) goto or_satisfied; - if ( strcmp(oldstat->user_tags[n].tag,stat->user_tags[n].tag) ) goto or_satisfied; - else { - if ( strcmp(oldstat->user_tags[n].value, stat->user_tags[n].value) ) goto or_satisfied; - } - } - } - break; case EDG_WLL_QUERY_ATTR_TIME: if ( !stat->stateEnterTimes || !stat->stateEnterTimes[1+conds[i][j].attr_id.state] ) @@ -1630,23 +1589,16 @@ int match_status(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, const edg_ if ( conds[i][j].value.t.tv_sec <= stat->stateEnterTimes[1+conds[i][j].attr_id.state] && conds[i][j].value2.t.tv_sec >= stat->stateEnterTimes[1+conds[i][j].attr_id.state] ) goto or_satisfied; break; - case EDG_WLL_QUERY_OP_CHANGED: - if ( oldstat->stateEnterTimes[1+conds[i][j].attr_id.state] != stat->stateEnterTimes[1+conds[i][j].attr_id.state] ) goto or_satisfied; - break; } break; case EDG_WLL_QUERY_ATTR_JDL_ATTR: - if ( conds[i][j].op == EDG_WLL_QUERY_OP_CHANGED ) { - if ( (oldstat->jdl && !stat->jdl) || - (!oldstat->jdl && stat->jdl) ) 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") && conds[i][j].op != EDG_WLL_QUERY_OP_CHANGED) break; + if (!strcmp(stat->jdl,"blabla")) break; ad = cclassad_create(stat->jdl); if (ad) { @@ -1661,24 +1613,6 @@ int match_status(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, const edg_ else if ( conds[i][j].op == EDG_WLL_QUERY_OP_UNEQUAL ) goto or_satisfied; } } - if ( conds[i][j].op == EDG_WLL_QUERY_OP_CHANGED ) { - struct cclassad *ad2 = NULL; - char *extr_val2 = NULL; - - // Jobs that do not have a JDL come with blabla: - if ( (!strcmp(stat->jdl,"blabla") && strcmp(oldstat->jdl,"blabla")) || - (strcmp(stat->jdl,"blabla") && !strcmp(oldstat->jdl,"blabla")) ) goto or_satisfied; - - ad2 = cclassad_create(oldstat->jdl); - if (ad2) { - if (!cclassad_evaluate_to_string(ad2, conds[i][j].attr_id.tag, &extr_val2)) // Extract attribute value - extr_val2 = NULL; - cclassad_delete(ad2); - } - if (extr_val2) { - if ( strcmp(extr_val, extr_val2) ) goto or_satisfied; - } - } } break; case EDG_WLL_QUERY_ATTR_STATEENTERTIME: @@ -1702,9 +1636,6 @@ int match_status(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, const edg_ if ( conds[i][j].value.t.tv_sec <= stat->stateEnterTime.tv_sec && conds[i][j].value2.t.tv_sec >= stat->stateEnterTime.tv_sec ) goto or_satisfied; break; - case EDG_WLL_QUERY_OP_CHANGED: - if ( oldstat->stateEnterTime.tv_sec != stat->stateEnterTime.tv_sec ) goto or_satisfied; - break; } case EDG_WLL_QUERY_ATTR_LASTUPDATETIME: if ( !stat->lastUpdateTime.tv_sec ) @@ -1727,9 +1658,6 @@ int match_status(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, const edg_ if ( conds[i][j].value.t.tv_sec <= stat->lastUpdateTime.tv_sec && conds[i][j].value2.t.tv_sec >= stat->lastUpdateTime.tv_sec ) goto or_satisfied; break; - case EDG_WLL_QUERY_OP_CHANGED: - if ( oldstat->lastUpdateTime.tv_sec != stat->lastUpdateTime.tv_sec ) goto or_satisfied; - break; } default: break; -- 1.8.2.3