Search in sources :

Example 46 with WorkflowJobGetJPAExecutor

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

the class TestWorkflowKillXCommand method testWfKillFailedToLoadJob.

/**
 * Test : kill job failed to load the job.
 *
 * @throws Exception
 */
public void testWfKillFailedToLoadJob() throws Exception {
    final String testWfId = "0000001-" + new Date().getTime() + "-testWfKill-W";
    WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.OK);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(job.getId());
    WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
    job = jpaService.execute(wfJobGetCmd);
    action = jpaService.execute(wfActionGetCmd);
    assertEquals(job.getStatus(), WorkflowJob.Status.RUNNING);
    assertEquals(action.getStatus(), WorkflowAction.Status.OK);
    WorkflowInstance wfInstance = job.getWorkflowInstance();
    assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.RUNNING);
    try {
        new KillXCommand(testWfId).call();
        fail("Job doesn't exist. Should fail.");
    } catch (CommandException ce) {
    }
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) CommandException(org.apache.oozie.command.CommandException) JPAService(org.apache.oozie.service.JPAService) WorkflowInstance(org.apache.oozie.workflow.WorkflowInstance) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) Date(java.util.Date) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 47 with WorkflowJobGetJPAExecutor

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

the class TestWorkflowKillXCommand method testWfKillSuccess1.

/**
 * Test : kill RUNNING job and PREP action successfully.
 *
 * @throws Exception
 */
public void testWfKillSuccess1() throws Exception {
    WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.PREP);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(job.getId());
    WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
    job = jpaService.execute(wfJobGetCmd);
    action = jpaService.execute(wfActionGetCmd);
    assertEquals(job.getStatus(), WorkflowJob.Status.RUNNING);
    assertEquals(action.getStatus(), WorkflowAction.Status.PREP);
    WorkflowInstance wfInstance = job.getWorkflowInstance();
    assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.RUNNING);
    new KillXCommand(job.getId()).call();
    job = jpaService.execute(wfJobGetCmd);
    action = jpaService.execute(wfActionGetCmd);
    assertEquals(job.getStatus(), WorkflowJob.Status.KILLED);
    assertEquals(action.getStatus(), WorkflowAction.Status.KILLED);
    wfInstance = job.getWorkflowInstance();
    assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.KILLED);
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowInstance(org.apache.oozie.workflow.WorkflowInstance) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 48 with WorkflowJobGetJPAExecutor

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

the class TestWorkflowKillXCommand method testWfKillSuccessAfterNodeDefUpgrade.

/**
 * Test : kill RUNNING job after NodeDef upgrade.
 *
 * @throws Exception
 */
public void testWfKillSuccessAfterNodeDefUpgrade() throws Exception {
    services.destroy();
    setSystemProperty(LiteWorkflowStoreService.CONF_NODE_DEF_VERSION, LiteWorkflowStoreService.NODE_DEF_VERSION_0);
    services = new Services();
    services.init();
    WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.PREP);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(job.getId());
    WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
    job = jpaService.execute(wfJobGetCmd);
    action = jpaService.execute(wfActionGetCmd);
    assertEquals(job.getStatus(), WorkflowJob.Status.RUNNING);
    assertEquals(action.getStatus(), WorkflowAction.Status.PREP);
    WorkflowInstance wfInstance = job.getWorkflowInstance();
    assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.RUNNING);
    services.destroy();
    sleep(5000);
    setSystemProperty(LiteWorkflowStoreService.CONF_NODE_DEF_VERSION, LiteWorkflowStoreService.NODE_DEF_VERSION_1);
    services = new Services();
    services.init();
    sleep(5000);
    new KillXCommand(job.getId()).call();
    jpaService = Services.get().get(JPAService.class);
    job = jpaService.execute(wfJobGetCmd);
    action = jpaService.execute(wfActionGetCmd);
    assertEquals(job.getStatus(), WorkflowJob.Status.KILLED);
    assertEquals(action.getStatus(), WorkflowAction.Status.KILLED);
    wfInstance = job.getWorkflowInstance();
    assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.KILLED);
    services.destroy();
    sleep(5000);
    setSystemProperty(LiteWorkflowStoreService.CONF_NODE_DEF_VERSION, LiteWorkflowStoreService.NODE_DEF_VERSION_2);
    services = new Services();
    services.init();
    sleep(5000);
    jpaService = Services.get().get(JPAService.class);
    job = jpaService.execute(wfJobGetCmd);
    action = jpaService.execute(wfActionGetCmd);
    assertEquals(job.getStatus(), WorkflowJob.Status.KILLED);
    assertEquals(action.getStatus(), WorkflowAction.Status.KILLED);
    wfInstance = job.getWorkflowInstance();
    assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.KILLED);
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) Services(org.apache.oozie.service.Services) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowInstance(org.apache.oozie.workflow.WorkflowInstance) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 49 with WorkflowJobGetJPAExecutor

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

