use of org.apache.oozie.CoordinatorJobInfo in project oozie by apache.
the class TestCoordJobInfoGetJPAExecutor method _testGetJobInfoForFrequencyAndUnit.
/**
* Test to verify various combinations of frequency and time unit filters for jobs
*
* @throws Exception
*/
private void _testGetJobInfoForFrequencyAndUnit() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
// Test specifying frequency value as 1 minute
Map<String, List<String>> filter = new HashMap<String, List<String>>();
List<String> unitList = new ArrayList<String>();
List<String> frequencyList = new ArrayList<String>();
unitList.add("MINUTE");
filter.put(OozieClient.FILTER_UNIT, unitList);
frequencyList = new ArrayList<String>();
frequencyList.add("1");
filter.put(OozieClient.FILTER_FREQUENCY, frequencyList);
CoordJobInfoGetJPAExecutor coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
CoordinatorJobInfo ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 0);
frequencyList.remove(0);
unitList.remove(0);
// Test specifying frequency value as 3 days
unitList.add("DAY");
filter.put(OozieClient.FILTER_UNIT, unitList);
frequencyList.add("3");
filter.put(OozieClient.FILTER_FREQUENCY, frequencyList);
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 0);
frequencyList.remove(0);
unitList.remove(0);
// Test specifying frequency value as 1 day
unitList.add("DAY");
filter.put(OozieClient.FILTER_UNIT, unitList);
frequencyList.add("1");
filter.put(OozieClient.FILTER_FREQUENCY, frequencyList);
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 3);
}
use of org.apache.oozie.CoordinatorJobInfo in project oozie by apache.
the class TestCoordJobInfoGetJPAExecutor method testGetJobInfoForEndCreatedTime.
public void testGetJobInfoForEndCreatedTime() throws Exception {
CoordinatorJobBean coordinatorJob1 = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, false, false);
CoordinatorJobBean coordinatorJob2 = addRecordToCoordJobTable(CoordinatorJob.Status.KILLED, false, false);
CoordinatorJobBean coordinatorJob3 = addRecordToCoordJobTable(CoordinatorJob.Status.FAILED, false, false);
Date createTime1 = DateUtils.parseDateUTC("2012-01-03T10:00Z");
Date createTime2 = DateUtils.parseDateUTC("2012-01-05T10:00Z");
Date createTime3 = DateUtils.parseDateUTC("2012-01-010T10:00Z");
coordinatorJob1.setCreatedTime(createTime1);
coordinatorJob2.setCreatedTime(createTime2);
coordinatorJob3.setCreatedTime(createTime3);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQueryExecutor.CoordJobQuery.UPDATE_COORD_JOB, coordinatorJob1);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQueryExecutor.CoordJobQuery.UPDATE_COORD_JOB, coordinatorJob2);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQueryExecutor.CoordJobQuery.UPDATE_COORD_JOB, coordinatorJob3);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
Map<String, List<String>> filter = new HashMap<String, List<String>>();
CoordJobInfoGetJPAExecutor coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
CoordinatorJobInfo ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(3, ret.getCoordJobs().size());
filter.clear();
filter.put(OozieClient.FILTER_CREATED_TIME_START, Arrays.asList("2012-01-02T10:00Z"));
filter.put(OozieClient.FILTER_CREATED_TIME_END, Arrays.asList("2012-01-07T10:00Z"));
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(2, ret.getCoordJobs().size());
// default, expected order of results is by createTime DESC
CoordinatorJobBean jobBean = ret.getCoordJobs().get(0);
assertEquals(coordinatorJob2.getStatus(), jobBean.getStatus());
assertEquals(coordinatorJob2.getCreatedTime(), jobBean.getCreatedTime());
CoordinatorJobBean jobBean1 = ret.getCoordJobs().get(1);
assertEquals(coordinatorJob1.getStatus(), jobBean1.getStatus());
assertEquals(coordinatorJob1.getCreatedTime(), jobBean1.getCreatedTime());
}
use of org.apache.oozie.CoordinatorJobInfo in project oozie by apache.
the class TestCoordJobInfoGetJPAExecutor method _testGetJobInfoForAppName.
private void _testGetJobInfoForAppName() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
Map<String, List<String>> filter = new HashMap<String, List<String>>();
List<String> list = new ArrayList<String>();
list.add("COORD-TEST");
filter.put(OozieClient.FILTER_NAME, list);
CoordJobInfoGetJPAExecutor coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
CoordinatorJobInfo ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 3);
}
use of org.apache.oozie.CoordinatorJobInfo in project oozie by apache.
the class TestCoordJobInfoGetJPAExecutor method _testGetJobInfoForFrequency.
private void _testGetJobInfoForFrequency() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
Map<String, List<String>> filter = new HashMap<String, List<String>>();
List<String> frequencyList = new ArrayList<String>();
frequencyList.add("1");
filter.put(OozieClient.FILTER_FREQUENCY, frequencyList);
CoordJobInfoGetJPAExecutor coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
CoordinatorJobInfo ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 3);
}
use of org.apache.oozie.CoordinatorJobInfo in project oozie by apache.
the class TestCoordJobInfoGetJPAExecutor method testGetJobInfoForTextAndStatus.
public void testGetJobInfoForTextAndStatus() throws Exception {
CoordinatorJobBean coordinatorJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, false, false);
coordinatorJob.setAppName("coord-job-1");
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQueryExecutor.CoordJobQuery.UPDATE_COORD_JOB, coordinatorJob);
Map<String, List<String>> filter = new HashMap<String, List<String>>();
List<String> textFilterList = new ArrayList<String>();
textFilterList.add("coord-job-1");
List<String> textStatusList = new ArrayList<String>();
textStatusList.add(CoordinatorJob.Status.RUNNING.toString());
filter.put(OozieClient.FILTER_TEXT, textFilterList);
filter.put(OozieClient.FILTER_STATUS, textStatusList);
JPAService jpaService = Services.get().get(JPAService.class);
CoordJobInfoGetJPAExecutor coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
CoordinatorJobInfo coordJobsInfo = jpaService.execute(coordInfoGetCmd);
assertEquals(1, coordJobsInfo.getCoordJobs().size());
}
Aggregations