zombie job prefix is now dependent on jobtype
authorMiloš Mulač <mulac@civ.zcu.cz>
Fri, 10 Oct 2008 10:39:19 +0000 (10:39 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Fri, 10 Oct 2008 10:39:19 +0000 (10:39 +0000)
org.glite.lb.server/src/query.c
org.glite.lb.server/src/srv_purge.c

index 2b4ae3e..d4f3a54 100644 (file)
@@ -537,7 +537,7 @@ limit_cycle_cleanup:
                        }
 
                        trio_asprintf(&zquery,"SELECT * FROM "
-                                               "(SELECT  concat('https://',p.prefix,'/',j.jobid,s.suffix) AS dg_jobid FROM "
+                                               "(SELECT  concat('https://',p.prefix,j.jobid,s.suffix) AS dg_jobid FROM "
                                                "zombie_suffixes AS s, zombie_jobs AS j, zombie_prefixes AS p WHERE "
                                                "(s.suffix_id = j.suffix_id) AND (p.prefix_id = j.prefix_id)) AS result "
                                                "WHERE %s", zomb_where);        
index 9d10138..ef92cc8 100644 (file)
@@ -511,21 +511,31 @@ static int dump_events(edg_wll_Context ctx, glite_jobid_const_t job, int dump, c
        return edg_wll_Error(ctx,NULL,NULL);
 }
 
-
-static int get_jobid_suffix(edg_wll_Context ctx, glite_jobid_const_t job, char **unique, char **suffix)
+static enum edg_wll_StatJobtype get_job_type(edg_wll_Context ctx, glite_jobid_const_t job)
 {
-       char            *ptr = NULL, *dbjob = NULL;
-       edg_wll_JobStat stat;
+       edg_wll_JobStat                 stat;
+       enum edg_wll_StatJobtype        type;
 
-       
        memset(&stat, 0, sizeof(stat));
        if (edg_wll_JobStatusServer(ctx, job, 0 /*no flags*/, &stat)) {
-               goto err;
-       }
+               edg_wll_FreeStatus(&stat);
+                return(EDG_WLL_NUMBER_OF_JOBTYPES);
+        }
+
+       type = stat.jobtype;
+       edg_wll_FreeStatus(&stat);
+
+       return(type);   
+}
+
+static int get_jobid_suffix(edg_wll_Context ctx, glite_jobid_const_t job, char **unique, char **suffix)
+{
+       char            *ptr = NULL, *dbjob = NULL;
        
+
        dbjob = glite_jobid_getUnique(job);
 
-       switch (stat.jobtype) {
+       switch (get_job_type(ctx, job)) {
                case EDG_WLL_STAT_SIMPLE:
                case EDG_WLL_STAT_DAG:
                case EDG_WLL_STAT__PARTITIONABLE_UNUSED:
@@ -555,6 +565,10 @@ static int get_jobid_suffix(edg_wll_Context ctx, glite_jobid_const_t job, char *
                        // condor jobs
                        assert(0); // XXX: todo
                        break;
+               case EDG_WLL_NUMBER_OF_JOBTYPES:
+                       // error getting job type, description in context
+                       goto err;
+                       break;
                default:
                        edg_wll_SetError(ctx,EINVAL,"Uknown job type");
                        goto err;
@@ -562,12 +576,53 @@ static int get_jobid_suffix(edg_wll_Context ctx, glite_jobid_const_t job, char *
        }
 
 err:   
-       edg_wll_FreeStatus(&stat);
        free(dbjob);
 
        return edg_wll_Error(ctx, NULL, NULL);
 }
 
+static int get_jobid_prefix(edg_wll_Context ctx, glite_jobid_const_t job, char **prefix)
+{
+       char    *ser = NULL;
+       
+
+       switch (get_job_type(ctx, job)) {
+               case EDG_WLL_STAT_SIMPLE:
+               case EDG_WLL_STAT_DAG:
+               case EDG_WLL_STAT__PARTITIONABLE_UNUSED:
+               case EDG_WLL_STAT__PARTITIONED_UNUSED:
+               case EDG_WLL_STAT_COLLECTION:
+                       // glite job prefix
+                       ser = glite_jobid_getServer(job);
+                       asprintf(prefix,"%s/",ser);
+                       free(ser);
+                       break;
+
+               case EDG_WLL_STAT_PBS:
+                       // PBS jobs; prefix same as glite job prefix
+                       ser = glite_jobid_getServer(job);
+                       asprintf(prefix,"%s/",ser);
+                       free(ser);
+                       break;
+
+               case EDG_WLL_STAT_CONDOR:
+                       // condor jobs
+                       assert(0); // XXX: todo
+                       break;
+               case EDG_WLL_NUMBER_OF_JOBTYPES:
+                       // error getting job type, description in context
+                       goto err;
+                       break;
+               default:
+                       edg_wll_SetError(ctx,EINVAL,"Uknown job type");
+                       goto err;
+                       break;
+       }
+
+err:   
+       return edg_wll_Error(ctx, NULL, NULL);
+}
+
 
 int purge_one(edg_wll_Context ctx,glite_jobid_const_t job,int dump, int purge, int purge_from_proxy_only)
 {
@@ -640,8 +695,10 @@ int purge_one(edg_wll_Context ctx,glite_jobid_const_t job,int dump, int purge, i
 
                if ( purge )
                {
-                       // get job suffix before its state is deleted
+                       // get job prefix/suffix before its state is deleted
                        if ( get_jobid_suffix(ctx, job, &root, &suffix) ) goto rollback;
+                       if ( get_jobid_prefix(ctx, job, &prefix) ) goto rollback;
+                       
                
                }
 
@@ -666,7 +723,6 @@ int purge_one(edg_wll_Context ctx,glite_jobid_const_t job,int dump, int purge, i
                if ( purge )
                {
                        /* Store zombie prefix */
-                       prefix = glite_jobid_getServer(job);
                
                        // See if that prefix is already stored in the database 
                        trio_asprintf(&stmt,"select prefix_id from zombie_prefixes where prefix = '%|Ss'", prefix);
@@ -695,6 +751,7 @@ int purge_one(edg_wll_Context ctx,glite_jobid_const_t job,int dump, int purge, i
                        ret = edg_wll_FetchRow(ctx,q, 1, NULL, &prefix_id);
                        glite_lbu_FreeStmt(&q);
 
+
                        /* Store zombie suffix */
 
                        // See if that suffix is already stored in the database