Search in sources :

Example 6 with CoordinatorJobInfo

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);
}
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 7 with CoordinatorJobInfo

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

Example 8 with CoordinatorJobInfo

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);
}
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 9 with CoordinatorJobInfo

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);
}
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 10 with CoordinatorJobInfo

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());
}
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)

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