Search in sources :

Example 76 with CoordinatorJobBean

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

the class TestCoordMaterializeTransitionXCommand method testCronFrequencyCatchupThrottleMoreThanDurationNoDSTChange.

public void testCronFrequencyCatchupThrottleMoreThanDurationNoDSTChange() throws Exception {
    final String startInThePast = "2013-03-10T08:00Z";
    final Date startTime = DateUtils.parseDateOozieTZ(startInThePast);
    final String startPlusOneHourAndSome = "2013-03-10T09:01Z";
    final Date endTime = DateUtils.parseDateOozieTZ(startPlusOneHourAndSome);
    CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.PREP, startTime, endTime, false, false, 0);
    job.setNextMaterializedTime(startTime);
    job.setMatThrottling(5);
    final String everyHour = "0 * * * *";
    job.setFrequency(everyHour);
    job.setTimeUnit(Timeunit.CRON);
    CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, job);
    new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(1)).call();
    final String startPlusOneHour = "2013-03-10T09:00Z";
    final Date[] nominalTimesWithoutDSTChange = new Date[] { DateUtils.parseDateOozieTZ(startInThePast), DateUtils.parseDateOozieTZ(startPlusOneHour) };
    checkCoordActionsNominalTime(job.getId(), 2, nominalTimesWithoutDSTChange);
    checkTwoActionsAfterCatchup(job);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) Date(java.util.Date)

Example 77 with CoordinatorJobBean

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

the class TestCoordMaterializeTransitionXCommand method testMatLookupCommand4.

/**
 * Test a coordinator job that will run beyond 5 minutes from now,
 * materilization should not happen.
 * @throws Exception
 */
public void testMatLookupCommand4() throws Exception {
    Date startTime = DateUtils.toDate(new Timestamp(System.currentTimeMillis() + 360 * 1000));
    Date endTime = DateUtils.parseDateOozieTZ("2099-02-03T23:59Z");
    CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.PREP, startTime, endTime, false, false, 0);
    new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(1)).call();
    checkCoordJobs(job.getId(), CoordinatorJob.Status.PREP);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) Timestamp(java.sql.Timestamp) Date(java.util.Date)

Example 78 with CoordinatorJobBean

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

the class TestCoordMaterializeTransitionXCommand method testActionMaterForHcatalog.

public void testActionMaterForHcatalog() throws Exception {
    Services.get().destroy();
    Services services = super.setupServicesForHCatalog();
    services.init();
    Date startTime = DateUtils.parseDateOozieTZ("2009-03-06T010:00Z");
    Date endTime = DateUtils.parseDateOozieTZ("2009-03-11T10:00Z");
    CoordinatorJobBean job = addRecordToCoordJobTableForWaiting("coord-job-for-matd-hcat.xml", CoordinatorJob.Status.RUNNING, startTime, endTime, false, false, 0);
    new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(1)).call();
    CoordinatorActionBean actionBean = getCoordAction(job.getId() + "@1");
    assertEquals("file://dummyhdfs/2009/05/_SUCCESS" + CoordCommandUtils.RESOLVED_UNRESOLVED_SEPARATOR + "${coord:latestRange(-1,0)}", actionBean.getMissingDependencies());
    assertEquals("hcat://dummyhcat:1000/db1/table1/ds=2009-12" + CoordELFunctions.INSTANCE_SEPARATOR + "hcat://dummyhcat:1000/db3/table3/ds=2009-05" + CoordELFunctions.INSTANCE_SEPARATOR + "hcat://dummyhcat:1000/db3/table3/ds=2009-26", actionBean.getPushMissingDependencies());
}
Also used : Services(org.apache.oozie.service.Services) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) Date(java.util.Date)

Example 79 with CoordinatorJobBean

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

the class TestCoordPushDependencyCheckXCommand method testResolveCoordConfiguration.

