new query operator CHANGED introduced
authorMiloš Mulač <mulac@civ.zcu.cz>
Wed, 29 Oct 2008 13:45:40 +0000 (13:45 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Wed, 29 Oct 2008 13:45:40 +0000 (13:45 +0000)
- validity checks not done yet
old status passed to NotifMatch
- implementation of CHANGED operator not done yet

org.glite.lb.common/interface/query_rec.h
org.glite.lb.server/src/db_store.c
org.glite.lb.server/src/jobstat.c
org.glite.lb.server/src/jobstat.h
org.glite.lb.server/src/lb_html.c
org.glite.lb.server/src/notif_match.c
org.glite.lb.server/src/ws_typemap.h
org.glite.lb.server/src/ws_typeref.c.T
org.glite.lb.ws-interface/src/LBTypes.xml.T

index 8a660d1..3498a01 100644 (file)
@@ -71,6 +71,8 @@ typedef enum _edg_wll_QueryOp{
        EDG_WLL_QUERY_OP_GREATER,       /**< attribute is less than the operand value \see _edg_wll_QueryRec */
        EDG_WLL_QUERY_OP_WITHIN,        /**< attribute is in given interval \see _edg_wll_QueryRec */
        EDG_WLL_QUERY_OP_UNEQUAL,       /**< attribute is not equal to the operand value \see _edg_wll_QueryRec */
+       EDG_WLL_QUERY_OP_CHANGED,       /**< attribute has changed from last check; supported only in notification matching 
+                                               \see _edg_wll_QueryRec */
 } edg_wll_QueryOp;
 
 
index 5ddf771..dde7ce4 100644 (file)
 
 
 extern int unset_proxy_flag(edg_wll_Context, edg_wlc_JobId);
-extern int edg_wll_NotifMatch(edg_wll_Context, const edg_wll_JobStat *);
+extern int edg_wll_NotifMatch(edg_wll_Context, const edg_wll_JobStat *, const edg_wll_JobStat *);
 extern int enable_lcas;
 
 
-static int db_store_finalize(edg_wll_Context ctx, char *event, edg_wll_Event *ev, edg_wll_JobStat *newstat, int reg_to_JP);
+static int db_store_finalize(edg_wll_Context ctx, char *event, edg_wll_Event *ev, edg_wll_JobStat *oldstat, edg_wll_JobStat *newstat, int reg_to_JP);
 
 
 int
@@ -36,10 +36,12 @@ db_store(edg_wll_Context ctx, char *event)
   edg_wll_Event        *ev = NULL;
   int                  seq, reg_to_JP = 0, local_job;
   edg_wll_JobStat      newstat;
+  edg_wll_JobStat      oldstat;
 
 
   edg_wll_ResetError(ctx);
   memset(&newstat,0,sizeof newstat);
+  memset(&oldstat,0,sizeof oldstat);
 
   if(edg_wll_ParseEvent(ctx, event, &ev)) goto err;
 
@@ -91,7 +93,7 @@ db_store(edg_wll_Context ctx, char *event)
                        edg_wll_FreeStatus(&newstat);
                        newstat.state = EDG_WLL_JOB_UNDEF;
                }
-               if (edg_wll_StepIntState(ctx,ev->any.jobId, ev, seq, &newstat)) goto rollback;
+               if (edg_wll_StepIntState(ctx,ev->any.jobId, ev, seq, &oldstat, &newstat)) goto rollback;
                
                if (newstat.remove_from_proxy) 
                        if (edg_wll_PurgeServerProxy(ctx, ev->any.jobId)) goto rollback;
@@ -115,12 +117,13 @@ rollback:;
   if (edg_wll_Error(ctx, NULL, NULL)) goto err;
 
 
-  db_store_finalize(ctx, event, ev, &newstat, reg_to_JP);
+  db_store_finalize(ctx, event, ev, &oldstat, &newstat, reg_to_JP);
 
 
 err:
   if(ev) { edg_wll_FreeEvent(ev); free(ev); }
   if ( newstat.state ) edg_wll_FreeStatus(&newstat);
