Search in sources :

Example 1 with WorkflowActionInsertJPAExecutor

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

the class TestActionStartXCommand method addRecordToWfActionTableWithAppPathConfig.

/**
 * Create workflow action with custom action configuration
 *
 * @param wfId workflow id
 * @param actionName action name
 * @param status workflow action status
 * @return workflow action bean
 * @throws Exception thrown if failed to create workflow action
 */
protected WorkflowActionBean addRecordToWfActionTableWithAppPathConfig(String wfId, String actionName, WorkflowAction.Status status) throws Exception {
    WorkflowActionBean action = createWorkflowActionWithAppPathConfig(wfId, status);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        WorkflowActionInsertJPAExecutor actionInsertCmd = new WorkflowActionInsertJPAExecutor(action);
        jpaService.execute(actionInsertCmd);
    } catch (JPAExecutorException ce) {
        ce.printStackTrace();
        fail("Unable to insert the test wf action record to table");
        throw ce;
    }
    return action;
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) WorkflowActionInsertJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 2 with WorkflowActionInsertJPAExecutor

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

the class TestActionStartXCommand method addRecordToWfActionTableWithFS.

private WorkflowActionBean addRecordToWfActionTableWithFS(String wfId, String actionName, WorkflowAction.Status status) throws Exception {
    WorkflowActionBean action = createWorkflowActionForFS(wfId, status);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        WorkflowActionInsertJPAExecutor actionInsertCmd = new WorkflowActionInsertJPAExecutor(action);
        jpaService.execute(actionInsertCmd);
    } catch (JPAExecutorException ce) {
        ce.printStackTrace();
        fail("Unable to insert the test wf action record to table");
        throw ce;
    }
    return action;
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) WorkflowActionInsertJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 3 with WorkflowActionInsertJPAExecutor

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

the class TestActionStartXCommand method addRecordToWfActionTable.

/* (non-Javadoc)
     * @see org.apache.oozie.test.XDataTestCase#addRecordToWfActionTable(
     * java.lang.String, java.lang.String, org.apache.oozie.client.WorkflowAction.Status)
     */
@Override
protected WorkflowActionBean addRecordToWfActionTable(String wfId, String actionName, WorkflowAction.Status status) throws Exception {
    WorkflowActionBean action = createWorkflowActionSetPending(wfId, status);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        WorkflowActionInsertJPAExecutor actionInsertCmd = new WorkflowActionInsertJPAExecutor(action);
        jpaService.execute(actionInsertCmd);
    } catch (JPAExecutorException ce) {
        ce.printStackTrace();
        fail("Unable to insert the test wf action record to table");
        throw ce;
    }
    return action;
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) WorkflowActionInsertJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 4 with WorkflowActionInsertJPAExecutor

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

the class TestEventGeneration method _createWorkflowAction.

private String _createWorkflowAction(String wfId, String actionName) throws JPAExecutorException {
    WorkflowActionBean action = new WorkflowActionBean();
    action.setName(actionName);
    action.setId(Services.get().get(UUIDService.class).generateChildId(wfId, actionName));
    action.setJobId(wfId);
    action.setType("java");
    action.setTransition("transition");
    action.setStatus(WorkflowAction.Status.PREP);
    action.setStartTime(new Date());
    action.setEndTime(new Date());
    action.setLastCheckTime(new Date());
    action.setPendingOnly();
    String actionXml = "<java>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<main-class>" + "${dummy}" + "</java>";
    action.setConf(actionXml);
    jpaService.execute(new WorkflowActionInsertJPAExecutor(action));
    return action.getId();
}
Also used : WorkflowActionInsertJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionInsertJPAExecutor) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) Date(java.util.Date)

Example 5 with WorkflowActionInsertJPAExecutor

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

the class TestWorkflowActionKillXCommand method addRecordToWfActionTable.

protected WorkflowActionBean addRecordToWfActionTable(String wfId, String externalJobID, String actionName, WorkflowAction.Status status, String childID) throws Exception {
    WorkflowActionBean action = new WorkflowActionBean();
    action.setId(Services.get().get(UUIDService.class).generateChildId(wfId, actionName));
    action.setJobId(wfId);
    action.setName(actionName);
    action.setType("map-reduce");
    action.setStatus(status);
    action.setStartTime(new Date());
    action.setEndTime(new Date());
    action.setLastCheckTime(new Date());
    action.setPending();
    action.setExternalId(externalJobID);
    action.setExternalStatus("RUNNING");
    action.setExternalChildIDs(childID);
    String actionXml = "<map-reduce>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<configuration>" + "<property><name>mapred.mapper.class</name><value>" + MapperReducerForTest.class.getName() + "</value></property>" + "<property><name>mapred.reducer.class</name><value>" + MapperReducerForTest.class.getName() + "</value></property>" + "<property><name>mapred.input.dir</name><value>inputDir</value></property>" + "<property><name>mapred.output.dir</name><value>outputDir</value></property>" + "</configuration>" + "</map-reduce>";
    action.setConf(actionXml);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        WorkflowActionInsertJPAExecutor actionInsertExe = new WorkflowActionInsertJPAExecutor(action);
        jpaService.execute(actionInsertExe);
    } catch (JPAExecutorException je) {
        je.printStackTrace();
        fail("Unable to insert the test wf action record to table");
        throw je;
    }
    return action;
}
Also used : MapperReducerForTest(org.apache.oozie.action.hadoop.MapperReducerForTest) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) WorkflowActionInsertJPAExecutor(org.apache.oozie.executor.jpa.WorkflowActionInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) Date(java.util.Date)

Aggregations

WorkflowActionBean (org.apache.oozie.WorkflowActionBean)11 WorkflowActionInsertJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionInsertJPAExecutor)11 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)9 JPAService (org.apache.oozie.service.JPAService)7 Date (java.util.Date)4 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Configuration (org.apache.hadoop.conf.Configuration)1 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)1 MapReduceActionExecutor (org.apache.oozie.action.hadoop.MapReduceActionExecutor)1 MapperReducerForTest (org.apache.oozie.action.hadoop.MapperReducerForTest)1 ActionExecutorContext (org.apache.oozie.command.wf.ActionXCommand.ActionExecutorContext)1 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)1 RecoveryRunnable (org.apache.oozie.service.RecoveryService.RecoveryRunnable)1 XConfiguration (org.apache.oozie.util.XConfiguration)1 FailingDBHelperForTest (org.apache.oozie.util.db.FailingDBHelperForTest)1 Test (org.junit.Test)1