Search in sources :

Example 11 with BundleJobBean

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

the class TestStatusTransitService method testBundleStatusTransitServiceSucceeded1.

/**
 * Test : all bundle actions are succeeded - bundle job's status will be updated to succeeded.
 *
 * @throws Exception
 */
public void testBundleStatusTransitServiceSucceeded1() throws Exception {
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.RUNNING, false);
    final JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    final String jobId = job.getId();
    BundleActionBean ba1 = addRecordToBundleActionTable(jobId, "action1", 0, Job.Status.SUCCEEDED);
    addRecordToBundleActionTable(jobId, "action2", 0, Job.Status.SUCCEEDED);
    addRecordToBundleActionTable(jobId, "action3", 0, Job.Status.SUCCEEDED);
    Runnable runnable = new StatusTransitRunnable();
    runnable.run();
    waitFor(5 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
            return bundle.getStatus().equals(Job.Status.SUCCEEDED);
        }
    });
    job = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
    assertEquals(Job.Status.SUCCEEDED, job.getStatus());
}
Also used : BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) BundleJobBean(org.apache.oozie.BundleJobBean) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) BundleActionBean(org.apache.oozie.BundleActionBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Example 12 with BundleJobBean

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

the class TestStatusTransitService method testBundleStatusTransitServicePaused.

/**
 * Test : Check the transition of a PAUSEDWITHERROR bundle job to PAUSED
 * @throws Exception
 */
public void testBundleStatusTransitServicePaused() throws Exception {
    Services.get().destroy();
    setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
    services = new Services();
    setClassesToBeExcluded(services.getConf(), excludedServices);
    services.init();
    BundleJobBean bundleJob = createBundleJob(Job.Status.PAUSEDWITHERROR, true);
    bundleJob.setPauseTime(DateUtils.parseDateOozieTZ("2009-02-01T01:00Z"));
    final JPAService jpaService = Services.get().get(JPAService.class);
    BundleJobInsertJPAExecutor bundleInsertjpa = new BundleJobInsertJPAExecutor(bundleJob);
    jpaService.execute(bundleInsertjpa);
    final String bundleId = bundleJob.getId();
    addRecordToBundleActionTable(bundleId, "action1", 1, Job.Status.PAUSED);
    addRecordToBundleActionTable(bundleId, "action2", 1, Job.Status.PAUSED);
    addRecordToBundleActionTable(bundleId, "action3", 0, Job.Status.SUCCEEDED);
    Runnable runnable = new StatusTransitRunnable();
    runnable.run();
    waitFor(5 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
            return bundle.getStatus() == Job.Status.PAUSED;
        }
    });
    bundleJob = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
    assertEquals(Job.Status.PAUSED, bundleJob.getStatus());
}
Also used : BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) BundleJobBean(org.apache.oozie.BundleJobBean) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) BundleJobInsertJPAExecutor(org.apache.oozie.executor.jpa.BundleJobInsertJPAExecutor) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Example 13 with BundleJobBean

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

the class TestStatusTransitService method testBundleStatusTransitServiceSuspendedWithError.

/**
 * Test : Check the transition of a bundle job from RUNNING TO SUSPENDEDWITHERROR
 * @throws Exception
 */
public void testBundleStatusTransitServiceSuspendedWithError() throws Exception {
    Services.get().destroy();
    setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
    services = new Services();
    setClassesToBeExcluded(services.getConf(), excludedServices);
    services.init();
    BundleJobBean bundleJob = this.addRecordToBundleJobTable(Job.Status.RUNNING, true);
    final JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    final String bundleId = bundleJob.getId();
    addRecordToBundleActionTable(bundleId, "action1", 0, Job.Status.SUSPENDED);
    addRecordToBundleActionTable(bundleId, "action2", 0, Job.Status.SUSPENDEDWITHERROR);
    Runnable runnable = new StatusTransitRunnable();
    runnable.run();
    waitFor(5 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
            return bundle.isPending() == false;
        }
    });
    bundleJob = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
    assertFalse(bundleJob.isPending());
    assertEquals(Job.Status.SUSPENDEDWITHERROR, bundleJob.getStatus());
}
Also used : BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) BundleJobBean(org.apache.oozie.BundleJobBean) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Example 14 with BundleJobBean

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

