Search in sources :

Example 31 with WorkflowAction

use of org.apache.oozie.client.WorkflowAction in project oozie by apache.

the class TestDistCpActionExecutor method submitAction.

protected String submitAction(Context context) throws Exception {
    DistcpActionExecutor ae = new DistcpActionExecutor();
    WorkflowAction action = context.getAction();
    ae.prepareActionDir(getFileSystem(), context);
    ae.submitLauncher(getFileSystem(), context, action);
    String jobId = action.getExternalId();
    String jobTracker = action.getTrackerUri();
    String consoleUrl = action.getConsoleUrl();
    assertNotNull(jobId);
    assertNotNull(jobTracker);
    assertNotNull(consoleUrl);
    ae.submitLauncher(getFileSystem(), context, context.getAction());
    return context.getAction().getExternalId();
}
Also used : WorkflowAction(org.apache.oozie.client.WorkflowAction)

Example 32 with WorkflowAction

use of org.apache.oozie.client.WorkflowAction in project oozie by apache.

the class ForTestingActionExecutor method end.

public void end(Context context, WorkflowAction action) throws ActionExecutorException {
    Element eConf = getConfiguration(action.getConf());
    Namespace ns = eConf.getNamespace();
    String error = eConf.getChild("error", ns).getText().trim();
    if ("end.transient".equals(error)) {
        throw new ActionExecutorException(ActionExecutorException.ErrorType.TRANSIENT, TEST_ERROR, "end");
    }
    if ("end.non-transient".equals(error)) {
        throw new ActionExecutorException(ActionExecutorException.ErrorType.NON_TRANSIENT, TEST_ERROR, "end");
    }
    if ("end.error".equals(error)) {
        throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, TEST_ERROR, "end");
    }
    String signalValue = eConf.getChild("signal-value", ns).getText().trim();
    String externalStatus = action.getExternalStatus();
    WorkflowAction.Status status = null;
    if (externalStatus.equals("ok")) {
        status = WorkflowAction.Status.OK;
    } else {
        status = WorkflowAction.Status.ERROR;
    }
    if (signalValue.equals("based_on_action_status")) {
        signalValue = status.toString();
    }
    boolean callSetEndData = true;
    Element setEndData = eConf.getChild("avoid-set-end-data", ns);
    if (null != setEndData) {
        if (setEndData.getText().trim().equals("true")) {
            callSetEndData = false;
        }
    }
    if (callSetEndData) {
        context.setEndData(status, signalValue);
    }
}
Also used : WorkflowAction(org.apache.oozie.client.WorkflowAction) Element(org.jdom.Element) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) Namespace(org.jdom.Namespace)

Example 33 with WorkflowAction

use of org.apache.oozie.client.WorkflowAction in project oozie by apache.

the class TestReRunXCommand method _testRerunFork.

