Search in sources :

Example 91 with CoordinatorJobBean

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

Example 92 with CoordinatorJobBean

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

the class TestSLAAlertXCommand method testBundleSLAAlertCommands.

public void testBundleSLAAlertCommands() throws Exception {
    setupSLAJobs();
    String jobIdsStr = bundle.getId();
    String actions = "1,2";
    String coords = null;
    bundleEngine.disableSLAAlert(jobIdsStr, actions, null, coords);
    checkSLAStatus(coord1.getId() + "@1", true);
    checkSLAStatus(coord1.getId() + "@2", true);
    checkSLAStatus(coord1.getId() + "@3", false);
    checkSLAStatus(coord1.getId() + "@5", false);
    checkSLAStatus(coord1.getId() + "@4", false);
    checkSLAStatus(coord2.getId() + "@1", true);
    checkSLAStatus(coord2.getId() + "@1", true);
    bundleEngine.enableSLAAlert(jobIdsStr, null, null, null);
    checkSLAStatus(coord1.getId() + "@1", false);
    checkSLAStatus(coord1.getId() + "@2", false);
    checkSLAStatus(coord1.getId() + "@3", false);
    checkSLAStatus(coord1.getId() + "@5", false);
    checkSLAStatus(coord1.getId() + "@4", false);
    checkSLAStatus(coord2.getId() + "@1", false);
    checkSLAStatus(coord2.getId() + "@2", false);
    CoordinatorJobBean job1 = CoordJobQueryExecutor.getInstance().get(CoordJobQueryExecutor.CoordJobQuery.GET_COORD_JOB, coord1.getId());
    XConfiguration xConf = new XConfiguration(new StringReader(job1.getConf()));
    assertEquals(xConf.get(OozieClient.SLA_DISABLE_ALERT), null);
    CoordinatorJobBean job2 = CoordJobQueryExecutor.getInstance().get(CoordJobQueryExecutor.CoordJobQuery.GET_COORD_JOB, coord2.getId());
    xConf = new XConfiguration(new StringReader(job2.getConf()));
    assertEquals(xConf.get(OozieClient.SLA_DISABLE_ALERT), null);
    bundleEngine.disableSLAAlert(jobIdsStr, null, null, "coord1");
    checkSLAStatus(coord1.getId() + "@1", true);
    checkSLAStatus(coord1.getId() + "@2", true);
    checkSLAStatus(coord1.getId() + "@3", true);
    checkSLAStatus(coord1.getId() + "@4", true);
    checkSLAStatus(coord1.getId() + "@5", true);
    checkSLAStatus(coord2.getId() + "@1", false);
    checkSLAStatus(coord2.getId() + "@2", false);
    job1 = CoordJobQueryExecutor.getInstance().get(CoordJobQueryExecutor.CoordJobQuery.GET_COORD_JOB, coord1.getId());
    xConf = new XConfiguration(new StringReader(job1.getConf()));
    assertEquals(xConf.get(OozieClient.SLA_DISABLE_ALERT), SLAOperations.ALL_VALUE);
    bundleEngine.disableSLAAlert(jobIdsStr, null, null, "coord2");
    // with multiple coordID.
    String dates = "2014-01-01T00:00Z::2014-01-03T00:00Z";
    bundleEngine.enableSLAAlert(jobIdsStr, null, dates, "coord1," + coord2.getId());
    checkSLAStatus(coord1.getId() + "@1", false);
    checkSLAStatus(coord1.getId() + "@2", false);
    checkSLAStatus(coord1.getId() + "@3", false);
    checkSLAStatus(coord1.getId() + "@4", true);
    checkSLAStatus(coord1.getId() + "@5", true);
    checkSLAStatus(coord2.getId() + "@1", false);
    checkSLAStatus(coord2.getId() + "@2", false);
    checkSLAStatus(coord2.getId() + "@3", false);
    checkSLAStatus(coord2.getId() + "@4", true);
    try {
        bundleEngine.disableSLAAlert(jobIdsStr, null, null, "dummy");
        fail("Should throw Exception");
    } catch (BaseEngineException e) {
        assertEquals(e.getErrorCode(), ErrorCode.E1026);
    }
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) XConfiguration(org.apache.oozie.util.XConfiguration) StringReader(java.io.StringReader) BaseEngineException(org.apache.oozie.BaseEngineException)

