Search in sources :

Example 96 with CoordinatorJobBean

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

the class TestBulkCoordXCommand method verifyJobsStatus.

private void verifyJobsStatus(List<String> jobIds, CoordinatorJob.Status status) throws Exception {
    for (String id : jobIds) {
        CoordinatorJobBean job = CoordJobQueryExecutor.getInstance().get(CoordJobQueryExecutor.CoordJobQuery.GET_COORD_JOB, id);
        assertEquals(status, job.getStatus());
    }
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean)

Example 97 with CoordinatorJobBean

use of org.apache.oozie.CoordinatorJobBean 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 98 with CoordinatorJobBean

use of org.apache.oozie.CoordinatorJobBean 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 99 with CoordinatorJobBean

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

the class TestCoordActionInputCheckXCommand method addRecordToCoordJobTable.

private CoordinatorJobBean addRecordToCoordJobTable(String jobId, Date start, Date end, String dataInType) throws CommandException {
    CoordinatorJobBean coordJob = new CoordinatorJobBean();
    coordJob.setId(jobId);
    coordJob.setAppName("testApp");
    coordJob.setAppPath("testAppPath");
    coordJob.setStatus(CoordinatorJob.Status.RUNNING);
    coordJob.setCreatedTime(new Date());
    coordJob.setLastModifiedTime(new Date());
    coordJob.setUser("testUser");
    coordJob.setGroup("testGroup");
    coordJob.setTimeZone("UTC");
    coordJob.setTimeUnit(Timeunit.DAY);
    coordJob.setMatThrottling(2);
    try {
        coordJob.setStartTime(start);
        coordJob.setEndTime(end);
    } catch (Exception e) {
        e.printStackTrace();
        fail("Could not set Date/time");
    }
    String testDir = getTestCaseDir();
    XConfiguration jobConf = new XConfiguration();
    jobConf.set(OozieClient.USER_NAME, getTestUser());
    String confStr = jobConf.toXmlString(false);
    coordJob.setConf(confStr);
    String appXml = "<coordinator-app xmlns='uri:oozie:coordinator:0.2' name='NAME' frequency=\"1\" start='2009-02-01T01:00" + TZ + "' end='2009-02-03T23:59" + TZ + "' timezone='UTC' freq_timeunit='DAY' end_of_duration='NONE'>";
    appXml += "<controls>";
    appXml += "<timeout>10</timeout>";
    appXml += "<concurrency>2</concurrency>";
    appXml += "<execution>LIFO</execution>";
    appXml += "</controls>";
    appXml += "<input-events>";
    appXml += "<data-in name='A' dataset='a'>";
    appXml += "<dataset name='a' frequency='7' initial-instance='2009-01-01T01:00" + TZ + "' timezone='UTC'" + " freq_timeunit='DAY' end_of_duration='NONE'>";
    appXml += "<uri-template>" + getTestCaseFileUri("${YEAR}/${MONTH}/${DAY}") + "</uri-template>";
    appXml += "</dataset>";
    if (dataInType.equals("future")) {
        appXml += "<start-instance>${coord:" + dataInType + "(0,5)}</start-instance>";
        appXml += "<end-instance>${coord:" + dataInType + "(3,5)}</end-instance>";
    } else if (dataInType.equals("latest")) {
        appXml += "<start-instance>${coord:" + dataInType + "(-3)}</start-instance>";
        appXml += "<end-instance>${coord:" + dataInType + "(0)}</end-instance>";
    } else if (dataInType.equals("current")) {
        appXml += "<start-instance>${coord:" + dataInType + "(-3)}</start-instance>";
        appXml += "<end-instance>${coord:" + dataInType + "(1)}</end-instance>";
    }
    appXml += "</data-in>";
    appXml += "</input-events>";
    appXml += "<output-events>";
    appXml += "<data-out name='LOCAL_A' dataset='local_a'>";
    appXml += "<dataset name='local_a' frequency='7' initial-instance='2009-01-01T01:00" + TZ + "' timezone='UTC'" + " freq_timeunit='DAY' end_of_duration='NONE'>";
    appXml += "<uri-template>" + getTestCaseFileUri("${YEAR}/${MONTH}/${DAY}") + "</uri-template>";
    appXml += "</dataset>";
    appXml += "<start-instance>${coord:current(-3)}</start-instance>";
    appXml += "<instance>${coord:current(0)}</instance>";
    appXml += "</data-out>";
    appXml += "</output-events>";
    appXml += "<action>";
    appXml += "<workflow>";
    appXml += "<app-path>hdfs:///tmp/workflows/</app-path>";
    appXml += "<configuration>";
    appXml += "<property>";
    appXml += "<name>inputA</name>";
    appXml += "<value>${coord:dataIn('A')}</value>";
    appXml += "</property>";
    appXml += "<property>";
    appXml += "<name>inputB</name>";
    appXml += "<value>${coord:dataOut('LOCAL_A')}</value>";
    appXml += "</property>";
    appXml += "</configuration>";
    appXml += "</workflow>";
    appXml += "</action>";
    appXml += "</coordinator-app>";
    coordJob.setJobXml(appXml);
    coordJob.setLastActionNumber(0);
    coordJob.setFrequency("1");
    coordJob.setExecutionOrder(Execution.FIFO);
    coordJob.setConcurrency(1);
    JPAService jpaService = Services.get().get(JPAService.class);
    if (jpaService != null) {
        try {
            jpaService.execute(new CoordJobInsertJPAExecutor(coordJob));
        } catch (JPAExecutorException e) {
            throw new CommandException(e);
        }
    } else {
        fail("Unable to insert the test job record to table");
    }
    return coordJob;
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) XConfiguration(org.apache.oozie.util.XConfiguration) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordJobInsertJPAExecutor(org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor) CommandException(org.apache.oozie.command.CommandException) JPAService(org.apache.oozie.service.JPAService) Date(java.util.Date) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException) CommandException(org.apache.oozie.command.CommandException)

Example 100 with CoordinatorJobBean

use of org.apache.oozie.CoordinatorJobBean 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

CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)373 Date (java.util.Date)177 JPAService (org.apache.oozie.service.JPAService)153 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)149 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)121 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)114 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)53 CommandException (org.apache.oozie.command.CommandException)49 BundleJobBean (org.apache.oozie.BundleJobBean)46 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)43 IOException (java.io.IOException)39 XConfiguration (org.apache.oozie.util.XConfiguration)38 ArrayList (java.util.ArrayList)36 BundleActionBean (org.apache.oozie.BundleActionBean)36 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)34 Configuration (org.apache.hadoop.conf.Configuration)33 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)32 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)30 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)30 Path (org.apache.hadoop.fs.Path)24