public void execute(Job job, Command cmd, int phase, String destid, Throwable reason) throws LBException {
if (job == null) {
return;
}
ContextIL ctx = new ContextIL(ILPrefix);
if (job.getSequenceCode() == null) {
ctx.setSeqCode(new SeqCode(SeqCode.CREAM, "no_seqcodes_with_cream_execute_" + cmd.getId() + "_" + phase));
} else {
SeqCode sc = new SeqCode(SeqCode.CREAMWMS, job.getSequenceCode());
sc.incrementSeqCode(new Sources(Sources.CREAM_EXECUTOR));
job.setSequenceCode(sc.toString());
ctx.setSeqCode(sc);
if (jobDB != null && !JobCommandConstant.JOB_PURGE.equals(cmd.getName())) {
try {
jobDB.update(job);
} catch (DatabaseException ex) {
throw new LBException(ex.getMessage());
}
}
}
ctx.setSource(new Sources(Sources.CREAM_EXECUTOR));
ctx.setUser(cmd.getUserId());
Jobid jobid;
if (job.getGridJobId() == null || Job.NOT_AVAILABLE_VALUE.equals(job.getGridJobId())) {
jobid = new Jobid(defaultLBURI.getHost(), defaultLBURI.getPort(), job.getId());
} else {
jobid = new Jobid(job.getGridJobId());
}
ctx.setJobid(jobid);
EventCREAMCall event = new EventCREAMCall();
event.setCallee(new Sources(Sources.LRMS));
event.setCmdid(""+cmd.getId());
// logger.debug("execute: id = " + cmd.getId() + " name = " +
// cmd.getName()+ " category = " + cmd.getCategory() +
// " failureReason = " + cmd.getFailureReason() + " description = " +
// cmd.getDescription());
switch (phase) {
case START:
event.setResult(EventCREAMCall.Result.START);
break;
case OK:
event.setResult(EventCREAMCall.Result.OK);
event.setDestid(destid);
break;
case FAILED:
event.setResult(EventCREAMCall.Result.FAILED);
event.setReason(reason.getMessage());
break;
}
if (JobCommandConstant.JOB_START.equals(cmd.getName())) {
event.setCommand(EventCREAMCall.Command.CMDSTART);
} else if (JobCommandConstant.JOB_CANCEL.equals(cmd.getName())) {
event.setCommand(EventCREAMCall.Command.CMDCANCEL);
} else if (JobCommandConstant.JOB_PURGE.equals(cmd.getName())) {
event.setCommand(EventCREAMCall.Command.CMDPURGE);
} else if (JobCommandConstant.JOB_SUSPEND.equals(cmd.getName())) {
event.setCommand(EventCREAMCall.Command.CMDSUSPEND);
} else if (JobCommandConstant.JOB_RESUME.equals(cmd.getName())) {
event.setCommand(EventCREAMCall.Command.CMDRESUME);
} else {
throw new LBException("LBLogger.execute(): not handled " + cmd.getName());
}
ctx.log(event);
}