Search in sources :

Example 11 with CoordinatorAction

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

the class TestPastActionsTimeOut method _testTimeout.

/**
 * The catch-up mode time up has been setup in {@link CoordActionMaterializeXCommand}
 * @param jobId job id
 * @throws Exception thrown if failed
 */
private void _testTimeout(final String jobId) throws Exception {
    final CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
    waitFor(6000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJob job = ce.getCoordJob(jobId);
            return !(job.getStatus().equals(CoordinatorJob.Status.PREP));
        }
    });
    CoordinatorJob job = ce.getCoordJob(jobId);
    assertTrue(!(job.getStatus().equals(CoordinatorJob.Status.PREP)));
    waitFor(6000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJob job = ce.getCoordJob(jobId);
            List<CoordinatorAction> actions = job.getActions();
            return actions.size() > 0;
        }
    });
    job = ce.getCoordJob(jobId);
    List<CoordinatorAction> actions = job.getActions();
    assertTrue(actions.size() > 0);
    for (CoordinatorAction action : actions) {
        CoordinatorActionBean json = (CoordinatorActionBean) action;
        assertEquals(10, json.getTimeOut());
    }
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob) CoordinatorEngine(org.apache.oozie.CoordinatorEngine) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordinatorAction(org.apache.oozie.client.CoordinatorAction) List(java.util.List) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException) StoreException(org.apache.oozie.store.StoreException)

Example 12 with CoordinatorAction

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

the class TestCoordUpdateXCommand method testReRunRefresh.

// test coord re-run with refresh. will use the updated coord definition.
public void testReRunRefresh() throws Exception {
    Configuration conf = new XConfiguration();
    File appPathFile1 = new File(getTestCaseDir(), "coordinator.xml");
    String jobId = setupCoord(conf, "coord-multiple-input-instance3.xml");
    sleep(1000);
    final int actionNum = 1;
    final String actionId = jobId + "@" + actionNum;
    final OozieClient coordClient = LocalOozie.getCoordClient();
    waitFor(120 * 1000, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            CoordinatorAction bean = coordClient.getCoordActionInfo(actionId);
            return (bean.getStatus() == CoordinatorAction.Status.WAITING || bean.getStatus() == CoordinatorAction.Status.SUBMITTED);
        }
    });
    CoordinatorAction bean = coordClient.getCoordActionInfo(actionId);
    assertEquals(bean.getMissingDependencies(), "!!${coord:latest(0)}#${coord:latest(-1)}");
    CoordinatorJobBean job = getCoordJobs(jobId);
    Reader reader = IOUtils.getResourceAsReader("coord-multiple-input-instance4.xml", -1);
    Writer writer = new FileWriter(appPathFile1);
    IOUtils.copyCharStream(reader, writer);
    conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile1.toURI().toString());
    new CoordUpdateXCommand(false, conf, jobId).call();
    job = getCoordJobs(jobId);
    Element processedJobXml = XmlUtils.parseXml(job.getJobXml());
    Namespace namespace = processedJobXml.getNamespace();
    String text = ((Element) processedJobXml.getChild("input-events", namespace).getChild("data-in", namespace).getChildren("instance", namespace).get(0)).getText();
    assertEquals(text, "${coord:future(0, 1)}");
    new CoordActionsKillXCommand(jobId, RestConstants.JOB_COORD_SCOPE_ACTION, Integer.toString(actionNum)).call();
    coordClient.reRunCoord(jobId, RestConstants.JOB_COORD_SCOPE_ACTION, Integer.toString(actionNum), true, true);
    bean = coordClient.getCoordActionInfo(actionId);
    sleep(1000);
    assertEquals(bean.getMissingDependencies(), "!!${coord:future(0, 1)}");
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) FileWriter(java.io.FileWriter) Element(org.jdom.Element) Reader(java.io.Reader) StringReader(java.io.StringReader) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException) XException(org.apache.oozie.XException) CommandException(org.apache.oozie.command.CommandException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Namespace(org.jdom.Namespace) XConfiguration(org.apache.oozie.util.XConfiguration) OozieClient(org.apache.oozie.client.OozieClient) CoordinatorAction(org.apache.oozie.client.CoordinatorAction) File(java.io.File) FileWriter(java.io.FileWriter) Writer(java.io.Writer)

Example 13 with CoordinatorAction

use of org.apache.oozie.client.CoordinatorAction 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 14 with CoordinatorAction

use of org.apache.oozie.client.CoordinatorAction 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)