public void _testRerunFork() throws Exception {
    // We need the shell schema and action for this test
    Services.get().setService(ActionService.class);
    Services.get().getConf().set(SchemaService.WF_CONF_EXT_SCHEMAS, "shell-action-0.3.xsd");
    Services.get().setService(SchemaService.class);
    Reader reader = IOUtils.getResourceAsReader("rerun-wf-fork.xml", -1);
    Writer writer = new FileWriter(new File(getTestCaseDir(), "workflow.xml"));
    IOUtils.copyCharStream(reader, writer);
    final OozieClient wfClient = LocalOozie.getClient();
    Properties conf = wfClient.createConfiguration();
    conf.setProperty("nameNode", getNameNodeUri());
    conf.setProperty("jobTracker", getJobTrackerUri());
    conf.setProperty(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
    conf.setProperty(OozieClient.USER_NAME, getTestUser());
    // expected to fail
    conf.setProperty("cmd4", "echo1");
    final String jobId1 = wfClient.submit(conf);
    wfClient.start(jobId1);
    waitFor(200 * 1000, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            return wfClient.getJobInfo(jobId1).getStatus() == WorkflowJob.Status.KILLED;
        }
    });
    wfClient.kill(jobId1);
    assertEquals(WorkflowJob.Status.KILLED, wfClient.getJobInfo(jobId1).getStatus());
    List<WorkflowAction> actions = wfClient.getJobInfo(jobId1).getActions();
    // fork
    assertEquals(WorkflowAction.Status.OK, actions.get(1).getStatus());
    // sh1
    assertEquals(WorkflowAction.Status.OK, actions.get(2).getStatus());
    // sh2
    assertEquals(WorkflowAction.Status.OK, actions.get(3).getStatus());
    // sh3
    assertEquals(WorkflowAction.Status.OK, actions.get(4).getStatus());
    // j
    assertEquals(WorkflowAction.Status.OK, actions.get(5).getStatus());
    // sh4
    assertEquals(WorkflowAction.Status.ERROR, actions.get(6).getStatus());
    // rerun failed node, which is after the fork
    conf.setProperty(OozieClient.RERUN_FAIL_NODES, "true");
    conf.setProperty("cmd4", "echo");
    wfClient.reRun(jobId1, conf);
    waitFor(200 * 1000, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            return wfClient.getJobInfo(jobId1).getStatus() == WorkflowJob.Status.SUCCEEDED;
        }
    });
    assertEquals(WorkflowJob.Status.SUCCEEDED, wfClient.getJobInfo(jobId1).getStatus());
    actions = wfClient.getJobInfo(jobId1).getActions();
    // fork
    assertEquals(WorkflowAction.Status.OK, actions.get(1).getStatus());
    // sh1
    assertEquals(WorkflowAction.Status.OK, actions.get(2).getStatus());
    // sh2
    assertEquals(WorkflowAction.Status.OK, actions.get(3).getStatus());
    // sh3
    assertEquals(WorkflowAction.Status.OK, actions.get(4).getStatus());
    // join
    assertEquals(WorkflowAction.Status.OK, actions.get(5).getStatus());
    // sh4
    assertEquals(WorkflowAction.Status.OK, actions.get(6).getStatus());
}
Also used : OozieClient(org.apache.oozie.client.OozieClient) WorkflowAction(org.apache.oozie.client.WorkflowAction) FileWriter(java.io.FileWriter) Reader(java.io.Reader) Properties(java.util.Properties) File(java.io.File) FileWriter(java.io.FileWriter) Writer(java.io.Writer) OozieClientException(org.apache.oozie.client.OozieClientException) IOException(java.io.IOException)

Example 34 with WorkflowAction

use of org.apache.oozie.client.WorkflowAction in project oozie by apache.

the class TestSignalXCommand method _testSuspendPoints.

public void _testSuspendPoints() throws Exception {
    services.destroy();
    LocalOozie.start();
    FileSystem fs = getFileSystem();
    Path appPath = new Path(getFsTestCaseDir(), "app");
    fs.mkdirs(appPath);
    Reader reader = IOUtils.getResourceAsReader("wf-suspendpoints.xml", -1);
    Writer writer = new OutputStreamWriter(fs.create(new Path(appPath, "workflow.xml")));
    IOUtils.copyCharStream(reader, writer);
    writer.close();
    reader.close();
    final OozieClient oc = LocalOozie.getClient();
    Properties conf = oc.createConfiguration();
    conf.setProperty(OozieClient.APP_PATH, new Path(appPath, "workflow.xml").toString());
    conf.setProperty(OozieClient.USER_NAME, getTestUser());
    conf.setProperty("oozie.suspend.on.nodes", "action1,nonexistant_action_name,decision1, action3,join1 ,fork1,action4b");
    final String jobId = oc.submit(conf);
    assertNotNull(jobId);
    WorkflowJob wf = oc.getJobInfo(jobId);
    assertEquals(WorkflowJob.Status.PREP, wf.getStatus());
    long beforeStart = System.currentTimeMillis();
    oc.start(jobId);
    checkSuspendActions(wf, oc, jobId, WorkflowJob.Status.SUSPENDED, new String[] { "action1" }, new String[] { ":start:" });
    // Check for creation time
    long afterStart = System.currentTimeMillis();
    WorkflowJob wf1 = oc.getJobInfo(jobId);
    for (WorkflowAction action : wf1.getActions()) {
        WorkflowActionBean bean = (WorkflowActionBean) action;
        assertNotNull(bean.getCreatedTime());
        assertTrue((bean.getCreatedTime().getTime() > beforeStart) && (bean.getCreatedTime().getTime() < afterStart));
    }
    oc.resume(jobId);
    checkSuspendActions(wf, oc, jobId, WorkflowJob.Status.SUSPENDED, new String[] { "decision1" }, new String[] { ":start:", "action1", "action2" });
    oc.resume(jobId);
    checkSuspendActions(wf, oc, jobId, WorkflowJob.Status.SUSPENDED, new String[] { "action3" }, new String[] { ":start:", "action1", "action2", "decision1" });
    oc.resume(jobId);
    checkSuspendActions(wf, oc, jobId, WorkflowJob.Status.SUSPENDED, new String[] { "fork1" }, new String[] { ":start:", "action1", "action2", "decision1", "action3" });
    oc.resume(jobId);
    checkSuspendActions(wf, oc, jobId, WorkflowJob.Status.SUSPENDED, new String[] { "action4a", "action4b", "action4c" }, new String[] { ":start:", "action1", "action2", "decision1", "action3", "fork1" });
    oc.resume(jobId);
    checkSuspendActions(wf, oc, jobId, WorkflowJob.Status.SUSPENDED, new String[] { "join1" }, new String[] { ":start:", "action1", "action2", "decision1", "action3", "fork1", "action4a", "action4b", "action4c" });
    oc.resume(jobId);
    checkSuspendActions(wf, oc, jobId, WorkflowJob.Status.SUCCEEDED, new String[] {}, new String[] { ":start:", "action1", "action2", "decision1", "action3", "fork1", "action4a", "action4b", "action4c", "join1", "end" });
    LocalOozie.stop();
}
Also used : Path(org.apache.hadoop.fs.Path) OozieClient(org.apache.oozie.client.OozieClient) WorkflowAction(org.apache.oozie.client.WorkflowAction) FileSystem(org.apache.hadoop.fs.FileSystem) Reader(java.io.Reader) OutputStreamWriter(java.io.OutputStreamWriter) Properties(java.util.Properties) WorkflowJob(org.apache.oozie.client.WorkflowJob) OutputStreamWriter(java.io.OutputStreamWriter) Writer(java.io.Writer) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 35 with WorkflowAction