the class TestAuthorizationService method testAuthorizationServiceForBundle.

public void testAuthorizationServiceForBundle() throws Exception {
    init(false, true);
    BundleJobBean job = this.addRecordToBundleJobTable(Job.Status.PREP, false);
    assertNotNull(job);
    AuthorizationService as = services.get(AuthorizationService.class);
    assertNotNull(as);
    as.authorizeForJob(getTestUser(), job.getId(), false);
    as.authorizeForJob(getTestUser(), job.getId(), true);
}
Also used : BundleJobBean(org.apache.oozie.BundleJobBean)

Example 15 with BundleJobBean

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

the class TestJMSTopicService method testMixedTopic1.

@Test
public void testMixedTopic1() throws Exception {
    services = setupServicesForTopic();
    services.getConf().set(JMSTopicService.TOPIC_NAME, JMSTopicService.JobType.WORKFLOW.getValue() + " = workflow," + JMSTopicService.JobType.COORDINATOR.getValue() + "=coord, default = " + JMSTopicService.TopicType.JOBID.getValue());
    services.init();
    JMSTopicService jmsTopicService = Services.get().get(JMSTopicService.class);
    WorkflowJobBean wfj = addRecordToWfJobTable(WorkflowJob.Status.SUCCEEDED, WorkflowInstance.Status.SUCCEEDED);
    assertEquals("workflow", jmsTopicService.getTopic(wfj.getId()));
    assertEquals("workflow", jmsTopicService.getTopic(AppType.WORKFLOW_JOB, wfj.getUser(), wfj.getId(), null));
    WorkflowActionBean wab = addRecordToWfActionTable(wfj.getId(), "1", WorkflowAction.Status.RUNNING);
    assertEquals("workflow", jmsTopicService.getTopic(wab.getId()));
    assertEquals("workflow", jmsTopicService.getTopic(AppType.WORKFLOW_ACTION, wfj.getUser(), wab.getId(), wab.getWfId()));
    CoordinatorJobBean cjb = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, true, true);
    assertEquals("coord", jmsTopicService.getTopic(cjb.getId()));
    assertEquals("coord", jmsTopicService.getTopic(AppType.COORDINATOR_JOB, cjb.getUser(), cjb.getId(), null));
    CoordinatorActionBean cab = addRecordToCoordActionTable(cjb.getId(), 1, CoordinatorAction.Status.SUCCEEDED, "coord-action-for-action-input-check.xml", 0);
    assertEquals("coord", jmsTopicService.getTopic(cab.getId()));
    assertEquals("coord", jmsTopicService.getTopic(AppType.COORDINATOR_ACTION, cjb.getUser(), cab.getId(), cab.getJobId()));
    BundleJobBean bjb = addRecordToBundleJobTable(Job.Status.RUNNING, true);
    assertEquals(bjb.getId(), jmsTopicService.getTopic(bjb.getId()));
    assertEquals(bjb.getId(), jmsTopicService.getTopic(AppType.BUNDLE_JOB, bjb.getUser(), bjb.getId(), null));
    BundleActionBean bab = addRecordToBundleActionTable(bjb.getId(), "1", 1, Job.Status.RUNNING);
    assertEquals(bjb.getId(), jmsTopicService.getTopic(bab.getBundleActionId()));
    assertEquals(bjb.getId(), jmsTopicService.getTopic(AppType.BUNDLE_ACTION, bjb.getUser(), bab.getBundleActionId(), bab.getBundleId()));
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) BundleJobBean(org.apache.oozie.BundleJobBean) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) BundleActionBean(org.apache.oozie.BundleActionBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) Test(org.junit.Test)

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