Search in sources :

Example 16 with ActionExecutor

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;
}
Also used : CallbackService(org.apache.oozie.service.CallbackService) ActionExecutor(org.apache.oozie.action.ActionExecutor) CommandException(org.apache.oozie.command.CommandException) ActionService(org.apache.oozie.service.ActionService)

Example 17 with ActionExecutor

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);
}
Also used : KillActionExecutor(org.apache.oozie.action.control.KillActionExecutor) StartActionExecutor(org.apache.oozie.action.control.StartActionExecutor) ActionExecutor(org.apache.oozie.action.ActionExecutor) EndActionExecutor(org.apache.oozie.action.control.EndActionExecutor) ForkActionExecutor(org.apache.oozie.action.control.ForkActionExecutor) JoinActionExecutor(org.apache.oozie.action.control.JoinActionExecutor)

Example 18 with ActionExecutor

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());
}
Also used : ActionExecutor(org.apache.oozie.action.ActionExecutor)

Example 19 with ActionExecutor

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());
}
Also used : ActionExecutor(org.apache.oozie.action.ActionExecutor)

Example 20 with ActionExecutor

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());
}
Also used : ActionExecutor(org.apache.oozie.action.ActionExecutor)

Aggregations

ActionExecutor (org.apache.oozie.action.ActionExecutor)28 ActionService (org.apache.oozie.service.ActionService)5 IOException (java.io.IOException)4 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)4 Path (org.apache.hadoop.fs.Path)3 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)3 ForkActionExecutor (org.apache.oozie.action.control.ForkActionExecutor)3 StartActionExecutor (org.apache.oozie.action.control.StartActionExecutor)3 CommandException (org.apache.oozie.command.CommandException)3 StringReader (java.io.StringReader)2 Date (java.util.Date)2 SLAEventBean (org.apache.oozie.SLAEventBean)2 ControlNodeActionExecutor (org.apache.oozie.action.control.ControlNodeActionExecutor)2 EndActionExecutor (org.apache.oozie.action.control.EndActionExecutor)2 JoinActionExecutor (org.apache.oozie.action.control.JoinActionExecutor)2 KillActionExecutor (org.apache.oozie.action.control.KillActionExecutor)2 JavaActionExecutor (org.apache.oozie.action.hadoop.JavaActionExecutor)2 SubWorkflowActionExecutor (org.apache.oozie.action.oozie.SubWorkflowActionExecutor)2 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)2 WorkflowActionQuery (org.apache.oozie.executor.jpa.WorkflowActionQueryExecutor.WorkflowActionQuery)2