use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordMaterializeTransitionXCommand method testActionMaterWithPauseTime1.
public void testActionMaterWithPauseTime1() throws Exception {
Date startTime = DateUtils.parseDateOozieTZ("2009-03-06T10:00Z");
Date endTime = DateUtils.parseDateOozieTZ("2009-03-06T10:14Z");
Date pauseTime = DateUtils.parseDateOozieTZ("2009-03-06T10:04Z");
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, pauseTime, "5");
new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(1)).call();
Date[] nominalTimes = new Date[] { DateUtils.parseDateOozieTZ("2009-03-06T10:00Z") };
checkCoordActionsNominalTime(job.getId(), 1, nominalTimes);
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordMaterializeTransitionXCommand method testActionMaterEndOfWeeks.
public void testActionMaterEndOfWeeks() throws Exception {
Configuration conf = new XConfiguration();
File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
String appXml = "<coordinator-app name=\"test\" frequency=\"${coord:endOfWeeks(1)}\" start=\"2016-02-03T01:00Z\" " + "end=\"2016-03-03T23:59Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.2\"> <controls> " + "<execution>LIFO</execution> </controls> <datasets> " + "<dataset name=\"a\" frequency=\"${coord:endOfWeeks(1)}\" initial-instance=\"2016-01-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("coord/workflows/${YEAR}/${DAY}") + "</uri-template> " + "</dataset> " + "<dataset name=\"local_a\" frequency=\"${coord:endOfWeeks(1)}\" initial-instance=\"2016-01-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("coord/workflows/${YEAR}/${DAY}") + "</uri-template> " + " </dataset> " + "</datasets> <input-events> " + "<data-in name=\"A\" dataset=\"a\"> <instance>${coord:latest(0)}</instance> </data-in> " + "</input-events> " + "<output-events> <data-out name=\"LOCAL_A\" dataset=\"local_a\"> " + "<instance>${coord:current(-1)}</instance> </data-out> </output-events> <action> <workflow> " + "<app-path>hdfs:///tmp/workflows/</app-path> " + "<configuration> <property> <name>inputA</name> <value>${coord:dataIn('A')}</value> </property> " + "<property> <name>inputB</name> <value>${coord:dataOut('LOCAL_A')}</value> " + "</property></configuration> </workflow> </action> </coordinator-app>";
writeToFile(appXml, appPathFile);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
conf.set(OozieClient.USER_NAME, getTestUser());
CoordSubmitXCommand sc = new CoordSubmitXCommand(conf);
String jobId = sc.call();
CoordinatorJobBean job = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, jobId);
assertEquals(job.getLastActionNumber(), 0);
job.setMatThrottling(10);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, job);
new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(1)).call();
job = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, job.getId());
assertEquals(4, job.getLastActionNumber());
String jobXml = job.getJobXml();
Element eJob = XmlUtils.parseXml(jobXml);
TimeZone appTz = DateUtils.getTimeZone(job.getTimeZone());
TimeUnit endOfFlag = TimeUnit.valueOf(eJob.getAttributeValue("end_of_duration"));
TimeUnit freqTU = TimeUnit.valueOf(job.getTimeUnitStr());
Calendar origStart = Calendar.getInstance(appTz);
origStart.setTime(job.getStartTimestamp());
// Move to the End of duration, if needed.
DateUtils.moveToEnd(origStart, endOfFlag);
origStart.add(freqTU.getCalendarUnit(), 4 * Integer.parseInt(job.getFrequency()));
assertEquals(origStart.getTime(), job.getNextMaterializedTime());
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordMaterializeTransitionXCommand method testActionMaterWithCronFrequency2.
public void testActionMaterWithCronFrequency2() throws Exception {
Date startTime = DateUtils.parseDateOozieTZ("2013-07-18T00:00Z");
Date endTime = DateUtils.parseDateOozieTZ("2013-07-18T01:00Z");
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, null, "10-20 * * * *");
new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(1)).call();
Date[] nominalTimes = new Date[] { DateUtils.parseDateOozieTZ("2013-07-18T00:10Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:11Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:12Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:13Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:14Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:15Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:16Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:17Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:18Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:19Z"), DateUtils.parseDateOozieTZ("2013-07-18T00:20Z") };
final int expectedNominalTimeCount = 11;
checkCoordActionsNominalTime(job.getId(), expectedNominalTimeCount, nominalTimes);
try {
JPAService jpaService = Services.get().get(JPAService.class);
job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId()));
assertTrue(job.isDoneMaterialization());
assertEquals(job.getLastActionNumber(), expectedNominalTimeCount);
assertEquals(job.getNextMaterializedTime(), DateUtils.parseDateOozieTZ("2013-07-18T01:10Z"));
} catch (JPAExecutorException se) {
se.printStackTrace();
fail("Job ID " + job.getId() + " was not stored properly in db");
}
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordMaterializeTransitionXCommand method testActionMaterWithDST2.
public void testActionMaterWithDST2() throws Exception {
Date startTime = DateUtils.parseDateOozieTZ("2012-11-04T07:00Z");
Date endTime = DateUtils.parseDateOozieTZ("2012-11-04T11:00Z");
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, null, "0 * * * *");
new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(4)).call();
Date[] nominalTimes = new Date[] { DateUtils.parseDateOozieTZ("2012-11-04T07:00Z"), DateUtils.parseDateOozieTZ("2012-11-04T08:00Z"), DateUtils.parseDateOozieTZ("2012-11-04T09:00Z"), DateUtils.parseDateOozieTZ("2012-11-04T10:00Z"), DateUtils.parseDateOozieTZ("2012-11-04T11:00Z") };
final int expectedNominalTimeCount = 5;
checkCoordActionsNominalTime(job.getId(), expectedNominalTimeCount, nominalTimes);
try {
JPAService jpaService = Services.get().get(JPAService.class);
job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId()));
assertTrue(job.isDoneMaterialization());
assertEquals(job.getLastActionNumber(), expectedNominalTimeCount);
assertEquals(job.getNextMaterializedTime(), DateUtils.parseDateOozieTZ("2012-11-04T12:00Z"));
} catch (JPAExecutorException se) {
se.printStackTrace();
fail("Job ID " + job.getId() + " was not stored properly in db");
}
}
use of org.apache.oozie.CoordinatorJobBean in project oozie by apache.
the class TestCoordMaterializeTransitionXCommand method testActionMater.
public void testActionMater() throws Exception {
Date startTime = DateUtils.parseDateOozieTZ("2009-03-06T010:00Z");
Date endTime = DateUtils.parseDateOozieTZ("2009-03-11T10:00Z");
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, false, false, 0);
new CoordMaterializeTransitionXCommand(job.getId(), hoursToSeconds(1)).call();
checkCoordAction(job.getId() + "@1");
}
Aggregations