use of org.apache.oozie.action.ActionExecutor in project oozie by apache.
the class CompletedActionXCommand method execute.
/*
* (non-Javadoc)
*
* @see org.apache.oozie.command.XCommand#execute()
*/
@Override
protected Void execute() throws CommandException {
// we'll requeue this command a few times and hope that it switches to RUNNING before giving up
if (this.wfactionBean.getStatus() == WorkflowActionBean.Status.PREP) {
int maxEarlyRequeueCount = Services.get().get(CallbackService.class).getEarlyRequeueMaxRetries();
if (this.earlyRequeueCount < maxEarlyRequeueCount) {
long delay = getRequeueDelay();
LOG.warn("Received early callback for action still in PREP state; will wait [{0}]ms and requeue up to [{1}] more" + " times", delay, (maxEarlyRequeueCount - earlyRequeueCount));
queue(new CompletedActionXCommand(this.actionId, this.externalStatus, null, this.getPriority(), this.earlyRequeueCount + 1), delay);
} else {
throw new CommandException(ErrorCode.E0822, actionId);
}
} else {
// RUNNING
ActionExecutor executor = Services.get().get(ActionService.class).getExecutor(this.wfactionBean.getType());
// every status change, not only on completion.
if (executor.isCompleted(externalStatus)) {
queue(new ActionCheckXCommand(this.wfactionBean.getId(), getPriority(), -1));
}
}
return null;
}
use of org.apache.oozie.action.ActionExecutor in project oozie by apache.
the class ActionService method initExecutor.
private void initExecutor(Class<? extends ActionExecutor> klass) {
@SuppressWarnings("deprecation") ActionExecutor executor = (ActionExecutor) ReflectionUtils.newInstance(klass, services.getConf());
LOG.debug("Initializing action type [{0}] class [{1}]", executor.getType(), klass);
ActionExecutor.enableInit();
executor.initActionType();
ActionExecutor.disableInit();
LOG.trace("Initialized Executor for action type [{0}] class [{1}]", executor.getType(), klass);
}
use of org.apache.oozie.action.ActionExecutor in project oozie by apache.
the class TestJavaActionExecutor method testSimpestSleSubmitOK.
public void testSimpestSleSubmitOK() throws Exception {
String actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<main-class>" + LauncherMainTester.class.getName() + "</main-class>" + "</java>";
Context context = createContext(actionXml, null);
submitAction(context);
waitUntilYarnAppDoneAndAssertSuccess(context.getAction().getExternalId());
ActionExecutor ae = new JavaActionExecutor();
ae.check(context, context.getAction());
assertEquals("SUCCEEDED", context.getAction().getExternalStatus());
assertNull(context.getAction().getData());
ae.end(context, context.getAction());
assertEquals(WorkflowAction.Status.OK, context.getAction().getStatus());
}
use of org.apache.oozie.action.ActionExecutor in project oozie by apache.
the class TestJavaActionExecutor method testSubmitOKWithVcoresAndMemory.
public void testSubmitOKWithVcoresAndMemory() throws Exception {
String actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<configuration>" + " <property><name>oozie.launcher.vcores</name><value>1</value></property>" + " <property><name>oozie.launcher.memory.mb</name><value>1024</value></property>" + "</configuration>" + "<main-class>" + LauncherMainTester.class.getName() + "</main-class>" + "</java>";
Context context = createContext(actionXml, null);
submitAction(context);
waitUntilYarnAppDoneAndAssertSuccess(context.getAction().getExternalId());
ActionExecutor ae = new JavaActionExecutor();
ae.check(context, context.getAction());
assertEquals("SUCCEEDED", context.getAction().getExternalStatus());
assertNull(context.getAction().getData());
ae.end(context, context.getAction());
assertEquals(WorkflowAction.Status.OK, context.getAction().getStatus());
}
use of org.apache.oozie.action.ActionExecutor in project oozie by apache.
the class TestJavaActionExecutor method testEmptyArgs.
private void testEmptyArgs(boolean nullArgsAllowed, String expectedExternalStatus, WorkflowAction.Status expectedStatus) throws Exception {
ConfigurationService.setBoolean(LauncherAMUtils.CONF_OOZIE_NULL_ARGS_ALLOWED, nullArgsAllowed);
String actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<main-class>" + LauncherMainTester.class.getName() + "</main-class>" + "<arg></arg>" + "</java>";
Context context = createContext(actionXml, null);
submitAction(context);
waitUntilYarnAppDoneAndAssertSuccess(context.getAction().getExternalId());
ActionExecutor ae = new JavaActionExecutor();
ae.check(context, context.getAction());
assertTrue(ae.isCompleted(context.getAction().getExternalStatus()));
assertEquals(expectedExternalStatus, context.getAction().getExternalStatus());
assertNull(context.getAction().getData());
ae.end(context, context.getAction());
assertEquals(expectedStatus, context.getAction().getStatus());
}
Aggregations