the class TestWorkflowKillXCommand method testWfKillFailed.

/**
 * Test : kill job but failed to kill an already successful action.
 *
 * @throws Exception
 */
public void testWfKillFailed() throws Exception {
    WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.OK);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(job.getId());
    WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
    job = jpaService.execute(wfJobGetCmd);
    action = jpaService.execute(wfActionGetCmd);
    assertEquals(job.getStatus(), WorkflowJob.Status.RUNNING);
    assertEquals(action.getStatus(), WorkflowAction.Status.OK);
    WorkflowInstance wfInstance = job.getWorkflowInstance();
    assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.RUNNING);
    new KillXCommand(job.getId()).call();
    job = jpaService.execute(wfJobGetCmd);
    action = jpaService.execute(wfActionGetCmd);
    assertEquals(job.getStatus(), WorkflowJob.Status.KILLED);
    assertEquals(action.getStatus(), WorkflowAction.Status.OK);
    wfInstance = job.getWorkflowInstance();
    assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.KILLED);
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowInstance(org.apache.oozie.workflow.WorkflowInstance) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 50 with WorkflowJobGetJPAExecutor

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

the class TestEventGeneration method testForNoDuplicatesWorkflowEvents.

@Test
public void testForNoDuplicatesWorkflowEvents() throws Exception {
    // test workflow job events
    Reader reader = IOUtils.getResourceAsReader("wf-no-op.xml", -1);
    Writer writer = new FileWriter(getTestCaseDir() + "/workflow.xml");
    IOUtils.copyCharStream(reader, writer);
    final DagEngine engine = new DagEngine(getTestUser());
    Configuration conf = new XConfiguration();
    conf.set(OozieClient.APP_PATH, getTestCaseFileUri("workflow.xml"));
    conf.set(OozieClient.USER_NAME, getTestUser());
    final String jobId1 = engine.submitJob(conf, true);
    final WorkflowJobGetJPAExecutor readCmd = new WorkflowJobGetJPAExecutor(jobId1);
    waitFor(1 * 100, new Predicate() {

        @Override
        public boolean evaluate() throws Exception {
            return jpaService.execute(readCmd).getStatus() == WorkflowJob.Status.SUCCEEDED;
        }
    });
    assertEquals(2, queue.size());
    assertEquals(EventStatus.STARTED, ((JobEvent) queue.poll()).getEventStatus());
    assertEquals(EventStatus.SUCCESS, ((JobEvent) queue.poll()).getEventStatus());
    queue.clear();
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) XConfiguration(org.apache.oozie.util.XConfiguration) DagEngine(org.apache.oozie.DagEngine) Configuration(org.apache.hadoop.conf.Configuration) XConfiguration(org.apache.oozie.util.XConfiguration) FileWriter(java.io.FileWriter) Reader(java.io.Reader) Writer(java.io.Writer) FileWriter(java.io.FileWriter) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CommandException(org.apache.oozie.command.CommandException) Test(org.junit.Test)

Aggregations

WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)60 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)58 JPAService (org.apache.oozie.service.JPAService)49 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)45 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)42 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)38 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)30 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)29 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)25 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)23 BundleActionBean (org.apache.oozie.BundleActionBean)13 BundleJobBean (org.apache.oozie.BundleJobBean)13 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)13 Date (java.util.Date)12 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)12 Configuration (org.apache.hadoop.conf.Configuration)10 WorkflowInstance (org.apache.oozie.workflow.WorkflowInstance)10 XConfiguration (org.apache.oozie.util.XConfiguration)8 LiteWorkflowInstance (org.apache.oozie.workflow.lite.LiteWorkflowInstance)6 FileWriter (java.io.FileWriter)5