Search in sources :

Example 61 with JPAExecutorException

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

the class XDataTestCase method addRecordToCoordJobTable.

/**
 * Insert coord job for testing.
 *
 * @param testFileName test file name
 * @param status coord job status
 * @param start start time
 * @param end end time
 * @param pending true if pending is true
 * @param doneMatd true if doneMaterialization is true
 * @param lastActionNum last action number
 * @return coord job bean
 * @throws Exception
 */
protected CoordinatorJobBean addRecordToCoordJobTable(String testFileName, CoordinatorJob.Status status, Date start, Date end, boolean pending, boolean doneMatd, int lastActionNum) throws Exception {
    CoordinatorJobBean coordJob = createCoordJob(testFileName, status, start, end, pending, doneMatd, lastActionNum);
    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 62 with JPAExecutorException

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

the class XDataTestCase method addRecordToCoordActionTable.

/**
 * Insert coord action for testing.
 *
 * @param jobId coord job id
 * @param actionNum action number
 * @param status coord action status
 * @param resourceXmlName xml file name
 * @param pending pending counter
 * @param actionNominalTime
 * @return coord action bean
 * @throws Exception thrown if unable to create coord action bean
 */
protected CoordinatorActionBean addRecordToCoordActionTable(String jobId, int actionNum, CoordinatorAction.Status status, String resourceXmlName, int pending, Date actionNominalTime) throws Exception {
    CoordinatorActionBean action = createCoordAction(jobId, actionNum, status, resourceXmlName, pending, actionNominalTime);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        CoordActionInsertJPAExecutor coordActionInsertCmd = new CoordActionInsertJPAExecutor(action);
        jpaService.execute(coordActionInsertCmd);
    } catch (JPAExecutorException je) {
        je.printStackTrace();
        fail("Unable to insert the test coord action record to table");
        throw je;
    }
    return action;
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordActionInsertJPAExecutor(org.apache.oozie.executor.jpa.CoordActionInsertJPAExecutor) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) JPAService(org.apache.oozie.service.JPAService)

Example 63 with JPAExecutorException

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

the class XDataTestCase method insertRecordCoordAction.

/**
 * Inserts a record to coord action table
 *
 * @param action the record to be inserted
 * @throws Exception
 */
protected void insertRecordCoordAction(CoordinatorActionBean action) throws Exception {
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        CoordActionInsertJPAExecutor coordActionInsertCmd = new CoordActionInsertJPAExecutor(action);
        jpaService.execute(coordActionInsertCmd);
    } catch (JPAExecutorException je) {
        je.printStackTrace();
        fail("Unable to insert the test coord action record to table");
        throw je;
    }
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordActionInsertJPAExecutor(org.apache.oozie.executor.jpa.CoordActionInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 64 with JPAExecutorException

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

the class XDataTestCase method addRecordToWfJobTable.

/**
 * Insert subwf job for testing.
 *
 * @param jobStatus workflow job status
 * @param instanceStatus workflow instance status
 * @param parentId the id of the parent workflow
 * @return workflow job bean
 * @throws Exception thrown if unable to create workflow job bean
 */
protected WorkflowJobBean addRecordToWfJobTable(WorkflowJob.Status jobStatus, WorkflowInstance.Status instanceStatus, String parentId) throws Exception {
    WorkflowJobBean subwfBean = addRecordToWfJobTable(jobStatus, instanceStatus);
    subwfBean.setParentId(parentId);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW_PARENT_MODIFIED, subwfBean);
    } catch (JPAExecutorException je) {
        je.printStackTrace();
        fail("Unable to insert the test wf job record to table");
        throw je;
    }
    return subwfBean;
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean)

Example 65 with JPAExecutorException

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

the class XDataTestCase method addRecordToSLARegistrationTable.

/**
 * Insert sla registration for test
 * @param appName application name
 * @param status  sla status
 * @return
 * @throws Exception
 */
protected SLARegistrationBean addRecordToSLARegistrationTable(String appName, SLAStatus status) throws Exception {
    SLARegistrationBean sla = new SLARegistrationBean();
    Date today = new Date();
    sla.setId(Services.get().get(UUIDService.class).generateId(ApplicationType.COORDINATOR));
    sla.setAppName(appName);
    sla.setAppType(AppType.COORDINATOR_JOB);
    sla.setExpectedDuration(100);
    sla.setExpectedEnd(today);
    sla.setExpectedStart(today);
    sla.setJobData("test-job-data");
    sla.setCreatedTime(today);
    sla.setNominalTime(today);
    sla.setNotificationMsg("test-sla-notification-msg");
    sla.setParentId(Services.get().get(UUIDService.class).generateId(ApplicationType.BUNDLE));
    sla.setSlaConfig("alert-events");
    sla.setUpstreamApps("test-upstream-apps");
    sla.setUser("oozie");
    try {
        SLARegistrationQueryExecutor.getInstance().insert(sla);
    } catch (JPAExecutorException je) {
        je.printStackTrace();
        fail("Unable to insert the test sla registration record to table");
        throw je;
    }
    return sla;
}
Also used : SLARegistrationBean(org.apache.oozie.sla.SLARegistrationBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) 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