+  if ( oldstat.state ) edg_wll_FreeStatus(&oldstat);
 
   return edg_wll_Error(ctx,NULL,NULL);
 }
@@ -135,10 +138,12 @@ db_parent_store(edg_wll_Context ctx, edg_wll_Event *ev, intJobStat *is)
   int  seq;
   int   err;
   edg_wll_JobStat      newstat;
+  edg_wll_JobStat      oldstat;
 
 
   edg_wll_ResetError(ctx);
   memset(&newstat,0,sizeof newstat);
+  memset(&oldstat,0,sizeof oldstat);
 
   /* Transaction opened from db_store */
 
@@ -167,7 +172,7 @@ db_parent_store(edg_wll_Context ctx, edg_wll_Event *ev, intJobStat *is)
   }
 #endif
 
-  err = edg_wll_StepIntStateParent(ctx,ev->any.jobId, ev, seq, is, ctx->isProxy? NULL: &newstat);
+  err = edg_wll_StepIntStateParent(ctx,ev->any.jobId, ev, seq, is, &oldstat, ctx->isProxy? NULL: &newstat);
 
   if (err) goto err;
 
@@ -176,12 +181,13 @@ db_parent_store(edg_wll_Context ctx, edg_wll_Event *ev, intJobStat *is)
     assert(event);
   }
 
-  db_store_finalize(ctx, event, ev, &newstat, 0);
+  db_store_finalize(ctx, event, ev, &oldstat, &newstat, 0);
 
 err:
 
   free(event);
   if ( newstat.state ) edg_wll_FreeStatus(&newstat);
+  if ( oldstat.state ) edg_wll_FreeStatus(&oldstat);
   
   return edg_wll_Error(ctx,NULL,NULL);
 }
@@ -263,7 +269,7 @@ static int forward_event_to_server(edg_wll_Context ctx, char *event, edg_wll_Eve
 }
 
 
-static int db_store_finalize(edg_wll_Context ctx, char *event, edg_wll_Event *ev, edg_wll_JobStat *newstat, int reg_to_JP) 
+static int db_store_finalize(edg_wll_Context ctx, char *event, edg_wll_Event *ev, edg_wll_JobStat *oldstat, edg_wll_JobStat *newstat, int reg_to_JP) 
 {
        int     local_job = is_job_local(ctx, ev->any.jobId);
 
@@ -289,10 +295,10 @@ static int db_store_finalize(edg_wll_Context ctx, char *event, edg_wll_Event *ev
                        if ((ev->any.priority & EDG_WLL_LOGFLAG_DIRECT) || local_job) 
                                /* event will not arrive to server, only flag was set           */
                                /* check whether some pending notifications are not triggered   */
-                               edg_wll_NotifMatch(ctx, newstat);
+                               edg_wll_NotifMatch(ctx, oldstat, newstat);
                        }
                else {
-                               edg_wll_NotifMatch(ctx, newstat);
+                               edg_wll_NotifMatch(ctx, oldstat, newstat);
                }
        }
 
index 43a5c81..13465f1 100644 (file)
@@ -1111,37 +1111,35 @@ edg_wll_ErrorCode edg_wll_StepIntStateParent(edg_wll_Context ctx,
                                        edg_wll_Event *e,
                                        int seq,
                                        intJobStat *ijsp,
+                                       edg_wll_JobStat *oldstat,
                                        edg_wll_JobStat *stat_out)
 {
        int             res;
        int             be_strict = 0;
        char            *errstring = NULL;
-       edg_wll_JobStat oldstat;
        char            *oldstat_rgmaline = NULL;
 
 
-       memset(&oldstat,0,sizeof oldstat);
-
-       edg_wll_CpyStatus(&ijsp->pub,&oldstat);
+       edg_wll_CpyStatus(&ijsp->pub,oldstat);
 
        if (ctx->rgma_export) oldstat_rgmaline = write2rgma_statline(ijsp);
 
        res = processEvent(ijsp, e, seq, be_strict, &errstring);
        if (res == RET_FATAL || res == RET_INTERNAL) { /* !strict */
-               edg_wll_FreeStatus(&oldstat);
+               edg_wll_FreeStatus(oldstat);
+               memset(oldstat,0,sizeof *oldstat);
                return edg_wll_SetError(ctx, EINVAL, errstring);
        }
        // XXX: store it in update_parent status ?? 
        edg_wll_StoreIntState(ctx, ijsp, seq);
 
-       edg_wll_UpdateStatistics(ctx,&oldstat,e,&ijsp->pub);
+       edg_wll_UpdateStatistics(ctx,oldstat,e,&ijsp->pub);
 
        if (ctx->rgma_export) write2rgma_chgstatus(ijsp, oldstat_rgmaline);
 
        if (stat_out) {
                edg_wll_CpyStatus(&ijsp->pub, stat_out);
        }
-       edg_wll_FreeStatus(&oldstat);
 
        return edg_wll_Error(ctx, NULL, NULL);
 }
