Search in sources :

Example 56 with CoordinatorActionBean

use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.

the class TestBulkCoordXCommand method testBulkCoordResumeNegative.

public void testBulkCoordResumeNegative() throws Exception {
    String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
    Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
    CoordinatorJobBean job1 = addRecordToCoordJobTable(CoordinatorJob.Status.SUSPENDED, start, end, false, false, 0);
    CoordinatorActionBean action1 = addRecordToCoordActionTable(job1.getId(), 1, CoordinatorAction.Status.SUSPENDED, "coord-action-get.xml", 0);
    Map<String, List<String>> map = new HashMap<String, List<String>>();
    List<String> names = new ArrayList<String>();
    names.add("COORD");
    map.put("name", names);
    new BulkCoordXCommand(map, 1, 50, OperationType.Resume).call();
    List<String> jobIds = new ArrayList<String>();
    jobIds.add(job1.getId());
    List<String> actionIds = new ArrayList<String>();
    actionIds.add(action1.getId());
    verifyJobsStatus(jobIds, CoordinatorJob.Status.SUSPENDED);
    verifyActionsStatus(actionIds, CoordinatorAction.Status.SUSPENDED);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Date(java.util.Date)

Example 57 with CoordinatorActionBean

use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.

the class TestBulkCoordXCommand method verifyActionsStatus.

private void verifyActionsStatus(List<String> actionIds, CoordinatorAction.Status status) throws Exception {
    for (String id : actionIds) {
        CoordinatorActionBean action = CoordActionQueryExecutor.getInstance().get(CoordActionQueryExecutor.CoordActionQuery.GET_COORD_ACTION, id);
        assertEquals(status, action.getStatus());
    }
}
Also used : CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean)

Example 58 with CoordinatorActionBean

use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.

the class TestCoordActionInputCheckXCommand method testExceptionOnInvalidElFunction.

public void testExceptionOnInvalidElFunction() {
    try {
        CoordinatorJobBean job = addRecordToCoordJobTableForWaiting("coord-hdfsinput-invalid-elfunction.xml", CoordinatorJob.Status.RUNNING, false, true);
        CoordinatorActionBean action = addRecordToCoordActionTableForWaiting(job.getId(), 1, CoordinatorAction.Status.WAITING, "coord-hdfsinput-invalid-elfunction.xml");
        createTestCaseSubDir("2009/01/29/_SUCCESS".split("/"));
        createTestCaseSubDir("2009/01/22/_SUCCESS".split("/"));
        createTestCaseSubDir("2009/01/15/_SUCCESS".split("/"));
        createTestCaseSubDir("2009/01/08/_SUCCESS".split("/"));
        sleep(3000);
        final String actionId = action.getId();
        try {
            new CoordActionInputCheckXCommand(action.getId(), job.getId()).call();
            waitFor(6000, new Predicate() {

                @Override
                public boolean evaluate() throws Exception {
                    CoordinatorActionBean action = CoordActionQueryExecutor.getInstance().get(CoordActionQueryExecutor.CoordActionQuery.GET_COORD_ACTION, actionId);
                    return action.getStatus() == CoordinatorAction.Status.FAILED;
                }
            });
            fail("Should throw an exception");
        } catch (Exception e) {
            assertTrue(e.getMessage().contains("Coord Action Input Check Error"));
        }
    } catch (Exception e) {
        e.printStackTrace(System.out);
        fail("Unexpected exception");
    }
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException) CommandException(org.apache.oozie.command.CommandException)

Example 59 with CoordinatorActionBean

use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.

the class TestCoordActionInputCheckXCommand method testActionInputCheck.

public void testActionInputCheck() throws Exception {
    String jobId = "0000000-" + new Date().getTime() + "-TestCoordActionInputCheckXCommand-C";
    Date startTime = DateUtils.parseDateOozieTZ("2009-02-01T23:59" + TZ);
    Date endTime = DateUtils.parseDateOozieTZ("2009-02-02T23:59" + TZ);
    CoordinatorJobBean job = addRecordToCoordJobTable(jobId, startTime, endTime);
    new CoordMaterializeTransitionXCommand(job.getId(), 3600).call();
    createTestCaseSubDir("2009/02/05/_SUCCESS".split("/"));
    createTestCaseSubDir("2009/01/15/_SUCCESS".split("/"));
    new CoordActionInputCheckXCommand(job.getId() + "@1", job.getId()).call();
    JPAService jpaService = Services.get().get(JPAService.class);
    CoordinatorActionBean action = jpaService.execute(new CoordActionGetJPAExecutor(job.getId() + "@1"));
    System.out.println("missingDeps " + action.getMissingDependencies() + " Xml " + action.getActionXml());
    if (action.getMissingDependencies().indexOf("/2009/02/05/") >= 0) {
        fail("directory should be resolved :" + action.getMissingDependencies());
    }
    if (action.getMissingDependencies().indexOf("/2009/01/15/") < 0) {
        fail("directory should NOT be resolved :" + action.getMissingDependencies());
    }
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordActionGetJPAExecutor(org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService) Date(java.util.Date)

Example 60 with CoordinatorActionBean

use of org.apache.oozie.CoordinatorActionBean in project oozie by apache.

the class TestCoordActionInputCheckXCommand method testHarFileInputCheck.

public void testHarFileInputCheck() throws Exception {
    CoordinatorJobBean job = addRecordToCoordJobTableForWaiting("coord-job-for-action-input-check.xml", CoordinatorJob.Status.RUNNING, false, true);
    String pathName = createTestCaseSubDir("2009/01/29".split("/"));
    CoordJobQueryExecutor.getInstance().executeUpdate(CoordJobQueryExecutor.CoordJobQuery.UPDATE_COORD_JOB, job);
    String missingDeps = "file://" + pathName + CoordELFunctions.INSTANCE_SEPARATOR + "har:///dirx/archive.har/data";
    String actionId1 = addInitRecords(missingDeps, null, TZ, job, 1);
    new CoordActionInputCheckXCommand(actionId1, job.getId()).call();
    CoordinatorActionBean coordAction = CoordActionQueryExecutor.getInstance().get(CoordActionQuery.GET_COORD_ACTION, actionId1);
    // the directory (2009/01/29) exists and successfully removed from
    // missing dependency of the coord action
    assertEquals(coordAction.getMissingDependencies(), "har:///dirx/archive.har/data");
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean)

Aggregations

CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)307 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)148 Date (java.util.Date)117 JPAService (org.apache.oozie.service.JPAService)113 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)102 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)60 CommandException (org.apache.oozie.command.CommandException)55 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)53 IOException (java.io.IOException)49 XConfiguration (org.apache.oozie.util.XConfiguration)44 Configuration (org.apache.hadoop.conf.Configuration)43 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)42 ArrayList (java.util.ArrayList)40 JDOMException (org.jdom.JDOMException)33 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)32 StringReader (java.io.StringReader)30 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)29 StoreException (org.apache.oozie.store.StoreException)24 Test (org.junit.Test)24 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)22