Search in sources :

Example 61 with BundleJobBean

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

the class TestBundleJobInfoGetJPAExecutor method testBundleJobInfoGet.

public void testBundleJobInfoGet() throws Exception {
    BundleJobBean bundleJob1 = addRecordToBundleJobTable(Job.Status.PREP, false);
    addRecordToBundleJobTable(Job.Status.RUNNING, false);
    _testGetJobInfoForStatus();
    _testGetJobInfoForGroup();
    addRecordToBundleJobTable(Job.Status.KILLED, false);
    addRecordToBundleJobTable(Job.Status.SUCCEEDED, false);
    _testGetJobInfoForAppName();
    _testGetJobInfoForUser();
    _testGetJobInfoForUserAndStatus();
    _testGetJobInfoForId(bundleJob1.getId());
}
Also used : BundleJobBean(org.apache.oozie.BundleJobBean)

Example 62 with BundleJobBean

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

the class TestBundleJobQueryExecutor method testGetUpdateQuery.

public void testGetUpdateQuery() throws Exception {
    EntityManager em = jpaService.getEntityManager();
    BundleJobBean bean = addRecordToBundleJobTable(Job.Status.PREP, false);
    // UPDATE_BUNDLE_JOB
    Query query = BundleJobQueryExecutor.getInstance().getUpdateQuery(BundleJobQuery.UPDATE_BUNDLE_JOB, bean, em);
    assertEquals(query.getParameterValue("appName"), bean.getAppName());
    assertEquals(query.getParameterValue("appPath"), bean.getAppPath());
    assertEquals(query.getParameterValue("conf"), bean.getConfBlob());
    assertEquals(query.getParameterValue("timeOut"), bean.getTimeout());
    assertEquals(query.getParameterValue("createdTime"), bean.getCreatedTimestamp());
    assertEquals(query.getParameterValue("endTime"), bean.getEndTimestamp());
    assertEquals(query.getParameterValue("jobXml"), bean.getJobXmlBlob());
    assertEquals(query.getParameterValue("lastModifiedTime"), bean.getLastModifiedTimestamp());
    assertEquals(query.getParameterValue("origJobXml"), bean.getOrigJobXmlBlob());
    assertEquals(query.getParameterValue("startTime"), bean.getstartTimestamp());
    assertEquals(query.getParameterValue("status"), bean.getStatus().toString());
    assertEquals(query.getParameterValue("timeUnit"), bean.getTimeUnitStr());
    assertEquals(query.getParameterValue("pending"), bean.getPending());
    assertEquals(query.getParameterValue("id"), bean.getId());
    // UPDATE_BUNDLE_JOB_STATUS
    query = BundleJobQueryExecutor.getInstance().getUpdateQuery(BundleJobQuery.UPDATE_BUNDLE_JOB_STATUS, bean, em);
    assertEquals(query.getParameterValue("status"), bean.getStatus().toString());
    assertEquals(query.getParameterValue("id"), bean.getId());
    // UPDATE_BUNDLE_JOB_STATUS_PENDING
    query = BundleJobQueryExecutor.getInstance().getUpdateQuery(BundleJobQuery.UPDATE_BUNDLE_JOB_STATUS_PENDING, bean, em);
    assertEquals(query.getParameterValue("status"), bean.getStatus().toString());
    assertEquals(query.getParameterValue("pending"), bean.getPending());
    assertEquals(query.getParameterValue("id"), bean.getId());
    // UPDATE_BUNDLE_JOB_STATUS_PENDING_SUSP_MOD_TIME:
    query = BundleJobQueryExecutor.getInstance().getUpdateQuery(BundleJobQuery.UPDATE_BUNDLE_JOB_STATUS_PENDING_SUSP_MOD_TIME, bean, em);
    assertEquals(query.getParameterValue("status"), bean.getStatus().toString());
    assertEquals(query.getParameterValue("lastModifiedTime"), bean.getLastModifiedTimestamp());
    assertEquals(query.getParameterValue("pending"), bean.getPending());
    assertEquals(query.getParameterValue("suspendedTime"), bean.getSuspendedTimestamp());
    assertEquals(query.getParameterValue("id"), bean.getId());
    // UPDATE_BUNDLE_JOB_STATUS_PENDING_MODTIME:
    query = BundleJobQueryExecutor.getInstance().getUpdateQuery(BundleJobQuery.UPDATE_BUNDLE_JOB_STATUS_PENDING_MODTIME, bean, em);
    assertEquals(query.getParameterValue("status"), bean.getStatus().toString());
    assertEquals(query.getParameterValue("lastModifiedTime"), bean.getLastModifiedTimestamp());
    assertEquals(query.getParameterValue("pending"), bean.getPending());
    assertEquals(query.getParameterValue("id"), bean.getId());
    // UPDATE_BUNDLE_JOB_STATUS_PAUSE_ENDTIME:
    query = BundleJobQueryExecutor.getInstance().getUpdateQuery(BundleJobQuery.UPDATE_BUNDLE_JOB_STATUS_PAUSE_ENDTIME, bean, em);
    assertEquals(query.getParameterValue("status"), bean.getStatus().toString());
    assertEquals(query.getParameterValue("pauseTime"), bean.getPauseTimestamp());
    assertEquals(query.getParameterValue("endTime"), bean.getEndTimestamp());
    assertEquals(query.getParameterValue("id"), bean.getId());
    // UPDATE_BUNDLE_JOB_PAUSE_KICKOFF:
    query = BundleJobQueryExecutor.getInstance().getUpdateQuery(BundleJobQuery.UPDATE_BUNDLE_JOB_PAUSE_KICKOFF, bean, em);
    assertEquals(query.getParameterValue("pauseTime"), bean.getPauseTimestamp());
    assertEquals(query.getParameterValue("kickoffTime"), bean.getKickoffTimestamp());
    assertEquals(query.getParameterValue("id"), bean.getId());
    em.close();
}
Also used : EntityManager(javax.persistence.EntityManager) Query(javax.persistence.Query) BundleJobQuery(org.apache.oozie.executor.jpa.BundleJobQueryExecutor.BundleJobQuery) BundleJobBean(org.apache.oozie.BundleJobBean)

