Search in sources :

Example 11 with CoordActionInputCheckXCommand

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

the class TestCoordinatorInputLogic method testMultipleInstance.

public void testMultipleInstance() throws Exception {
    Configuration conf = getConf();
    Date now = new Date();
    // @formatter:off
    String inputLogic = "<and name=\"test\">" + "<data-in dataset=\"A\" min=\"2\"/>" + "<data-in dataset=\"B\"/>" + "</and>";
    String event = "<data-in name=\"A\" dataset=\"a\">" + "<instance>${coord:current(-5)}</instance>" + "<instance>${coord:latest(-1)}</instance>" + "<instance>${coord:futureRange(0,2,10)}</instance>" + "</data-in>" + "<data-in name=\"B\" dataset=\"b\">" + "<instance>${coord:latest(0)}</instance>" + "<instance>${coord:latestRange(-3,0)}</instance>" + "</data-in>";
    // @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, event);
    List<String> inputDir = createDirWithTime("input-data/a/", now, 3, 5, 0, -1, -2);
    inputDir.addAll(createDirWithTime("input-data/b/", now, 0, 1));
    startCoordActionForWaiting(jobId);
    CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
    assertTrue(CoordinatorAction.Status.WAITING.equals(actionBean.getStatus()));
    inputDir.addAll(createDirWithTime("input-data/b/", now, 2, 3));
    new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
    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, 10);
    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) CoordActionInputCheckXCommand(org.apache.oozie.command.coord.CoordActionInputCheckXCommand) Date(java.util.Date)

Example 12 with CoordActionInputCheckXCommand

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

the class TestCoordinatorInputLogic method testSimpleOr1.

public void testSimpleOr1() throws Exception {
    Configuration conf = getConf();
    // @formatter:off
    String inputLogic = "<or name=\"test\">" + "<and>" + "<data-in dataset=\"C\" />" + "<data-in dataset=\"D\" />" + "</and>" + "<or>" + "<data-in dataset=\"A\" />" + "<data-in dataset=\"B\" />" + "</or>" + "</or>";
    String jobId = _testCoordSubmit("coord-inputlogic.xml", conf, inputLogic);
    new CoordMaterializeTransitionXCommand(jobId, 3600).call();
    CoordinatorActionBean actionBean = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, jobId + "@1");
    assertEquals(actionBean.getStatus(), CoordinatorAction.Status.WAITING);
    new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
    String input1 = createTestCaseSubDir("input-data/b/2014/10/08/00/_SUCCESS".split("/"));
    startCoordAction(jobId);
    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, 1);
    checkDataSets(dataSets, input1);
}
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 13 with CoordActionInputCheckXCommand

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

the class TestCoordinatorInputLogic method startCoordAction.

private void startCoordAction(final String jobId, final CoordinatorAction.Status coordActionStatus) throws CommandException, JPAExecutorException {
    new CoordMaterializeTransitionXCommand(jobId, 3600).call();
    new CoordActionInputCheckXCommand(jobId + "@1", jobId).call();
    waitFor(50 * 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");
    assertFalse(actionBean.getStatus().equals(coordActionStatus));
    CoordinatorJob coordJob = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, jobId);
    new CoordActionStartXCommand(actionBean.getId(), coordJob.getUser(), coordJob.getAppName(), actionBean.getJobId()).call();
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordinatorAction(org.apache.oozie.client.CoordinatorAction) CoordActionStartXCommand(org.apache.oozie.command.coord.CoordActionStartXCommand) 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)

Aggregations

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