use of org.apache.oozie.CoordinatorJobInfo in project oozie by apache.
the class TestCoordJobInfoGetJPAExecutor method testGetJobInfoForText.
public void testGetJobInfoForText() throws Exception {
CoordinatorJobBean coordinatorJob1 = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, false, false);
CoordinatorJobBean coordinatorJob2 = addRecordToCoordJobTable(CoordinatorJob.Status.KILLED, false, false);
coordinatorJob1.setAppName("oozie-coord1");
coordinatorJob2.setAppName("oozie-coord2");
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQueryExecutor.CoordJobQuery.UPDATE_COORD_JOB, coordinatorJob1);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQueryExecutor.CoordJobQuery.UPDATE_COORD_JOB, coordinatorJob2);
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(2, ret.getCoordJobs().size());
filter.clear();
ArrayList<String> textList = new ArrayList<String>();
textList.add("tes");
filter.put(OozieClient.FILTER_TEXT, textList);
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 2);
textList.clear();
textList.add("oozie-coord1");
filter.put(OozieClient.FILTER_TEXT, textList);
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 1);
textList.clear();
textList.add("random");
filter.put(OozieClient.FILTER_TEXT, textList);
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 0);
textList.clear();
textList.add("oozie-coord");
filter.put(OozieClient.FILTER_TEXT, textList);
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 2);
textList.add("tes");
filter.put(OozieClient.FILTER_TEXT, textList);
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
try {
jpaService.execute(coordInfoGetCmd);
fail("CoordJobInfoGetJPAExecutor should have thrown E0302 exception.");
} catch (XException e) {
assertEquals(ErrorCode.E0302, e.getErrorCode());
assertEquals(e.getMessage(), "E0302: Invalid parameter [cannot specify multiple strings to search]");
}
// Update coord appName and validate text filter
coordinatorJob1.setAppName("updated-app-name1");
coordinatorJob2.setAppName("updated-app-name2");
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQueryExecutor.CoordJobQuery.UPDATE_COORD_JOB, coordinatorJob1);
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQueryExecutor.CoordJobQuery.UPDATE_COORD_JOB, coordinatorJob2);
textList.clear();
textList.add("oozie-coord");
filter.put(OozieClient.FILTER_TEXT, textList);
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 0);
textList.clear();
textList.add("updated-app");
filter.put(OozieClient.FILTER_TEXT, textList);
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 2);
textList.clear();
textList.add("updated-app-name1");
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 1);
}
use of org.apache.oozie.CoordinatorJobInfo in project oozie by apache.
the class TestCoordJobInfoGetJPAExecutor method _testGetJobInfoForUserAndStatus.
private void _testGetJobInfoForUserAndStatus() throws Exception {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
Map<String, List<String>> filter = new HashMap<String, List<String>>();
List<String> list1 = new ArrayList<String>();
list1.add(getTestUser());
filter.put(OozieClient.FILTER_USER, list1);
List<String> list2 = new ArrayList<String>();
list2.add("KILLED");
filter.put(OozieClient.FILTER_STATUS, list2);
CoordJobInfoGetJPAExecutor coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
CoordinatorJobInfo ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 2);
}
use of org.apache.oozie.CoordinatorJobInfo in project oozie by apache.
the class TestCoordJobInfoGetJPAExecutor method testCoordGetJobsSortBy.
public void testCoordGetJobsSortBy() throws Exception {
CoordinatorJobBean coordinatorJob1 = addRecordToCoordJobTable(CoordinatorJob.Status.FAILED, false, false);
CoordinatorJobBean coordinatorJob2 = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, false, false);
coordinatorJob1.setLastModifiedTime(DateUtils.parseDateUTC("2012-01-04T10:00Z"));
coordinatorJob1.setCreatedTime(DateUtils.parseDateUTC("2012-01-03T10:00Z"));
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQueryExecutor.CoordJobQuery.UPDATE_COORD_JOB, coordinatorJob1);
coordinatorJob2.setLastModifiedTime(DateUtils.parseDateUTC("2012-01-05T10:00Z"));
coordinatorJob2.setCreatedTime(DateUtils.parseDateUTC("2012-01-02T10:00Z"));
CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQueryExecutor.CoordJobQuery.UPDATE_COORD_JOB, coordinatorJob2);
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("lastmodifiedtime");
filter.put(OozieClient.FILTER_SORT_BY, list);
CoordJobInfoGetJPAExecutor coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
CoordinatorJobInfo ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(2, ret.getCoordJobs().size());
compareCoordJobs(coordinatorJob2, ret.getCoordJobs().get(0));
// test default behavior
filter.clear();
list.clear();
coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(2, ret.getCoordJobs().size());
compareCoordJobs(coordinatorJob1, ret.getCoordJobs().get(0));
}
use of org.apache.oozie.CoordinatorJobInfo in project oozie by apache.
the class TestCoordJobInfoGetJPAExecutor method _testGetJobInfoForGroup.
private void _testGetJobInfoForGroup() 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(getTestGroup());
filter.put(OozieClient.FILTER_GROUP, list);
CoordJobInfoGetJPAExecutor coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
CoordinatorJobInfo ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 2);
}
use of org.apache.oozie.CoordinatorJobInfo in project oozie by apache.
the class TestCoordJobInfoGetJPAExecutor method _testGetJobInfoForUser.
private void _testGetJobInfoForUser() 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(getTestUser());
filter.put(OozieClient.FILTER_USER, list);
CoordJobInfoGetJPAExecutor coordInfoGetCmd = new CoordJobInfoGetJPAExecutor(filter, 1, 20);
CoordinatorJobInfo ret = jpaService.execute(coordInfoGetCmd);
assertNotNull(ret);
assertEquals(ret.getCoordJobs().size(), 3);
}
Aggregations