pass notification flags to server
authorMiloš Mulač <mulac@civ.zcu.cz>
Mon, 20 Oct 2008 15:21:10 +0000 (15:21 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Mon, 20 Oct 2008 15:21:10 +0000 (15:21 +0000)
- no implementation on server side yet

org.glite.lb.client/examples/feed_shark.c
org.glite.lb.client/interface/notification.h
org.glite.lb.client/src/Notification.cpp
org.glite.lb.client/src/notification.c
org.glite.lb.client/src/notify.c
org.glite.lb.common/interface/xml_parse.h
org.glite.lb.common/src/xml_parse.c.T
org.glite.lb.server/src/lb_proto.c
org.glite.lb.server/src/lb_xml_parse.c.T
org.glite.lb.server/src/lb_xml_parse.h
org.glite.lb.server/src/notification.c

index 63eafe1..8004537 100644 (file)
@@ -48,7 +48,7 @@ int main(int argc,char *argv[])
                edg_wll_QueryRec        const *empty[] = { NULL };
                char    *notif_s;
 
-               if (edg_wll_NotifNew(ctx,empty,-1,NULL,&notif,&valid)) {
+               if (edg_wll_NotifNew(ctx,empty,0,-1,NULL,&notif,&valid)) {
                        char    *et,*ed;
 
                        edg_wll_Error(ctx,&et,&ed);
index 13cd8be..5d8a021 100644 (file)
@@ -33,6 +33,9 @@ extern "C" {
  *             Only a single occurence of a specific attribute is allowed
  *             among ANDed conditions (due to the ability to modify them
  *             further).
+ * \param[in] flags            verbosity of notifications
+               0                       - send basic job status info
+               EDG_WLL_STAT_CLASSADS   - send also JDL in job status
  * \param[in] fd               = -1 create or reuse the default listening socket (one per context)
  *          >= 0 non-default listening socket 
  * \param[in] address_override         if not NULL, use this address instead of extracting it
@@ -50,6 +53,7 @@ extern "C" {
 int edg_wll_NotifNew(
        edg_wll_Context         context,
        edg_wll_QueryRec        const * const *conditions,
+       int                     flags,
        int                     fd,
        const char              *address_override,
        edg_wll_NotifId         *id_out,
index 467f80f..d0c1ea7 100644 (file)
@@ -269,7 +269,7 @@ Notification::Register(void)
        /* convert query to conditions */
        conditions = convertQueryVectorExt(queryExt);
        /* register */
-       ret = edg_wll_NotifNew(ctx,conditions,-1,NULL,&notifId,&valid);
+       ret = edg_wll_NotifNew(ctx,conditions,0,-1,NULL,&notifId,&valid);
        check_result(ret,ctx,"edg_wll_NotifNew");
        /* clean */
        if (conditions) {
index c9e2c75..14dd73b 100644 (file)
@@ -219,6 +219,7 @@ err:
 int edg_wll_NotifNew(
         edg_wll_Context         ctx,
         edg_wll_QueryRec        const * const *conditions,
+       int                     flags,
         int                     fd,
         const char              *address_override,
         edg_wll_NotifId         *id_out,
@@ -242,7 +243,7 @@ int edg_wll_NotifNew(
                goto err;
        
        if ( (ret = edg_wll_NotifRequestToXML(ctx, "New", notifId, address, 
-                       EDG_WLL_NOTIF_NOOP, *valid, conditions, &send_mess)) )
+                       EDG_WLL_NOTIF_NOOP, *valid, conditions, flags, &send_mess)) )
                goto err;
 
        ctx->p_tmp_timeout = ctx->p_notif_timeout;
@@ -305,7 +306,7 @@ int edg_wll_NotifBind(
                goto err;
 
        if (edg_wll_NotifRequestToXML(ctx, "Bind", id, address, 
-                       EDG_WLL_NOTIF_NOOP, *valid, NULL, &send_mess)) 
+                       EDG_WLL_NOTIF_NOOP, *valid, NULL, 0, &send_mess)) 
                goto err;
 
        ctx->p_tmp_timeout = ctx->p_notif_timeout;
@@ -347,7 +348,7 @@ int edg_wll_NotifChange(
                goto err;
                
        if (edg_wll_NotifRequestToXML(ctx, "Change", id, NULL, 
-                       op, -1, conditions, &send_mess)) 
+                       op, -1, conditions, 0, &send_mess)) 
                goto err;
 
        ctx->p_tmp_timeout = ctx->p_notif_timeout;
@@ -386,7 +387,7 @@ int edg_wll_NotifRefresh(
                goto err;
                
        if (edg_wll_NotifRequestToXML(ctx, "Refresh", id, NULL, 
-                       EDG_WLL_NOTIF_NOOP, *valid, NULL, &send_mess)) 
+                       EDG_WLL_NOTIF_NOOP, *valid, NULL, 0, &send_mess)) 
                goto err;
 
        ctx->p_tmp_timeout = ctx->p_notif_timeout;
@@ -425,7 +426,7 @@ int edg_wll_NotifDrop(
                goto err;
                
        if (edg_wll_NotifRequestToXML(ctx, "Drop", id, NULL, 
-                       EDG_WLL_NOTIF_NOOP, -1, NULL, &send_mess)) 
+                       EDG_WLL_NOTIF_NOOP, -1, NULL, 0, &send_mess)) 
                goto err;
 
        ctx->p_tmp_timeout = ctx->p_notif_timeout;
index 8d248f7..e9bd12c 100644 (file)
@@ -32,10 +32,11 @@ static void usage(char *cmd)
                        me);
        }
        if ( !cmd || !strcmp(cmd, "new") )
