Search in sources :

Example 21 with JPAExecutorException

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

the class TestActionUserRetry method testUserRetry.

public void testUserRetry() throws JPAExecutorException, IOException, CommandException {
    Configuration conf = new XConfiguration();
    String workflowUri = getTestCaseFileUri("workflow.xml");
    // @formatter:off
    String appXml = "<workflow-app xmlns=\"uri:oozie:workflow:0.3\" name=\"wf-fork\">" + "<start to=\"fork1\"/>" + "<fork name=\"fork1\">" + "<path start=\"action1\"/>" + "<path start=\"action2\"/>" + "</fork>" + "<action name=\"action1\" retry-max=\"2\" retry-interval=\"0\">" + "<test xmlns=\"uri:test\">" + "<signal-value>${wf:conf('signal-value')}</signal-value>" + "<external-status>${wf:conf('external-status')}</external-status> " + "<error>${wf:conf('error')}</error>" + "<avoid-set-execution-data>${wf:conf('avoid-set-execution-data')}</avoid-set-execution-data>" + "<avoid-set-end-data>${wf:conf('avoid-set-end-data')}</avoid-set-end-data>" + "<running-mode>${wf:conf('running-mode')}</running-mode>" + "</test>" + "<ok to=\"join1\"/>" + "<error to=\"kill\"/>" + "</action>" + "<action name=\"action2\">" + "<fs></fs><ok to=\"join1\"/>" + "<error to=\"kill\"/>" + "</action>" + "<join name=\"join1\" to=\"end\"/>" + "<kill name=\"kill\"><message>killed</message></kill>" + "<end name=\"end\"/>" + "</workflow-app>";
    // @Formatter:on
    writeToFile(appXml, workflowUri);
    conf.set(OozieClient.APP_PATH, workflowUri);
    conf.set(OozieClient.USER_NAME, getTestUser());
    conf.set("error", "start.error");
    conf.set("external-status", "error");
    conf.set("signal-value", "based_on_action_status");
    SubmitXCommand sc = new SubmitXCommand(conf);
    final String jobId = sc.call();
    new StartXCommand(jobId).call();
    final WorkflowActionsGetForJobJPAExecutor actionsGetExecutor = new WorkflowActionsGetForJobJPAExecutor(jobId);
    final JPAService jpaService = Services.get().get(JPAService.class);
    waitFor(20 * 1000, new Predicate() {

        public boolean evaluate() throws Exception {
            List<WorkflowActionBean> actions = jpaService.execute(actionsGetExecutor);
            WorkflowActionBean action = null;
            for (WorkflowActionBean bean : actions) {
                if (bean.getType().equals("test")) {
                    action = bean;
                    break;
                }
            }
            return (action != null && action.getUserRetryCount() == 2);
        }
    });
    List<WorkflowActionBean> actions = jpaService.execute(actionsGetExecutor);
    WorkflowActionBean action = null;
    for (WorkflowActionBean bean : actions) {
        if (bean.getType().equals("test")) {
            action = bean;
            break;
        }
    }
    assertNotNull(action);
    assertEquals(2, action.getUserRetryCount());
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) WorkflowActionsGetForJobJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionsGetForJobJPAExecutor) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) List(java.util.List) JPAService(org.apache.oozie.service.JPAService) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException) CommandException(org.apache.oozie.command.CommandException) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 22 with JPAExecutorException

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

the class TestCoordRerunXCommand method addRecordToCoordJobTableWithPausedTime.

