if($ctype{$f->{type}}) {
my $cstr = $ftype eq '_common_' ? 'any' : lcfirst $ftype;
if ($cstr =~ m/^pBS/) { $cstr = ucfirst $cstr; }
+ if ($cstr =~ m/^cREAM/) { $cstr = ucfirst $cstr; }
if ($cstr =~ m/^condor/) { $cstr = ucfirst $cstr; }
my $cname = getName $f 'C';
gen "$indent\tcase Event::".uc($f->{name}).": return(cev->$cstr.$cname);\n";
# conversion from int to string (well, enum to string)
my $cstr = $ftype eq '_common_' ? 'any' : lcfirst $ftype;
if ($cstr =~ m/^pBS/) { $cstr = ucfirst $cstr; }
+ if ($cstr =~ m/^cREAM/) { $cstr = ucfirst $cstr; }
if ($cstr =~ m/^condor/) { $cstr = ucfirst $cstr; }
my $cname = getName $f 'C';
my $fn = $ftype eq '_common_' ? "" : ucfirst $ftype;
$event->getTypes) {
my $tl = lcfirst $t;
if ($tl =~ m/^pBS/) { $tl = ucfirst $tl; }
+ if ($tl =~ m/^cREAM/) { $tl = ucfirst $tl; }
if ($tl =~ m/^condor/) { $tl = ucfirst $tl; }
gen $indent."edg_wll_${t}Event\t${tl};\n";
}
my $tu = uc $t;
my $tl = lcfirst $t;
if ($tl =~ m/^pBS/) { $tl = ucfirst $tl; }
+ if ($tl =~ m/^cREAM/) { $tl = ucfirst $tl; }
if ($tl =~ m/^condor/) { $tl = ucfirst $tl; }
gen $indent."case EDG_WLL_EVENT_$tu : \n";
selectType $event $t;
my $tu = uc $t;
my $tl = lcfirst $t;
if ($tl =~ m/^pBS/) { $tl = ucfirst $tl; }
+ if ($tl =~ m/^cREAM/) { $tl = ucfirst $tl; }
if ($tl =~ m/^condor/) { $tl = ucfirst $tl; }
gen $indent."case EDG_WLL_EVENT_$tu :\n";
selectType $event $t;
my $tu = uc $t;
my $tl = lcfirst $t;
if ($tl =~ m/^pBS/) { $tl = ucfirst $tl; }
+ if ($tl =~ m/^cREAM/) { $tl = ucfirst $tl; }
if ($tl =~ m/^condor/) { $tl = ucfirst $tl; }
my $misuse = "if (eventcode != EDG_WLL_EVENT_$tu ) MISUSE";
selectType $event $t;
my $tu = uc $t;
my $tl = lcfirst $t;
if ($tl =~ m/^pBS/) { $tl = ucfirst $tl; }
+ if ($tl =~ m/^cREAM/) { $tl = ucfirst $tl; }
if ($tl =~ m/^condor/) { $tl = ucfirst $tl; }
my $free = "";
gen $indent."case EDG_WLL_EVENT_$tu :\n";
my $tu = uc $t;
my $tl = lcfirst $t;
if ($tl =~ m/^pBS/) { $tl = ucfirst $tl; }
+ if ($tl =~ m/^cREAM/) { $tl = ucfirst $tl; }
if ($tl =~ m/^condor/) { $tl = ucfirst $tl; }
gen $indent."case EDG_WLL_EVENT_$tu :\n";
selectType $event $t;
my $tu = uc $t;
my $tl = lcfirst $t;
if ($tl =~ m/^pBS/) { $tl = ucfirst $tl; }
+ if ($tl =~ m/^cREAM/) { $tl = ucfirst $tl; }
if ($tl =~ m/^condor/) { $tl = ucfirst $tl; }
selectType $event $t;
my $tu = uc $t;
my $tl = lcfirst $t;
if ($tl =~ m/^pBS/) { $tl = ucfirst $tl; }
+ if ($tl =~ m/^cREAM/) { $tl = ucfirst $tl; }
if ($tl =~ m/^condor/) { $tl = ucfirst $tl; }
my $misuse = "if (eventcode != EDG_WLL_EVENT_$tu ) MISUSE";
selectType $event $t;
my $ft = $f->{type};
$fo[0] = $fo[0] eq '_common_' ? 'any' : lcfirst $fo[0];
if ($fo[0] =~ m/^pBS/) { $fo[0] = ucfirst $fo[0]; }
+ if ($fo[0] =~ m/^cREAM/) { $fo[0] = ucfirst $fo[0]; }
if ($fo[0] =~ m/^condor/) { $fo[0] = ucfirst $fo[0]; }
gen "$bi XMLCtx->eventsOutGlobal[XMLCtx->position].$fo[0].$t =\n";
gen "$bi \tedg_wll_from_string_to_$ft(XMLCtx);\n";
my $u = uc $_;
$_ = lcfirst $_;
if ($_ =~ m/^pBS/) { $_ = ucfirst $_; }
+ if ($_ =~ m/^cREAM/) { $_ = ucfirst $_; }
if ($_ =~ m/^condor/) { $_ = ucfirst $_; }
gen "$bi case EDG_WLL_EVENT_$u :\n";
gen "$bi \t XMLCtx->eventsOutGlobal[XMLCtx->position].$_.$t =\n";
for my $e ($event->getTypesOrdered) {
my $u = lcfirst $e;
if ($u =~ m/^pBS/) { $u = ucfirst $u; }
+ if ($u =~ m/^cREAM/) { $u = ucfirst $u; }
if ($u =~ m/^condor/) { $u = ucfirst $u; }
my $c = getTypeComment $event $e;
gen "\tCPPUNIT_TEST($u);\n";
for my $e ($event->getTypesOrdered) {
my $u = lcfirst $e;
if ($u =~ m/^pBS/) { $u = ucfirst $u; }
+ if ($u =~ m/^cREAM/) { $u = ucfirst $u; }
if ($u =~ m/^condor/) { $u = ucfirst $u; }
my $c = getTypeComment $event $e;
gen "\tvoid $u();\n";
for my $e ($event->getTypesOrdered) {
my $l = lcfirst $e;
if ($l =~ m/^pBS/) { $l = ucfirst $l; }
+ if ($l =~ m/^cREAM/) { $l = ucfirst $l; }
if ($l =~ m/^condor/) { $l = ucfirst $l; }
my $u = uc $e;
my $c = getTypeComment $event $e;
my $uctype = uc $_;
my $flctype = lcfirst $_;
if ($flctype =~ m/^pBS/) { $flctype = ucfirst $flctype; }
+ if ($flctype =~ m/^cREAM/) { $flctype = ucfirst $flctype; }
if ($flctype =~ m/^condor/) { $flctype = ucfirst $flctype; }
my $frs = $f->{codes} ?
"event->$flctype.$name = edg_wll_StringTo$_${fucname}(value);" :
my $n = $f->{null};
$t = lcfirst $t;
if ($t =~ m/^pBS/) { $t = ucfirst $t; }
+ if ($t =~ m/^cREAM/) { $t = ucfirst $t; }
if ($t =~ m/^condor/) { $t = ucfirst $t; }
gen "\t\tedg_wll_add_$ft\_to_XMLBody(&pomB, eventsOut[i].$t.$_, \"$_\", $n);\n";
}
my $n = $f->{null};
$t = lcfirst $t;
if ($t =~ m/^pBS/) { $t = ucfirst $t; }
+ if ($t =~ m/^cREAM/) { $t = ucfirst $t; }
if ($t =~ m/^condor/) { $t = ucfirst $t; }
gen "\t\tedg_wll_add_$ft\_to_XMLBody(&pomB, eventsOut[i].$t.$_, \"$_\", $n);\n";
}
my $uctype = uc $type;
my $flctype = lcfirst $type;
if ($flctype =~ m/^pBS/) { $flctype = ucfirst $flctype; }
+ if ($flctype =~ m/^cREAM/) { $flctype = ucfirst $flctype; }
if ($flctype =~ m/^condor/) { $flctype = ucfirst $flctype; }
gen qq{
! case EDG_WLL_EVENT_$uctype:
$tn = $f->{type};
$native_en = lcfirst $e;
if ($native_en =~ m/^pBS/) { $native_en = ucfirst $native_en; }
+ if ($native_en =~ m/^cREAM/) { $native_en = ucfirst $native_en; }
if ($native_en =~ m/^condor/) { $native_en = ucfirst $native_en; }
$native_fn = $f->{name};
$soap_en = $e;
} else {
$act = lcfirst $name;
if ($act =~ m/^pBS/) { $act = ucfirst $act; }
+ if ($act =~ m/^cREAM/) { $act = ucfirst $act; }
if ($act =~ m/^condor/) { $act = ucfirst $act; }
}
my $usuc = $fn;
my $tu = uc $t;
my $tl = lcfirst $t;
if ($tl =~ m/^pBS/) { $tl = ucfirst $tl; }
+ if ($tl =~ m/^cREAM/) { $tl = ucfirst $tl; }
if ($tl =~ m/^condor/) { $tl = ucfirst $tl; }
selectType $event $t;
PLUGIN_LIBS:= -L${stagedir}/lib -lglite_lb_common_${nothrflavour}\
${classadslib} -lstdc++ ${expatlib} -lexpat\
-PLUGIN_LOBJS:=seqcode_aux.lo process_event.lo process_event_pbs.lo process_event_condor.lo lb_plugin.lo
-MACHINE_OBJS:=seqcode_aux.o process_event.o process_event_pbs.o process_event_condor.o
+PLUGIN_LOBJS:=seqcode_aux.lo process_event.lo process_event_pbs.lo process_event_condor.lo process_event_cream.lo lb_plugin.lo
+MACHINE_OBJS:=seqcode_aux.o process_event.o process_event_pbs.o process_event_condor.o process_event_cream.o
PLUGIN_LIB=glite_lb_plugin.la
MACHINE_LIB=libglite_lb_statemachine.a
return processEvent_PBS(js,e,ev_seq,strict,errstring);
case EDG_WLL_STAT_CONDOR:
return processEvent_Condor(js,e,ev_seq,strict,errstring);
- case EDG_WLL_STAT_CREAM:
- return RET_OK; /* TODO: mulac */
+ case EDG_WLL_STAT_CREAM:
+ return processEvent_Cream(js,e,ev_seq,strict,errstring);
case -1: return RET_UNREG;
default:
trio_asprintf(errstring,"undefined job type %d",js->pub.jobtype);
--- /dev/null
+#ident "$Header$"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <assert.h>
+#include <syslog.h>
+
+#include "glite/lb/context-int.h"
+
+#include "glite/lbu/trio.h"
+
+#include "intjobstat.h"
+#include "seqcode_aux.h"
+
+/* TBD: share in whole logging or workload */
+#ifdef __GNUC__
+#define UNUSED_VAR __attribute__((unused))
+#else
+#define UNUSED_VAR
+#endif
+
+static int compare_timestamps(struct timeval a, struct timeval b)
+{
+ if ( (a.tv_sec > b.tv_sec) ||
+ ((a.tv_sec == b.tv_sec) && (a.tv_usec > b.tv_usec)) ) return 1;
+ if ( (a.tv_sec < b.tv_sec) ||
+ ((a.tv_sec == b.tv_sec) && (a.tv_usec < b.tv_usec)) ) return -1;
+ return 0;
+}
+
+
+// XXX move this defines into some common place to be reusable
+#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_Cream(intJobStat *js, edg_wll_Event *e, int ev_seq, int strict, char **errstring)
+{
+ edg_wll_JobStatCode old_state = js->pub.state;
+ int res = RET_OK;
+
+
+/* not used in CREAM
+ if ((js->last_seqcode != NULL) &&
+ (edg_wll_compare_pbs_seq(js->last_seqcode, e->any.seqcode) > 0) ) {
+ res = RET_LATE;
+ }
+*/
+ switch (e->any.type) {
+ case EDG_WLL_EVENT_REGJOB:
+ if (USABLE(res)) {
+ js->pub.state = EDG_WLL_JOB_SUBMITTED;
+ js->pub.cream_state = EDG_WLL_STAT_REGISTERED;
+ }
+ if (USABLE_DATA(res)) {
+ }
+ break;
+ case EDG_WLL_EVENT_CREAMSTART:
+ // nothing to be done
+ break;
+ case EDG_WLL_EVENT_CREAMPURGE:
+ // no state transition
+ case EDG_WLL_EVENT_CREAMSTORE:
+ if (USABLE(res)) {
+ 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;
+ }
+ }
+ if (USABLE_DATA(res)) {
+ }
+ break;
+ case EDG_WLL_EVENT_CREAMCALL:
+ if (USABLE(res)) {
+ if (e->CREAMCall.callee == EDG_WLL_SOURCE_LRMS && e->any.source == EDG_WLL_SOURCE_LRMS)
+ js->pub.state = EDG_WLL_JOB_SCHEDULED;
+ js->pub.cream_state = EDG_WLL_STAT_IDLE;
+
+ }
+ if (USABLE_DATA(res)) {
+ js->pub.cream_reason = e->CREAMCall.reason;
+ }
+ break;
+
+ case EDG_WLL_EVENT_CREAMRUNNING:
+ if (USABLE(res)) {
+ js->pub.state = EDG_WLL_JOB_RUNNING;
+ js->pub.cream_state = EDG_WLL_STAT_RUNNING;
+ }
+ if (USABLE_DATA(res)) {
+ js->pub.cream_node = e->CREAMRunning.node;
+ }
+ break;
+ case EDG_WLL_EVENT_CREAMREALLYRUNNING:
+ if (USABLE(res)) {
+ js->pub.state = EDG_WLL_JOB_RUNNING;
+ js->pub.cream_state = EDG_WLL_STAT_REALLYRUNNING;
+ }
+ if (USABLE_DATA(res)) {
+ }
+ break;
+ case EDG_WLL_EVENT_CREAMDONE:
+ if (USABLE(res)) {
+ js->pub.state = EDG_WLL_JOB_DONE;
+ js->pub.cream_state = (e->CREAMDone.status_code == EDG_WLL_DONE_OK) ? EDG_WLL_STAT_DONEOK : EDG_WLL_STAT_DONEFAILED;
+ }
+ if (USABLE_DATA(res)) {
+ js->pub.cream_done_code = e->CREAMDone.status_code;
+ js->pub.cream_exit_code = e->CREAMDone.exit_code;
+ js->pub.cream_reason = e->CREAMDone.reason;
+ }
+ break;
+ case EDG_WLL_EVENT_CREAMCANCEL:
+ if (USABLE(res)) {
+ if (e->CREAMCancel.status_code == EDG_WLL_CANCEL_DONE) {
+ js->pub.state = EDG_WLL_JOB_CANCELLED;
+ js->pub.cream_state = EDG_WLL_STAT_ABORTED;
+ }
+ }
+ if (USABLE_DATA(res)) {
+ js->pub.cream_cancel_reason = e->CREAMCancel.reason;
+ }
+ break;
+ case EDG_WLL_EVENT_CREAMABORT:
+ if (USABLE(res)) {
+ js->pub.state = EDG_WLL_JOB_ABORTED;
+ js->pub.cream_state = EDG_WLL_STAT_ABORTED;
+ }
+ if (USABLE_DATA(res)) {
+ js->pub.cream_reason = e->CREAMAbort.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 (USABLE(res)) {
+ rep(js->last_seqcode, e->any.seqcode);
+
+ js->pub.lastUpdateTime = e->any.timestamp;
+ if (old_state != js->pub.state) {
+ js->pub.stateEnterTime = js->pub.lastUpdateTime;
+ js->pub.stateEnterTimes[1 + js->pub.state]
+ = (int)js->pub.lastUpdateTime.tv_sec;
+ }
+ }
+ if (! js->pub.location) js->pub.location = strdup("this is CREAM");
+
+
+ return RET_OK;
+}
+