}
// Release the run barrier now so any concurrent HandleSlotFilled tasks
// will stop trying to release it.
runBarrier.setReleased();
UpdateSpec updateSpec = new UpdateSpec(rootJobKey);
updateSpec.getTransaction("releaseRunBarrier").includeBarrier(runBarrier);
backEnd.save(updateSpec);
updateSpec = new UpdateSpec(rootJobKey);
switch (jobState) {
case WAITING_TO_RUN:
case RETRY:
// OK, proceed
break;
case WAITING_TO_FINALIZE:
logger.info("This job has already been run " + jobRecord);
return;
case STOPPED:
logger.info("This job has been stoped. " + jobRecord);
return;
}
// Deserialize the instance of Job and set some values on the instance
JobInstanceRecord record = jobRecord.getJobInstanceInflated();
if (null == record) {
throw new RuntimeException("Internal logic error:" + jobRecord
+ " does not have jobInstanceInflated.");
}
Job<?> jobObject = record.getJobInstanceDeserialized();
setJobRecord(jobObject, jobRecord);
String currentRunGUID = GUIDGenerator.nextGUID();
setCurrentRunGuid(jobObject, currentRunGUID);
setUpdateSpec(jobObject, updateSpec);
// Get the run() method we will invoke and its arguments
Object[] params = runBarrier.buildArgumentArray();
Method runMethod = findAppropriateRunMethod(jobObject.getClass(), params);
if (logger.isLoggable(Level.FINEST)) {
StringBuilder builder = new StringBuilder(1024);
builder.append("Running " + jobRecord + " with params: ");
builder.append(StringUtils.toString(params));
logger.finest(builder.toString());
}
// Set the Job's start time and save the jobRecord now before we invoke
// run(). The start time will be displayed in the UI.
jobRecord.incrementAttemptNumber();
jobRecord.setStartTime(new Date());
UpdateSpec tempSpec = new UpdateSpec(jobRecord.getRootJobKey());
tempSpec.getNonTransactionalGroup().includeJob(jobRecord);
backEnd.save(tempSpec);
// Invoke the run() method. This has the side-effect of populating
// the UpdateSpec with any child job graph generated by the run().
Value<?> returnValue = null;