Purge notifications.
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Fri, 28 Aug 2009 13:20:37 +0000 (13:20 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Fri, 28 Aug 2009 13:20:37 +0000 (13:20 +0000)
org.glite.lb.client/src/notify.c
org.glite.lb.server/src/db_store.c
org.glite.lb.server/src/il_notification.h
org.glite.lb.server/src/srv_purge.c

index 913939d..2e7fc2c 100644 (file)
@@ -198,7 +198,7 @@ int main(int argc,char **argv)
                                for (sti = 0; sti < strlen(statelist); sti++) 
                                        if (statelist[sti] == ',') stdelims++;
                                conditions[i] = (edg_wll_QueryRec *)calloc(stdelims+2,sizeof(edg_wll_QueryRec));
-                               while(single = strtok(statelist, ",")) {
+                               while((single = strtok(statelist, ","))) {
                                        single_code = edg_wll_StringToStat(single);
                                        if (single_code != -1) {
                                                conditions[i][statno].attr = EDG_WLL_QUERY_ATTR_STATUS;
index dde7ce4..54cbcf0 100644 (file)
@@ -15,6 +15,7 @@
 #include "il_lbproxy.h"
 #include "jobstat.h"
 #include "db_supp.h"
+#include "il_notification.h"
 
 #ifdef LB_PERF
 #include "glite/lb/lb_perftest.h"
@@ -23,7 +24,6 @@
 
 
 extern int unset_proxy_flag(edg_wll_Context, edg_wlc_JobId);
-extern int edg_wll_NotifMatch(edg_wll_Context, const edg_wll_JobStat *, const edg_wll_JobStat *);
 extern int enable_lcas;
 
 
index 45b396e..ef142d2 100644 (file)
@@ -97,6 +97,11 @@ edg_wll_NotifCancelRegId(edg_wll_Context context,
                         edg_wll_NotifId reg_id);
 
 
+/**
+ * Check and perform notifications.
+ */
+int edg_wll_NotifMatch(edg_wll_Context context, const edg_wll_JobStat *oldstat, const edg_wll_JobStat *stat);
+
 #ifdef __cplusplus
 }
 #endif
index f3b2c8b..62538f2 100644 (file)
@@ -30,6 +30,7 @@
 #include "db_calls.h"
 #include "db_supp.h"
 #include "jobstat.h"
+#include "il_notification.h"
 
 
 #define DUMP_FILE_STORAGE                                      "/tmp/"
@@ -45,7 +46,7 @@ static const char* const resp_headers[] = {
 
 static int purge_check(edg_wll_Context ctx, edg_wll_JobStat *stat, time_t start, time_t *timeout);
 static int purge_one_with_subjobs(edg_wll_Context ctx, edg_wll_JobStat *stat, int dumpfile, const edg_wll_PurgeRequest *request, edg_wll_PurgeResult *result, int *njobs, int *parse);
-static int purge_one(edg_wll_Context ctx,glite_jobid_const_t,int,int,int);
+static int purge_one(edg_wll_Context ctx,edg_wll_JobStat *,int,int,int);
 int unset_proxy_flag(edg_wll_Context ctx, glite_jobid_const_t job);
 static int unset_server_flag(edg_wll_Context ctx, glite_jobid_const_t job);
 int job_exists(edg_wll_Context ctx, glite_jobid_const_t job);
@@ -191,7 +192,11 @@ int edg_wll_CreateFileStorage(edg_wll_Context ctx, char *file_type, char *prefix
 
 int edg_wll_PurgeServerProxy(edg_wll_Context ctx, glite_jobid_const_t job)
 {
-       switch ( purge_one(ctx, job, -1, 1, 1) ) {
+       edg_wll_JobStat stat;
+
+       memset(&stat, 0, sizeof stat);
+       stat.jobId = (glite_jobid_t)job;
+       switch ( purge_one(ctx, &stat, -1, 1, 1) ) {
                case 0:
                case ENOENT:
                        return(edg_wll_ResetError(ctx));
@@ -621,11 +626,10 @@ static int purge_check(edg_wll_Context ctx, edg_wll_JobStat *stat, time_t start,
 #define GRAN 32
 
 static int purge_one_with_subjobs(edg_wll_Context ctx, edg_wll_JobStat *stat, int dumpfile, const edg_wll_PurgeRequest *request, edg_wll_PurgeResult *result, int *njobs, int *parse) {
-       glite_jobid_t subjob = NULL;
        char *job_s;
        int i;
 
-       if (purge_one(ctx,stat->jobId,dumpfile,request->flags&EDG_WLL_PURGE_REALLY_PURGE,ctx->isProxy)) return edg_wll_Error(ctx, NULL, NULL);
+       if (purge_one(ctx,stat,dumpfile,request->flags&EDG_WLL_PURGE_REALLY_PURGE,ctx->isProxy)) return edg_wll_Error(ctx, NULL, NULL);
 
 /* XXX: change with the streaming interface */
        if (request->flags & EDG_WLL_PURGE_LIST_JOBS) {
@@ -640,15 +644,9 @@ static int purge_one_with_subjobs(edg_wll_Context ctx, edg_wll_JobStat *stat, in
        /* purge the subjobs */
        if (stat->children_num && stat->children) {
                for (i = 0; i < stat->children_num && stat->children[i]; i++) {
-                       if (glite_jobid_parse(stat->children[i], &subjob)) {
-                               fprintf(stderr,"%s: parse error (internal inconsistency !)\n",stat->children[i]);
-                               *parse = 1;
-                       }
-                       if (purge_one(ctx, subjob, dumpfile, request->flags&EDG_WLL_PURGE_REALLY_PURGE,ctx->isProxy)) {
-                               glite_jobid_free(subjob);
+                       if (purge_one(ctx, stat->children_states + i, dumpfile, request->flags&EDG_WLL_PURGE_REALLY_PURGE,ctx->isProxy)) {
                                return edg_wll_Error(ctx, NULL, NULL);
                        }
-                       glite_jobid_free(subjob);
 
                        if (request->flags & EDG_WLL_PURGE_LIST_JOBS) {
                                if (*njobs % GRAN == 0 || !result->jobs)
@@ -664,7 +662,7 @@ static int purge_one_with_subjobs(edg_wll_Context ctx, edg_wll_JobStat *stat, in
 }
 
 
-int purge_one(edg_wll_Context ctx,glite_jobid_const_t job,int dump, int purge, int purge_from_proxy_only)
+int purge_one(edg_wll_Context ctx,edg_wll_JobStat *stat,int dump, int purge, int purge_from_proxy_only)
 {
        char    *dbjob = NULL;
        char    *stmt = NULL;
@@ -674,6 +672,8 @@ int purge_one(edg_wll_Context ctx,glite_jobid_const_t job,int dump, int purge, i
        char    *prefix = NULL, *suffix = NULL, *root = NULL;
        char    *prefix_id = NULL, *suffix_id = NULL;
        int     sql_retval;
+       glite_jobid_const_t job = stat->jobId;
+       edg_wll_JobStat new_stat;
 
        edg_wll_ResetError(ctx);
        if ( !purge && dump < 0 ) return 0;
@@ -860,6 +860,11 @@ int purge_one(edg_wll_Context ctx,glite_jobid_const_t job,int dump, int purge, i
                        }
                        glite_lbu_FreeStmt(&q);
                        free(stmt); stmt = NULL;
+
+                       /* notifications */
+                       memcpy(&new_stat, stat, sizeof new_stat);
+                       new_stat.state = EDG_WLL_JOB_PURGED;
+                       edg_wll_NotifMatch(ctx, stat, &new_stat);
                }
 
                if (dump >= 0)