Example 15 with CoordinatorAction

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

the class TestCoordinatorEngine method testEmptyDoneFlag.

/**
 * Test Missing Dependencies with Empty Done Flag in Schema
 *
 * @throws Exception
 */
public void testEmptyDoneFlag() throws Exception {
    Configuration conf = new XConfiguration();
    String appPath = getTestCaseFileUri("coordinator.xml");
    String appXml = "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" start=\"2009-02-01T01:00Z\" end=" + "\"2009-02-01T02:00Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.1\"> <controls> <timeout>10</timeout> <concurrency>2</concurrency> " + "<execution>LIFO</execution> </controls> <datasets> " + "<dataset name=\"local_a\" frequency=\"${coord:days(1)}\" initial-instance=\"2009-02-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("workflows/${YEAR}/${MONTH}/${DAY}") + "</uri-template> " + "<done-flag></done-flag> </dataset>" + "</datasets> <input-events> " + "<data-in name=\"A\" dataset=\"local_a\"> <instance>${coord:current(0)}</instance> </data-in>  " + "</input-events> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows2/</app-path> " + "<configuration> <property> <name>inputA</name> <value>${coord:dataIn('A')}</value> </property> " + "</configuration> </workflow> </action> </coordinator-app>";
    writeToFile(appXml, appPath);
    conf.set(OozieClient.COORDINATOR_APP_PATH, appPath);
    conf.set(OozieClient.USER_NAME, getTestUser());
    final CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
    final String jobId = ce.submitJob(conf, true);
    waitFor(5000, new Predicate() {

        public boolean evaluate() throws Exception {
            try {
                List<CoordinatorAction> actions = ce.getCoordJob(jobId).getActions();
                for (CoordinatorAction action : actions) {
                    CoordinatorAction.Status actionStatus = action.getStatus();
                    if (actionStatus == CoordinatorAction.Status.WAITING) {
                        return true;
                    }
                }
            } catch (Exception ex) {
                return false;
            }
            return false;
        }
    });
    List<CoordinatorAction> actions = ce.getCoordJob(jobId).getActions();
    assertTrue(actions.size() > 0);
    CoordinatorAction action = actions.get(0);
    String missingDeps = action.getMissingDependencies();
    System.out.println("..Missing deps=" + missingDeps);
    assertEquals(getTestCaseFileUri("workflows/2009/02/01"), missingDeps);
}
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) List(java.util.List) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException) StoreException(org.apache.oozie.store.StoreException)

Aggregations

CoordinatorAction (org.apache.oozie.client.CoordinatorAction)28 IOException (java.io.IOException)11 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)11 CoordinatorJob (org.apache.oozie.client.CoordinatorJob)9 XConfiguration (org.apache.oozie.util.XConfiguration)8 Configuration (org.apache.hadoop.conf.Configuration)7 List (java.util.List)6 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)6 CommandException (org.apache.oozie.command.CommandException)6 StoreException (org.apache.oozie.store.StoreException)6 CoordActionInputCheckXCommand (org.apache.oozie.command.coord.CoordActionInputCheckXCommand)4 CoordMaterializeTransitionXCommand (org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand)4 File (java.io.File)3 BundleJob (org.apache.oozie.client.BundleJob)3 JDOMException (org.jdom.JDOMException)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 URI (java.net.URI)2 CoordinatorEngine (org.apache.oozie.CoordinatorEngine)2 BulkResponse (org.apache.oozie.client.BulkResponse)2 OozieClientException (org.apache.oozie.client.OozieClientException)2