Search in sources :

Example 56 with BundleJobBean

use of org.apache.oozie.BundleJobBean in project oozie by apache.

the class TestBundleActionQueryExecutor method testGetList.

public void testGetList() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
    this.addRecordToBundleActionTable(job.getId(), "coord1", 0, Job.Status.PREP);
    this.addRecordToBundleActionTable(job.getId(), "coord2", 1, Job.Status.RUNNING);
    this.addRecordToBundleActionTable(job.getId(), "coord3", 1, Job.Status.RUNNING);
    List<BundleActionBean> bActions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_WAITING_ACTIONS_OLDER_THAN, (long) (1000 * 60));
    assertEquals(0, bActions.size());
    bActions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_WAITING_ACTIONS_OLDER_THAN, (long) (-1000 * 60));
    assertEquals(2, bActions.size());
    // GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE
    List<BundleActionBean> retList = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, job.getId());
    assertEquals(3, retList.size());
    for (BundleActionBean bean : retList) {
        assertTrue(bean.getCoordName().equals("coord1") || bean.getCoordName().equals("coord2") || bean.getCoordName().equals("coord3"));
    }
}
Also used : BundleJobBean(org.apache.oozie.BundleJobBean) BundleActionBean(org.apache.oozie.BundleActionBean)

Example 57 with BundleJobBean

use of org.apache.oozie.BundleJobBean in project oozie by apache.

the class TestBundleActionsCountForJobGetJPAExecutor method testBundleActionsForJobCountGet.

public void testBundleActionsForJobCountGet() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
    this.addRecordToBundleActionTable(job.getId(), "action1", 1, Job.Status.RUNNING);
    _testGetForJobCount(job.getId(), 1);
    this.addRecordToBundleActionTable(job.getId(), "action2", 0, Job.Status.RUNNING);
    this.addRecordToBundleActionTable(job.getId(), "action3", 1, Job.Status.RUNNING);
    _testGetForJobCount(job.getId(), 3);
}
Also used : BundleJobBean(org.apache.oozie.BundleJobBean)

Example 58 with BundleJobBean

use of org.apache.oozie.BundleJobBean in project oozie by apache.

the class TestBundleJobInfoGetJPAExecutor method testGetJobInfoForEndCreatedTime.

