Search in sources :

Example 41 with WorkflowActionGetJPAExecutor

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

the class TestActionStartXCommand method testActionWithEscapedStringAndCDATA.

/**
 * Test workflow action with CDATA section and string configuration that needs to be escaped can be submitted without
 * throwing exceptions.
 * <p/>
 * Escaped string needs to be 'escaped' before converting to XML Document, otherwise,
 * exception will be thrown.
 * @see org.apache.oozie.DagELFunctions#configureEvaluator(org.apache.oozie.util.ELEvaluator.ELEvaluator evaluator,
 *  org.apache.oozie.WorkflowJobBean, org.apache.oozie.WorkflowActionBean)
 *
 * @throws Exception thrown if failed to execute test case
 */
public void testActionWithEscapedStringAndCDATA() throws Exception {
    // create workflow job and action beans with escaped parameters and CDATA value
    JPAService jpaService = Services.get().get(JPAService.class);
    WorkflowJobBean job = this.addRecordToWfJobTableWithEscapedStringAndCDATA(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action = this.addRecordToWfActionTableWithEscapedStringAndCDATA(job.getId(), WorkflowAction.Status.PREP);
    WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
    // start workflow action
    new ActionStartXCommand(action.getId(), "map-reduce").call();
    action = jpaService.execute(wfActionGetCmd);
    assertNotNull(action.getExternalId());
    ActionExecutorContext context = new ActionXCommand.ActionExecutorContext(job, action, false, false);
    MapReduceActionExecutor actionExecutor = new MapReduceActionExecutor();
    Configuration conf = actionExecutor.createBaseHadoopConf(context, XmlUtils.parseXml(action.getConf()));
    String user = conf.get("user.name");
    String launcherId = action.getExternalId();
    waitUntilYarnAppDoneAndAssertSuccess(launcherId);
    Map<String, String> actionData = LauncherHelper.getActionData(getFileSystem(), context.getActionDir(), conf);
    assertTrue(LauncherHelper.hasIdSwap(actionData));
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) MapReduceActionExecutor(org.apache.oozie.action.hadoop.MapReduceActionExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) ActionExecutorContext(org.apache.oozie.command.wf.ActionXCommand.ActionExecutorContext)

Example 42 with WorkflowActionGetJPAExecutor

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

the class TestActionStartXCommand method testActionStart.

public void testActionStart() throws Exception {
    JPAService jpaService = Services.get().get(JPAService.class);
    WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.PREP);
    WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
    new ActionStartXCommand(action.getId(), "map-reduce").call();
    action = jpaService.execute(wfActionGetCmd);
    assertNotNull(action.getExternalId());
    ActionExecutorContext context = new ActionXCommand.ActionExecutorContext(job, action, false, false);
    MapReduceActionExecutor actionExecutor = new MapReduceActionExecutor();
    Configuration conf = actionExecutor.createBaseHadoopConf(context, XmlUtils.parseXml(action.getConf()));
    String launcherId = action.getExternalId();
    waitUntilYarnAppDoneAndAssertSuccess(launcherId);
    Map<String, String> actionData = LauncherHelper.getActionData(getFileSystem(), context.getActionDir(), conf);
    assertTrue(LauncherHelper.hasIdSwap(actionData));
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) MapReduceActionExecutor(org.apache.oozie.action.hadoop.MapReduceActionExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) ActionExecutorContext(org.apache.oozie.command.wf.ActionXCommand.ActionExecutorContext)

Example 43 with WorkflowActionGetJPAExecutor

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

the class TestWorkflowActionKillXCommand method testWfActionKillFailed.

/**
 * Test : kill a non-killed action. Will throw the exception from {@link
 * WorkflowActionKillXCommand.verifyPrecondition()}
 *
 * @throws Exception
 */
public void testWfActionKillFailed() throws Exception {
    String externalJobID = launchSleepJob(1000);
    WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), externalJobID, "1", WorkflowAction.Status.RUNNING, null);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
    action = jpaService.execute(wfActionGetCmd);
    assertEquals(action.getStatus(), WorkflowAction.Status.RUNNING);
    assertEquals(action.getExternalStatus(), "RUNNING");
    new ActionKillXCommand(action.getId()).call();
    // action is not in KILLED, action status must not change
    action = jpaService.execute(wfActionGetCmd);
    assertEquals(action.getStatus(), WorkflowAction.Status.RUNNING);
    assertEquals(action.getExternalStatus(), "RUNNING");
}
Also used : WorkflowActionGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 44 with WorkflowActionGetJPAExecutor

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

the class TestWorkflowKillXCommand method testWfKillSuccess2.

/**
 * Test : kill RUNNING job and RUNNING action successfully.
 *
 * @throws Exception
 */
public void testWfKillSuccess2() throws Exception {
    WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
    WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.RUNNING);
    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.RUNNING);
    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 45 with WorkflowActionGetJPAExecutor

use of org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor 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)

Aggregations

WorkflowActionBean (org.apache.oozie.WorkflowActionBean)51 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)51 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)47 JPAService (org.apache.oozie.service.JPAService)47 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)38 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)35 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)22 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)21 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)21 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)20 BundleActionBean (org.apache.oozie.BundleActionBean)9 BundleJobBean (org.apache.oozie.BundleJobBean)9 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)9 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)9 WorkflowInstance (org.apache.oozie.workflow.WorkflowInstance)9 Configuration (org.apache.hadoop.conf.Configuration)6 MapReduceActionExecutor (org.apache.oozie.action.hadoop.MapReduceActionExecutor)6 ActionExecutorContext (org.apache.oozie.command.wf.ActionXCommand.ActionExecutorContext)6 LiteWorkflowInstance (org.apache.oozie.workflow.lite.LiteWorkflowInstance)5 Date (java.util.Date)3