private void completeJob(Action job, boolean failJob, long endTime)
throws Exception {
ActionEvent e = null;
ActionState endState = null;
if (failJob) {
e = new ActionFailedEvent(job.getId(), endTime);
endState = ActionState.FAILED;
} else {
e = new ActionCompletedEvent(job.getId(), endTime);
endState = ActionState.COMPLETED;
}