public void testGetJobInfoForEndCreatedTime() throws Exception {
    BundleJobBean bundleJob1 = addRecordToBundleJobTable(BundleJob.Status.RUNNING, false);
    BundleJobBean bundleJob2 = addRecordToBundleJobTable(BundleJob.Status.KILLED, false);
    BundleJobBean bundleJob3 = addRecordToBundleJobTable(BundleJob.Status.FAILED, 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");
    bundleJob1.setCreatedTime(createTime1);
    bundleJob2.setCreatedTime(createTime2);
    bundleJob3.setCreatedTime(createTime3);
    BundleJobQueryExecutor.getInstance().executeUpdate(BundleJobQueryExecutor.BundleJobQuery.UPDATE_BUNDLE_JOB, bundleJob1);
    BundleJobQueryExecutor.getInstance().executeUpdate(BundleJobQueryExecutor.BundleJobQuery.UPDATE_BUNDLE_JOB, bundleJob2);
    BundleJobQueryExecutor.getInstance().executeUpdate(BundleJobQueryExecutor.BundleJobQuery.UPDATE_BUNDLE_JOB, bundleJob3);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    Map<String, List<String>> filter = new HashMap<String, List<String>>();
    BundleJobInfoGetJPAExecutor bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
    BundleJobInfo ret = jpaService.execute(bundleInfoGetCmd);
    assertNotNull(ret);
    assertEquals(3, ret.getBundleJobs().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"));
    bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
    ret = jpaService.execute(bundleInfoGetCmd);
    assertNotNull(ret);
    assertEquals(2, ret.getBundleJobs().size());
    // default, expected order of results is by createTime DESC
    BundleJobBean jobBean = ret.getBundleJobs().get(0);
    assertEquals(bundleJob2.getStatus(), jobBean.getStatus());
    assertEquals(bundleJob2.getCreatedTime(), jobBean.getCreatedTime());
    BundleJobBean jobBean1 = ret.getBundleJobs().get(1);
    assertEquals(bundleJob1.getStatus(), jobBean1.getStatus());
    assertEquals(bundleJob1.getCreatedTime(), jobBean1.getCreatedTime());
}
Also used : BundleJobBean(org.apache.oozie.BundleJobBean) HashMap(java.util.HashMap) BundleJobInfo(org.apache.oozie.BundleJobInfo) ArrayList(java.util.ArrayList) List(java.util.List) JPAService(org.apache.oozie.service.JPAService) Date(java.util.Date)

Example 59 with BundleJobBean

use of org.apache.oozie.BundleJobBean in project oozie by apache.

the class TestBundleJobInfoGetJPAExecutor method testGetJobInfoForText.

public void testGetJobInfoForText() throws Exception {
    BundleJobBean bundleJob1 = addRecordToBundleJobTable(BundleJob.Status.RUNNING, false);
    BundleJobBean bundleJob2 = addRecordToBundleJobTable(BundleJob.Status.KILLED, false);
    bundleJob1.setAppName("oozie-bundle1");
    bundleJob2.setAppName("oozie-bundle2");
    BundleJobQueryExecutor.getInstance().executeUpdate(BundleJobQueryExecutor.BundleJobQuery.UPDATE_BUNDLE_JOB, bundleJob1);
    BundleJobQueryExecutor.getInstance().executeUpdate(BundleJobQueryExecutor.BundleJobQuery.UPDATE_BUNDLE_JOB, bundleJob2);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    Map<String, List<String>> filter = new HashMap<String, List<String>>();
    BundleJobInfoGetJPAExecutor bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
    BundleJobInfo ret = jpaService.execute(bundleInfoGetCmd);
    assertNotNull(ret);
    assertEquals(2, ret.getBundleJobs().size());
    filter.clear();
    ArrayList<String> textList = new ArrayList<String>();
    textList.add("tes");
    filter.put(OozieClient.FILTER_TEXT, textList);
    bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
    ret = jpaService.execute(bundleInfoGetCmd);
    assertNotNull(ret);
    assertEquals(ret.getBundleJobs().size(), 2);
    textList.clear();
    textList.add("oozie-bundle1");
    filter.put(OozieClient.FILTER_TEXT, textList);
    bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
    ret = jpaService.execute(bundleInfoGetCmd);
    assertNotNull(ret);
    assertEquals(ret.getBundleJobs().size(), 1);
    textList.clear();
    textList.add("random");
    filter.put(OozieClient.FILTER_TEXT, textList);
    bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
    ret = jpaService.execute(bundleInfoGetCmd);
    assertNotNull(ret);
    assertEquals(ret.getBundleJobs().size(), 0);
    textList.clear();
    textList.add("oozie-bundle");
    filter.put(OozieClient.FILTER_TEXT, textList);
    bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
    ret = jpaService.execute(bundleInfoGetCmd);
    assertNotNull(ret);
    assertEquals(ret.getBundleJobs().size(), 2);
    textList.add("tes");
    filter.put(OozieClient.FILTER_TEXT, textList);
    bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
    try {
        jpaService.execute(bundleInfoGetCmd);
        fail("BundleJobInfoGetJPAExecutor 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 bundle appName, user and validate text filter
    bundleJob1.setAppName("updated-app-name1");
    bundleJob2.setAppName("updated-app-name2");
    BundleJobQueryExecutor.getInstance().executeUpdate(BundleJobQueryExecutor.BundleJobQuery.UPDATE_BUNDLE_JOB, bundleJob1);
    BundleJobQueryExecutor.getInstance().executeUpdate(BundleJobQueryExecutor.BundleJobQuery.UPDATE_BUNDLE_JOB, bundleJob2);
    textList.clear();
    textList.add("oozie-bundle");
    filter.put(OozieClient.FILTER_TEXT, textList);
    bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
    ret = jpaService.execute(bundleInfoGetCmd);
    assertNotNull(ret);
    assertEquals(ret.getBundleJobs().size(), 0);
    textList.clear();
    textList.add("updated-app");
    filter.put(OozieClient.FILTER_TEXT, textList);
    bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
    ret = jpaService.execute(bundleInfoGetCmd);
    assertNotNull(ret);
    assertEquals(ret.getBundleJobs().size(), 2);
    textList.clear();
    textList.add("updated-app-name1");
    bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
    ret = jpaService.execute(bundleInfoGetCmd);
    assertNotNull(ret);
    assertEquals(ret.getBundleJobs().size(), 1);
}
Also used : BundleJobBean(org.apache.oozie.BundleJobBean) HashMap(java.util.HashMap) XException(org.apache.oozie.XException) BundleJobInfo(org.apache.oozie.BundleJobInfo) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JPAService(org.apache.oozie.service.JPAService)

Example 60 with BundleJobBean

use of org.apache.oozie.BundleJobBean in project oozie by apache.

the class TestBundleJobInfoGetJPAExecutor method testGetJobInfoForTextAndStatus.

public void testGetJobInfoForTextAndStatus() throws Exception {
    BundleJobBean bundleJob = addRecordToBundleJobTable(BundleJob.Status.RUNNING, false);
    bundleJob.setAppName("bundle-job-1");
    BundleJobQueryExecutor.getInstance().executeUpdate(BundleJobQueryExecutor.BundleJobQuery.UPDATE_BUNDLE_JOB, bundleJob);
    Map<String, List<String>> filter = new HashMap<String, List<String>>();
    List<String> textFilterList = new ArrayList<String>();
    textFilterList.add("bundle-job-1");
    List<String> textStatusList = new ArrayList<String>();
    textStatusList.add(BundleJob.Status.RUNNING.toString());
    filter.put(OozieClient.FILTER_TEXT, textFilterList);
    filter.put(OozieClient.FILTER_STATUS, textStatusList);
    JPAService jpaService = Services.get().get(JPAService.class);
    BundleJobInfoGetJPAExecutor bundleInfoGetCmd = new BundleJobInfoGetJPAExecutor(filter, 1, 20);
    BundleJobInfo bundleJobsInfo = jpaService.execute(bundleInfoGetCmd);
    assertEquals(1, bundleJobsInfo.getBundleJobs().size());
}
Also used : BundleJobBean(org.apache.oozie.BundleJobBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) BundleJobInfo(org.apache.oozie.BundleJobInfo) ArrayList(java.util.ArrayList) List(java.util.List) JPAService(org.apache.oozie.service.JPAService)

Aggregations

BundleJobBean (org.apache.oozie.BundleJobBean)159 JPAService (org.apache.oozie.service.JPAService)78 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)69 BundleActionBean (org.apache.oozie.BundleActionBean)58 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)46 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)44 Date (java.util.Date)35 ArrayList (java.util.ArrayList)24 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)24 List (java.util.List)21 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)21 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)21 HashMap (java.util.HashMap)20 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)20 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)18 IOException (java.io.IOException)16 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)16 XConfiguration (org.apache.oozie.util.XConfiguration)16 Query (javax.persistence.Query)14 CommandException (org.apache.oozie.command.CommandException)14