Search in sources :

Example 66 with JPAExecutorException

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

the class XDataTestCase method addRecordToCoordJobTableForWaiting.

protected CoordinatorJobBean addRecordToCoordJobTableForWaiting(String testFileName, CoordinatorJobBean coordJob) throws Exception {
    String testDir = getTestCaseDir();
    String appXml = getCoordJobXmlForWaiting(testFileName, testDir);
    coordJob.setJobXml(appXml);
    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 : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordJobInsertJPAExecutor(org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 67 with JPAExecutorException

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

the class XDataTestCase method addRecordToBundleActionTable.

/**
 * Create bundle action bean and save to db
 *
 * @param jobId bundle job id
 * @param coordName coordinator name
 * @param pending true if action is pending
 * @param status job status
 * @return bundle action bean
 * @throws Exception
 */
protected BundleActionBean addRecordToBundleActionTable(String jobId, String coordName, int pending, Job.Status status) throws Exception {
    BundleActionBean action = createBundleAction(jobId, null, coordName, pending, status);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        BundleActionInsertJPAExecutor bundleActionJPAExecutor = new BundleActionInsertJPAExecutor(action);
        jpaService.execute(bundleActionJPAExecutor);
    } catch (JPAExecutorException ex) {
        ex.printStackTrace();
        fail("Unable to insert the test bundle action record to table");
        throw ex;
    }
    return action;
}
Also used : BundleActionInsertJPAExecutor(org.apache.oozie.executor.jpa.BundleActionInsertJPAExecutor) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) JPAService(org.apache.oozie.service.JPAService) BundleActionBean(org.apache.oozie.BundleActionBean)

Example 68 with JPAExecutorException

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

the class XDataTestCase method addRecordToCoordJobTableWithBundle.

/**
 * Add coordinator job bean with bundle id info.
 *
 * @param bundleId bundle id
 * @param coordId coord id and coord name
 * @param status job status
 * @param pending true if pending is true
 * @param doneMatd true if doneMaterialization is true
 * @param lastActionNumber last action number
 * @return coordinator job bean
 * @throws Exception
 */
protected CoordinatorJobBean addRecordToCoordJobTableWithBundle(String bundleId, String coordId, CoordinatorJob.Status status, boolean pending, boolean doneMatd, int lastActionNumber) throws Exception {
    CoordinatorJobBean coordJob = createCoordJob(status, pending, doneMatd);
    coordJob.setBundleId(bundleId);
    // coord id and coord name are the same
    coordJob.setId(coordId);
    coordJob.setAppName(coordId);
    coordJob.setLastActionNumber(lastActionNumber);
    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 69 with JPAExecutorException

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

the class CoordMaterializeTransitionXCommand method materialize.

/* (non-Javadoc)
     * @see org.apache.oozie.command.MaterializeTransitionXCommand#materialize()
     */
@Override
protected void materialize() throws CommandException {
    Instrumentation.Cron cron = new Instrumentation.Cron();
    cron.start();
    try {
        materializeActions(false);
        updateJobMaterializeInfo(coordJob);
    } catch (CommandException ex) {
        LOG.warn("Exception occurred:" + ex.getMessage() + " Making the job failed ", ex);
        coordJob.setStatus(Job.Status.FAILED);
        coordJob.resetPending();
        // remove any materialized actions and slaEvents
        insertList.clear();
    } catch (Exception e) {
        LOG.error("Exception occurred:" + e.getMessage() + " Making the job failed ", e);
        coordJob.setStatus(Job.Status.FAILED);
        try {
            CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQuery.UPDATE_COORD_JOB_MATERIALIZE, coordJob);
        } catch (JPAExecutorException jex) {
            throw new CommandException(ErrorCode.E1011, jex);
        }
        throw new CommandException(ErrorCode.E1012, e.getMessage(), e);
    } finally {
        cron.stop();
        instrumentation.addCron(INSTRUMENTATION_GROUP, getName() + ".materialize", cron);
    }
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) Instrumentation(org.apache.oozie.util.Instrumentation) CommandException(org.apache.oozie.command.CommandException) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) JDOMException(org.jdom.JDOMException) IOException(java.io.IOException) CommandException(org.apache.oozie.command.CommandException) PreconditionException(org.apache.oozie.command.PreconditionException)

Example 70 with JPAExecutorException

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

the class CoordPushDependencyCheckXCommand method updateCoordAction.

protected void updateCoordAction(CoordinatorActionBean coordAction, boolean isChangeInDependency) throws CommandException {
    coordAction.setLastModifiedTime(new Date());
    if (jpaService != null) {
        try {
            if (isChangeInDependency) {
                coordAction.setPushMissingDependencies(coordAction.getPushInputDependencies().serialize());
                CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION_FOR_PUSH_INPUTCHECK, coordAction);
                if (EventHandlerService.isEnabled() && coordAction.getStatus() != CoordinatorAction.Status.READY) {
                    // since event is not to be generated unless action
                    // RUNNING via StartX
                    generateEvent(coordAction, coordJob.getUser(), coordJob.getAppName(), null);
                }
            } else {
                CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION_FOR_MODIFIED_DATE, coordAction);
            }
        } catch (JPAExecutorException jex) {
            throw new CommandException(ErrorCode.E1021, jex.getMessage(), jex);
        } catch (IOException ioe) {
            throw new CommandException(ErrorCode.E1021, ioe.getMessage(), ioe);
        }
    }
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CommandException(org.apache.oozie.command.CommandException) IOException(java.io.IOException) Date(java.util.Date)

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