propagate notif expiration to IL
authorAleš Křenek <ljocha@ics.muni.cz>
Mon, 10 Dec 2007 10:12:28 +0000 (10:12 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Mon, 10 Dec 2007 10:12:28 +0000 (10:12 +0000)
org.glite.lb.server/src/il_notification.c
org.glite.lb.server/src/il_notification.h
org.glite.lb.server/src/notif_match.c
org.glite.lb.server/src/notification.c

index 72be506..3a20e7f 100644 (file)
@@ -43,6 +43,7 @@ notif_create_ulm(
        const char      *host,
        const uint16_t  port,
        const char      *owner,
+       int             expires,
        const char      *notif_data,
        char            **ulm_data,
        char            **reg_id_s)
@@ -66,6 +67,8 @@ notif_create_ulm(
        event->notification.dest_port = port;
        if (notif_data) event->notification.jobstat = strdup(notif_data);
 
+       event->notification.expires = expires;
+
        if ((*ulm_data = edg_wll_UnparseNotifEvent(context,event)) == NULL) {
                edg_wll_SetError(context, ret = ENOMEM, "edg_wll_UnparseNotifEvent()"); 
                goto out;
@@ -94,6 +97,7 @@ edg_wll_NotifSend(edg_wll_Context       context,
                  const char           *host,
                   int                   port,
                  const char           *owner,
+                 int                   expires,
                   const char           *notif_data)
 {
        struct timeval  timeout = {NOTIF_TIMEOUT, 0};
@@ -108,6 +112,7 @@ edg_wll_NotifSend(edg_wll_Context       context,
                                 host, 
                                 port, 
                                 owner, 
+                                expires,
                                 notif_data,
                                 &ulm_data,
                                 &reg_id_s))) {
@@ -148,6 +153,7 @@ edg_wll_NotifJobStatus(edg_wll_Context      context,
                       const char      *host,
                        int              port,
                       const char      *owner,
+                      int              expires,
                       const edg_wll_JobStat notif_job_stat)
 {
        int ret=0;
@@ -161,7 +167,7 @@ edg_wll_NotifJobStatus(edg_wll_Context      context,
                goto out;
        }
 
-       if (ret=edg_wll_NotifSend(context, reg_id, host, port, owner, xml_esc_data)) {
+       if ((ret=edg_wll_NotifSend(context, reg_id, host, port, owner, expires, xml_esc_data))) {
                char *ed = NULL, *et = NULL;
 
                if(ret) edg_wll_UpdateError(context, ret, "edg_wll_NotifJobStatus()");
@@ -181,12 +187,13 @@ out:
 
 
 int 
-edg_wll_NotifChangeDestination(edg_wll_Context context,
+edg_wll_NotifChangeIL(edg_wll_Context context,
                                edg_wll_NotifId reg_id,
                                const char      *host,
-                               int             port)
+                               int             port,
+                              int             expires)
 {
-       return(edg_wll_NotifSend(context, reg_id, host, port, "", ""));
+       return(edg_wll_NotifSend(context, reg_id, host, port, "", expires, ""));
 }
 
 
@@ -194,6 +201,6 @@ int
 edg_wll_NotifCancelRegId(edg_wll_Context context,
                         edg_wll_NotifId reg_id)
 {
-       return(edg_wll_NotifSend(context, reg_id, NULL, 0, "", ""));
+       return(edg_wll_NotifSend(context, reg_id, NULL, 0, "", 0, ""));
 }
 
index 52487c4..187c226 100644 (file)
@@ -43,6 +43,7 @@ edg_wll_NotifSend(edg_wll_Context       context,
                  const char           *host,
                   int                   port,
                  const char           *owner,
+                 int                   expires,
                   const char           *notif_data);
 
 
@@ -63,6 +64,7 @@ edg_wll_NotifJobStatus(edg_wll_Context        context,
                       const char      *host,
                        int              port,
                       const char      *owner,
+                      int              expires,
                       const edg_wll_JobStat notif_job_stat);
 
 
@@ -74,10 +76,11 @@ edg_wll_NotifJobStatus(edg_wll_Context      context,
  * \see edg_wll_NotifSend()
  */
 int 
-edg_wll_NotifChangeDestination(edg_wll_Context context,
+edg_wll_NotifChangeIL(edg_wll_Context context,
                                edg_wll_NotifId reg_id,
                                const char      *host,
-                               int             port);
+                               int             port,
+                              int              expires);
 
 /** Cancel registration.
  * Creates ULM string and uses edg_wll_NotifSend() to pass it to
index e48014e..cde8fbf 100644 (file)
@@ -27,7 +27,7 @@ int edg_wll_NotifMatch(edg_wll_Context ctx, const edg_wll_JobStat *stat)
        edg_wll_NotifId         nid = NULL;
        char    *jobq,*ju = NULL,*jobc[5];
        edg_wll_Stmt    jobs = NULL;
-       int     ret,i;
+       int     ret,i,expires;
        time_t  now = time(NULL);
 
        edg_wll_ResetError(ctx);
@@ -49,7 +49,7 @@ int edg_wll_NotifMatch(edg_wll_Context ctx, const edg_wll_JobStat *stat)
        if (edg_wll_ExecStmt(ctx,jobq,&jobs) < 0) goto err;
 
        while ((ret = edg_wll_FetchRow(jobs,jobc)) > 0) {
-               if (now > edg_wll_DBToTime(jobc[2]))
+               if (now > (expires = edg_wll_DBToTime(jobc[2])))
                        edg_wll_NotifExpired(ctx,jobc[0]);
                else if (notif_match_conditions(ctx,stat,jobc[4]) &&
                                notif_check_acl(ctx,stat,jobc[3]))
@@ -81,7 +81,7 @@ int edg_wll_NotifMatch(edg_wll_Context ctx, const edg_wll_JobStat *stat)
                        /* XXX: only temporary hack!!!
                         */
                        ctx->p_instance = strdup("");
-                       if ( edg_wll_NotifJobStatus(ctx, nid, dest, port, jobc[3], *stat) )
+                       if ( edg_wll_NotifJobStatus(ctx, nid, dest, port, jobc[3], expires, *stat) )
                        {
                                free(dest);
                                for (i=0; i<sizeof(jobc)/sizeof(jobc[0]); i++) free(jobc[i]);
index d664573..032940e 100644 (file)
@@ -637,17 +637,25 @@ static int update_notif(
                 */
        }
 
-       if ( host ) {
-               printf("edg_wll_NotifChangeDestination(ctx, %s, %s, %d)\n",
+       if ( host || valid) {
+               char    *v = strdup(valid),*v2 = strchr(v+1,'\'');
+               int     expires;
+               
+               *v2 = 0;
+               expires = edg_wll_DBToTime(v+1);
+/*
+               printf("edg_wll_NotifChangeIL(ctx, %s, %s, %d)\n",
                                nid_s? nid_s: "nid", host, port);
-               if ( edg_wll_NotifChangeDestination(ctx, nid, host, port) ) {
+*/
+               if ( edg_wll_NotifChangeIL(ctx, nid, host, port, expires) ) {
                        char *errt, *errd;
 
                        edg_wll_Error(ctx, &errt, &errd);
-                       printf("edg_wll_NotifChangeDestination(): %s (%s)\n", errt, errd);
+                       fprintf(stderr,"edg_wll_NotifChangeIL(): %s (%s)\n", errt, errd);
                        free(errt);
                        free(errd);
                }
+               free(v);
        }