@@ -1159,6 +1157,7 @@ edg_wll_ErrorCode edg_wll_StepIntState(edg_wll_Context ctx,
                                        glite_jobid_const_t job,
                                        edg_wll_Event *e,
                                        int seq,
+                                       edg_wll_JobStat *oldstat,
                                        edg_wll_JobStat *stat_out)
 {
        intJobStat      *ijsp;
@@ -1167,30 +1166,31 @@ edg_wll_ErrorCode edg_wll_StepIntState(edg_wll_Context ctx,
        int             be_strict = 0;
        char            *errstring = NULL;
        intJobStat      jobstat;
-       edg_wll_JobStat oldstat;
        char            *oldstat_rgmaline = NULL;
 
 
-       memset(&oldstat,0,sizeof oldstat);
-
        if (!edg_wll_LoadIntState(ctx, job, DONT_LOCK, seq - 1, &ijsp)) {
-               edg_wll_CpyStatus(&ijsp->pub,&oldstat);
+               edg_wll_CpyStatus(&ijsp->pub,oldstat);
 
                if (ctx->rgma_export) oldstat_rgmaline = write2rgma_statline(ijsp);
 
                res = processEvent(ijsp, e, seq, be_strict, &errstring);
                if (res == RET_FATAL || res == RET_INTERNAL) { /* !strict */
-                       edg_wll_FreeStatus(&oldstat);
+                       edg_wll_FreeStatus(oldstat);
+                       memset(oldstat,0,sizeof *oldstat);
                        return edg_wll_SetError(ctx, EINVAL, errstring);
                }
                edg_wll_StoreIntState(ctx, ijsp, seq);
 
-               edg_wll_UpdateStatistics(ctx,&oldstat,e,&ijsp->pub);
+               edg_wll_UpdateStatistics(ctx,oldstat,e,&ijsp->pub);
 
                /* check whether subjob state change does not change parent state */
-               if ((ijsp->pub.parent_job) && (oldstat.state != ijsp->pub.state)) { 
-                       if (update_parent_status(ctx, &oldstat, ijsp, e))
+               if ((ijsp->pub.parent_job) && (oldstat->state != ijsp->pub.state)) { 
+                       if (update_parent_status(ctx, oldstat, ijsp, e)) {
+                               edg_wll_FreeStatus(oldstat);
+                               memset(oldstat,0,sizeof *oldstat);
                                return edg_wll_SetError(ctx, EINVAL, "update_parent_status()");
+                       }
                }
 
                if (ctx->rgma_export) write2rgma_chgstatus(ijsp, oldstat_rgmaline);
@@ -1201,7 +1201,6 @@ edg_wll_ErrorCode edg_wll_StepIntState(edg_wll_Context ctx,
                }
                else destroy_intJobStat(ijsp);
                free(ijsp);
-               edg_wll_FreeStatus(&oldstat);
        }
        else if (!edg_wll_intJobStatus(ctx, job, flags,&jobstat, js_enable_store, 1)) 
        {
index ed0ed2d..4862db0 100644 (file)
@@ -18,9 +18,9 @@ edg_wll_ErrorCode edg_wll_RestoreSubjobState(edg_wll_Context , glite_jobid_const
 
 
 /* update stored job state according to new event */
-edg_wll_ErrorCode edg_wll_StepIntState(edg_wll_Context ctx, glite_jobid_const_t job, edg_wll_Event *e, int seq, edg_wll_JobStat *stat_out);
+edg_wll_ErrorCode edg_wll_StepIntState(edg_wll_Context ctx, glite_jobid_const_t job, edg_wll_Event *e, int seq, edg_wll_JobStat *old_stat, edg_wll_JobStat *stat_out);
 
-edg_wll_ErrorCode edg_wll_StepIntStateParent(edg_wll_Context,glite_jobid_const_t,edg_wll_Event *,int,intJobStat *,edg_wll_JobStat *);
+edg_wll_ErrorCode edg_wll_StepIntStateParent(edg_wll_Context,glite_jobid_const_t,edg_wll_Event *,int,intJobStat *, edg_wll_JobStat *old_stat, edg_wll_JobStat *);
 
 /* create embriotic job state for DAGs' subjob */
 
index 075a72f..a1c3c50 100644 (file)
@@ -228,6 +228,9 @@ printf("flags %d - %s", ni->flags, flags);
                                case EDG_WLL_QUERY_OP_WITHIN: GS ("within");
                                        break;
                                case EDG_WLL_QUERY_OP_UNEQUAL: GS ("!=");
+                                       break;
+                               case EDG_WLL_QUERY_OP_CHANGED: GS ("changed");
+                                       break;
                        }
                        char *buf;
                        switch (l2->attr){
index c38ba95..4ab6a6a 100644 (file)
@@ -26,7 +26,7 @@ extern int debug;
 
 int edg_wll_NotifExpired(edg_wll_Context,const char *);
 
-int edg_wll_NotifMatch(edg_wll_Context ctx, const edg_wll_JobStat *stat)
+int edg_wll_NotifMatch(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, const edg_wll_JobStat *stat)
 {
        edg_wll_NotifId         nid = NULL;
        char    *jobq,*ju = NULL,*jobc[6];
index f42fa73..44d9c39 100644 (file)
@@ -32,6 +32,7 @@
 #define LESS           lbt__queryOp__LESS
 #define GREATER                lbt__queryOp__GREATER
 #define WITHIN         lbt__queryOp__WITHIN
+#define CHANGED                lbt__queryOp__CHANGED
 
 #define SUBMITTED      lbt__statName__SUBMITTED
 #define WAITING                lbt__statName__WAITING
index 9eaa269..c556d7a 100644 (file)
@@ -422,6 +422,7 @@ void edg_wll_SoapToQueryOp(const enum lbt__queryOp in, edg_wll_QueryOp *out)
        case LESS: *out = EDG_WLL_QUERY_OP_LESS; break;
        case GREATER: *out = EDG_WLL_QUERY_OP_GREATER; break;
        case WITHIN: *out = EDG_WLL_QUERY_OP_WITHIN; break;
+       case CHANGED: *out = EDG_WLL_QUERY_OP_CHANGED; break;
        }
 }
 
@@ -434,6 +435,7 @@ void edg_wll_QueryOpToSoap(const edg_wll_QueryOp in, enum lbt__queryOp *out)
        case EDG_WLL_QUERY_OP_LESS: *out = LESS; break;
        case EDG_WLL_QUERY_OP_GREATER: *out = GREATER; break;
        case EDG_WLL_QUERY_OP_WITHIN: *out = WITHIN; break;
+       case EDG_WLL_QUERY_OP_CHANGED: *out = CHANGED; break;
        default: assert(0);
        }
 }
index 8f161fc..fb8b566 100644 (file)
                        <val name="GREATER"> Attribute is greater than the specified value or equal </val>
                        <val name="WITHIN"> Attribute is withing a range (queryRecord.value2 must be specified) </val>
                        <val name="UNEQUAL"> Attribute is not equal to the specified value.</val>
+                       <val name="CHANGED"> Attribute has changed its value from last check (notification conditions only).</val>
                </enum>
                
                <choice name="queryRecValue">