Example 93 with CoordinatorJobBean

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

the class TestAbandonedCoordChecker method testKill.

public void testKill() throws Exception {
    Date start = DateUtils.addMonths(new Date(), -1);
    // 4 hrs
    Date end = DateUtils.addHours(new Date(), 4);
    Date createdTime = start;
    CoordinatorJobBean job1 = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, createdTime, true, false, 6);
    addRecordToCoordActionTable(job1.getId(), 6, CoordinatorAction.Status.FAILED);
    CoordinatorJobBean job2 = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, createdTime, true, false, 4);
    addRecordToCoordActionTable(job2.getId(), 4, CoordinatorAction.Status.FAILED);
    new AbandonedCoordCheckerRunnable(5, true).run();
    assertEquals(CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, job1.getId()).getStatus(), CoordinatorJob.Status.KILLED);
    assertEquals(CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, job2.getId()).getStatus(), CoordinatorJob.Status.RUNNING);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) Date(java.util.Date) AbandonedCoordCheckerRunnable(org.apache.oozie.service.AbandonedCoordCheckerService.AbandonedCoordCheckerRunnable)

Example 94 with CoordinatorJobBean

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

the class TestBulkCoordXCommand method testBulkCoordResumeNoOp.

public void testBulkCoordResumeNoOp() throws Exception {
    String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
    Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    CoordinatorJobBean job1 = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 0);
    CoordinatorActionBean action1 = addRecordToCoordActionTable(job1.getId(), 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
    Map<String, List<String>> map = new HashMap<String, List<String>>();
    List<String> names = new ArrayList<String>();
    names.add("COORD-TEST");
    map.put("name", names);
    new BulkCoordXCommand(map, 1, 50, OperationType.Resume).call();
    List<String> jobIds = new ArrayList<String>();
    jobIds.add(job1.getId());
    List<String> actionIds = new ArrayList<String>();
    actionIds.add(action1.getId());
    verifyJobsStatus(jobIds, CoordinatorJob.Status.RUNNING);
    verifyActionsStatus(actionIds, CoordinatorAction.Status.RUNNING);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Date(java.util.Date)

Example 95 with CoordinatorJobBean

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

the class TestBulkCoordXCommand method testBulkCoordResumeNegative.

public void testBulkCoordResumeNegative() throws Exception {
    String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
    Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    CoordinatorJobBean job1 = addRecordToCoordJobTable(CoordinatorJob.Status.SUSPENDED, start, end, false, false, 0);
    CoordinatorActionBean action1 = addRecordToCoordActionTable(job1.getId(), 1, CoordinatorAction.Status.SUSPENDED, "coord-action-get.xml", 0);
    Map<String, List<String>> map = new HashMap<String, List<String>>();
    List<String> names = new ArrayList<String>();
    names.add("COORD");
    map.put("name", names);
    new BulkCoordXCommand(map, 1, 50, OperationType.Resume).call();
    List<String> jobIds = new ArrayList<String>();
    jobIds.add(job1.getId());
    List<String> actionIds = new ArrayList<String>();
    actionIds.add(action1.getId());
    verifyJobsStatus(jobIds, CoordinatorJob.Status.SUSPENDED);
    verifyActionsStatus(actionIds, CoordinatorAction.Status.SUSPENDED);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Date(java.util.Date)

Aggregations

CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)373 Date (java.util.Date)177 JPAService (org.apache.oozie.service.JPAService)153 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)149 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)121 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)114 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)53 CommandException (org.apache.oozie.command.CommandException)49 BundleJobBean (org.apache.oozie.BundleJobBean)46 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)43 IOException (java.io.IOException)39 XConfiguration (org.apache.oozie.util.XConfiguration)38 ArrayList (java.util.ArrayList)36 BundleActionBean (org.apache.oozie.BundleActionBean)36 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)34 Configuration (org.apache.hadoop.conf.Configuration)33 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)32 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)30 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)30 Path (org.apache.hadoop.fs.Path)24