*
* @see org.apache.oodt.cas.resource.structs.JobInstance#execute(org.apache.oodt.cas.resource.structs.JobInput)
*/
public boolean execute(JobInput in) throws JobInputException {
if (!(in instanceof TaskJobInput)) {
throw new JobInputException("Task Job: unknown JobInput class: ["
+ in.getClass().getName() + "]");
}
// otherwise, we're all good
TaskJobInput taskInput = (TaskJobInput) in;
// Instantiate the Workflow Task Instance
WorkflowTaskInstance inst = GenericWorkflowObjectFactory
.getTaskObjectFromClassName(taskInput
.getWorkflowTaskInstanceClassName());
// override what ProcessingNode we are running on
// the workflow manager by default inserts its own host
// as the ProcessingNode
taskInput.getDynMetadata().replaceMetadata(PROCESSING_NODE,
getHostname());
updateMetadata(taskInput.getDynMetadata());
// update status to started again (now that the job is distributed and
// about to run
updateStatus(STARTED, taskInput.getDynMetadata());
// go ahead and persist the workflow instance, after we
// save the current task start date time
String currentTaskIsoStartDateTimeStr = DateConvert
.isoFormat(new Date());
setWorkflowInstanceCurrentTaskStartDateTime(
currentTaskIsoStartDateTimeStr, taskInput.getDynMetadata());
setWorkflowInstanceCurrentTaskEndDateTime("", taskInput
.getDynMetadata()); /* clear this out */
// now we just call inst with the given task cfg and metadata
try {
inst.run(taskInput.getDynMetadata(), taskInput.getTaskConfig());
} catch (WorkflowTaskInstanceException e) {
throw new JobInputException("Failed to run task", e);
}
String currentTaskIsoEndDateTimeStr = DateConvert.isoFormat(new Date());
setWorkflowInstanceCurrentTaskEndDateTime(currentTaskIsoEndDateTimeStr,
taskInput.getDynMetadata());