Search in sources :

Example 76 with JPAService

use of org.apache.oozie.service.JPAService in project oozie by apache.

the class TestPurgeXCommand method testPurgeCoordWithWFChild3MoreThanLimit.

/**
 * Test : The workflow should get purged, and the coordinator parent should get purged --> both will get purged
 *
 * @throws Exception
 */
public void testPurgeCoordWithWFChild3MoreThanLimit() throws Exception {
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
    WorkflowJobBean wfJob1 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
    WorkflowJobBean wfJob2 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
    WorkflowJobBean wfJob3 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
    WorkflowJobBean wfJob4 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
    WorkflowJobBean wfJob5 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
    WorkflowActionBean wfAction1 = addRecordToWfActionTable(wfJob1.getId(), "1", WorkflowAction.Status.OK);
    WorkflowActionBean wfAction2 = addRecordToWfActionTable(wfJob2.getId(), "1", WorkflowAction.Status.OK);
    WorkflowActionBean wfAction3 = addRecordToWfActionTable(wfJob3.getId(), "1", WorkflowAction.Status.OK);
    WorkflowActionBean wfAction4 = addRecordToWfActionTable(wfJob4.getId(), "1", WorkflowAction.Status.OK);
    WorkflowActionBean wfAction5 = addRecordToWfActionTable(wfJob5.getId(), "1", WorkflowAction.Status.OK);
    CoordinatorActionBean coordAction1 = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob1.getId(), "SUCCEEDED", 0);
    CoordinatorActionBean coordAction2 = addRecordToCoordActionTable(coordJob.getId(), 2, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob2.getId(), "SUCCEEDED", 0);
    CoordinatorActionBean coordAction3 = addRecordToCoordActionTable(coordJob.getId(), 3, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob3.getId(), "SUCCEEDED", 0);
    CoordinatorActionBean coordAction4 = addRecordToCoordActionTable(coordJob.getId(), 4, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob4.getId(), "SUCCEEDED", 0);
    CoordinatorActionBean coordAction5 = addRecordToCoordActionTable(coordJob.getId(), 5, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob5.getId(), "SUCCEEDED", 0);
    WorkflowJobGetJPAExecutor wfJob1GetCmd = new WorkflowJobGetJPAExecutor(wfJob1.getId());
    WorkflowJobGetJPAExecutor wfJob2GetCmd = new WorkflowJobGetJPAExecutor(wfJob2.getId());
    WorkflowJobGetJPAExecutor wfJob3GetCmd = new WorkflowJobGetJPAExecutor(wfJob3.getId());
    WorkflowJobGetJPAExecutor wfJob4GetCmd = new WorkflowJobGetJPAExecutor(wfJob4.getId());
    WorkflowJobGetJPAExecutor wfJob5GetCmd = new WorkflowJobGetJPAExecutor(wfJob5.getId());
    WorkflowActionGetJPAExecutor wfAction1GetCmd = new WorkflowActionGetJPAExecutor(wfAction1.getId());
    WorkflowActionGetJPAExecutor wfAction2GetCmd = new WorkflowActionGetJPAExecutor(wfAction2.getId());
    WorkflowActionGetJPAExecutor wfAction3GetCmd = new WorkflowActionGetJPAExecutor(wfAction3.getId());
    WorkflowActionGetJPAExecutor wfAction4GetCmd = new WorkflowActionGetJPAExecutor(wfAction4.getId());
    WorkflowActionGetJPAExecutor wfAction5GetCmd = new WorkflowActionGetJPAExecutor(wfAction5.getId());
    CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
    CoordActionGetJPAExecutor coordAction1GetCmd = new CoordActionGetJPAExecutor(coordAction1.getId());
    CoordActionGetJPAExecutor coordAction2GetCmd = new CoordActionGetJPAExecutor(coordAction2.getId());
    CoordActionGetJPAExecutor coordAction3GetCmd = new CoordActionGetJPAExecutor(coordAction3.getId());
    CoordActionGetJPAExecutor coordAction4GetCmd = new CoordActionGetJPAExecutor(coordAction4.getId());
    CoordActionGetJPAExecutor coordAction5GetCmd = new CoordActionGetJPAExecutor(coordAction5.getId());
    wfJob1 = jpaService.execute(wfJob1GetCmd);
    wfJob2 = jpaService.execute(wfJob2GetCmd);
    wfJob3 = jpaService.execute(wfJob3GetCmd);
    wfJob4 = jpaService.execute(wfJob4GetCmd);
    wfJob5 = jpaService.execute(wfJob5GetCmd);
    wfAction1 = jpaService.execute(wfAction1GetCmd);
    wfAction2 = jpaService.execute(wfAction2GetCmd);
    wfAction3 = jpaService.execute(wfAction3GetCmd);
    wfAction4 = jpaService.execute(wfAction4GetCmd);
    wfAction5 = jpaService.execute(wfAction5GetCmd);
    coordJob = jpaService.execute(coordJobGetCmd);
    coordAction1 = jpaService.execute(coordAction1GetCmd);
    coordAction2 = jpaService.execute(coordAction2GetCmd);
    coordAction3 = jpaService.execute(coordAction3GetCmd);
    coordAction4 = jpaService.execute(coordAction4GetCmd);
    coordAction5 = jpaService.execute(coordAction5GetCmd);
    assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob1.getStatus());
    assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob2.getStatus());
    assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob3.getStatus());
    assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob4.getStatus());
    assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob5.getStatus());
    assertEquals(WorkflowAction.Status.OK, wfAction1.getStatus());
    assertEquals(WorkflowAction.Status.OK, wfAction2.getStatus());
    assertEquals(WorkflowAction.Status.OK, wfAction3.getStatus());
    assertEquals(WorkflowAction.Status.OK, wfAction4.getStatus());
    assertEquals(WorkflowAction.Status.OK, wfAction5.getStatus());
    assertEquals(CoordinatorJob.Status.SUCCEEDED, coordJob.getStatus());
    assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction1.getStatus());
    assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction2.getStatus());
    assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction3.getStatus());
    assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction4.getStatus());
    assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction5.getStatus());
    new PurgeXCommand(7, 7, 1, 10).call();
    try {
        jpaService.execute(coordJobGetCmd);
        fail("Coordinator Job should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0604, je.getErrorCode());
    }
    try {
        jpaService.execute(coordAction1GetCmd);
        fail("Coordinator Action 1 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(coordAction2GetCmd);
        fail("Coordinator Action 2 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(coordAction3GetCmd);
        fail("Coordinator Action 3 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(coordAction4GetCmd);
        fail("Coordinator Action 4 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(coordAction5GetCmd);
        fail("Coordinator Action 5 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(wfJob1GetCmd);
        fail("Workflow Job 1 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0604, je.getErrorCode());
    }
    try {
        jpaService.execute(wfJob2GetCmd);
        fail("Workflow Job 2 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0604, je.getErrorCode());
    }
    try {
        jpaService.execute(wfJob3GetCmd);
        fail("Workflow Job 3 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0604, je.getErrorCode());
    }
    try {
        jpaService.execute(wfJob4GetCmd);
        fail("Workflow Job 4 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0604, je.getErrorCode());
    }
    try {
        jpaService.execute(wfJob5GetCmd);
        fail("Workflow Job 5 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0604, je.getErrorCode());
    }
    try {
        jpaService.execute(wfAction1GetCmd);
        fail("Workflow Action 1 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(wfAction2GetCmd);
        fail("Workflow Action 2 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(wfAction3GetCmd);
        fail("Workflow Action 3 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(wfAction4GetCmd);
        fail("Workflow Action 4 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(wfAction5GetCmd);
        fail("Workflow Action 5 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) CoordActionGetJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 77 with JPAService

use of org.apache.oozie.service.JPAService in project oozie by apache.

the class TestPurgeXCommand method testPurgeWFWithSubWF2.

/**
 * Test : The subworkflow shouldn't get purged, but the workflow parent should get purged --> neither will get purged
 *
 * @throws Exception
 */
public void testPurgeWFWithSubWF2() throws Exception {
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    WorkflowJobBean wfJob = addRecordToWfJobTableForNegCase(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
    WorkflowActionBean wfAction = addRecordToWfActionTable(wfJob.getId(), "1", WorkflowAction.Status.OK);
    WorkflowJobBean subwfJob = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING, wfJob.getId());
    WorkflowActionBean subwfAction = addRecordToWfActionTable(subwfJob.getId(), "1", WorkflowAction.Status.RUNNING);
    WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(wfJob.getId());
    WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(wfAction.getId());
    WorkflowJobGetJPAExecutor subwfJobGetCmd = new WorkflowJobGetJPAExecutor(subwfJob.getId());
    WorkflowActionGetJPAExecutor subwfActionGetCmd = new WorkflowActionGetJPAExecutor(subwfAction.getId());
    wfJob = jpaService.execute(wfJobGetCmd);
    wfAction = jpaService.execute(wfActionGetCmd);
    subwfJob = jpaService.execute(subwfJobGetCmd);
    subwfAction = jpaService.execute(subwfActionGetCmd);
    assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob.getStatus());
    assertEquals(WorkflowAction.Status.OK, wfAction.getStatus());
    assertEquals(WorkflowJob.Status.RUNNING, subwfJob.getStatus());
    assertEquals(WorkflowAction.Status.RUNNING, subwfAction.getStatus());
    new PurgeXCommand(7, 1, 1, 10).call();
    try {
        jpaService.execute(wfJobGetCmd);
    } catch (JPAExecutorException je) {
        fail("Workflow Job should not have been purged");
    }
    try {
        jpaService.execute(wfActionGetCmd);
    } catch (JPAExecutorException je) {
        fail("Workflow Action should not have been purged");
    }
    try {
        jpaService.execute(subwfJobGetCmd);
    } catch (JPAExecutorException je) {
        fail("SubWorkflow Job should not have been purged");
    }
    try {
        jpaService.execute(subwfActionGetCmd);
    } catch (JPAExecutorException je) {
        fail("SubWorkflow Action should not have been purged");
    }
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 78 with JPAService

use of org.apache.oozie.service.JPAService in project oozie by apache.

the class TestPurgeXCommand method testPurgeBundleWithCoordChildWithWFChild1.

/**
 * Test : The workflow and coordinator should get purged, but the bundle parent shouldn't get purged --> none will get purged
 *
 * @throws Exception
 */
public void testPurgeBundleWithCoordChildWithWFChild1() throws Exception {
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    BundleJobBean bundleJob = addRecordToBundleJobTable(Job.Status.SUCCEEDED, DateUtils.parseDateOozieTZ("2011-01-01T01:00Z"));
    CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
    WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
    WorkflowActionBean wfAction = addRecordToWfActionTable(wfJob.getId(), "1", WorkflowAction.Status.OK);
    CoordinatorActionBean coordAction = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob.getId(), "SUCCEEDED", 0);
    BundleActionBean bundleAction = addRecordToBundleActionTable(bundleJob.getId(), coordJob.getId(), coordJob.getAppName(), 0, Job.Status.SUCCEEDED);
    WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(wfJob.getId());
    WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(wfAction.getId());
    CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
    CoordActionGetJPAExecutor coordActionGetCmd = new CoordActionGetJPAExecutor(coordAction.getId());
    BundleJobGetJPAExecutor bundleJobGetCmd = new BundleJobGetJPAExecutor(bundleJob.getId());
    BundleActionGetJPAExecutor bundleActionGetCmd = new BundleActionGetJPAExecutor(bundleJob.getId(), coordJob.getAppName());
    wfJob = jpaService.execute(wfJobGetCmd);
    wfAction = jpaService.execute(wfActionGetCmd);
    coordJob = jpaService.execute(coordJobGetCmd);
    coordAction = jpaService.execute(coordActionGetCmd);
    bundleJob = jpaService.execute(bundleJobGetCmd);
    bundleAction = jpaService.execute(bundleActionGetCmd);
    assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob.getStatus());
    assertEquals(WorkflowAction.Status.OK, wfAction.getStatus());
    assertEquals(CoordinatorJob.Status.SUCCEEDED, coordJob.getStatus());
    assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction.getStatus());
    assertEquals(BundleJobBean.Status.SUCCEEDED, bundleJob.getStatus());
    assertEquals(BundleJobBean.Status.SUCCEEDED, bundleAction.getStatus());
    new PurgeXCommand(7, 7, getNumDaysToNotBePurged(bundleJob.getLastModifiedTime()), 10).call();
    try {
        jpaService.execute(bundleJobGetCmd);
    } catch (JPAExecutorException je) {
        fail("Bundle Job should not have been purged");
    }
    try {
        jpaService.execute(bundleActionGetCmd);
    } catch (JPAExecutorException je) {
        fail("Bundle Action should not have been purged");
    }
    try {
        jpaService.execute(coordJobGetCmd);
    } catch (JPAExecutorException je) {
        fail("Coordinator Job should not have been purged");
    }
    try {
        jpaService.execute(coordActionGetCmd);
    } catch (JPAExecutorException je) {
        fail("Coordinator Action should not have been purged");
    }
    try {
        jpaService.execute(wfJobGetCmd);
    } catch (JPAExecutorException je) {
        fail("Workflow Job should not have been purged");
    }
    try {
        jpaService.execute(wfActionGetCmd);
    } catch (JPAExecutorException je) {
        fail("Workflow Action should not have been purged");
    }
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) BundleActionGetJPAExecutor(org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor) CoordActionGetJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) BundleJobBean(org.apache.oozie.BundleJobBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) BundleActionBean(org.apache.oozie.BundleActionBean)

Example 79 with JPAService

use of org.apache.oozie.service.JPAService in project oozie by apache.

the class TestPurgeXCommand method testPurgeWFWithSubWF3MoreThanLimit.

/**
 * Test : The subworkflow should get purged, and the workflow parent should get purged --> both will get purged
 * There are more subworkflow children than the limit
 *
 * @throws Exception
 */
public void testPurgeWFWithSubWF3MoreThanLimit() throws Exception {
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
    WorkflowActionBean wfAction1 = addRecordToWfActionTable(wfJob.getId(), "1", WorkflowAction.Status.OK);
    WorkflowActionBean wfAction2 = addRecordToWfActionTable(wfJob.getId(), "2", WorkflowAction.Status.OK);
    WorkflowActionBean wfAction3 = addRecordToWfActionTable(wfJob.getId(), "3", WorkflowAction.Status.OK);
    WorkflowActionBean wfAction4 = addRecordToWfActionTable(wfJob.getId(), "4", WorkflowAction.Status.OK);
    WorkflowActionBean wfAction5 = addRecordToWfActionTable(wfJob.getId(), "5", WorkflowAction.Status.OK);
    WorkflowJobBean subwfJob1 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJob.getId());
    WorkflowJobBean subwfJob2 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJob.getId());
    WorkflowJobBean subwfJob3 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJob.getId());
    WorkflowJobBean subwfJob4 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJob.getId());
    WorkflowJobBean subwfJob5 = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED, wfJob.getId());
    WorkflowActionBean subwfAction1 = addRecordToWfActionTable(subwfJob1.getId(), "1", WorkflowAction.Status.OK);
    WorkflowActionBean subwfAction2 = addRecordToWfActionTable(subwfJob2.getId(), "1", WorkflowAction.Status.OK);
    WorkflowActionBean subwfAction3 = addRecordToWfActionTable(subwfJob3.getId(), "1", WorkflowAction.Status.OK);
    WorkflowActionBean subwfAction4 = addRecordToWfActionTable(subwfJob4.getId(), "1", WorkflowAction.Status.OK);
    WorkflowActionBean subwfAction5 = addRecordToWfActionTable(subwfJob5.getId(), "1", WorkflowAction.Status.OK);
    WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(wfJob.getId());
    WorkflowActionGetJPAExecutor wfAction1GetCmd = new WorkflowActionGetJPAExecutor(wfAction1.getId());
    WorkflowActionGetJPAExecutor wfAction2GetCmd = new WorkflowActionGetJPAExecutor(wfAction2.getId());
    WorkflowActionGetJPAExecutor wfAction3GetCmd = new WorkflowActionGetJPAExecutor(wfAction3.getId());
    WorkflowActionGetJPAExecutor wfAction4GetCmd = new WorkflowActionGetJPAExecutor(wfAction4.getId());
    WorkflowActionGetJPAExecutor wfAction5GetCmd = new WorkflowActionGetJPAExecutor(wfAction5.getId());
    WorkflowJobGetJPAExecutor subwfJob1GetCmd = new WorkflowJobGetJPAExecutor(subwfJob1.getId());
    WorkflowJobGetJPAExecutor subwfJob2GetCmd = new WorkflowJobGetJPAExecutor(subwfJob2.getId());
    WorkflowJobGetJPAExecutor subwfJob3GetCmd = new WorkflowJobGetJPAExecutor(subwfJob3.getId());
    WorkflowJobGetJPAExecutor subwfJob4GetCmd = new WorkflowJobGetJPAExecutor(subwfJob4.getId());
    WorkflowJobGetJPAExecutor subwfJob5GetCmd = new WorkflowJobGetJPAExecutor(subwfJob5.getId());
    WorkflowActionGetJPAExecutor subwfAction1GetCmd = new WorkflowActionGetJPAExecutor(subwfAction1.getId());
    WorkflowActionGetJPAExecutor subwfAction2GetCmd = new WorkflowActionGetJPAExecutor(subwfAction2.getId());
    WorkflowActionGetJPAExecutor subwfAction3GetCmd = new WorkflowActionGetJPAExecutor(subwfAction3.getId());
    WorkflowActionGetJPAExecutor subwfAction4GetCmd = new WorkflowActionGetJPAExecutor(subwfAction4.getId());
    WorkflowActionGetJPAExecutor subwfAction5GetCmd = new WorkflowActionGetJPAExecutor(subwfAction5.getId());
    wfJob = jpaService.execute(wfJobGetCmd);
    wfAction1 = jpaService.execute(wfAction1GetCmd);
    wfAction2 = jpaService.execute(wfAction2GetCmd);
    wfAction3 = jpaService.execute(wfAction3GetCmd);
    wfAction4 = jpaService.execute(wfAction4GetCmd);
    wfAction5 = jpaService.execute(wfAction5GetCmd);
    subwfJob1 = jpaService.execute(subwfJob1GetCmd);
    subwfJob2 = jpaService.execute(subwfJob2GetCmd);
    subwfJob3 = jpaService.execute(subwfJob3GetCmd);
    subwfJob4 = jpaService.execute(subwfJob4GetCmd);
    subwfJob5 = jpaService.execute(subwfJob5GetCmd);
    subwfAction1 = jpaService.execute(subwfAction1GetCmd);
    subwfAction2 = jpaService.execute(subwfAction2GetCmd);
    subwfAction3 = jpaService.execute(subwfAction3GetCmd);
    subwfAction4 = jpaService.execute(subwfAction4GetCmd);
    subwfAction5 = jpaService.execute(subwfAction5GetCmd);
    assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob.getStatus());
    assertEquals(WorkflowAction.Status.OK, wfAction1.getStatus());
    assertEquals(WorkflowAction.Status.OK, wfAction2.getStatus());
    assertEquals(WorkflowAction.Status.OK, wfAction3.getStatus());
    assertEquals(WorkflowAction.Status.OK, wfAction4.getStatus());
    assertEquals(WorkflowAction.Status.OK, wfAction5.getStatus());
    assertEquals(WorkflowJob.Status.SUCCEEDED, subwfJob1.getStatus());
    assertEquals(WorkflowJob.Status.SUCCEEDED, subwfJob2.getStatus());
    assertEquals(WorkflowJob.Status.SUCCEEDED, subwfJob3.getStatus());
    assertEquals(WorkflowJob.Status.SUCCEEDED, subwfJob4.getStatus());
    assertEquals(WorkflowJob.Status.SUCCEEDED, subwfJob5.getStatus());
    assertEquals(WorkflowAction.Status.OK, subwfAction1.getStatus());
    assertEquals(WorkflowAction.Status.OK, subwfAction2.getStatus());
    assertEquals(WorkflowAction.Status.OK, subwfAction3.getStatus());
    assertEquals(WorkflowAction.Status.OK, subwfAction4.getStatus());
    assertEquals(WorkflowAction.Status.OK, subwfAction5.getStatus());
    new PurgeXCommand(7, 1, 1, 3).call();
    try {
        jpaService.execute(wfJobGetCmd);
        fail("Workflow Job should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0604, je.getErrorCode());
    }
    try {
        jpaService.execute(wfAction1GetCmd);
        fail("Workflow Action 1 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(wfAction2GetCmd);
        fail("Workflow Action 2 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(wfAction3GetCmd);
        fail("Workflow Action 3 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(wfAction4GetCmd);
        fail("Workflow Action 4 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(wfAction5GetCmd);
        fail("Workflow Action 5 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(subwfJob1GetCmd);
        fail("SubWorkflow Job 1 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0604, je.getErrorCode());
    }
    try {
        jpaService.execute(subwfJob2GetCmd);
        fail("SubWorkflow Job 2 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0604, je.getErrorCode());
    }
    try {
        jpaService.execute(subwfJob3GetCmd);
        fail("SubWorkflow Job 3 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0604, je.getErrorCode());
    }
    try {
        jpaService.execute(subwfJob4GetCmd);
        fail("SubWorkflow Job 4 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0604, je.getErrorCode());
    }
    try {
        jpaService.execute(subwfJob5GetCmd);
        fail("SubWorkflow Job 5 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0604, je.getErrorCode());
    }
    try {
        jpaService.execute(subwfAction1GetCmd);
        fail("SubWorkflow Action 1 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(subwfAction2GetCmd);
        fail("SubWorkflow Action 2 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(subwfAction3GetCmd);
        fail("SubWorkflow Action 3 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(subwfAction4GetCmd);
        fail("SubWorkflow Action 4 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(subwfAction5GetCmd);
        fail("SubWorkflow Action 5 should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 80 with JPAService

use of org.apache.oozie.service.JPAService in project oozie by apache.

the class TestPurgeXCommand method testPurgeLongRunningCoordWithWFChild.

/**
 * Test : The workflow should get purged, but the coordinator parent shouldn't get purged -->
 * the workflow and corresponding coord actions will get purged after we turn the purge.old.coord.action on
 * Coordinator itself will not be purged
 *
 * @throws Exception
 */
public void testPurgeLongRunningCoordWithWFChild() throws Exception {
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, false, false);
    WorkflowJobBean wfJob = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
    WorkflowActionBean wfAction = addRecordToWfActionTable(wfJob.getId(), "1", WorkflowAction.Status.OK);
    CoordinatorActionBean coordAction = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", wfJob.getId(), "SUCCEEDED", 0);
    WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(wfJob.getId());
    WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(wfAction.getId());
    CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
    CoordActionGetJPAExecutor coordActionGetCmd = new CoordActionGetJPAExecutor(coordAction.getId());
    wfJob = jpaService.execute(wfJobGetCmd);
    wfAction = jpaService.execute(wfActionGetCmd);
    coordJob = jpaService.execute(coordJobGetCmd);
    coordAction = jpaService.execute(coordActionGetCmd);
    assertEquals(WorkflowJob.Status.SUCCEEDED, wfJob.getStatus());
    assertEquals(WorkflowAction.Status.OK, wfAction.getStatus());
    assertEquals(CoordinatorJob.Status.RUNNING, coordJob.getStatus());
    assertEquals(CoordinatorAction.Status.SUCCEEDED, coordAction.getStatus());
    new PurgeXCommand(7, getNumDaysToNotBePurged(coordJob.getLastModifiedTime()), 1, 10, true).call();
    try {
        jpaService.execute(coordJobGetCmd);
    } catch (JPAExecutorException je) {
        fail("Coordinator Job should not have been purged");
    }
    try {
        jpaService.execute(coordActionGetCmd);
        fail("Coordinator Action should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
    try {
        jpaService.execute(wfJobGetCmd);
        fail("Workflow Job should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0604, je.getErrorCode());
    }
    try {
        jpaService.execute(wfActionGetCmd);
        fail("Workflow Action should have been purged");
    } catch (JPAExecutorException je) {
        assertEquals(ErrorCode.E0605, je.getErrorCode());
    }
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) CoordActionGetJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Aggregations

JPAService (org.apache.oozie.service.JPAService)449 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)156 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)152 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)113 Date (java.util.Date)95 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)94 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)84 BundleJobBean (org.apache.oozie.BundleJobBean)78 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)78 ArrayList (java.util.ArrayList)76 CommandException (org.apache.oozie.command.CommandException)66 List (java.util.List)59 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)54 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)54 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)49 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)47 HashMap (java.util.HashMap)41 BundleActionBean (org.apache.oozie.BundleActionBean)35 Configuration (org.apache.hadoop.conf.Configuration)32 EntityManager (javax.persistence.EntityManager)31