From: Miloš Mulač Date: Mon, 12 Feb 2007 16:29:41 +0000 (+0000) Subject: support for new PBS events, new flesh in pbs state automaton X-Git-Tag: gridsite-core_R_1_4_0~7 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=9592705472f4976871572904ae50c8a8e8986c9e;p=jra1mw.git support for new PBS events, new flesh in pbs state automaton - should be compilable --- diff --git a/org.glite.lb.client/examples/job_status.c b/org.glite.lb.client/examples/job_status.c index 5dc3e85..374e023 100644 --- a/org.glite.lb.client/examples/job_status.c +++ b/org.glite.lb.client/examples/job_status.c @@ -292,7 +292,7 @@ static void printstat(edg_wll_JobStat stat, int level) printf("%spbs_dest_host : %s\n", ind, stat.pbs_dest_host); printf("%spbs_pid : %d\n", ind, stat.pbs_pid); printf("%spbs_exit_status : %d\n", ind, stat.pbs_exit_status); - printf("%spbs_error : %s\n", ind, stat.pbs_error); + printf("%spbs_error_desc : %s\n", ind, stat.pbs_error_desc); } printf("\n"); diff --git a/org.glite.lb.server/src/jobstat_supp.c b/org.glite.lb.server/src/jobstat_supp.c index d0b5749..41c8fbd 100644 --- a/org.glite.lb.server/src/jobstat_supp.c +++ b/org.glite.lb.server/src/jobstat_supp.c @@ -507,7 +507,7 @@ static char *enc_JobStat(char *old, edg_wll_JobStat* stat) if (ret) ret = enc_string(ret, stat->pbs_dest_host); if (ret) ret = enc_int(ret, stat->pbs_pid); if (ret) ret = enc_int(ret, stat->pbs_exit_status); - if (ret) ret = enc_string(ret, stat->pbs_error); + if (ret) ret = enc_string(ret, stat->pbs_error_desc); return ret; } @@ -569,7 +569,7 @@ static edg_wll_JobStat* dec_JobStat(char *in, char **rest) if (tmp_in != NULL) stat->pbs_dest_host = dec_string(tmp_in, &tmp_in); if (tmp_in != NULL) stat->pbs_pid = dec_int(tmp_in, &tmp_in); if (tmp_in != NULL) stat->pbs_exit_status = dec_int(tmp_in, &tmp_in); - if (tmp_in != NULL) stat->pbs_error = dec_string(tmp_in, &tmp_in); + if (tmp_in != NULL) stat->pbs_error_desc = dec_string(tmp_in, &tmp_in); *rest = tmp_in; diff --git a/org.glite.lb.server/src/process_event_pbs.c b/org.glite.lb.server/src/process_event_pbs.c index 21a7a60..ddb0bac 100644 --- a/org.glite.lb.server/src/process_event_pbs.c +++ b/org.glite.lb.server/src/process_event_pbs.c @@ -33,6 +33,7 @@ static int compare_timestamps(struct timeval a, struct timeval b) #define USABLE(res) ((res) == RET_OK) #define USABLE_DATA(res) (1) #define rep(a,b) { free(a); a = (b == NULL) ? NULL : strdup(b); } +#define rep_cond(a,b) { if (b) { free(a); a = strdup(b); } } int processEvent_PBS(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring) { @@ -54,13 +55,14 @@ int processEvent_PBS(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, c if (USABLE_DATA(res)) { } break; + // XXX - do we need this event ?? case EDG_WLL_EVENT_PBSREG: if (USABLE(res)) { js->pub.state = EDG_WLL_JOB_SUBMITTED; rep(js->pub.pbs_state, "Q"); } if (USABLE_DATA(res)) { - js->pub.pbs_queue = strdup(e->PBSReg.queue); + rep_cond(js->pub.pbs_queue, e->PBSReg.queue); } break; case EDG_WLL_EVENT_PBSQUEUED: @@ -72,10 +74,11 @@ int processEvent_PBS(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, c if (!js->pub.pbs_queue) js->pub.pbs_queue = strdup(e->PBSQueued.queue); assert(!strcmp(js->pub.pbs_queue, e->PBSQueued.queue)); - rep(js->pub.pbs_owner,e->PBSQueued.owner); - rep(js->pub.pbs_name,e->PBSQueued.name); + rep_cond(js->pub.pbs_owner,e->PBSQueued.owner); + rep_cond(js->pub.pbs_name,e->PBSQueued.name); } break; + // XXX - do we need this event ?? case EDG_WLL_EVENT_PBSPLAN: if (USABLE(res)) { js->pub.state = EDG_WLL_JOB_READY; @@ -84,26 +87,87 @@ int processEvent_PBS(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, c if (USABLE_DATA(res)) { } break; + case EDG_WLL_EVENT_PBSMATCH: + if (USABLE(res)) { + js->pub.state = EDG_WLL_JOB_READY; + rep(js->pub.pbs_state, "Q"); + } + if (USABLE_DATA(res)) { + rep_cond(js->pub.pbs_dest_host,e->PBSMatch.dest_host); + } + break; + case EDG_WLL_EVENT_PBSPENDING: + if (USABLE(res)) { + js->pub.state = EDG_WLL_JOB_WAITING; + rep(js->pub.pbs_state, "Q"); + } + if (USABLE_DATA(res)) { + rep_cond(js->pub.pbs_reason,e->PBSPending.reason); + } + break; case EDG_WLL_EVENT_PBSRUN: if (USABLE(res)) { js->pub.state = EDG_WLL_JOB_RUNNING; rep(js->pub.pbs_state, "R"); } if (USABLE_DATA(res)) { - rep(js->pub.pbs_scheduler, e->PBSRun.scheduler); - rep(js->pub.pbs_dest_host, e->PBSRun.dest_host); + rep_cond(js->pub.pbs_scheduler, e->PBSRun.scheduler); + rep_cond(js->pub.pbs_dest_host, e->PBSRun.dest_host); js->pub.pbs_pid = e->PBSRun.pid; } break; case EDG_WLL_EVENT_PBSDONE: if (USABLE(res)) { js->pub.state = EDG_WLL_JOB_DONE; + js->pub.done_code = EDG_WLL_STAT_OK; rep(js->pub.pbs_state, "C"); } if (USABLE_DATA(res)) { js->pub.pbs_exit_status = e->PBSDone.exit_status; } break; + case EDG_WLL_EVENT_PBSRESOURCEUSAGE: + if (USABLE(res)) { + // signalize state done, done_code uknown + js->pub.state = EDG_WLL_JOB_DONE; + rep(js->pub.pbs_state, "C"); + } + if (USABLE_DATA(res)) { + /* + XXX: do we want this info in status? + char *new_resource_usage; + + asprintf(&new_resource_usage,"%s%s%s = %d [%s]", + (js->pub.pbs_resource_usage) ? js->pub.pbs_resource_usage : "", + (js->pub.pbs_resource_usage) ? "\n": "", + e->PBSResourceUsage.name, + e->PBSResourceUsage.quantity, + e->PBSResourceUsage.unit); + + if (js->pub.pbs_resource_usage) free(js->pub.pbs_resource_usage); + js->pub.pbs_resource_usage = new_resource_usage; + */ + } + break; + case EDG_WLL_EVENT_PBSERROR: + if (USABLE(res)) { + js->pub.state = EDG_WLL_JOB_DONE; + js->pub.done_code = EDG_WLL_STAT_FAILED; + rep(js->pub.pbs_state, "C"); + } + if (USABLE_DATA(res)) { + char *new_error_desc; + + asprintf(&new_error_desc,"%s%s%s", + (js->pub.pbs_error_desc) ? js->pub.pbs_error_desc : "", + (js->pub.pbs_error_desc) ? "\n" : "", + e->PBSError.error_desc); + + if (js->pub.pbs_error_desc) free(js->pub.pbs_error_desc); + js->pub.pbs_error_desc = new_error_desc; + } + break; + default: break; } diff --git a/org.glite.lb/project/events.T b/org.glite.lb/project/events.T index adec590..45a5288 100644 --- a/org.glite.lb/project/events.T +++ b/org.glite.lb/project/events.T @@ -251,7 +251,7 @@ string unit Units (sec, kB, etc.) @type PBSError Any error occured - string reason Error reason + string error_desc Error reason @type CondorSubmit Job SUBMITTED to Condor diff --git a/org.glite.lb/project/status.T b/org.glite.lb/project/status.T index 5953a58..d4668ab 100644 --- a/org.glite.lb/project/status.T +++ b/org.glite.lb/project/status.T @@ -85,7 +85,7 @@ string pbs_scheduler Name of pbs scheduler string pbs_dest_host Hostname of node where job is running int pbs_pid PID of running job int pbs_exit_status Job exit status -string pbs_error Glued error descriptions from error events +string pbs_error_desc Glued error descriptions from error events string condor_status Condor job status string condor_universe Condor job Universe (in job ClassAds)