protected CoordinatorJobBean addRecordToCoordJobTableWithPausedTime(CoordinatorJob.Status status, boolean pending, boolean doneMatd, Date pausedTime) throws Exception {
    CoordinatorJobBean coordJob = createCoordJob(status, pending, doneMatd);
    coordJob.setPauseTime(pausedTime);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(coordJob);
        jpaService.execute(coordInsertCmd);
    } catch (JPAExecutorException je) {
        je.printStackTrace();
        fail("Unable to insert the test coord job record to table");
        throw je;
    }
    return coordJob;
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordJobInsertJPAExecutor(org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 23 with JPAExecutorException

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

the class TestCoordUpdateXCommand method setUpBundleAndGetCoordID.

private String setUpBundleAndGetCoordID(XConfiguration jobConf) throws UnsupportedEncodingException, IOException, CommandException, JPAExecutorException {
    final Path coordPath1 = new Path(getFsTestCaseDir(), "coord1");
    final Path coordPath2 = new Path(getFsTestCaseDir(), "coord2");
    writeCoordXml(coordPath1, "coord-multiple-input-instance3.xml");
    writeCoordXml(coordPath2, "coord-multiple-input-instance3.xml");
    Path bundleAppPath = new Path(getFsTestCaseDir(), "bundle");
    String bundleAppXml = getBundleXml("bundle-submit-job.xml");
    assertNotNull(bundleAppXml);
    assertTrue(bundleAppXml.length() > 0);
    bundleAppXml = bundleAppXml.replaceAll("#app_path1", Matcher.quoteReplacement(new Path(coordPath1.toString(), "coordinator.xml").toString()));
    bundleAppXml = bundleAppXml.replaceAll("#app_path2", Matcher.quoteReplacement(new Path(coordPath2.toString(), "coordinator.xml").toString()));
    writeToFile(bundleAppXml, bundleAppPath, "bundle.xml");
    final Path appPath = new Path(bundleAppPath, "bundle.xml");
    jobConf.set(OozieClient.BUNDLE_APP_PATH, appPath.toString());
    jobConf.set("appName", "test");
    jobConf.set(OozieClient.USER_NAME, getTestUser());
    jobConf.set("coordName1", "NAME");
    jobConf.set("coordName2", "coord2");
    jobConf.set("isEnabled", "true");
    BundleSubmitXCommand command = new BundleSubmitXCommand(jobConf);
    final BundleJobBean bundleBean = (BundleJobBean) command.getJob();
    bundleBean.setStartTime(new Date());
    bundleBean.setEndTime(new Date());
    final String jobId = command.call();
    sleep(2000);
    new BundleStartXCommand(jobId).call();
    waitFor(200000, new Predicate() {

        public boolean evaluate() throws Exception {
            List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, jobId);
            return actions.get(0).getStatus().equals(Job.Status.RUNNING);
        }
    });
    final List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, jobId);
    return actions.get(0).getCoordId();
}
Also used : Path(org.apache.hadoop.fs.Path) BundleSubmitXCommand(org.apache.oozie.command.bundle.BundleSubmitXCommand) BundleStartXCommand(org.apache.oozie.command.bundle.BundleStartXCommand) BundleJobBean(org.apache.oozie.BundleJobBean) List(java.util.List) BundleActionBean(org.apache.oozie.BundleActionBean) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException) XException(org.apache.oozie.XException) CommandException(org.apache.oozie.command.CommandException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 24 with JPAExecutorException

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

the class TestCoordActionStartXCommand method checkCoordAction.

private void checkCoordAction(String actionId) {
    try {
        final JPAService jpaService = Services.get().get(JPAService.class);
        CoordinatorActionBean action = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
        if (action.getStatus() == CoordinatorAction.Status.SUBMITTED) {
            fail("CoordActionStartCommand didn't work because the status for action id" + actionId + " is :" + action.getStatus() + " expected to be NOT SUBMITTED (i.e. RUNNING)");
        }
        if (action.getExternalId() != null) {
            WorkflowJobBean wfJob = jpaService.execute(new WorkflowJobGetJPAExecutor(action.getExternalId()));
            assertEquals(wfJob.getParentId(), action.getId());
        }
    } catch (JPAExecutorException je) {
        fail("Action ID " + actionId + " was not stored properly in db");
    }
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordActionGetJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean)

Example 25 with JPAExecutorException

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

the class TestCoordActionUpdatePushMissingDependency method checkCoordAction.

private CoordinatorActionBean checkCoordAction(String actionId, String expDeps, CoordinatorAction.Status stat) throws Exception {
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        CoordinatorActionBean action = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
        String missDeps = action.getPushMissingDependencies();
        assertEquals(missDeps, expDeps);
        assertEquals(action.getStatus(), stat);
        return action;
    } catch (JPAExecutorException se) {
        throw new Exception("Action ID " + actionId + " was not stored properly in db");
    }
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordActionGetJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Aggregations

JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)195 JPAService (org.apache.oozie.service.JPAService)137 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)65 CommandException (org.apache.oozie.command.CommandException)63 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)55 Date (java.util.Date)53 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)49 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)45 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)43 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)37 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)33 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)31 IOException (java.io.IOException)26 BundleJobBean (org.apache.oozie.BundleJobBean)24 CoordJobInsertJPAExecutor (org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor)19 BundleActionBean (org.apache.oozie.BundleActionBean)18 Configuration (org.apache.hadoop.conf.Configuration)15 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)15 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)14 XConfiguration (org.apache.oozie.util.XConfiguration)14