- feed purging implemented
authorJiří Filipovič <fila@ics.muni.cz>
Thu, 28 Feb 2008 17:10:26 +0000 (17:10 +0000)
committerJiří Filipovič <fila@ics.muni.cz>
Thu, 28 Feb 2008 17:10:26 +0000 (17:10 +0000)
- TTL of the feed has set to 6 minutes

org.glite.jp.primary/src/feed.c
org.glite.jp.primary/src/new_ftp_backend.c
org.glite.jp.primary/src/soap_ops.c

index 6e59a2c..47e9fea 100644 (file)
@@ -23,7 +23,8 @@ 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       36000000
+//#define FEED_TTL     36000000
+#define FEED_TTL      360
 
 /* XXX: configurable */
 #define BATCH_FEED_SIZE        200
@@ -675,7 +676,7 @@ int glite_jpps_run_feed(
                f = make_jpfeed(destination,attrs,qry,*feed_id,(time_t) 0);
        f->continuous = continuous;
        glite_jp_add_deferred(ctx,run_feed_deferred,f);
-
+       
        return 0;
 }
 
@@ -710,3 +711,11 @@ int glite_jpps_register_feed(
        return 0;
 }
 
+int glite_jpps_refresh_feed(glite_jp_context_t ctx, char *feed_id,  time_t *expires){
+       time(expires); *expires += FEED_TTL;
+
+       glite_jppsbe_refresh_feed(ctx, feed_id, expires);
+       
+       return 0;       
+}
+
index 5c67166..353c81b 100644 (file)
@@ -477,7 +477,6 @@ int glite_jppsbe_start_upload(
        /* XXX authorization done in soap_ops.c */
 
        /* XXX name length */
-       printf("data_basename: %s\n", data_basename);
        if (asprintf(&data_basename, "%s%s%s", class,
                (name != NULL) ? "." : "",
                (name != NULL) ? name : "") == -1) {
@@ -2336,6 +2335,37 @@ cleanup:
 
 }
 
+int glite_jppsbe_refresh_feed(
+        glite_jp_context_t ctx,
+        char *feed_id,
+       time_t *expires
+)
+{
+       glite_jp_error_t        err;
+        memset(&err,0,sizeof err);
+
+       char *stmt = NULL;
+
+       trio_asprintf(&stmt, "update feeds set expires=%s where feedid='%ISs'",
+               expires, feed_id);
+       if (!stmt) {
+                err.code = ENOMEM;
+                goto error_out;
+        }
+
+        if (glite_jp_db_ExecSQL(ctx, stmt, NULL) < 0) {
+                err.code = EIO;
+                err.desc = "DB access failed";
+                goto error_out;
+        }
+
+error_out:
+        free(stmt);
+        if (err.code)
+                return glite_jp_stack_error(ctx,&err);
+        else
+                return 0;
+}
 
 /** purge expired feeds */
 int glite_jppsbe_purge_feeds(
@@ -2361,6 +2391,7 @@ int glite_jppsbe_purge_feeds(
        }
 
        while ((rows = glite_jp_db_FetchRow(ctx,q,1,NULL,&feed)) > 0) {
+               printf("feed %s has expired.\n", feed);
                free(stmt);
                trio_asprintf(&stmt,"delete from fed_jobs where feedid = '%|Ss'",feed);
                if ((rows = glite_jp_db_ExecSQL(ctx, stmt, NULL)) < 0) {
index 8c4ed06..c6a7604 100644 (file)
@@ -396,8 +396,21 @@ SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__FeedIndexRefresh(
                struct _jpelem__FeedIndexRefresh *in,
                struct _jpelem__FeedIndexRefreshResponse *out)
 {
-       fprintf(stderr,"%s: not implemented\n",__FUNCTION__);
-       abort();
+       CONTEXT_FROM_SOAP(soap,ctx);
+
+       time_t  expires = 0;
+        int     ret = SOAP_OK;
+
+       glite_jp_clear_error(ctx);
+       
+       if (glite_jpps_refresh_feed(ctx, in->feedId, &expires)){
+               err2fault(ctx,soap);
+                ret = SOAP_FAULT;
+               return ret;
+       }
+       out->feedExpires = expires;
+
+       return ret;
 }
 
 SOAP_FMAC5 int SOAP_FMAC6 __jpsrv__GetJobFiles(