use of org.apache.oozie.client.WorkflowAction in project oozie by apache.

the class TestPigActionExecutor method testExecutionStatsWithMaxStatsSizeLimit.

/*
     * Test the stats after setting the maximum allowed size of stats to a small
     * value
     */
public void testExecutionStatsWithMaxStatsSizeLimit() throws Exception {
    Services.get().destroy();
    // Set a very small value for max size of stats
    setSystemProperty(JavaActionExecutor.MAX_EXTERNAL_STATS_SIZE, new String("1"));
    new Services().init();
    // Set the action xml with the option for retrieving stats to true
    String actionXml = setPigActionXml(PIG_SCRIPT, true);
    Context context = createContext(actionXml);
    final String launcherId = submitAction(context);
    waitUntilYarnAppDoneAndAssertSuccess(launcherId);
    PigActionExecutor ae = new PigActionExecutor();
    WorkflowAction wfAction = context.getAction();
    ae.check(context, wfAction);
    ae.end(context, wfAction);
    // action should fail as the size of pig stats will always be greater
    // than 1 byte
    assertEquals("FAILED/KILLED", wfAction.getExternalStatus());
    assertNull(wfAction.getStats());
}
Also used : Services(org.apache.oozie.service.Services) WorkflowAction(org.apache.oozie.client.WorkflowAction)

Aggregations

WorkflowAction (org.apache.oozie.client.WorkflowAction)41 FileSystem (org.apache.hadoop.fs.FileSystem)9 Path (org.apache.hadoop.fs.Path)8 IOException (java.io.IOException)6 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)6 WorkflowJob (org.apache.oozie.client.WorkflowJob)6 Writer (java.io.Writer)5 Properties (java.util.Properties)5 OozieClient (org.apache.oozie.client.OozieClient)5 XConfiguration (org.apache.oozie.util.XConfiguration)5 OutputStreamWriter (java.io.OutputStreamWriter)4 Configuration (org.apache.hadoop.conf.Configuration)3 Element (org.jdom.Element)3 File (java.io.File)2 Reader (java.io.Reader)2 StringReader (java.io.StringReader)2 URISyntaxException (java.net.URISyntaxException)2 AccessControlException (org.apache.hadoop.security.AccessControlException)2 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)2 HadoopAccessorException (org.apache.oozie.service.HadoopAccessorException)2