Search in sources :

Example 71 with ActionExecutorException

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

the class TestFsActionExecutor method testFileSchemeWildcard.

public void testFileSchemeWildcard() throws Exception {
    FsActionExecutor ae = new FsActionExecutor();
    Services.get().destroy();
    setSystemProperty(HadoopAccessorService.SUPPORTED_FILESYSTEMS, "*");
    new Services().init();
    try {
        ae.validatePath(new Path("anyfs://bla"), true);
    } catch (ActionExecutorException ex) {
        fail("Wildcard indicates ALL schemes will be allowed. This should pass");
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Services(org.apache.oozie.service.Services) ActionExecutorException(org.apache.oozie.action.ActionExecutorException)

Example 72 with ActionExecutorException

use of org.apache.oozie.action.ActionExecutorException 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 73 with ActionExecutorException

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

the class ForTestingActionExecutor method start.

public void start(Context context, WorkflowAction action) throws ActionExecutorException {
    Element eConf = getConfiguration(action.getConf());
    Namespace ns = eConf.getNamespace();
    String error = eConf.getChild("error", ns).getText().trim();
    if ("start.transient".equals(error)) {
        throw new ActionExecutorException(ActionExecutorException.ErrorType.TRANSIENT, TEST_ERROR, "start");
    }
    if ("start.non-transient".equals(error)) {
        throw new ActionExecutorException(ActionExecutorException.ErrorType.NON_TRANSIENT, TEST_ERROR, "start");
    }
    if ("start.error".equals(error)) {
        throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, TEST_ERROR, "start");
    }
    String externalStatus = eConf.getChild("external-status", ns).getText().trim();
    Element externalChildIds = eConf.getChild("external-childIds", ns);
    String runningMode = "sync";
    Element runningModeElement = eConf.getChild("running-mode", ns);
    if (null != runningModeElement) {
        runningMode = runningModeElement.getText().trim();
    }
    if (runningMode.equals("async")) {
        context.setStartData("blah", "blah", "blah");
        return;
    }
    if (runningMode.equals("async-error")) {
        context.setStartData("blah", "blah", "blah");
        context.setExecutionData(externalStatus, null);
        if (null != externalChildIds) {
            context.setExternalChildIDs(externalChildIds.getText());
        }
        throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, TEST_ERROR, "start");
    }
    boolean callSetExecutionData = true;
    Element setStartData = eConf.getChild("avoid-set-execution-data", ns);
    if (null != setStartData) {
        if (setStartData.getText().trim().equals("true")) {
            callSetExecutionData = false;
        }
    }
    if (callSetExecutionData) {
        context.setExecutionData(externalStatus, null);
    }
    if (null != externalChildIds) {
        context.setExternalChildIDs(externalChildIds.getText());
    }
}
Also used : Element(org.jdom.Element) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) Namespace(org.jdom.Namespace)

Example 74 with ActionExecutorException

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

the class TestSshActionExecutor method testJobRecover.

