Allow checking zombies if a job is registered with the EDG_WLL_LOGLFLAG_EXCL set.
authorZdeněk Šustr <sustr4@cesnet.cz>
Tue, 15 Jun 2010 14:00:30 +0000 (14:00 +0000)
committerZdeněk Šustr <sustr4@cesnet.cz>
Tue, 15 Jun 2010 14:00:30 +0000 (14:00 +0000)
Implement cmdline option to turn that check on.

org.glite.lb.common/interface/context-int.h
org.glite.lb.server/doc/glite-lb-bkserverd.8
org.glite.lb.server/src/bkindex.c
org.glite.lb.server/src/bkserverd.c
org.glite.lb.server/src/store.c.T

index d7f4b0a..48c5d74 100644 (file)
@@ -176,6 +176,8 @@ glite_lb_padded_struct(_edg_wll_Context,150,
 
        time_t          rssTime;
        _edg_wll_authz_policy   authz_policy;
+
+       int             exclusive_zombies;
 )
 
 /* to be used internally: set, update and and clear the error information in 
index 60ca665..5493a6e 100644 (file)
@@ -264,6 +264,10 @@ File prefix for events.
 .BI -G\fR,\fP --proxy-purge
 Enable automatic purging of the jobs in terminal state for proxy service (disabled by default, purging cron job installed by YAIM).
 
+.TP
+.BI -E\fR,\fP --exclusive-zombies
+Check also purged jobs when registering a job with known JobID and the EDG_WLL_LOGLFLAG_EXCL flag set. 
+
 .\".SH USAGE
 .\" Add any additional description here
 
index ed18343..e0d302b 100644 (file)
@@ -48,6 +48,7 @@ int   enable_lcas;
 int    proxy_purge;
 struct _edg_wll_authz_policy authz_policy;
 char    *policy_file = NULL;
+int    exclusive_zombies;
 
 static struct option opts[] = {
        { "mysql",1,NULL,'m' },
index 3e074c8..fda4bf1 100644 (file)
@@ -184,6 +184,7 @@ static char *           port;
 static time_t          rss_time = 60*60;
 char *         policy_file = NULL;
 struct _edg_wll_authz_policy   authz_policy = { NULL, 0};
+static int             exclusive_zombies = 0;
 
 
 
@@ -234,10 +235,11 @@ static struct option opts[] = {
        {"proxy-purge", 0,      NULL,   'G'},
        {"rss-time",    1,      NULL,   'I'},
        {"policy",      1,      NULL,   'l'},
+       {"exclusive-zombies",   0,      NULL,   'E'},
        {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:GI:l:"
+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:GI:l:E"
 #ifdef GLITE_LB_SERVER_WITH_WS
        "w:"
 #endif
@@ -296,6 +298,7 @@ static void usage(char *me)
                "\t-G,--proxy-purge\t enable automatic purge on proxy service (disabled by default)\n"
                "\t-I,--rss-time\t age (in seconds) of job states published via RSS\n"
                "\t-l,--policy\tauthorization policy file\n"
+               "\t-E,--exclusive-zombies\twith 'exclusive' flag, avoid reusing even zombified JobIDs\n"
 
        ,me);
 }
@@ -509,6 +512,8 @@ int main(int argc, char *argv[])
                          break;
                case 'l': policy_file = strdup(optarg);
                          break;
+               case 'E': exclusive_zombies = 1;
+                         break;
                case '?': usage(name); return 1;
        }
 
@@ -1277,6 +1282,7 @@ int bk_handle_connection(int conn, struct timeval *timeout, void *data)
        }
        ctx->strict_locking = strict_locking;
        ctx->greyjobs = greyjobs;
+       ctx->exclusive_zombies = exclusive_zombies;
 
        return 0;
 }
index e72a773..9213926 100644 (file)
@@ -282,7 +282,7 @@ int store_job_server_proxy(edg_wll_Context ctx, edg_wll_Event *event, int *regis
 {
        char            *unique = edg_wlc_JobIdGetUnique(event->any.jobId);
        char            *q = NULL, *userid = NULL, *subj = NULL, *owner = NULL;
-       glite_lbu_Statement    stmt = NULL;
+       glite_lbu_Statement    stmt = NULL, stmt_zomb = NULL;
        int             nar, grey = 0;
        char            *can_peername = NULL;
        int             local_job = is_job_local(ctx, event->any.jobId);
@@ -310,7 +310,6 @@ int store_job_server_proxy(edg_wll_Context ctx, edg_wll_Event *event, int *regis
        if (nar < 0) goto err;
        else if (nar == 0) {
                /* Job not stored yet */
-
                if (event->any.type == EDG_WLL_EVENT_REGJOB) {
 
                /* XXX: directness is checked by any.user == peerName. Not perfect but better than event flags. */
@@ -320,6 +319,18 @@ int store_job_server_proxy(edg_wll_Context ctx, edg_wll_Event *event, int *regis
                                goto err;
 
                        }
+                       if ((event->any.priority & EDG_WLL_LOGLFLAG_EXCL) && ctx->exclusive_zombies) {
+                               trio_asprintf(&q,"select jobid from zombie_jobs "
+                                       "where zombie_jobs.jobid='%|Ss'",unique);
+
+                               if (edg_wll_ExecSQL(ctx,q,&stmt_zomb) > 0) {
+                                       edg_wll_SetError(ctx,EEXIST,"Zombie job with given jobid already exists. Rejecting event.");
+                                       goto err;
+                               }
+                               if (stmt_zomb) { glite_lbu_FreeStmt(&stmt_zomb); stmt_zomb = NULL; }
+                               free (q); q = NULL;
+                       }
+
                        /* else OK */
                }
                else {