Search in sources :

Example 11 with CoordActionInsertJPAExecutor

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

the class XDataTestCase method addRecordToCoordActionTableForWaiting.

protected CoordinatorActionBean addRecordToCoordActionTableForWaiting(String jobId, int actionNum, CoordinatorAction.Status status, String resourceXmlName, String missingDependencies, String pushMissingDependencies, String oozieTimeZoneMask) throws Exception {
    CoordinatorActionBean action = createCoordAction(jobId, actionNum, status, resourceXmlName, 0, oozieTimeZoneMask, null);
    action.setMissingDependencies(missingDependencies);
    action.setPushMissingDependencies(pushMissingDependencies);
    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 12 with CoordActionInsertJPAExecutor

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

the class XDataTestCase method addCoordForBulkMonitor.

protected void addCoordForBulkMonitor(String bundleId) throws Exception {
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    // adding coordinator job(s) for this bundle
    addRecordToCoordJobTableWithBundle(bundleId, "Coord1", CoordinatorJob.Status.RUNNING, true, true, 2);
    addRecordToCoordJobTableWithBundle(bundleId, "Coord2", CoordinatorJob.Status.RUNNING, true, true, 1);
    addRecordToCoordJobTableWithBundle(bundleId, "Coord3", CoordinatorJob.Status.RUNNING, true, true, 1);
    // adding coordinator action #1 to Coord#1
    CoordinatorActionBean action1 = new CoordinatorActionBean();
    action1.setId("Coord1@1");
    action1.setStatus(CoordinatorAction.Status.FAILED);
    action1.setCreatedTime(DateUtils.parseDateUTC(CREATE_TIME));
    action1.setJobId("Coord1");
    Calendar cal = Calendar.getInstance();
    cal.setTime(DateUtils.parseDateUTC(CREATE_TIME));
    cal.add(Calendar.DATE, -1);
    action1.setNominalTime(cal.getTime());
    CoordActionInsertJPAExecutor actionInsert = new CoordActionInsertJPAExecutor(action1);
    jpaService.execute(actionInsert);
    // adding coordinator action #2 to Coord#1
    CoordinatorActionBean action2 = new CoordinatorActionBean();
    action2.setId("Coord1@2");
    action2.setStatus(CoordinatorAction.Status.KILLED);
    action2.setCreatedTime(DateUtils.parseDateUTC(CREATE_TIME));
    action2.setJobId("Coord1");
    cal.setTime(DateUtils.parseDateUTC(CREATE_TIME));
    cal.add(Calendar.DATE, -1);
    action2.setNominalTime(cal.getTime());
    actionInsert = new CoordActionInsertJPAExecutor(action2);
    jpaService.execute(actionInsert);
    // adding coordinator action #3 to Coord#2
    CoordinatorActionBean action3 = new CoordinatorActionBean();
    action3.setId("Coord2@1");
    action3.setStatus(CoordinatorAction.Status.KILLED);
    action3.setCreatedTime(DateUtils.parseDateUTC(CREATE_TIME));
    action3.setJobId("Coord2");
    cal.setTime(DateUtils.parseDateUTC(CREATE_TIME));
    cal.add(Calendar.DATE, -1);
    action3.setNominalTime(cal.getTime());
    actionInsert = new CoordActionInsertJPAExecutor(action3);
    jpaService.execute(actionInsert);
}
Also used : CoordActionInsertJPAExecutor(org.apache.oozie.executor.jpa.CoordActionInsertJPAExecutor) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) Calendar(java.util.Calendar) JPAService(org.apache.oozie.service.JPAService)

Example 13 with CoordActionInsertJPAExecutor

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

the class XDataTestCase method addRecordToCoordActionTable.

protected CoordinatorActionBean addRecordToCoordActionTable(CoordinatorActionBean action, String wfId) throws Exception {
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        CoordActionInsertJPAExecutor coordActionInsertExecutor = new CoordActionInsertJPAExecutor(action);
        jpaService.execute(coordActionInsertExecutor);
        if (wfId != null) {
            WorkflowJobBean wfJob = jpaService.execute(new WorkflowJobGetJPAExecutor(wfId));
            wfJob.setParentId(action.getId());
            WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW_PARENT_MODIFIED, wfJob);
        }
    } catch (JPAExecutorException je) {
        je.printStackTrace();
        fail("Unable to insert the test coord action record to table");
        throw je;
    }
    return action;
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordActionInsertJPAExecutor(org.apache.oozie.executor.jpa.CoordActionInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean)

Example 14 with CoordActionInsertJPAExecutor

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

the class XDataTestCase method addRecordToCoordActionTable.

/**
 * Insert coord action and workflow id as external id for testing.
 *
 * @param jobId coord job id
 * @param actionNum action number
 * @param status coord action status
 * @param resourceXmlName xml file name
 * @param wfId wf id
 * @param wfStatus wf status
 * @param pending pending counter
 * @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, String wfId, String wfStatus, int pending) throws Exception {
    CoordinatorActionBean action = createCoordAction(jobId, actionNum, status, resourceXmlName, pending);
    action.setExternalId(wfId);
    action.setExternalStatus(wfStatus);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        CoordActionInsertJPAExecutor coordActionInsertExecutor = new CoordActionInsertJPAExecutor(action);
        jpaService.execute(coordActionInsertExecutor);
        if (wfId != null) {
            WorkflowJobBean wfJob = jpaService.execute(new WorkflowJobGetJPAExecutor(wfId));
            wfJob.setParentId(action.getId());
            WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW_PARENT_MODIFIED, wfJob);
        }
    } catch (JPAExecutorException je) {
        je.printStackTrace();
        fail("Unable to insert the test coord action record to table");
        throw je;
    }
    return action;
}
Also used : WorkflowJobGetJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor) 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) WorkflowJobBean(org.apache.oozie.WorkflowJobBean)

Aggregations

CoordActionInsertJPAExecutor (org.apache.oozie.executor.jpa.CoordActionInsertJPAExecutor)14 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)12 JPAService (org.apache.oozie.service.JPAService)9 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)8 Date (java.util.Date)5 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)4 SimpleDateFormat (java.text.SimpleDateFormat)3 Calendar (java.util.Calendar)2 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)2 FailingDBHelperForTest (org.apache.oozie.util.db.FailingDBHelperForTest)2 Test (org.junit.Test)2 File (java.io.File)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 Path (org.apache.hadoop.fs.Path)1 CommandException (org.apache.oozie.command.CommandException)1 StoreException (org.apache.oozie.store.StoreException)1 JDOMException (org.jdom.JDOMException)1 JSONArray (org.json.simple.JSONArray)1