Messaging support in server/client (using dest_url).
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Wed, 8 Sep 2010 12:31:09 +0000 (12:31 +0000)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Wed, 8 Sep 2010 12:31:09 +0000 (12:31 +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 9aaca27..5995c95 100644 (file)
@@ -58,8 +58,7 @@ int
 notif_create_ulm(
        edg_wll_Context context,
        edg_wll_NotifId reg_id,
-       const char      *host,
-       const uint16_t  port,
+       const char      *dest_url,
        const char      *owner,
        int             expires,
        const char      *notif_data,
@@ -68,6 +67,8 @@ notif_create_ulm(
 {
        int             ret;
        edg_wll_Event   *event=NULL;
+       char            *host = NULL;
+       uint16_t        port = 0;
 
        *ulm_data = NULL;
        *reg_id_s = NULL;
@@ -81,8 +82,24 @@ notif_create_ulm(
        if (context->p_instance) event->notification.src_instance = strdup(context->p_instance);
        event->notification.notifId = edg_wll_NotifIdDup(reg_id);
        if (owner) event->notification.owner = strdup(owner);
-       if (host) event->notification.dest_host = strdup(host);
-       event->notification.dest_port = port;
+       if (dest_url) {
+               if (strstr(dest_url, "//")) {
+               // using complete URL
+                       event->notification.dest_url = strdup(dest_url);
+               } else {
+               // using plain host:port
+                       host = strrchr(dest_url, ':');
+                       port = atoi(host+1);
+                       if ( !(host = strndup(dest_url, host-dest_url)) )
+                       {
+                               edg_wll_SetError(context, ret = errno, "updating notification records");
+                               goto out;
+                       }
+                       event->notification.dest_host = host;
+                       event->notification.dest_port = port;
+                       host = NULL;
+               }
+       }
        if (notif_data) event->notification.jobstat = strdup(notif_data);
 
        event->notification.expires = expires;
@@ -112,8 +129,7 @@ out:
 int
 edg_wll_NotifSend(edg_wll_Context       context,
                  edg_wll_NotifId       reg_id,
-                 const char           *host,
-                  int                   port,
+                 const char           *dest_url,
                  const char           *owner,
                  int                   expires,
                   const char           *notif_data)
@@ -127,8 +143,7 @@ edg_wll_NotifSend(edg_wll_Context       context,
 
        if((ret=notif_create_ulm(context, 
                                 reg_id, 
-                                host, 
-                                port, 
+                                dest_url,
                                 owner, 
                                 expires,
                                 notif_data,
@@ -169,8 +184,7 @@ out:
 int
 edg_wll_NotifJobStatus(edg_wll_Context context,
                       edg_wll_NotifId  reg_id,
-                      const char      *host,
-                       int              port,
+                      const char      *dest_url,
                       const char      *owner,
                        int             flags,
                       int              authz_flags,
@@ -199,7 +213,7 @@ edg_wll_NotifJobStatus(edg_wll_Context      context,
                goto out;
        }
 
-       if ((ret=edg_wll_NotifSend(context, reg_id, host, port, owner, expires, xml_esc_data))) {
+       if ((ret=edg_wll_NotifSend(context, reg_id, dest_url, owner, expires, xml_esc_data))) {
                char *ed = NULL, *et = NULL;
 
                if(ret) edg_wll_UpdateError(context, ret, "edg_wll_NotifJobStatus()");
@@ -221,11 +235,10 @@ out:
 int 
 edg_wll_NotifChangeIL(edg_wll_Context context,
                                edg_wll_NotifId reg_id,
-                               const char      *host,
-                               int             port,
+                               const char      *dest_url,
                               int             expires)
 {
-       return(edg_wll_NotifSend(context, reg_id, host, port, "", expires, ""));
+       return(edg_wll_NotifSend(context, reg_id, dest_url, "", expires, ""));
 }
 
 
@@ -234,6 +247,6 @@ edg_wll_NotifCancelRegId(edg_wll_Context context,
                         edg_wll_NotifId reg_id)
 {
 /* XXX: Jan 1 1970 00:00:01 -- quite sure to make it expire immediately */
-       return(edg_wll_NotifSend(context, reg_id, NULL, 0, "", 1, ""));
+       return(edg_wll_NotifSend(context, reg_id, NULL, "", 1, ""));
 }
 
index cf1facc..a1fcd5a 100644 (file)
@@ -60,8 +60,7 @@ extern char *notif_ilog_file_prefix;
 int
 edg_wll_NotifSend(edg_wll_Context       context,
                  edg_wll_NotifId       reg_id,
-                 const char           *host,
-                  int                   port,
+                 const char           *dest_url,
                  const char           *owner,
                  int                   expires,
                   const char           *notif_data);
@@ -82,8 +81,7 @@ edg_wll_NotifSend(edg_wll_Context       context,
 int
 edg_wll_NotifJobStatus(edg_wll_Context context,
                       edg_wll_NotifId  reg_id,
-                      const char      *host,
-                       int              port,
+                      const char      *dest_url,
                       const char      *owner,
                        int              flags,
                       int              authz_flags,
@@ -101,8 +99,7 @@ edg_wll_NotifJobStatus(edg_wll_Context       context,
 int 
 edg_wll_NotifChangeIL(edg_wll_Context context,
                                edg_wll_NotifId reg_id,
-                               const char      *host,
-                               int             port,
+                               const char      *dest_url,
                               int              expires);
 
 /** Cancel registration.
index a8fe6fa..762e206 100644 (file)
@@ -119,23 +119,12 @@ int edg_wll_NotifMatch(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, cons
                else if (notif_match_conditions(ctx,oldstat,stat,jobc[4]) &&
                                notif_check_acl(ctx,stat,jobc[3], &authz_flags))
                {
-                       char                       *dest, *aux;
-                       int                                     port;
+                       char                       *dest;
 
                        glite_common_log(LOG_CATEGORY_LB_SERVER, LOG_PRIORITY_DEBUG, "NOTIFY: %s, job %s", jobc[0], ju = edg_wlc_JobIdGetUnique(stat->jobId));
                        free(ju); ju = NULL;
 
-                       dest = strdup(jobc[1]);
-                       if ( !(aux = strrchr(dest, ':')) )
-                       {
-                               edg_wll_SetError(ctx, EINVAL, "Can't parse notification destination");
-                               free(dest);
-                               for (i=0; i<sizeof(jobc)/sizeof(jobc[0]); i++) free(jobc[i]);
-                               goto err;
-                       }
-                       *aux = 0;
-                       aux++;
-                       port = atoi(aux);
+                       dest = jobc[1];
                        
                        if (   edg_wll_NotifIdSetUnique(&nid, jobc[0]) )
                        {
@@ -145,13 +134,11 @@ int edg_wll_NotifMatch(edg_wll_Context ctx, const edg_wll_JobStat *oldstat, cons
                        /* XXX: only temporary hack!!!
                         */
                        ctx->p_instance = strdup("");
-                       if ( edg_wll_NotifJobStatus(ctx, nid, dest, port, jobc[3], atoi(jobc[5]), authz_flags, expires, *stat) )
+                       if ( edg_wll_NotifJobStatus(ctx, nid, dest, jobc[3], atoi(jobc[5]), authz_flags, expires, *stat) )
                        {
-                               free(dest);
                                for (i=0; i<sizeof(jobc)/sizeof(jobc[0]); i++) free(jobc[i]);
                                goto err;
                        }
-                       free(dest);
                }
                
                for (i=0; i<sizeof(jobc)/sizeof(jobc[0]); i++) free(jobc[i]);
index e36b6c5..c64b401 100644 (file)
@@ -671,13 +671,6 @@ static int update_notif(
        }
        if ( dest )
        {
-               host = strrchr(dest, ':');
-               port = atoi(host+1);
-               if ( !(host = strndup(dest, host-dest)) )
-               {
-                       edg_wll_SetError(ctx, errno, "updating notification records");
-                       goto cleanup;
-               }
                trio_asprintf(&aux, "%s destination='%|Ss'", stmt, dest);
                free(stmt);
                stmt = aux;
@@ -719,7 +712,7 @@ static int update_notif(
                 */
        }
 
-       if ( host || valid) {
+       if ( dest || valid) {
                char    *v = strdup(valid),*v2 = strchr(v+1,'\'');
                int     expires;
                
@@ -729,7 +722,7 @@ static int update_notif(
                printf("edg_wll_NotifChangeIL(ctx, %s, %s, %d)\n",
                                nid_s? nid_s: "nid", host, port);
 */
-               if ( edg_wll_NotifChangeIL(ctx, nid, host, port, expires) ) {
+               if ( edg_wll_NotifChangeIL(ctx, nid, dest, expires) ) {
                        char *errt, *errd;
 
                        edg_wll_Error(ctx, &errt, &errd);