Search in sources :

Example 26 with BundleActionBean

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

the class TestBundleActionQueryExecutor method testGetUpdateQuery.

public void testGetUpdateQuery() throws Exception {
    EntityManager em = jpaService.getEntityManager();
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
    BundleActionBean bundleAction = this.addRecordToBundleActionTable(job.getId(), "action1", 1, Job.Status.PREP);
    // UPDATE_BUNDLE_ACTION_PENDING_MODTIME
    Query query = BundleActionQueryExecutor.getInstance().getUpdateQuery(BundleActionQuery.UPDATE_BUNDLE_ACTION_PENDING_MODTIME, bundleAction, em);
    assertEquals(query.getParameterValue("lastModifiedTime"), bundleAction.getLastModifiedTimestamp());
    assertEquals(query.getParameterValue("pending"), bundleAction.getPending());
    assertEquals(query.getParameterValue("bundleActionId"), bundleAction.getBundleActionId());
    // UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME:
    query = BundleActionQueryExecutor.getInstance().getUpdateQuery(BundleActionQuery.UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME_COORDID, bundleAction, em);
    assertEquals(query.getParameterValue("status"), bundleAction.getStatus().toString());
    assertEquals(query.getParameterValue("lastModifiedTime"), bundleAction.getLastModifiedTimestamp());
    assertEquals(query.getParameterValue("pending"), bundleAction.getPending());
    assertEquals(query.getParameterValue("coordId"), bundleAction.getCoordId());
    assertEquals(query.getParameterValue("bundleActionId"), bundleAction.getBundleActionId());
    // UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME_COORDID
    query = BundleActionQueryExecutor.getInstance().getUpdateQuery(BundleActionQuery.UPDATE_BUNDLE_ACTION_STATUS_PENDING_MODTIME_COORDID, bundleAction, em);
    assertEquals(query.getParameterValue("status"), bundleAction.getStatus().toString());
    assertEquals(query.getParameterValue("lastModifiedTime"), bundleAction.getLastModifiedTimestamp());
    assertEquals(query.getParameterValue("pending"), bundleAction.isPending() ? 1 : 0);
    assertEquals(query.getParameterValue("coordId"), bundleAction.getCoordId());
    assertEquals(query.getParameterValue("bundleActionId"), bundleAction.getBundleActionId());
    em.close();
}
Also used : EntityManager(javax.persistence.EntityManager) Query(javax.persistence.Query) BundleActionQuery(org.apache.oozie.executor.jpa.BundleActionQueryExecutor.BundleActionQuery) BundleJobBean(org.apache.oozie.BundleJobBean) BundleActionBean(org.apache.oozie.BundleActionBean)

Example 27 with BundleActionBean

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

the class TestBundleActionQueryExecutor method testGet.

public void testGet() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
    BundleActionBean bundleAction = this.addRecordToBundleActionTable(job.getId(), "action1", 1, Job.Status.PREP);
    // GET_UNIGNORED_BUNDLE_ACTION_STATUS_PENDING_FOR_BUNDLE
    BundleActionBean retBean = BundleActionQueryExecutor.getInstance().get(BundleActionQuery.GET_BUNDLE_UNIGNORED_ACTION_STATUS_PENDING_FOR_BUNDLE, bundleAction.getBundleId());
    assertEquals(bundleAction.getCoordId(), retBean.getCoordId());
    assertEquals(bundleAction.getStatusStr(), retBean.getStatusStr());
    assertEquals(bundleAction.getPending(), retBean.getPending());
    // GET_BUNDLE_ACTION
    retBean = BundleActionQueryExecutor.getInstance().get(BundleActionQuery.GET_BUNDLE_ACTION, bundleAction.getBundleActionId());
    assertEquals(bundleAction.getStatus(), retBean.getStatus());
}
Also used : BundleJobBean(org.apache.oozie.BundleJobBean) BundleActionBean(org.apache.oozie.BundleActionBean)

Example 28 with BundleActionBean

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

the class TestBundleActionQueryExecutor method testGetSelectQuery.

public void testGetSelectQuery() throws Exception {
    EntityManager em = jpaService.getEntityManager();
    BundleActionBean bean = addRecordToBundleActionTable("test-bundle-id", "test-coord", 0, Job.Status.RUNNING);
    Query query = null;
    query = BundleActionQueryExecutor.getInstance().getSelectQuery(BundleActionQuery.GET_BUNDLE_ACTION, em, bean.getBundleId());
    assertEquals(query.getParameterValue("bundleActionId"), bean.getBundleId());
    query = BundleActionQueryExecutor.getInstance().getSelectQuery(BundleActionQuery.GET_BUNDLE_WAITING_ACTIONS_OLDER_THAN, em, (long) 100);
    Date date = DateUtils.toDate((Timestamp) (query.getParameterValue("lastModifiedTime")));
    assertTrue(date.before(Calendar.getInstance().getTime()));
    query = BundleActionQueryExecutor.getInstance().getSelectQuery(BundleActionQuery.GET_BUNDLE_UNIGNORED_ACTION_STATUS_PENDING_FOR_BUNDLE, em, bean.getBundleId());
    assertEquals(query.getParameterValue("bundleId"), bean.getBundleId());
}
Also used : EntityManager(javax.persistence.EntityManager) Query(javax.persistence.Query) BundleActionQuery(org.apache.oozie.executor.jpa.BundleActionQueryExecutor.BundleActionQuery) BundleActionBean(org.apache.oozie.BundleActionBean) Date(java.util.Date)

Example 29 with BundleActionBean

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

the class TestBundleActionQueryExecutor method testInsert.

public void testInsert() throws Exception {
    BundleActionBean bean = new BundleActionBean();
    bean.setBundleActionId("test-oozie");
    bean.setCoordName("testApp");
    bean.setStatus(Job.Status.RUNNING);
    BundleActionQueryExecutor.getInstance().insert(bean);
    BundleActionBean retBean = BundleActionQueryExecutor.getInstance().get(BundleActionQuery.GET_BUNDLE_ACTION, "test-oozie");
    assertEquals(retBean.getCoordName(), "testApp");
    assertEquals(retBean.getStatus(), Job.Status.RUNNING);
}
Also used : BundleActionBean(org.apache.oozie.BundleActionBean)

Example 30 with BundleActionBean

use of org.apache.oozie.BundleActionBean 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)

Aggregations

BundleActionBean (org.apache.oozie.BundleActionBean)76 BundleJobBean (org.apache.oozie.BundleJobBean)58 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)36 JPAService (org.apache.oozie.service.JPAService)35 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)33 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)30 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)24 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)20 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)20 Date (java.util.Date)19 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)19 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)16 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)13 IOException (java.io.IOException)10 CommandException (org.apache.oozie.command.CommandException)10 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)10 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)9 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)9 XConfiguration (org.apache.oozie.util.XConfiguration)8 ArrayList (java.util.ArrayList)6