-               fprintf(stderr,"\n'new' command usage: %s new [ { -s socket_fd | -a fake_addr } -t requested_validity ] {-j jobid | -o owner | -n network_server | -v virtual_organization }\n"
+               fprintf(stderr,"\n'new' command usage: %s new [ { -s socket_fd | -a fake_addr } -t requested_validity ] {-j jobid | -o owner | -n network_server | -v virtual_organization } [-f flags]\n"
                        "    jobid              Job ID to connect notif. reg. with\n"
                        "    owner              Match this owner DN\n"
                        "    requested_validity Validity of notification req. in seconds\n"
+                       "    flags              0 - return basic status, 1 - return also JDL in status\n"
                        "    network_server     Match only this networ server (WMS entry point)\n\n"
                        , me);
        if ( !cmd || !strcmp(cmd, "bind") )
@@ -80,7 +81,7 @@ int main(int argc,char **argv)
        char                       *errt, *errd;
        void            *fields = NULL;
 
-       int     sock = -1;
+       int     sock = -1, flags = 0;
        char    *fake_addr = NULL;
                
 //     sleep(20);
@@ -105,7 +106,7 @@ int main(int argc,char **argv)
                char    *arg = NULL;
                int     attr = 0;
 
-               while ((c = getopt(argc-1,argv+1,"j:o:v:n:s:a:t:")) > 0) switch (c) {
+               while ((c = getopt(argc-1,argv+1,"j:o:v:n:s:a:t:f:")) > 0) switch (c) {
                        case 'j':
                                if (arg) { usage("new"); return EX_USAGE; }
                                attr = EDG_WLL_QUERY_ATTR_JOBID;
@@ -130,6 +131,8 @@ int main(int argc,char **argv)
                                fake_addr = optarg; break;
                        case 't':
                                valid = time(NULL) + atol(optarg); break;
+                       case 'f':
+                               flags = atoi(optarg); break;
                        default:
                                usage("new"); return EX_USAGE;
                }
@@ -153,7 +156,7 @@ int main(int argc,char **argv)
 
                if ( !edg_wll_NotifNew(ctx,
                                        (edg_wll_QueryRec const* const*)conditions,
-                                       sock, fake_addr, &id_out, &valid))
+                                       flags, sock, fake_addr, &id_out, &valid))
                        fprintf(stderr,"notification ID: %s\nvalid: %s (%ld)\n",
                                        edg_wll_NotifIdUnparse(id_out),
                                        TimeToStr(valid),
index 862f6dc..aaac256 100644 (file)
@@ -68,7 +68,7 @@ extern int edg_wll_LoadRequestToXML(edg_wll_Context ctx, const edg_wll_LoadReque
 
 extern int edg_wll_IndexedAttrsRequestToXML(edg_wll_Context ctx, char **message);
 
-extern int edg_wll_NotifRequestToXML( edg_wll_Context ctx, const char *function, const edg_wll_NotifId notifId, const char *address, edg_wll_NotifChangeOp op, time_t validity, edg_wll_QueryRec const * const *conditions, char **message);
+extern int edg_wll_NotifRequestToXML( edg_wll_Context ctx, const char *function, const edg_wll_NotifId notifId, const char *address, edg_wll_NotifChangeOp op, time_t validity, edg_wll_QueryRec const * const *conditions, int flags, char **message);
 
 extern int edg_wll_QuerySequenceCodeToXML(edg_wll_Context ctx, glite_jobid_const_t jobId, char **message);
 
index ce6fafe..5c47b2c 100644 (file)
@@ -2867,9 +2867,10 @@ int edg_wll_NotifRequestToXML(
                edg_wll_NotifChangeOp op,
                time_t validity,
                edg_wll_QueryRec const * const *conditions,
+               int flags,
                 char **message)
 {
-       char *pomA=NULL, *pomB=NULL, *pomC=NULL;
+       char *pomA=NULL, *pomB=NULL, *pomC=NULL, *cflags=NULL;
 
 
        pomA = strdup("");
@@ -2879,16 +2880,17 @@ int edg_wll_NotifRequestToXML(
        edg_wll_add_time_t_to_XMLBody(&pomA, validity, "requestedValidity", -1);
        if (conditions && conditions[0] && conditions[0][0].attr != EDG_WLL_QUERY_ATTR_UNDEF)
                edg_wll_JobQueryRecToXML(ctx, conditions, &pomB);
-               
+       cflags = edg_wll_stat_flags_to_string(flags);
 
        if (pomB)
-               trio_asprintf(&pomC,"%s function=\"%s\">\r\n%s\t<and>\r\n%s\t</and>\r\n%s",
-                       NOTIF_REQUEST_BEGIN,function,pomA,pomB,NOTIF_REQUEST_END);
+               trio_asprintf(&pomC,"%s function=\"%s\">\r\n\t<flags>%s</flags>\r\n%s\t<and>\r\n%s\t</and>\r\n%s",
+                       NOTIF_REQUEST_BEGIN,function,cflags,pomA,pomB,NOTIF_REQUEST_END);
        else
-               trio_asprintf(&pomC,"%s function=\"%s\">\r\n%s%s",
-                       NOTIF_REQUEST_BEGIN,function,pomA,NOTIF_REQUEST_END);
+               trio_asprintf(&pomC,"%s function=\"%s\">\r\n\t<flags>%s</flags>\r\n%s%s",
+                       NOTIF_REQUEST_BEGIN,function,cflags,pomA,NOTIF_REQUEST_END);
 
 
+       free(cflags);
        free(pomA);
        free(pomB);
         *message = pomC;
index 8db8237..d90447b 100644 (file)
@@ -61,7 +61,7 @@ static const char* const response_headers_html[] = {
 };
 
 extern int edg_wll_NotifNewServer(edg_wll_Context,
-                               edg_wll_QueryRec const * const *, char const *,
+                               edg_wll_QueryRec const * const *, int flags, char const *,
                                const edg_wll_NotifId, time_t *);
 extern int edg_wll_NotifBindServer(edg_wll_Context,
                                const edg_wll_NotifId, const char *, time_t *);
@@ -889,12 +889,13 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx,
                        edg_wll_NotifId notifId;
                        edg_wll_NotifChangeOp op;
                        edg_wll_QueryRec **conditions;
+                       int flags;
                        time_t validity = -1;
                        int i,j;
                        
                        
                        if (parseNotifRequest(ctx, messageBody, &function, &notifId, 
-                                               &address, &op, &validity, &conditions))
+                                               &address, &op, &validity, &conditions, &flags))
                                ret = HTTP_BADREQ;
                        else {
                                int     fatal = 0, err = 0;
@@ -903,7 +904,7 @@ edg_wll_ErrorCode edg_wll_Proto(edg_wll_Context ctx,
                                // navratove chyby nejsou zname, nutno predelat dle aktualni situace
                                if (!strcmp(function,"New")) 
                                        err = edg_wll_NotifNewServer(ctx,
-                                                               (edg_wll_QueryRec const * const *)conditions,
+                                                               (edg_wll_QueryRec const * const *)conditions, flags,
                                                                address, notifId, &validity);
                                else if (!strcmp(function,"Bind"))
                                        err = edg_wll_NotifBindServer(ctx, notifId, address, &validity);
index 99a4286..6eabd2d 100644 (file)
@@ -373,7 +373,8 @@ static void startNotifRequest(void *data, const char *el, const char **attr)
                                XMLCtx->jobQueryRec_begin = XML_GetCurrentByteIndex(XMLCtx->p);
                        }
                        else if ( (strcasecmp(el,"notifId")) && (strcasecmp(el,"clientAddress")) && 
-                               (strcasecmp(el,"notifChangeOp")) && (strcasecmp(el,"requestedValidity")) ) unexp()
+                               (strcasecmp(el,"notifChangeOp")) && (strcasecmp(el,"requestedValidity")) &&
+                               (strcasecmp(el,"flags")) ) unexp()
                        break;
                case 2: /* fall through */
                case 3: /* do not check xml tags, processed in startJobQueryRec */
@@ -858,6 +859,15 @@ static void endNotifRequest(void *data, const char *el UNUSED_VAR)
                        parseJobQueryRec(XMLCtx->ctx, XMLCtx->message_body + XMLCtx->jobQueryRec_begin, len,
                                &XMLCtx->job_conditions);
                }
+               else if (!strcmp(XMLCtx->element,"flags") && XMLCtx->char_buf) {
+                       char    *s;
+
+                       s = glite_lbu_UnescapeXML((const char *) XMLCtx->char_buf);
+                       // XXX: check if it works
+                       XMLCtx->flags = edg_wll_string_to_stat_flags(s);
+                       free(s);
+               }
+
        }
 
        edg_wll_freeBuf(XMLCtx);
