From 6c00efa3d8c36db5115e7d6437465d65de9ce0b8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Milo=C5=A1=20Mula=C4=8D?= Date: Wed, 12 Jul 2006 12:49:30 +0000 Subject: [PATCH] - store jobid-userid relation for embryonic subjobs in jobs table - store owner and submission time is states table - some cleanup => jobs_status of embryonic subjob now returns reasonable values --- org.glite.lb.server/src/jobstat.c | 18 ++++++++---------- org.glite.lb.server/src/jobstat.h | 4 ++++ org.glite.lb.server/src/store.c.T | 19 ++++++++++++++----- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/org.glite.lb.server/src/jobstat.c b/org.glite.lb.server/src/jobstat.c index 6ff978e..d152dee 100644 --- a/org.glite.lb.server/src/jobstat.c +++ b/org.glite.lb.server/src/jobstat.c @@ -38,11 +38,7 @@ static void warn (const char* format, ...) UNUSED_VAR ; static char *job_owner(edg_wll_Context,char *); -int edg_wll_intJobStatus(edg_wll_Context, const edg_wlc_JobId, int, intJobStat *, int); -edg_wll_ErrorCode edg_wll_StoreIntState(edg_wll_Context, intJobStat *, int); -edg_wll_ErrorCode edg_wll_StoreIntStateEmbryonic(edg_wll_Context, edg_wlc_JobId, edg_wlc_JobId); -static edg_wll_ErrorCode states_values_embryonic(edg_wll_Context, edg_wlc_JobId, edg_wlc_JobId, char **, char**); -edg_wll_ErrorCode edg_wll_LoadIntState(edg_wll_Context , edg_wlc_JobId , int, intJobStat **); +static edg_wll_ErrorCode states_values_embryonic(edg_wll_Context, edg_wlc_JobId, const edg_wll_RegJobEvent *e, char **, char**); int js_enable_store = 1; @@ -564,7 +560,7 @@ cleanup: static edg_wll_ErrorCode states_values_embryonic( edg_wll_Context ctx, edg_wlc_JobId jobid, - edg_wlc_JobId parent_job, + const edg_wll_RegJobEvent *e, char **icnames, char **values) { @@ -576,11 +572,13 @@ static edg_wll_ErrorCode states_values_embryonic( init_intJobStat(stat); if (edg_wlc_JobIdDup(jobid, &stat->pub.jobId) || - edg_wlc_JobIdDup(parent_job, &stat->pub.parent_job)) goto err; + edg_wlc_JobIdDup(e->jobId, &stat->pub.parent_job)) goto err; stat->pub.state = EDG_WLL_JOB_SUBMITTED; + stat->pub.owner = strdup(e->user); + stat->pub.stateEnterTimes[1 + EDG_WLL_JOB_SUBMITTED] = (int)e->timestamp.tv_sec; jobid_md5 = edg_wlc_JobIdGetUnique(jobid); - parent_md5 = edg_wlc_JobIdGetUnique(parent_job); + parent_md5 = edg_wlc_JobIdGetUnique(e->jobId); stat_enc = enc_intJobStat(strdup(""), stat); if (jobid_md5 == NULL || parent_md5 == NULL || stat_enc == NULL) goto err; @@ -603,13 +601,13 @@ err: edg_wll_ErrorCode edg_wll_StoreIntStateEmbryonic(edg_wll_Context ctx, edg_wlc_JobId jobid, - edg_wlc_JobId parent_job) + const edg_wll_RegJobEvent *e) { char *values = NULL; char *stmt = NULL; char *icnames = NULL; - if (states_values_embryonic(ctx, jobid, parent_job, &icnames, &values)) + if (states_values_embryonic(ctx, jobid, e, &icnames, &values)) goto cleanup; /* TODO diff --git a/org.glite.lb.server/src/jobstat.h b/org.glite.lb.server/src/jobstat.h index 57bc480..be29e0f 100644 --- a/org.glite.lb.server/src/jobstat.h +++ b/org.glite.lb.server/src/jobstat.h @@ -55,6 +55,10 @@ void destroy_intJobStat_extension(intJobStat *p); edg_wll_ErrorCode edg_wll_IColumnsSQLPart(edg_wll_Context, void *, intJobStat *, int , char **, char **); edg_wll_ErrorCode edg_wll_RefreshIColumns(edg_wll_Context, void *); int edg_wll_intJobStatus( edg_wll_Context, const edg_wlc_JobId, int, intJobStat *, int); +edg_wll_ErrorCode edg_wll_StoreIntState(edg_wll_Context, intJobStat *, int); +edg_wll_ErrorCode edg_wll_StoreIntStateEmbryonic(edg_wll_Context, edg_wlc_JobId, const edg_wll_RegJobEvent *e); +edg_wll_ErrorCode edg_wll_LoadIntState(edg_wll_Context , edg_wlc_JobId , int, intJobStat **); + intJobStat* dec_intJobStat(char *, char **); char *enc_intJobStat(char *, intJobStat* ); diff --git a/org.glite.lb.server/src/store.c.T b/org.glite.lb.server/src/store.c.T index 47c7c94..a0c213a 100644 --- a/org.glite.lb.server/src/store.c.T +++ b/org.glite.lb.server/src/store.c.T @@ -32,6 +32,7 @@ #include "lbs_db.h" #include "lock.h" #include "lb_authz.h" +#include "jobstat.h" static int store_user(edg_wll_Context,const char *,const char *); static int store_job(edg_wll_Context,const edg_wlc_JobId,const char *); @@ -40,7 +41,7 @@ static int store_seq(edg_wll_Context,edg_wll_Event *,int); static int check_dup(edg_wll_Context,edg_wll_Event *); static int check_auth(edg_wll_Context,edg_wll_Event *e); static int register_subjobs(edg_wll_Context,const edg_wll_RegJobEvent *); -static int register_subjobs_embrionic(edg_wll_Context,const edg_wll_RegJobEvent *); +static int register_subjobs_embryonic(edg_wll_Context,const edg_wll_RegJobEvent *); void edg_wll_StoreAnonymous(edg_wll_Context ctx,int anon) { ctx->allowAnonymous = anon; @@ -201,7 +202,7 @@ int edg_wll_StoreEvent(edg_wll_Context ctx,edg_wll_Event *e,int *seq) e->regJob.nsubjobs > 0) #ifdef LB_DAG_EMBRIONIC - err = register_subjobs_embrionic(ctx,&e->regJob); + err = register_subjobs_embryonic(ctx,&e->regJob); #else err = register_subjobs(ctx,&e->regJob); #endif @@ -568,11 +569,12 @@ static int register_subjobs(edg_wll_Context ctx,const edg_wll_RegJobEvent *e) return edg_wll_Error(ctx,NULL,NULL); } -static int register_subjobs_embrionic(edg_wll_Context ctx,const edg_wll_RegJobEvent *e) +static int register_subjobs_embryonic(edg_wll_Context ctx,const edg_wll_RegJobEvent *e) { - int i,err; + int i, err = 0; edg_wlc_JobId *subjobs; struct timeval now; + char *userid = strdup(strmd5(e->user,NULL)); edg_wll_ResetError(ctx); @@ -592,10 +594,17 @@ static int register_subjobs_embrionic(edg_wll_Context ctx,const edg_wll_RegJobEv for (i=0; insubjobs; i++) { char *et,*ed,*job_s; + /* save jobid-userid relation into jobs table */ + if ((err = store_job(ctx, subjobs[i], userid))) + edg_wll_Error(ctx,&et,&ed); - if ((err = edg_wll_StoreIntStateEmbryonic(ctx, subjobs[i], e->jobId))) + if (!err && (err = edg_wll_StoreIntStateEmbryonic(ctx, subjobs[i], e))) edg_wll_Error(ctx,&et,&ed); +job_s = edg_wlc_JobIdUnparse(subjobs[i]); +printf("%s\n", job_s); +free(job_s); + if (err) { job_s = edg_wlc_JobIdUnparse(subjobs[i]); fprintf(stderr,"%s: %s (%s)\n",job_s,et,ed); -- 1.8.2.3