From 81a60e92fb1d31a0a6d365c5d0cc0d2ed275fec2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ji=C5=99=C3=AD=20Filipovi=C4=8D?= Date: Wed, 16 Nov 2011 12:32:59 +0000 Subject: [PATCH] - process events from CREAM+WMS jobs - forgotten commit on resubmission in file transfers --- org.glite.lb.state-machine/src/process_event.c | 118 ++++++++++++++++++ .../src/process_event_cream.c | 134 +++++++++++++-------- .../src/process_event_file_transfer.c | 7 ++ 3 files changed, 209 insertions(+), 50 deletions(-) diff --git a/org.glite.lb.state-machine/src/process_event.c b/org.glite.lb.state-machine/src/process_event.c index 694f9fa..c6b3060 100644 --- a/org.glite.lb.state-machine/src/process_event.c +++ b/org.glite.lb.state-machine/src/process_event.c @@ -46,6 +46,7 @@ static int processEvent_glite(intJobStat *js, edg_wll_Event *e, int ev_seq, int int processEvent_PBS(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring); int processEvent_Condor(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring); int processEvent_Cream(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring); +int processData_Cream(intJobStat *js, edg_wll_Event *e); int processEvent_FileTransfer(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring); int processEvent_FileTransferCollection(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring); @@ -331,6 +332,9 @@ static int processEvent_glite(intJobStat *js, edg_wll_Event *e, int ev_seq, int res = RET_LATE; } + if (e->any.source == EDG_WLL_SOURCE_CREAM_EXECUTOR || e->any.source == EDG_WLL_SOURCE_CREAM_INTERFACE){ + processData_Cream(js, e); + } switch (e->any.type) { case EDG_WLL_EVENT_TRANSFER: @@ -1004,6 +1008,120 @@ static int processEvent_glite(intJobStat *js, edg_wll_Event *e, int ev_seq, int ignore_seq_code = 1; break; +/************************************ CREAM events ****************************/ + case EDG_WLL_EVENT_CREAMSTART: + break; + + case EDG_WLL_EVENT_CREAMPURGE: + break; + + case EDG_WLL_EVENT_CREAMACCEPTED: + break; + + case EDG_WLL_EVENT_CREAMSTORE: + if (USABLE(res, strict)) { + switch (e->CREAMStore.command) { + case EDG_WLL_CREAMSTORE_CMDSTART: + if (e->CREAMStore.result == EDG_WLL_CREAMSTORE_OK) { + js->pub.state = EDG_WLL_JOB_WAITING; + js->pub.cream_state = EDG_WLL_STAT_PENDING; + } + break; + case EDG_WLL_CREAMSTORE_CMDSUSPEND: + if (e->CREAMStore.result == EDG_WLL_CREAMSTORE_OK) { + js->pub.suspended = 1; + } + break; + case EDG_WLL_CREAMSTORE_CMDRESUME: + if (e->CREAMStore.result == EDG_WLL_CREAMSTORE_OK) { + js->pub.suspended = 0; + } + break; + default: + break; + } + rep_cond(js->pub.cream_reason, e->CREAMStore.reason); + rep_cond(js->pub.reason, e->CREAMStore.reason); + } + break; + case EDG_WLL_EVENT_CREAMCALL: + if (e->any.source == EDG_WLL_SOURCE_CREAM_EXECUTOR && + e->CREAMCall.callee == EDG_WLL_SOURCE_LRMS && + e->CREAMCall.command == EDG_WLL_CREAMCALL_CMDSTART && + e->CREAMCall.result == EDG_WLL_CREAMCALL_OK) + { + if (USABLE(res, strict)) { + // BLAH -> LRMS + js->pub.state = EDG_WLL_JOB_SCHEDULED; + js->pub.cream_state = EDG_WLL_STAT_IDLE; + rep_cond(js->pub.cream_reason, e->CREAMCall.reason); + rep_cond(js->pub.reason, e->CREAMCall.reason); + } + } + if (e->CREAMCall.command == EDG_WLL_CREAMCALL_CMDCANCEL && + e->CREAMCall.result == EDG_WLL_CREAMCALL_OK) + { + if (USABLE(res, strict)){ + js->pub.cream_cancelling = 1; + js->pub.cancelling = 1; + rep_cond(js->pub.cream_reason, e->CREAMCall.reason); + rep_cond(js->pub.reason, e->CREAMCall.reason); + } + } + break; + case EDG_WLL_EVENT_CREAMCANCEL: + if (USABLE(res, strict)) { + if (e->CREAMCancel.status_code == EDG_WLL_CANCEL_DONE) { + js->pub.state = EDG_WLL_JOB_CANCELLED; + js->pub.cream_state = EDG_WLL_STAT_ABORTED; + } + rep(js->pub.cream_reason, e->CREAMCancel.reason); + rep(js->pub.reason, e->CREAMCancel.reason); + } + break; + case EDG_WLL_EVENT_CREAMABORT: + if (USABLE(res, strict)) { + js->pub.state = EDG_WLL_JOB_ABORTED; + js->pub.cream_state = EDG_WLL_STAT_ABORTED; + rep(js->pub.cream_reason, e->CREAMAbort.reason); + rep(js->pub.reason, e->CREAMAbort.reason); + } + break; + case EDG_WLL_EVENT_CREAMSTATUS: + if (USABLE(res, strict) && e->CREAMStatus.result == EDG_WLL_CREAMSTATUS_DONE) + { + switch (js->pub.cream_state = edg_wll_StringToCreamStat(e->CREAMStatus.new_state)) + { + case EDG_WLL_STAT_REGISTERED: + case EDG_WLL_NUMBER_OF_CREAM_STATES: + break; + + case EDG_WLL_STAT_PENDING: js->pub.state = EDG_WLL_JOB_WAITING; break; + case EDG_WLL_STAT_IDLE: js->pub.state = EDG_WLL_JOB_SCHEDULED; break; + case EDG_WLL_STAT_RUNNING: + js->pub.state = EDG_WLL_JOB_RUNNING; + js->pub.jw_status = EDG_WLL_STAT_WRAPPER_RUNNING; + break; + case EDG_WLL_STAT_REALLY_RUNNING: + js->pub.state = EDG_WLL_JOB_RUNNING; + js->pub.jw_status = EDG_WLL_STAT_PAYLOAD_RUNNING; + break; + case EDG_WLL_STAT_HELD: /* TODO */ break; + case EDG_WLL_STAT_DONE_OK: + js->pub.state = EDG_WLL_JOB_DONE; + js->pub.done_code = EDG_WLL_STAT_OK; + js->pub.cream_done_code = EDG_WLL_STAT_OK; + break; + case EDG_WLL_STAT_DONE_FAILED: + js->pub.state = EDG_WLL_JOB_DONE; + js->pub.done_code = EDG_WLL_STAT_FAILED; + js->pub.cream_done_code = EDG_WLL_STAT_FAILED; + break; + case EDG_WLL_STAT_ABORTED: js->pub.state = EDG_WLL_JOB_ABORTED; break; + } + } + break; + default: goto bad_event; break; diff --git a/org.glite.lb.state-machine/src/process_event_cream.c b/org.glite.lb.state-machine/src/process_event_cream.c index 253c055..1502fea 100644 --- a/org.glite.lb.state-machine/src/process_event_cream.c +++ b/org.glite.lb.state-machine/src/process_event_cream.c @@ -48,6 +48,89 @@ static char *cream_states[EDG_WLL_NUMBER_OF_CREAM_STATES]; #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 processData_Cream(intJobStat *js, edg_wll_Event *e) +{ + int res = RET_OK; + + switch (e->any.type) { + case EDG_WLL_EVENT_REGJOB: + if (USABLE_DATA(res)) { + rep_cond(js->pub.cream_owner, js->pub.owner); + rep_cond(js->pub.jdl, e->regJob.jdl); + rep_cond(js->pub.cream_jdl, e->regJob.jdl); + rep_cond(js->pub.cream_endpoint, e->regJob.ns); + rep_cond(js->pub.destination, e->regJob.ns); + rep_cond(js->pub.network_server, e->regJob.ns); + } + break; + case EDG_WLL_EVENT_CREAMSTART: + // nothing to be done + break; + case EDG_WLL_EVENT_CREAMPURGE: + // no state transition + break; + case EDG_WLL_EVENT_CREAMACCEPTED: + if (USABLE(res)){ + rep(js->pub.cream_id, e->CREAMAccepted.local_jobid); + rep(js->pub.globusId, e->CREAMAccepted.local_jobid); + } + break; + case EDG_WLL_EVENT_CREAMSTATUS: + if (USABLE(res) && e->CREAMStatus.result == EDG_WLL_CREAMSTATUS_DONE) + { + if (e->CREAMStatus.exit_code && strcmp(e->CREAMStatus.exit_code, "N/A")) + { + js->pub.cream_exit_code = atoi(e->CREAMStatus.exit_code); + js->pub.exit_code = atoi(e->CREAMStatus.exit_code); + } + if (e->CREAMStatus.worker_node){ /*XXX should never be false */ + if (js->pub.cream_node) + free(js->pub.cream_node); + js->pub.cream_node = strdup(e->CREAMStatus.worker_node); + if (js->pub.ce_node) + free(js->pub.ce_node); + js->pub.ce_node = strdup(e->CREAMStatus.worker_node); + } + if (e->CREAMStatus.LRMS_jobid){ /*XXX should never be false */ + if (js->pub.cream_lrms_id) + free(js->pub.cream_lrms_id); + js->pub.cream_lrms_id = strdup(e->CREAMStatus.LRMS_jobid); + if (js->pub.localId) + free(js->pub.localId); + js->pub.localId = strdup(e->CREAMStatus.LRMS_jobid); + } + if (e->CREAMStatus.failure_reason){ + if (js->pub.cream_failure_reason) + free(js->pub.cream_failure_reason); + js->pub.cream_failure_reason = strdup(e->CREAMStatus.failure_reason); + if (js->pub.failure_reasons){ + char *glued_reasons; + asprintf(&glued_reasons,"%s\n", e->CREAMStatus.failure_reason); + rep(js->pub.failure_reasons, glued_reasons); + } + else + asprintf(&(js->pub.failure_reasons),"%s", e->CREAMStatus.failure_reason); + } + } + break; + + case EDG_WLL_EVENT_USERTAG: + if (USABLE_DATA(res)) { + if (e->userTag.name != NULL && e->userTag.value != NULL) { + add_taglist(e->userTag.name, e->userTag.value, e->any.seqcode, js); + } + } + break; + + default: + break; + } + + if (! js->pub.location) js->pub.location = strdup("this is CREAM"); + + return RET_OK; +} + int processEvent_Cream(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring) { edg_wll_JobStatCode old_state = js->pub.state; @@ -71,14 +154,6 @@ int processEvent_Cream(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, js->pub.state = EDG_WLL_JOB_SUBMITTED; js->pub.cream_state = EDG_WLL_STAT_REGISTERED; } - if (USABLE_DATA(res)) { - rep_cond(js->pub.cream_owner, js->pub.owner); - rep_cond(js->pub.jdl, e->regJob.jdl); - rep_cond(js->pub.cream_jdl, e->regJob.jdl); - rep_cond(js->pub.cream_endpoint, e->regJob.ns); - rep_cond(js->pub.destination, e->regJob.ns); - rep_cond(js->pub.network_server, e->regJob.ns); - } break; case EDG_WLL_EVENT_CREAMSTART: // nothing to be done @@ -87,10 +162,6 @@ int processEvent_Cream(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, // no state transition break; case EDG_WLL_EVENT_CREAMACCEPTED: - if (USABLE(res)){ - rep(js->pub.cream_id, e->CREAMAccepted.local_jobid); - rep(js->pub.globusId, e->CREAMAccepted.local_jobid); - } break; case EDG_WLL_EVENT_CREAMSTORE: if (USABLE(res)) { @@ -206,48 +277,10 @@ int processEvent_Cream(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, break; case EDG_WLL_STAT_ABORTED: js->pub.state = EDG_WLL_JOB_ABORTED; break; } - if (e->CREAMStatus.exit_code && strcmp(e->CREAMStatus.exit_code, "N/A")) - { - js->pub.cream_exit_code = atoi(e->CREAMStatus.exit_code); - js->pub.exit_code = atoi(e->CREAMStatus.exit_code); - } - if (e->CREAMStatus.worker_node){ /*XXX should never be false */ - if (js->pub.cream_node) - free(js->pub.cream_node); - js->pub.cream_node = strdup(e->CREAMStatus.worker_node); - if (js->pub.ce_node) - free(js->pub.ce_node); - js->pub.ce_node = strdup(e->CREAMStatus.worker_node); - } - if (e->CREAMStatus.LRMS_jobid){ /*XXX should never be false */ - if (js->pub.cream_lrms_id) - free(js->pub.cream_lrms_id); - js->pub.cream_lrms_id = strdup(e->CREAMStatus.LRMS_jobid); - if (js->pub.localId) - free(js->pub.localId); - js->pub.localId = strdup(e->CREAMStatus.LRMS_jobid); - } - if (e->CREAMStatus.failure_reason){ - if (js->pub.cream_failure_reason) - free(js->pub.cream_failure_reason); - js->pub.cream_failure_reason = strdup(e->CREAMStatus.failure_reason); - if (js->pub.failure_reasons){ - char *glued_reasons; - asprintf(&glued_reasons,"%s\n", e->CREAMStatus.failure_reason); - rep(js->pub.failure_reasons, glued_reasons); - } - else - asprintf(&(js->pub.failure_reasons),"%s", e->CREAMStatus.failure_reason); - } } break; case EDG_WLL_EVENT_USERTAG: - if (USABLE_DATA(res)) { - if (e->userTag.name != NULL && e->userTag.value != NULL) { - add_taglist(e->userTag.name, e->userTag.value, e->any.seqcode, js); - } - } break; default: @@ -266,6 +299,7 @@ int processEvent_Cream(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, } if (! js->pub.location) js->pub.location = strdup("this is CREAM"); + processData_Cream(js, e); return RET_OK; } diff --git a/org.glite.lb.state-machine/src/process_event_file_transfer.c b/org.glite.lb.state-machine/src/process_event_file_transfer.c index e4e03d5..a8aa872 100644 --- a/org.glite.lb.state-machine/src/process_event_file_transfer.c +++ b/org.glite.lb.state-machine/src/process_event_file_transfer.c @@ -136,6 +136,13 @@ int processEvent_FileTransfer(intJobStat *js, edg_wll_Event *e, int ev_seq, int #endif } break; + case EDG_WLL_EVENT_RESUBMISSION: + if (USABLE(res)) { + if (e->resubmission.result == EDG_WLL_RESUBMISSION_WONTRESUB) { + rep(js->pub.reason, e->resubmission.reason); + } + } + break; default: break; } -- 1.8.2.3