Search in sources :

Example 21 with CoordinatorJobInfo

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);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorJobInfo(org.apache.oozie.CoordinatorJobInfo) HashMap(java.util.HashMap) XException(org.apache.oozie.XException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JPAService(org.apache.oozie.service.JPAService)

Example 22 with CoordinatorJobInfo

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);
}
Also used : CoordinatorJobInfo(org.apache.oozie.CoordinatorJobInfo) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JPAService(org.apache.oozie.service.JPAService)

Example 23 with CoordinatorJobInfo

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));
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorJobInfo(org.apache.oozie.CoordinatorJobInfo) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JPAService(org.apache.oozie.service.JPAService)

Example 24 with CoordinatorJobInfo

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);
}
Also used : CoordinatorJobInfo(org.apache.oozie.CoordinatorJobInfo) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JPAService(org.apache.oozie.service.JPAService)

Example 25 with CoordinatorJobInfo

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);
}
Also used : CoordinatorJobInfo(org.apache.oozie.CoordinatorJobInfo) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JPAService(org.apache.oozie.service.JPAService)

Aggregations

CoordinatorJobInfo (org.apache.oozie.CoordinatorJobInfo)25 ArrayList (java.util.ArrayList)23 List (java.util.List)22 HashMap (java.util.HashMap)21 JPAService (org.apache.oozie.service.JPAService)16 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)6 Date (java.util.Date)2 CoordinatorEngine (org.apache.oozie.CoordinatorEngine)2 CoordinatorEngineException (org.apache.oozie.CoordinatorEngineException)2 XException (org.apache.oozie.XException)2 JSONObject (org.json.simple.JSONObject)2 Query (javax.persistence.Query)1 BundleEngine (org.apache.oozie.BundleEngine)1 BundleEngineException (org.apache.oozie.BundleEngineException)1 BundleJobInfo (org.apache.oozie.BundleJobInfo)1 DagEngine (org.apache.oozie.DagEngine)1 DagEngineException (org.apache.oozie.DagEngineException)1 WorkflowsInfo (org.apache.oozie.WorkflowsInfo)1 CommandException (org.apache.oozie.command.CommandException)1 CoordJobInfoGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobInfoGetJPAExecutor)1