Search in sources :

Example 11 with CoordJobGetJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.

the class TestStatusTransitService method testCoordStatusTransitServiceSuspendedBottomUp.

/**
 * Test : coord actions suspended and 1 succeeded - check status change to SUSPENDED and pending update to false
 *
 * @throws Exception
 */
public void testCoordStatusTransitServiceSuspendedBottomUp() throws Exception {
    String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
    Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, true, true, 4);
    addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.SUSPENDED, "coord-action-get.xml", 0);
    addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.SUSPENDED, "coord-action-get.xml", 0);
    addRecordToCoordActionTable(job.getId(), 3, CoordinatorAction.Status.SUSPENDED, "coord-action-get.xml", 0);
    addRecordToCoordActionTable(job.getId(), 4, CoordinatorAction.Status.SUCCEEDED, "coord-action-get.xml", 0);
    final String jobId = job.getId();
    final JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    Runnable runnable = new StatusTransitRunnable();
    runnable.run();
    // Keeping wait time to 20s to ensure status is updated
    waitFor(20 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJobBean coordJob = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
            return coordJob.getStatus() == CoordinatorJob.Status.SUSPENDED;
        }
    });
    CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
    job = jpaService.execute(coordGetCmd);
    assertEquals(CoordinatorJob.Status.SUSPENDED, job.getStatus());
    assertFalse(job.isPending());
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Example 12 with CoordJobGetJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.

the class TestStatusTransitService method testCoordStatusTransitRunningFromKilled.

// Test coord transition from killed to running when one action is rerun.
public void testCoordStatusTransitRunningFromKilled() throws Exception {
    final JPAService jpaService = Services.get().get(JPAService.class);
    String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
    Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    CoordinatorJobBean coordJob = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 1);
    final CoordinatorActionBean coordAction = addRecordToCoordActionTable(coordJob.getId(), 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", null, "RUNNING", 0);
    new CoordKillXCommand(coordJob.getId()).call();
    final CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(coordJob.getId());
    waitFor(5 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJobBean coordJob = jpaService.execute(coordJobGetCmd);
            return coordJob.getStatusStr().equals("KILLED");
        }
    });
    Runnable runnable = new StatusTransitRunnable();
    runnable.run();
    sleep(1000);
    coordJob = jpaService.execute(coordJobGetCmd);
    assertEquals(CoordinatorJob.Status.KILLED, coordJob.getStatus());
    coordAction.setStatus(CoordinatorAction.Status.RUNNING);
    coordJob.setPending();
    CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_STATUS_PENDING, coordJob);
    CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION, coordAction);
    runnable.run();
    sleep(1000);
    coordJob = jpaService.execute(coordJobGetCmd);
    assertEquals(CoordinatorJob.Status.RUNNING, coordJob.getStatus());
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordKillXCommand(org.apache.oozie.command.coord.CoordKillXCommand) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Example 13 with CoordJobGetJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.

the class TestCoordMaterializeTriggerService method testCoordMaterializeTriggerService1.

/**
 * Tests functionality of the CoordMaterializeTriggerService Runnable
 * command. </p> Insert a coordinator job with PREP. Then, runs the
 * CoordMaterializeTriggerService runnable and ensures the job status
 * changes to RUNNING.
 *
 * @throws Exception
 */
public void testCoordMaterializeTriggerService1() throws Exception {
    Date start = DateUtils.parseDateOozieTZ("2009-02-01T01:00Z");
    Date end = DateUtils.parseDateOozieTZ("2009-02-20T23:59Z");
    final CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.PREP, start, end, false, false, 0);
    waitForStatus(30000, job, CoordinatorJob.Status.PREP);
    Runnable runnable = new CoordMaterializeTriggerRunnable(3600, 300);
    runnable.run();
    waitForStatus(10000, job, CoordinatorJob.Status.RUNNING);
    CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
    CoordinatorJobBean coordJob = jpaService.execute(coordGetCmd);
    assertEquals(CoordinatorJob.Status.RUNNING, coordJob.getStatus());
    int numWaitingActions = jpaService.execute(new CoordJobGetRunningActionsCountJPAExecutor(coordJob.getId()));
    assert (numWaitingActions <= coordJob.getMatThrottling());
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordMaterializeTriggerRunnable(org.apache.oozie.service.CoordMaterializeTriggerService.CoordMaterializeTriggerRunnable) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) CoordMaterializeTriggerRunnable(org.apache.oozie.service.CoordMaterializeTriggerService.CoordMaterializeTriggerRunnable) CoordJobGetRunningActionsCountJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetRunningActionsCountJPAExecutor) Date(java.util.Date)

Example 14 with CoordJobGetJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.

the class TestCoordMaterializeTriggerService method testMaxMatThrottleNotPicked.

