Search in sources :

Example 1 with CoordMaterializeTransitionXCommand

use of org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand in project oozie by apache.

the class TestCoordinatorInputLogic method testNestedCondition.

public void testNestedCondition() throws Exception {
    Configuration conf = getConf();
    // @formatter:off
    String inputLogic = "<or name=\"test\">" + "<and>" + "<or>" + "<data-in dataset=\"A\" />" + "<data-in dataset=\"B\" />" + "</or>" + "<or>" + "<data-in dataset=\"C\" />" + "<data-in dataset=\"D\" />" + "</or>" + "</and>" + "<and>" + "<data-in dataset=\"A\" />" + "<data-in dataset=\"B\" />" + "</and>" + "</or>";
    // @formatter:on
    conf.set("partitionName", "test");
    final String jobId = _testCoordSubmit("coord-inputlogic.xml", conf, inputLogic);
    new CoordMaterializeTransitionXCommand(jobId, 3600).call();
    new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
    String input1 = createTestCaseSubDir("input-data/a/2014/10/08/00/_SUCCESS".split("/"));
    String input2 = createTestCaseSubDir("input-data/b/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, 2);
    checkDataSets(dataSets, input1, input2);
}
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)

Example 2 with CoordMaterializeTransitionXCommand

use of org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand in project oozie by apache.

the class TestCoordinatorInputLogic method testMinWait.

public void testMinWait() throws Exception {
    Configuration conf = getConf();
    Date now = new Date();
    String inputLogic = // @formatter:off
    "<combine name=\"test\" min= \"4\" 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)));
    // 5 hour before
    conf.set("initial_instance_a", DateUtils.formatDateOozieTZ(new Date(now.getTime() - 5 * 60 * 60 * 1000)));
    // 5 hour before
    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);
    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, 5);
    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 3 with CoordMaterializeTransitionXCommand

use of org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand in project oozie by apache.

the class TestCoordinatorInputLogic method testCombineNegative.

public void testCombineNegative() throws Exception {
    Configuration conf = getConf();
    // @formatter:off
    String inputLogic = "<combine name=\"test\">" + "<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());
    createTestCaseSubDir("input-data/a/2014/10/08/00/_SUCCESS".split("/"));
    createTestCaseSubDir("input-data/a/2014/10/07/23/_SUCCESS".split("/"));
    createTestCaseSubDir("input-data/b/2014/10/07/21/_SUCCESS".split("/"));
    createTestCaseSubDir("input-data/b/2014/10/07/20/_SUCCESS".split("/"));
    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);
        }
    });
    CoordinatorAction actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
    assertEquals(actionBean.getStatus(), CoordinatorAction.Status.WAITING);
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordinatorAction(org.apache.oozie.client.CoordinatorAction) 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 4 with CoordMaterializeTransitionXCommand

use of org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand 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 5 with CoordMaterializeTransitionXCommand

use of org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand in project oozie by apache.

the class TestCoordinatorInputLogic method testCoordWithoutInputCheck.

// TODO combine support for unresolved
// public void testLatestWithCombine() throws Exception {
// Configuration conf = getConf();
// conf.set("input_check", "combine(\"A\", \"B\")");
// conf.set("initial_instance_a", "2014-10-07T00:00Z");
// conf.set("initial_instance_b", "2014-10-07T00:00Z");
// 
// String jobId = _testCoordSubmit("coord-inputlogic-range-latest.xml", conf);
// 
// new CoordMaterializeTransitionXCommand(jobId, 3600).call();
// CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(
// CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
// sleep(2000);
// 
// new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
// assertEquals(actionBean.getStatus(), CoordinatorAction.Status.WAITING);
// createTestCaseSubDir("input-data/a/2014/10/08/00/_SUCCESS".split("/"));
// createTestCaseSubDir("input-data/a/2014/10/07/23/_SUCCESS".split("/"));
// createTestCaseSubDir("input-data/a/2014/10/07/22/_SUCCESS".split("/"));
// createTestCaseSubDir("input-data/b/2014/10/07/21/_SUCCESS".split("/"));
// 
// new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
// 
// actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
// assertEquals(actionBean.getStatus(), CoordinatorAction.Status.WAITING);
// 
// createTestCaseSubDir("input-data/b/2014/10/07/20/_SUCCESS".split("/"));
// new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
// 
// actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
// assertFalse(CoordinatorAction.Status.WAITING.equals(actionBean.getStatus()));
// 
// }
public void testCoordWithoutInputCheck() throws Exception {
    Configuration conf = new XConfiguration();
    String jobId = setupCoord(conf, "coord-multiple-input-instance3.xml");
    sleep(1000);
    new CoordMaterializeTransitionXCommand(jobId, 3600).call();
    new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
    CoordinatorAction actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
    assertEquals(actionBean.getMissingDependencies(), "!!${coord:latest(0)}#${coord:latest(-1)}");
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) CoordinatorAction(org.apache.oozie.client.CoordinatorAction) CoordMaterializeTransitionXCommand(org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand) CoordActionInputCheckXCommand(org.apache.oozie.command.coord.CoordActionInputCheckXCommand)

Aggregations

CoordMaterializeTransitionXCommand (org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand)13 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)11 CoordActionInputCheckXCommand (org.apache.oozie.command.coord.CoordActionInputCheckXCommand)11 Configuration (org.apache.hadoop.conf.Configuration)8 XConfiguration (org.apache.oozie.util.XConfiguration)8 StringReader (java.io.StringReader)6 CommandException (org.apache.oozie.command.CommandException)6 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)6 IOException (java.io.IOException)4 Date (java.util.Date)4 CoordinatorAction (org.apache.oozie.client.CoordinatorAction)4 JDOMException (org.jdom.JDOMException)4 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)2 CoordinatorJob (org.apache.oozie.client.CoordinatorJob)2 CoordActionStartXCommand (org.apache.oozie.command.coord.CoordActionStartXCommand)2 CoordPushDependencyCheckXCommand (org.apache.oozie.command.coord.CoordPushDependencyCheckXCommand)2 Test (org.junit.Test)2 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)1 Event (org.apache.oozie.client.event.Event)1 JobEvent (org.apache.oozie.client.event.JobEvent)1