Search in sources :

Example 91 with CoordinatorActionBean

use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.

the class TestCoordinatorInputLogic method testNestedCondition3.

public void testNestedCondition3() throws Exception {
    Configuration conf = getConf();
    // @formatter:off
    String inputLogic = "<and name=\"test\">" + "<and>" + "<data-in dataset=\"A\" />" + "<data-in dataset=\"B\" />" + "</and>" + "<and>" + "<data-in dataset=\"C\" />" + "<data-in dataset=\"D\" />" + "</and>" + "<and>" + "<data-in dataset=\"E\" />" + "<data-in dataset=\"F\" />" + "</and>" + "</and>";
    // @formatter:on
    conf.set("partitionName", "test");
    final String jobId = _testCoordSubmit("coord-inputlogic.xml", conf, inputLogic);
    String input1 = createTestCaseSubDir("input-data/a/2014/10/08/00/_SUCCESS".split("/"));
    String input2 = createTestCaseSubDir("input-data/b/2014/10/08/00/_SUCCESS".split("/"));
    String input3 = createTestCaseSubDir("input-data/c/2014/10/08/00/_SUCCESS".split("/"));
    String input4 = createTestCaseSubDir("input-data/d/2014/10/08/00/_SUCCESS".split("/"));
    String input5 = createTestCaseSubDir("input-data/e/2014/10/08/00/_SUCCESS".split("/"));
    String input6 = createTestCaseSubDir("input-data/f/2014/10/08/00/_SUCCESS".split("/"));
    startCoordAction(jobId);
    CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
    XConfiguration runConf = new XConfiguration(new StringReader(actionBean.getRunConf()));
    String dataSets = runConf.get("inputLogicData");
    assertEquals(dataSets.split(",").length, 6);
    checkDataSets(dataSets, input1, input2, input3, input4, input5, input6);
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) StringReader(java.io.StringReader)

Example 92 with CoordinatorActionBean

use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.

the class TestCoordinatorInputLogic method testWait.

public void testWait() throws Exception {
    Configuration conf = getConf();
    Date now = new Date();
    String inputLogic = // @formatter:off
    "<combine name=\"test\" wait=\"1\">" + "<data-in dataset=\"A\" />" + "<data-in dataset=\"B\" />" + "</combine>";
    // @formatter:on
    conf.set("start_time", DateUtils.formatDateOozieTZ(now));
    conf.set("end_time", DateUtils.formatDateOozieTZ(new Date(now.getTime() + 3 * 60 * 60 * 1000)));
    conf.set("initial_instance_a", DateUtils.formatDateOozieTZ(new Date(now.getTime() - 5 * 60 * 60 * 1000)));
    conf.set("initial_instance_b", DateUtils.formatDateOozieTZ(new Date(now.getTime() - 5 * 60 * 60 * 1000)));
    String jobId = _testCoordSubmit("coord-inputlogic-range.xml", conf, inputLogic, getInputEventForRange());
    new CoordMaterializeTransitionXCommand(jobId, 3600).call();
    List<String> inputDir = createDirWithTime("input-data/b/", now, 0, 1, 2, 3, 4);
    startCoordActionForWaiting(jobId);
    // wait for 1 min
    sleep(60 * 1000);
    inputDir.addAll(createDirWithTime("input-data/b/", now, 5));
    new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
    CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
    assertFalse(CoordinatorAction.Status.WAITING.equals(actionBean.getStatus()));
    XConfiguration runConf = new XConfiguration(new StringReader(actionBean.getRunConf()));
    String dataSets = runConf.get("inputLogicData");
    assertEquals(dataSets.split(",").length, 6);
    checkDataSets(dataSets, inputDir.toArray(new String[inputDir.size()]));
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) StringReader(java.io.StringReader) CoordMaterializeTransitionXCommand(org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand) CoordActionInputCheckXCommand(org.apache.oozie.command.coord.CoordActionInputCheckXCommand) Date(java.util.Date)

Example 93 with CoordinatorActionBean

use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.

the class TestCoordinatorInputLogic method testAndWithMin.