@Test
public void testResolveCoordConfiguration() throws Exception {
    String db = "default";
    String table = "tablename";
    String newHCatDependency1 = "hcat://" + server + "/" + db + "/" + table + "/dt=20120412;country=brazil";
    String newHCatDependency2 = "hcat://" + server + "/" + db + "/" + table + "/dt=20120430;country=usa";
    String newHCatDependency = newHCatDependency1 + CoordELFunctions.INSTANCE_SEPARATOR + newHCatDependency2;
    populateTable(db, table);
    CoordinatorJobBean job = addRecordToCoordJobTableForWaiting("coord-job-for-action-input-check.xml", CoordinatorJob.Status.RUNNING, false, true);
    CoordinatorActionBean action = addRecordToCoordActionTableForWaiting(job.getId(), 1, CoordinatorAction.Status.WAITING, "coord-action-for-action-push-check.xml", null, newHCatDependency, "Z");
    String actionId = action.getId();
    checkCoordAction(actionId, newHCatDependency, CoordinatorAction.Status.WAITING);
    new CoordPushDependencyCheckXCommand(actionId).call();
    CoordinatorActionBean caBean = checkCoordAction(actionId, "", CoordinatorAction.Status.READY);
    Element eAction = XmlUtils.parseXml(caBean.getActionXml());
    Element configElem = eAction.getChild("action", eAction.getNamespace()).getChild("workflow", eAction.getNamespace()).getChild("configuration", eAction.getNamespace());
    List<?> elementList = configElem.getChildren("property", configElem.getNamespace());
    Element e1 = (Element) elementList.get(0);
    Element e2 = (Element) elementList.get(1);
    assertEquals("hcat://dummyhcat:1000/db1/table1/ds=/2009-29,hcat://dummyhcat:1000/db1/table1/ds=/2009-29," + "hcat://dummyhcat:1000/db1/table1/ds=/2009-29", e1.getChild("value", e1.getNamespace()).getValue());
    assertEquals("hcat://dummyhcat:1000/db1/table1/ds=/2009-29", e2.getChild("value", e1.getNamespace()).getValue());
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) Element(org.jdom.Element) Test(org.junit.Test)

Example 80 with CoordinatorJobBean

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

the class TestCoordRerunXCommand method testCoordRerunWithFailedOption.

/**
 * Tests -failed option of rerun. If failed option is provided it should rerun the old workflow of an action
 * otherwise it should run the new workflow.
 * @throws Exception
 */
public void testCoordRerunWithFailedOption() throws Exception {
    Date start = DateUtils.parseDateOozieTZ("2009-02-01T01:00Z");
    Date end = DateUtils.parseDateOozieTZ("2009-02-01T23:59Z");
    CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 1);
    CoordinatorActionBean action = addRecordToWithLazyAction(coordJob.getId(), 1, CoordinatorAction.Status.SUBMITTED, "coord-rerun-action1.xml");
    final String actionId = action.getId();
    new CoordActionStartXCommand(actionId, getTestUser(), "myapp", "myjob").call();
    action = getCoordinatorAction(actionId);
    if (action.getStatus() == CoordinatorAction.Status.SUBMITTED) {
        fail("CoordActionStartCommand didn't work because the status for action id" + actionId + " is :" + action.getStatus() + " expected to be NOT SUBMITTED (i.e. RUNNING)");
    }
    final OozieClient coordClient = LocalOozie.getCoordClient();
    final OozieClient wclient = LocalOozie.getClient();
    waitFor(15 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            return (coordClient.getCoordActionInfo(actionId).getStatus() == CoordinatorAction.Status.RUNNING);
        }
    });
    wclient.kill(coordClient.getCoordActionInfo(actionId).getExternalId());
    waitFor(150 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            return (coordClient.getCoordActionInfo(actionId).getStatus() == CoordinatorAction.Status.KILLED);
        }
    });
    String externalId = coordClient.getCoordActionInfo(actionId).getExternalId();
    coordClient.reRunCoord(coordJob.getId(), RestConstants.JOB_COORD_SCOPE_ACTION, "1", false, true, true, new Properties());
    waitFor(150 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            return (coordClient.getCoordActionInfo(actionId).getStatus() == CoordinatorAction.Status.SUCCEEDED);
        }
    });
    assertEquals(externalId, coordClient.getCoordActionInfo(actionId).getExternalId());
    coordClient.reRunCoord(coordJob.getId(), RestConstants.JOB_COORD_SCOPE_ACTION, "1", false, true, false, new Properties());
    waitFor(150 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            return (coordClient.getCoordActionInfo(actionId).getStatus() == CoordinatorAction.Status.SUCCEEDED);
        }
    });
    assertNotSame(externalId, coordClient.getCoordActionInfo(actionId).getExternalId());
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) Properties(java.util.Properties) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) JDOMException(org.jdom.JDOMException) CommandException(org.apache.oozie.command.CommandException) StoreException(org.apache.oozie.store.StoreException) IOException(java.io.IOException)

Aggregations

CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)373 Date (java.util.Date)177 JPAService (org.apache.oozie.service.JPAService)153 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)149 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)121 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)114 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)53 CommandException (org.apache.oozie.command.CommandException)49 BundleJobBean (org.apache.oozie.BundleJobBean)46 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)43 IOException (java.io.IOException)39 XConfiguration (org.apache.oozie.util.XConfiguration)38 ArrayList (java.util.ArrayList)36 BundleActionBean (org.apache.oozie.BundleActionBean)36 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)34 Configuration (org.apache.hadoop.conf.Configuration)33 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)32 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)30 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)30 Path (org.apache.hadoop.fs.Path)24