public void testMaxMatThrottleNotPicked() throws Exception {
    Services.get().destroy();
    setSystemProperty(CoordMaterializeTriggerService.CONF_MATERIALIZATION_SYSTEM_LIMIT, "10");
    services = new Services();
    services.init();
    jpaService = services.get(JPAService.class);
    Date start = new Date();
    Date end = new Date(start.getTime() + 3600 * 5 * 1000);
    CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, start, end, false, false, 1);
    addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.WAITING, "coord-action-get.xml", 0);
    addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.WAITING, "coord-action-get.xml", 0);
    job.setMatThrottling(3);
    CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, job);
    job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId()));
    Date lastModifiedDate = job.getLastModifiedTime();
    Runnable runnable = new CoordMaterializeTriggerRunnable(3600, 300);
    runnable.run();
    waitForModification(job.getId(), lastModifiedDate);
    job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId()));
    assertNotSame(lastModifiedDate, job.getLastModifiedTime());
    job.setMatThrottling(2);
    CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB, job);
    job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId()));
    lastModifiedDate = job.getLastModifiedTime();
    runnable.run();
    job = jpaService.execute(new CoordJobGetJPAExecutor(job.getId()));
    assertEquals(lastModifiedDate, job.getLastModifiedTime());
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordMaterializeTriggerRunnable(org.apache.oozie.service.CoordMaterializeTriggerService.CoordMaterializeTriggerRunnable) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) CoordMaterializeTriggerRunnable(org.apache.oozie.service.CoordMaterializeTriggerService.CoordMaterializeTriggerRunnable) Date(java.util.Date)

Example 15 with CoordJobGetJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor in project oozie by apache.

the class TestPauseTransitService method testUnpauseBundleAndCoordinator.

/**
 * Test : Unpause a PAUSED bundle, then check bundle action has been updated to RUNNING by BundleStatusUpdateXCommand
 *
 * @throws Exception
 */
public void testUnpauseBundleAndCoordinator() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PAUSED, false);
    final JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    job.setPauseTime(null);
    BundleJobQueryExecutor.getInstance().executeUpdate(BundleJobQuery.UPDATE_BUNDLE_JOB_PAUSE_KICKOFF, job);
    BundleActionBean bundleAction1 = this.addRecordToBundleActionTable(job.getId(), "action1", 0, Job.Status.PAUSED);
    BundleActionBean bundleAction2 = this.addRecordToBundleActionTable(job.getId(), "action2", 0, Job.Status.PAUSED);
    String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
    Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    CoordinatorJobBean coordJob1 = addRecordToCoordJobTable("action1", CoordinatorJob.Status.PAUSED, start, end, false);
    CoordinatorJobBean coordJob2 = addRecordToCoordJobTable("action2", CoordinatorJob.Status.PAUSED, start, end, false);
    coordJob1.setPauseTime(null);
    coordJob1.setBundleId(job.getId());
    CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_BUNDLEID_APPNAMESPACE_PAUSETIME, coordJob1);
    coordJob2.setPauseTime(null);
    coordJob2.setBundleId(job.getId());
    CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_BUNDLEID_APPNAMESPACE_PAUSETIME, coordJob2);
    BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
    job = jpaService.execute(bundleJobGetExecutor);
    assertEquals(Job.Status.PAUSED, job.getStatus());
    Runnable pauseStartRunnable = new PauseTransitRunnable();
    pauseStartRunnable.run();
    final String jobId = job.getId();
    waitFor(10 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            BundleJobBean bJob1 = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
            return bJob1.getStatus() == Job.Status.RUNNING;
        }
    });
    final String coordJobId1 = coordJob1.getId();
    final String coordJobId2 = coordJob2.getId();
    waitFor(10 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJobBean cJob1 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId1));
            CoordinatorJobBean cJob2 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId2));
            return cJob1.getStatus() == Job.Status.RUNNING && cJob2.getStatus() == Job.Status.RUNNING;
        }
    });
    job = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
    assertEquals(Job.Status.RUNNING, job.getStatus());
    coordJob1 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId1));
    assertEquals(Job.Status.RUNNING, coordJob1.getStatus());
    coordJob2 = jpaService.execute(new CoordJobGetJPAExecutor(coordJobId2));
    assertEquals(Job.Status.RUNNING, coordJob2.getStatus());
    bundleAction1 = jpaService.execute(new BundleActionGetJPAExecutor(job.getId(), "action1"));
    assertEquals(Job.Status.RUNNING, bundleAction1.getStatus());
    bundleAction2 = jpaService.execute(new BundleActionGetJPAExecutor(job.getId(), "action2"));
    assertEquals(Job.Status.RUNNING, bundleAction2.getStatus());
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) BundleActionGetJPAExecutor(org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) BundleJobBean(org.apache.oozie.BundleJobBean) PauseTransitRunnable(org.apache.oozie.service.PauseTransitService.PauseTransitRunnable) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) PauseTransitRunnable(org.apache.oozie.service.PauseTransitService.PauseTransitRunnable) JPAService(org.apache.oozie.service.JPAService) BundleActionBean(org.apache.oozie.BundleActionBean)

Aggregations

CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)121 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)114 JPAService (org.apache.oozie.service.JPAService)85 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)79 Date (java.util.Date)66 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)42 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)32 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)30 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)29 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)25 BundleJobBean (org.apache.oozie.BundleJobBean)21 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)21 BundleActionBean (org.apache.oozie.BundleActionBean)20 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)20 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)20 CommandException (org.apache.oozie.command.CommandException)18 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)16 IOException (java.io.IOException)5 CoordMaterializeTriggerRunnable (org.apache.oozie.service.CoordMaterializeTriggerService.CoordMaterializeTriggerRunnable)5 Services (org.apache.oozie.service.Services)5