@@ -1332,7 +1342,7 @@ int parseStatsRequest(edg_wll_Context ctx, char *messageBody, char **function, e
        return ret;
 }
 /* parse Notif request from client */
-int parseNotifRequest(edg_wll_Context ctx, char *messageBody, char **function, edg_wll_NotifId *notifId, char **address, edg_wll_NotifChangeOp *op, time_t *validity, edg_wll_QueryRec ***conditions) 
+int parseNotifRequest(edg_wll_Context ctx, char *messageBody, char **function, edg_wll_NotifId *notifId, char **address, edg_wll_NotifChangeOp *op, time_t *validity, edg_wll_QueryRec ***conditions, int *flags
 {
        int     ret;
        edg_wll_XML_ctx         XMLCtx;
@@ -1394,6 +1404,7 @@ int parseNotifRequest(edg_wll_Context ctx, char *messageBody, char **function, e
                *op = EDG_WLL_NOTIF_NOOP;
                *validity = 0;
                *conditions = NULL;
+               *flags = 0;
        } else {
                *function = XMLCtx.notifFunction;
                *notifId = XMLCtx.notifId;
@@ -1401,6 +1412,7 @@ int parseNotifRequest(edg_wll_Context ctx, char *messageBody, char **function, e
                *op = XMLCtx.notifChangeOp;
                *validity = XMLCtx.notifValidity;
                *conditions = XMLCtx.job_conditions;
+               *flags = XMLCtx.flags;
        }
 
        
index 2eaccf7..5ea1e3d 100644 (file)
@@ -20,7 +20,7 @@ int parseQueryEventsRequest(edg_wll_Context ctx, char *messageBody, edg_wll_Quer
 int parsePurgeRequest(edg_wll_Context ctx, char *messageBody, int (*tagToIndex)(), edg_wll_PurgeRequest *request);
 int parseDumpRequest(edg_wll_Context ctx, char *messageBody, edg_wll_DumpRequest *request);
 int parseLoadRequest(edg_wll_Context ctx, char *messageBody, edg_wll_LoadRequest *request);
-int parseNotifRequest(edg_wll_Context ctx, char *messageBody, char **function, edg_wll_NotifId *notifId, char **address, edg_wll_NotifChangeOp *op, time_t *validity, edg_wll_QueryRec ***conditions);
+int parseNotifRequest(edg_wll_Context ctx, char *messageBody, char **function, edg_wll_NotifId *notifId, char **address, edg_wll_NotifChangeOp *op, time_t *validity, edg_wll_QueryRec ***conditions, int *flags);
 int parseQuerySequenceCodeRequest(edg_wll_Context ctx, char *messageBody, edg_wlc_JobId *jobId, char **source);
 int edg_wll_QueryEventsToXML(edg_wll_Context, edg_wll_Event *, char **);
 int edg_wll_QueryJobsToXML(edg_wll_Context, edg_wlc_JobId *, edg_wll_JobStat *, char **);
index dbb8275..21da94f 100644 (file)
@@ -33,6 +33,7 @@ static void adjust_validity(edg_wll_Context,time_t *);
 int edg_wll_NotifNewServer(
        edg_wll_Context                                 ctx,
        edg_wll_QueryRec const * const *conditions,
+       int     flags,
        char const                                         *address_override,
        const edg_wll_NotifId                   nid,
        time_t                                             *valid)