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;
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)
{
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;
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
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* );
#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 *);
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;
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
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);
for (i=0; i<e->nsubjobs; 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);