Search in sources :

Example 1 with AbandonedCoordCheckerRunnable

use of org.apache.oozie.service.AbandonedCoordCheckerService.AbandonedCoordCheckerRunnable 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 2 with AbandonedCoordCheckerRunnable

use of org.apache.oozie.service.AbandonedCoordCheckerService.AbandonedCoordCheckerRunnable in project oozie by apache.

the class TestAbandonedCoordChecker method testCatchupJob.

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

Example 3 with AbandonedCoordCheckerRunnable

use of org.apache.oozie.service.AbandonedCoordCheckerService.AbandonedCoordCheckerRunnable in project oozie by apache.

the class TestAbandonedCoordChecker method testStartTime.

public void testStartTime() throws Exception {
    Date start = DateUtils.addDays(new Date(), 1);
    Date end = DateUtils.addDays(new Date(), 6);
    Date createdTime = new Date();
    CoordinatorJobBean job1 = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, createdTime, true, false, 6);
    addRecordToCoordActionTable(job1.getId(), 6, CoordinatorAction.Status.FAILED);
    start = DateUtils.addDays(new Date(), -3);
    createdTime = DateUtils.addDays(new Date(), -4);
    CoordinatorJobBean job2 = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, createdTime, true, false, 4);
    addRecordToCoordActionTable(job2.getId(), 10, CoordinatorAction.Status.FAILED);
    new AbandonedCoordCheckerRunnable(5, true).run();
    // job1 should be RUNNING as starttime > 2 days buffer
    assertEquals(CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, job1.getId()).getStatus(), CoordinatorJob.Status.RUNNING);
    assertEquals(CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, job2.getId()).getStatus(), CoordinatorJob.Status.KILLED);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) Date(java.util.Date) AbandonedCoordCheckerRunnable(org.apache.oozie.service.AbandonedCoordCheckerService.AbandonedCoordCheckerRunnable)

Aggregations

Date (java.util.Date)3 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)3 AbandonedCoordCheckerRunnable (org.apache.oozie.service.AbandonedCoordCheckerService.AbandonedCoordCheckerRunnable)3