use of org.apache.oozie.executor.jpa.WorkflowJobGetActionsJPAExecutor in project oozie by apache.
the class ResumeXCommand method execute.
@Override
protected Void execute() throws CommandException {
try {
if (workflow.getStatus() == WorkflowJob.Status.SUSPENDED) {
InstrumentUtils.incrJobCounter(getName(), 1, getInstrumentation());
workflow.getWorkflowInstance().resume();
WorkflowInstance wfInstance = workflow.getWorkflowInstance();
((LiteWorkflowInstance) wfInstance).setStatus(WorkflowInstance.Status.RUNNING);
workflow.setWorkflowInstance(wfInstance);
workflow.setStatus(WorkflowJob.Status.RUNNING);
// for (WorkflowActionBean action : store.getActionsForWorkflow(id, false)) {
for (WorkflowActionBean action : jpaService.execute(new WorkflowJobGetActionsJPAExecutor(id))) {
// START_MANUAL or END_RETRY or END_MANUAL
if (action.isRetryOrManual()) {
action.setPendingOnly();
updateList.add(new UpdateEntry<WorkflowActionQuery>(WorkflowActionQuery.UPDATE_ACTION_STATUS_PENDING, action));
}
if (action.isPending()) {
if (action.getStatus() == WorkflowActionBean.Status.PREP || action.getStatus() == WorkflowActionBean.Status.START_MANUAL) {
// a repeated transient error, we have to clean up the action dir
if (// The control actions have invalid
!action.getType().equals(StartActionExecutor.TYPE) && // action dir paths because they
!action.getType().equals(ForkActionExecutor.TYPE) && // contain ":" (colons)
!action.getType().equals(JoinActionExecutor.TYPE) && !action.getType().equals(KillActionExecutor.TYPE) && !action.getType().equals(EndActionExecutor.TYPE)) {
ActionExecutorContext context = new ActionXCommand.ActionExecutorContext(workflow, action, false, false);
if (context.getAppFileSystem().exists(context.getActionDir())) {
context.getAppFileSystem().delete(context.getActionDir(), true);
}
}
queue(new ActionStartXCommand(action.getId(), action.getType()));
} else {
if (action.getStatus() == WorkflowActionBean.Status.START_RETRY) {
Date nextRunTime = action.getPendingAge();
queue(new ActionStartXCommand(action.getId(), action.getType()), nextRunTime.getTime() - System.currentTimeMillis());
} else {
if (action.getStatus() == WorkflowActionBean.Status.DONE || action.getStatus() == WorkflowActionBean.Status.END_MANUAL) {
queue(new ActionEndXCommand(action.getId(), action.getType()));
} else {
if (action.getStatus() == WorkflowActionBean.Status.END_RETRY) {
Date nextRunTime = action.getPendingAge();
queue(new ActionEndXCommand(action.getId(), action.getType()), nextRunTime.getTime() - System.currentTimeMillis());
}
}
}
}
}
}
workflow.setLastModifiedTime(new Date());
updateList.add(new UpdateEntry<WorkflowJobQuery>(WorkflowJobQuery.UPDATE_WORKFLOW_STATUS_INSTANCE_MODIFIED, workflow));
BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(null, updateList, null);
if (EventHandlerService.isEnabled()) {
generateEvent(workflow);
}
queue(new WorkflowNotificationXCommand(workflow));
}
return null;
} catch (WorkflowException ex) {
throw new CommandException(ex);
} catch (JPAExecutorException e) {
throw new CommandException(e);
} catch (HadoopAccessorException e) {
throw new CommandException(e);
} catch (IOException e) {
throw new CommandException(ErrorCode.E0902, e.getMessage(), e);
} catch (URISyntaxException e) {
throw new CommandException(ErrorCode.E0902, e.getMessage(), e);
} finally {
updateParentIfNecessary(workflow);
}
}
Aggregations