public void testAndWithMin() throws Exception {
    Configuration conf = getConf();
    // @formatter:off
    String inputLogic = "<and name=\"test\">" + "<data-in dataset=\"A\" min=\"2\"/>" + "<data-in dataset=\"B\" min=\"3\"/>" + "<data-in dataset=\"C\" min=\"0\"/>" + "</and>";
    // @formatter:on
    conf.set("initial_instance_a", "2014-10-07T00:00Z");
    conf.set("initial_instance_b", "2014-10-07T00:00Z");
    String jobId = _testCoordSubmit("coord-inputlogic-range.xml", conf, inputLogic, getInputEventForRange());
    String input1 = createTestCaseSubDir("input-data/a/2014/10/08/00/_SUCCESS".split("/"));
    String input2 = createTestCaseSubDir("input-data/a/2014/10/07/23/_SUCCESS".split("/"));
    String input3 = createTestCaseSubDir("input-data/b/2014/10/07/21/_SUCCESS".split("/"));
    String input4 = createTestCaseSubDir("input-data/b/2014/10/07/20/_SUCCESS".split("/"));
    String input5 = createTestCaseSubDir("input-data/b/2014/10/07/19/_SUCCESS".split("/"));
    startCoordAction(jobId);
    CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
    assertFalse(CoordinatorAction.Status.WAITING.equals(actionBean.getStatus()));
    XConfiguration runConf = new XConfiguration(new StringReader(actionBean.getRunConf()));
    String dataSets = runConf.get("inputLogicData");
    assertEquals(dataSets.split(",").length, 5);
    checkDataSets(dataSets, input1, input2, input3, input4, input5, input5);
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) StringReader(java.io.StringReader)

Example 94 with CoordinatorActionBean

use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.

the class TestCoordinatorInputLogic method startCoordActionForWaiting.

private void startCoordActionForWaiting(final String jobId) throws CommandException, JPAExecutorException, JDOMException {
    new CoordMaterializeTransitionXCommand(jobId, 3600).call();
    new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
    waitFor(5 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
            return !actionBean.getStatus().equals(CoordinatorAction.Status.WAITING);
        }
    });
    CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
    assertTrue("should be waiting", actionBean.getStatus().equals(CoordinatorAction.Status.WAITING));
}
Also used : CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordMaterializeTransitionXCommand(org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand) CoordActionInputCheckXCommand(org.apache.oozie.command.coord.CoordActionInputCheckXCommand) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) JDOMException(org.jdom.JDOMException) IOException(java.io.IOException) CommandException(org.apache.oozie.command.CommandException)

Example 95 with CoordinatorActionBean

use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.

the class TestCoordinatorInputLogic method testCombineWithMin.

public void testCombineWithMin() throws Exception {
    Configuration conf = getConf();
    String inputLogic = // @formatter:off
    "<combine name=\"test\" min=\"4\">" + "<data-in dataset=\"A\" />" + "<data-in dataset=\"B\" />" + "</combine>";
    // @formatter:on
    conf.set("initial_instance_a", "2014-10-07T00:00Z");
    conf.set("initial_instance_b", "2014-10-07T00:00Z");
    final String jobId = _testCoordSubmit("coord-inputlogic-range.xml", conf, inputLogic, getInputEventForRange());
    new CoordMaterializeTransitionXCommand(jobId, 3600).call();
    String input1 = createTestCaseSubDir("input-data/a/2014/10/08/00/_SUCCESS".split("/"));
    String input2 = createTestCaseSubDir("input-data/a/2014/10/07/23/_SUCCESS".split("/"));
    String input3 = createTestCaseSubDir("input-data/a/2014/10/07/22/_SUCCESS".split("/"));
    String input4 = createTestCaseSubDir("input-data/b/2014/10/07/21/_SUCCESS".split("/"));
    String input5 = createTestCaseSubDir("input-data/b/2014/10/07/20/_SUCCESS".split("/"));
    startCoordAction(jobId);
    CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
    assertFalse(CoordinatorAction.Status.WAITING.equals(actionBean.getStatus()));
    XConfiguration runConf = new XConfiguration(new StringReader(actionBean.getRunConf()));
    String dataSets = runConf.get("inputLogicData");
    assertEquals(dataSets.split(",").length, 5);
    checkDataSets(dataSets, input1, input2, input3, input4, input5);
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) StringReader(java.io.StringReader) CoordMaterializeTransitionXCommand(org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand)

Aggregations

CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)307 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)148 Date (java.util.Date)117 JPAService (org.apache.oozie.service.JPAService)113 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)102 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)60 CommandException (org.apache.oozie.command.CommandException)55 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)53 IOException (java.io.IOException)49 XConfiguration (org.apache.oozie.util.XConfiguration)44 Configuration (org.apache.hadoop.conf.Configuration)43 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)42 ArrayList (java.util.ArrayList)40 JDOMException (org.jdom.JDOMException)33 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)32 StringReader (java.io.StringReader)30 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)29 StoreException (org.apache.oozie.store.StoreException)24 Test (org.junit.Test)24 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)22