Example 63 with BundleJobBean

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

the class TestBundleJobQueryExecutor method testInsert.

public void testInsert() throws Exception {
    BundleJobBean bean = new BundleJobBean();
    bean.setId("test-oozie");
    bean.setAppName("testApp");
    bean.setUser("oozie");
    BundleJobQueryExecutor.getInstance().insert(bean);
    BundleJobBean retBean = BundleJobQueryExecutor.getInstance().get(BundleJobQuery.GET_BUNDLE_JOB, "test-oozie");
    assertEquals(retBean.getAppName(), "testApp");
    assertEquals(retBean.getUser(), "oozie");
}
Also used : BundleJobBean(org.apache.oozie.BundleJobBean)

Example 64 with BundleJobBean

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

the class TestBundleJobQueryExecutor method testGet.

public void testGet() throws Exception {
    BundleJobBean bean = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
    // GET_BUNDLE_JOB_ID_STATUS_PENDING_MODTIME
    BundleJobBean retBean = BundleJobQueryExecutor.getInstance().get(BundleJobQuery.GET_BUNDLE_JOB_ID_STATUS_PENDING_MOD_PAUSE_SUSPEND_TIME, bean.getId());
    assertEquals(bean.getId(), retBean.getId());
    assertEquals(bean.getStatusStr(), retBean.getStatusStr());
    assertEquals(bean.getPending(), retBean.getPending());
    assertEquals(bean.getLastModifiedTime().getTime(), retBean.getLastModifiedTime().getTime());
    // GET_BUNDLE_JOB_ID_JOBXML_CONF
    retBean = BundleJobQueryExecutor.getInstance().get(BundleJobQuery.GET_BUNDLE_JOB_ID_JOBXML_CONF, bean.getId());
    assertEquals(bean.getId(), retBean.getId());
    assertEquals(bean.getJobXml(), retBean.getJobXml());
    assertEquals(bean.getConf(), retBean.getConf());
    // GET_BUNDLE_JOB_STATUS
    retBean = BundleJobQueryExecutor.getInstance().get(BundleJobQuery.GET_BUNDLE_JOB_STATUS, bean.getId());
    assertEquals(bean.getStatus(), retBean.getStatus());
    assertEquals(bean.getId(), retBean.getId());
}
Also used : BundleJobBean(org.apache.oozie.BundleJobBean)

Example 65 with BundleJobBean

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

the class TestCoordJobsGetFromParentIdJPAExecutor method testGetBundleParent.

public void testGetBundleParent() throws Exception {
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    BundleJobBean bundleJobA = addRecordToBundleJobTable(Job.Status.SUCCEEDED, false);
    BundleJobBean bundleJobB = addRecordToBundleJobTable(Job.Status.SUCCEEDED, false);
    CoordinatorJobBean coordJobA1 = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
    CoordinatorJobBean coordJobA2 = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
    coordJobA2.setAppName("something_different");
    CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, coordJobA2);
    CoordinatorJobBean coordJobB = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
    CoordinatorActionBean coordActionA1 = addRecordToCoordActionTable(coordJobA1.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
    CoordinatorActionBean coordActionA2 = addRecordToCoordActionTable(coordJobA2.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
    CoordinatorActionBean coordActionB = addRecordToCoordActionTable(coordJobB.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
    BundleActionBean bundleActionA1 = addRecordToBundleActionTable(bundleJobA.getId(), coordJobA1.getId(), coordJobA1.getAppName(), 0, Job.Status.SUCCEEDED);
    BundleActionBean bundleActionA2 = addRecordToBundleActionTable(bundleJobA.getId(), coordJobA2.getId(), coordJobA2.getAppName(), 0, Job.Status.SUCCEEDED);
    BundleActionBean bundleActionB = addRecordToBundleActionTable(bundleJobB.getId(), coordJobB.getId(), coordJobB.getAppName(), 0, Job.Status.SUCCEEDED);
    List<String> children = new ArrayList<String>();
    children.addAll(jpaService.execute(new CoordJobsGetFromParentIdJPAExecutor(bundleJobA.getId(), 10)));
    checkChildren(children, coordJobA1.getId(), coordJobA2.getId());
    children = new ArrayList<String>();
    children.addAll(jpaService.execute(new CoordJobsGetFromParentIdJPAExecutor(bundleJobB.getId(), 10)));
    checkChildren(children, coordJobB.getId());
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) BundleJobBean(org.apache.oozie.BundleJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) ArrayList(java.util.ArrayList) JPAService(org.apache.oozie.service.JPAService) BundleActionBean(org.apache.oozie.BundleActionBean)

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