Search in sources :

Example 26 with ActionExecutor

use of org.apache.oozie.action.ActionExecutor in project oozie by apache.

the class TestJavaActionExecutor method testSubmitOKWithLauncherJavaOpts.

public void testSubmitOKWithLauncherJavaOpts() throws Exception {
    String actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<configuration>" + "  <property><name>oozie.launcher.javaopts</name><value>-DtestJavaOpts=true</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("FAILED/KILLED", context.getAction().getExternalStatus());
    assertNull(context.getAction().getData());
    ae.end(context, context.getAction());
    assertEquals(WorkflowAction.Status.ERROR, context.getAction().getStatus());
}
Also used : ActionExecutor(org.apache.oozie.action.ActionExecutor)

Example 27 with ActionExecutor

use of org.apache.oozie.action.ActionExecutor in project oozie by apache.

the class TestJavaActionExecutor method testRecovery.

public void testRecovery() throws Exception {
    final String actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<main-class>" + LauncherMainTester.class.getName() + "</main-class>" + "</java>";
    final Context context = createContext(actionXml, null);
    String launcherId = submitAction(context);
    waitFor(60 * 1000, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            JavaActionExecutor ae = new JavaActionExecutor();
            Configuration conf = ae.createBaseHadoopConf(context, XmlUtils.parseXml(actionXml));
            return LauncherHelper.getRecoveryId(conf, context.getActionDir(), context.getRecoveryId()) != null;
        }
    });
    final String runningJob2 = submitAction(context);
    assertEquals(launcherId, runningJob2);
    assertEquals(launcherId, context.getAction().getExternalId());
    waitUntilYarnAppDoneAndAssertSuccess(launcherId);
    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) Configuration(org.apache.hadoop.conf.Configuration) XConfiguration(org.apache.oozie.util.XConfiguration) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) IOException(java.io.IOException)

Example 28 with ActionExecutor

use of org.apache.oozie.action.ActionExecutor in project oozie by apache.

the class TestEventGeneration method testWorkflowActionEvent.

@Test
public void testWorkflowActionEvent() throws Exception {
    assertEquals(queue.size(), 0);
    // avoid noise from other apptype events by setting it to only
    // workflow action
    ehs.setAppTypes(new HashSet<String>(Arrays.asList("workflow_action")));
    WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.PREP, true);
    // adding record sets externalChildID to dummy workflow-id so resetting it
    action.setExternalChildIDs(null);
    WorkflowActionQueryExecutor.getInstance().executeUpdate(WorkflowActionQuery.UPDATE_ACTION_START, action);
    // Starting job
    new ActionStartXCommand(action.getId(), "map-reduce").call();
    WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
    action = jpaService.execute(wfActionGetCmd);
    assertEquals(WorkflowAction.Status.RUNNING, action.getStatus());
    assertEquals(1, queue.size());
    WorkflowActionEvent event = (WorkflowActionEvent) queue.poll();
    assertNotNull(event);
    assertEquals(EventStatus.STARTED, event.getEventStatus());
    assertEquals(AppType.WORKFLOW_ACTION, event.getAppType());
    assertEquals(action.getId(), event.getId());
    assertEquals(job.getUser(), event.getUser());
    assertEquals(action.getName(), event.getAppName());
    assertEquals(action.getStartTime(), event.getStartTime());
    assertEquals(0, queue.size());
    // Suspending job
    ActionExecutor.Context context = new ActionXCommand.ActionExecutorContext(job, action, false, false);
    ActionExecutor executor = Services.get().get(ActionService.class).getExecutor(action.getType());
    ActionCheckXCommandForTest dac = new ActionCheckXCommandForTest(context, executor, action.getId());
    dac.execute();
    action = dac.getAction();
    assertEquals(WorkflowAction.Status.START_MANUAL, action.getStatus());
    assertEquals(1, queue.size());
    event = (WorkflowActionEvent) queue.poll();
    assertNotNull(event);
    assertEquals(EventStatus.SUSPEND, event.getEventStatus());
    assertEquals(AppType.WORKFLOW_ACTION, event.getAppType());
    assertEquals(action.getId(), event.getId());
    assertEquals(job.getUser(), event.getUser());
    assertEquals(action.getName(), event.getAppName());
    assertEquals(0, queue.size());
    // Killing job
    action.setStatus(WorkflowAction.Status.KILLED);
    action.setPendingOnly();
    // its already set by XTestCase add action record method above
    action.setEndTime(null);
    WorkflowActionQueryExecutor.getInstance().executeUpdate(WorkflowActionQuery.UPDATE_ACTION_END, action);
    new ActionKillXCommand(action.getId()).call();
    action = jpaService.execute(wfActionGetCmd);
    assertEquals(WorkflowAction.Status.KILLED, action.getStatus());
    assertEquals(1, queue.size());
    event = (WorkflowActionEvent) queue.poll();
    assertNotNull(event);
    assertEquals(EventStatus.FAILURE, event.getEventStatus());
    assertEquals(AppType.WORKFLOW_ACTION, event.getAppType());
    assertEquals(action.getId(), event.getId());
    assertEquals(job.getUser(), event.getUser());
    assertEquals(action.getName(), event.getAppName());
    assertEquals(action.getStartTime(), event.getStartTime());
    assertNotNull(action.getEndTime());
    assertNotNull(event.getEndTime());
    assertEquals(action.getEndTime(), event.getEndTime());
    assertEquals(0, queue.size());
}
Also used : ControlNodeActionExecutor(org.apache.oozie.action.control.ControlNodeActionExecutor) ActionExecutor(org.apache.oozie.action.ActionExecutor) ActionKillXCommand(org.apache.oozie.command.wf.ActionKillXCommand) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) ActionStartXCommand(org.apache.oozie.command.wf.ActionStartXCommand) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) ActionService(org.apache.oozie.service.ActionService) Test(org.junit.Test)

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