public void testJobRecover() throws ActionExecutorException, InterruptedException {
    String baseDir = getTestCaseDir();
    Path appPath = new Path(getNameNodeUri(), baseDir);
    XConfiguration protoConf = new XConfiguration();
    protoConf.setStrings(WorkflowAppService.HADOOP_USER, getTestUser());
    XConfiguration wfConf = new XConfiguration();
    wfConf.set(OozieClient.APP_PATH, appPath.toString());
    WorkflowJobBean workflow = new WorkflowJobBean();
    workflow.setConf(wfConf.toXmlString());
    workflow.setAppPath(wfConf.get(OozieClient.APP_PATH));
    workflow.setProtoActionConf(protoConf.toXmlString());
    workflow.setId(Services.get().get(UUIDService.class).generateId(ApplicationType.WORKFLOW));
    final WorkflowActionBean action = new WorkflowActionBean();
    action.setId("actionId");
    action.setConf("<ssh xmlns='" + getActionXMLSchema() + "'>" + "<host>localhost</host>" + "<command>echo</command>" + "<capture-output/>" + "<args>\"prop1=something\"</args>" + "</ssh>");
    action.setName("ssh");
    final SshActionExecutor ssh = new SshActionExecutor();
    final Context context = new Context(workflow, action);
    ssh.start(context, action);
    sleep(200);
    final WorkflowActionBean action1 = new WorkflowActionBean();
    action1.setId("actionId");
    action1.setConf("<ssh xmlns='" + getActionXMLSchema() + "'>" + "<host>localhost</host>" + "<command>echo</command>" + "<capture-output/>" + "<args>\"prop1=nothing\"</args>" + "</ssh>");
    action1.setName("ssh");
    final SshActionExecutor ssh1 = new SshActionExecutor();
    final Context context1 = new Context(workflow, action1);
    sleep(500);
    ssh1.start(context1, action1);
    assertEquals(action1.getExternalId(), action.getExternalId());
    waitFor(30 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            ssh.check(context1, action1);
            return Status.DONE == action1.getStatus();
        }
    });
    ssh1.end(context1, action1);
    assertEquals(Status.OK, action1.getStatus());
    assertEquals("something", PropertiesUtils.stringToProperties(action1.getData()).getProperty("prop1"));
}
Also used : Path(org.apache.hadoop.fs.Path) XConfiguration(org.apache.oozie.util.XConfiguration) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) URISyntaxException(java.net.URISyntaxException) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) IOException(java.io.IOException)

Example 75 with ActionExecutorException

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

the class TestSshActionExecutor method testSshStartWithInvalidXml.

/**
 * test {@code SshActionExecutor.start()} method with invalid
 * xml configuration
 */
public void testSshStartWithInvalidXml() throws Exception {
    String baseDir = getTestCaseDir();
    Path appPath = new Path(getNameNodeUri(), baseDir);
    XConfiguration protoConf = new XConfiguration();
    protoConf.setStrings(WorkflowAppService.HADOOP_USER, getTestUser());
    XConfiguration wfConf = new XConfiguration();
    wfConf.set(OozieClient.APP_PATH, appPath.toString());
    WorkflowJobBean workflow = new WorkflowJobBean();
    workflow.setConf(wfConf.toXmlString());
    workflow.setAppPath(wfConf.get(OozieClient.APP_PATH));
    workflow.setProtoActionConf(protoConf.toXmlString());
    workflow.setId(Services.get().get(UUIDService.class).generateId(ApplicationType.WORKFLOW));
    WorkflowActionBean action = new WorkflowActionBean();
    action.setId("actionId");
    action.setConf("<ssh xmlns='" + getActionXMLSchema() + "'> invalid body ");
    action.setName("ssh");
    final SshActionExecutor ssh = new SshActionExecutor();
    final Context context = new Context(workflow, action);
    try {
        ssh.start(context, action);
        fail("testSshStartWithInvalidXml expected ex error");
    } catch (ActionExecutorException ex) {
    // ActionExecutorException should be thrown to pass the test
    }
}
Also used : Path(org.apache.hadoop.fs.Path) XConfiguration(org.apache.oozie.util.XConfiguration) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Aggregations

ActionExecutorException (org.apache.oozie.action.ActionExecutorException)75 Path (org.apache.hadoop.fs.Path)41 IOException (java.io.IOException)39 Element (org.jdom.Element)28 URISyntaxException (java.net.URISyntaxException)27 FileSystem (org.apache.hadoop.fs.FileSystem)25 HadoopAccessorException (org.apache.oozie.service.HadoopAccessorException)24 XConfiguration (org.apache.oozie.util.XConfiguration)23 Configuration (org.apache.hadoop.conf.Configuration)20 AccessControlException (org.apache.hadoop.security.AccessControlException)20 Namespace (org.jdom.Namespace)13 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)12 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)12 JDOMException (org.jdom.JDOMException)12 FileNotFoundException (java.io.FileNotFoundException)10 ELEvaluationException (org.apache.oozie.util.ELEvaluationException)10 ConnectException (java.net.ConnectException)9 UnknownHostException (java.net.UnknownHostException)9 RemoteException (org.apache.hadoop.ipc.RemoteException)9 ArrayList (java.util.ArrayList)8