Time for RSS feed.
authorJiří Filipovič <fila@ics.muni.cz>
Tue, 28 Apr 2009 10:50:17 +0000 (10:50 +0000)
committerJiří Filipovič <fila@ics.muni.cz>
Tue, 28 Apr 2009 10:50:17 +0000 (10:50 +0000)
org.glite.lb.server/src/bkserverd.c
org.glite.lb.server/src/lb_proto.c

index d733b49..26c1bff 100644 (file)
@@ -163,6 +163,7 @@ static char             sock_store[PATH_MAX],
 static int             con_queue = CON_QUEUE;
 static char             host[300];
 static char *           port;
+static time_t          rss_time = 60*60;
 
 
 
@@ -210,10 +211,11 @@ static struct option opts[] = {
        {"con-queue",   1,      NULL,   'q'},
        {"proxy-il-sock",       1,      NULL,   'W'},
        {"proxy-il-fprefix",    1,      NULL,   'Z'},
+       {"rss-time",    1,      NULL,   'I'},
        {NULL,0,NULL,0}
 };
 
-static const char *get_opt_string = "Ac:k:C:V:p:a:drm:ns:i:S:D:J:jR:F:xOL:N:X:Y:T:t:zb:gPBo:q:W:Z:"
+static const char *get_opt_string = "Ac:k:C:V:p:a:drm:ns:i:S:D:J:jR:F:xOL:N:X:Y:T:t:zb:gPBo:q:W:Z:I:"
 #ifdef GLITE_LB_SERVER_WITH_WS
        "w:"
 #endif
@@ -269,6 +271,7 @@ static void usage(char *me)
                "\t-q,--con-queue\t size of the connection queue (accept)\n"
                "\t-W,--proxy-il-sock\t socket to send events to\n"
                "\t-Z,--proxy-il-fprefix\t file prefix for events\n"
+               "\t-I,--rss-time age\t (in seconds) of job states published via RSS\n"
 
        ,me);
 }
@@ -472,6 +475,8 @@ int main(int argc, char *argv[])
                          break;
                case 'Z': lbproxy_ilog_file_prefix = strdup(optarg);
                          break;
+               case 'I': sscanf(optarg, "%d", &rss_time);
+                         break;
                case '?': usage(name); return 1;
        }
 
@@ -970,6 +975,8 @@ int bk_handle_connection(int conn, struct timeval *timeout, void *data)
 
        ctx->serverIdentity = strdup(server_subject);
 
+       ctx->rssTime = rss_time;
+
        gettimeofday(&conn_start, 0);
 
        h_errno = asyn_gethostbyaddr(&name, (char *)&a.sin_addr.s_addr,sizeof(a.sin_addr.s_addr), AF_INET, &dns_to);
@@ -1251,6 +1258,7 @@ int bk_handle_connection_proxy(int conn, struct timeval *timeout, void *data)
                return -1;
        }
 
+       ctx->rssTime = rss_time;
 
        return 0;
 }
index 47632b0..62aa4eb 100644 (file)
@@ -295,7 +295,7 @@ static int getJobsRSS(edg_wll_Context ctx, char *feedType, edg_wll_JobStat **sta
        char *can_peername = edg_wll_gss_normalize_subj(ctx->peerName, 0);
 
        if (strncmp(feedType, "finished", strlen("finished")) == 0){
-               conds = malloc(3*sizeof(*conds));
+               conds = malloc(4*sizeof(*conds));
                conds[0] = malloc(2*sizeof(**conds));
                conds[0][0].attr = EDG_WLL_QUERY_ATTR_OWNER;
                conds[0][0].op = EDG_WLL_QUERY_OP_EQUAL;
@@ -312,7 +312,13 @@ static int getJobsRSS(edg_wll_Context ctx, char *feedType, edg_wll_JobStat **sta
                 conds[1][2].op = EDG_WLL_QUERY_OP_EQUAL;
                 conds[1][2].value.i = EDG_WLL_JOB_CANCELLED;
                conds[1][3].attr = EDG_WLL_QUERY_ATTR_UNDEF;
-               conds[2] = NULL;
+               conds[2] = malloc(2*sizeof(**conds));
+               conds[2][0].attr = EDG_WLL_QUERY_ATTR_STATEENTERTIME;
+               conds[2][0].op = EDG_WLL_QUERY_OP_GREATER;
+               conds[2][0].value.t.tv_sec = time(NULL) - ctx->rssTime;
+               conds[2][0].value.t.tv_usec = 0;
+               conds[2][1].attr = EDG_WLL_QUERY_ATTR_UNDEF;
+               conds[3] = NULL;
        }
        else{
                *statesOut = NULL;