send all known attributes when a job is fed at the first time
authorAleš Křenek <ljocha@ics.muni.cz>
Fri, 14 Oct 2005 17:02:19 +0000 (17:02 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Fri, 14 Oct 2005 17:02:19 +0000 (17:02 +0000)
org.glite.jp.primary/src/bones_server.c
org.glite.jp.primary/src/feed.c
org.glite.jp.primary/src/is_client.c
org.glite.jp.primary/src/is_client.h

index b13e576..3d4f835 100644 (file)
@@ -225,6 +225,7 @@ static int data_init(void **data)
        glite_jppsbe_init_slave(ctx);   /* XXX: global but slave's */
        sleep(10);
        if (glite_jppsbe_read_feeds(ctx)) fputs(glite_jp_error_chain(ctx),stderr);
+       printf("[%d] slave init done\n",getpid());
 
        return 0;
 }
index 641100c..845453c 100644 (file)
@@ -23,7 +23,7 @@ extern pid_t  master;
  * seconds before feed expires: should be 
  * XXX: should be configurable, default for real deployment sort of 1 hour
  */
-#define FEED_TTL       120
+#define FEED_TTL       3600
 
 /* XXX: configurable */
 #define BATCH_FEED_SIZE        200
@@ -74,8 +74,16 @@ int full_feed(
        const char *job,
        glite_jp_attrval_t **attrs)
 {
-       /* TODO: */
-       abort();
+       int     i,ret;
+       char    **ma;
+
+       for (i=0; feed->attrs[i]; i++);
+       ma = malloc((i+2) * sizeof *ma);
+       ma[0] = GLITE_JP_ATTR_OWNER;
+       memcpy(ma+1,feed->attrs,(i+1) * sizeof *ma);
+       ret = glite_jpps_get_attrs(ctx,job,ma,i+1,attrs);
+       free(ma);
+       return ret;
 }
 
 /* XXX: limit on query size -- I'm lazy to malloc() */
@@ -93,10 +101,12 @@ static int match_feed(
 {
        int     i,fed;
        int     qi[QUERY_MAX];
-
+       char    *owner = NULL;
+       glite_jp_attrval_t      meta[QUERY_MAX+1];
        glite_jp_attrval_t *newattr = NULL;
 
        glite_jp_clear_error(ctx);
+       memset(meta,0,sizeof meta);
 
        if (feed->qry) {
                int     j,complete = 1;
@@ -124,7 +134,6 @@ static int match_feed(
                 * over multiple invocations of match_feed() for the same job.
                 */
                if (!complete) {
-                       glite_jp_attrval_t      meta[QUERY_MAX+1];
                        int     qi2[QUERY_MAX];
 
                        memset(meta,0,sizeof meta);
@@ -145,9 +154,11 @@ static int match_feed(
                                return glite_jp_stack_error(ctx,&err);
                        }
 
-                       for (i=0; meta[i].name; i++)
+                       for (i=0; meta[i].name; i++) {
                                if (!check_qry_item(ctx,feed->qry+qi2[i],meta+i))
                                        return 0;
+                               if (!strcmp(meta[i].name,GLITE_JP_ATTR_OWNER)) owner = meta[i].value;
+                       }
                }
        }
 
@@ -156,11 +167,21 @@ static int match_feed(
        if (!fed) {
                glite_jp_attrval_t      *a;
                full_feed(ctx,feed,job,&a);
-               glite_jpps_single_feed(ctx,feed->id,0,feed->destination,job,a);
+               for (i=0; a[i].name && strcmp(a[i].name,GLITE_JP_ATTR_OWNER); i++);
+               owner = a[i].value;
+
+               glite_jpps_single_feed(ctx,feed->id,0,feed->destination,job,owner,a);
                for (i=0; a[i].name; i++) glite_jp_attrval_free(a+i,0);
                free(a);
        }
-       else glite_jpps_single_feed(ctx,feed->id,0,feed->destination,job,attrs);
+       else {
+               if (!owner) {
+                       glite_jppsbe_get_job_metadata(ctx,job,meta);
+                       for (i=0; meta[i].name && strcmp(meta[i].name,GLITE_JP_ATTR_OWNER); i++);
+               }
+               glite_jpps_single_feed(ctx,feed->id,0,feed->destination,job,owner,attrs);
+       }
+       for (i=0; meta[i].name; i++) glite_jp_attrval_free(meta+i,0);
        return 0;
 }
 
@@ -232,6 +253,7 @@ int glite_jpps_match_file(
        void    *bh = NULL;
        int     ret;
        struct  jpfeed  *f = ctx->feeds;
+       glite_jp_attrval_t      meta[QUERY_MAX+1];
 
        int     nvals = 0,j,i;
        char            **attrs = NULL, **attrs2;
@@ -304,7 +326,10 @@ int glite_jpps_match_file(
                        memset(fattr+j,0,sizeof *fattr);
 
                }
-               glite_jpps_single_feed(ctx,f->id,0,f->destination,job,fattr);
+               glite_jppsbe_get_job_metadata(ctx,job,meta);
+               for (i=0; meta[i].name && strcmp(meta[i].name,GLITE_JP_ATTR_OWNER); i++);
+               glite_jpps_single_feed(ctx,f->id,0,f->destination,job,meta[i].value,fattr);
+               for (i=0; meta[i].name; i++) glite_jp_attrval_free(meta+i,0);
                if (!fed) for (i=0; fattr[i].name; i++) glite_jp_attrval_free(fattr+i,0);
                free(fattr);
        }
index dc248d5..d2d3f0d 100644 (file)
@@ -63,6 +63,7 @@ int glite_jpps_single_feed(
                int     done,
                const char *destination,
                const char *job,
+               const char *owner,
                glite_jp_attrval_t const *attrs
 )
 {
@@ -89,6 +90,7 @@ int glite_jpps_single_feed(
 
        for (i=0; attrs[i].name; i++);
        jr.jobid = (char *) job; /* XXX: const */
+       jr.owner = owner;
 
        jr.__sizeattributes = jp2s_attrValues(ctx->other_soap,
                        (glite_jp_attrval_t *) attrs, /* XXX: const */
index 98463b0..74e4456 100644 (file)
@@ -1,4 +1,4 @@
-int glite_jpps_single_feed(glite_jp_context_t,const char *,int,const char *,const char *,glite_jp_attrval_t const *);
+int glite_jpps_single_feed(glite_jp_context_t,const char *,int,const char *,const char *,const char *,glite_jp_attrval_t const *);
 int glite_jpps_multi_feed(glite_jp_context_t,const char *,int,int,const char *,char **,char **,glite_jp_attrval_t **);