Search in sources :

Example 1 with CoordJobInsertJPAExecutor

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

the class TestCoordRerunXCommand method addRecordToCoordJobTableWithPausedTime.

protected CoordinatorJobBean addRecordToCoordJobTableWithPausedTime(CoordinatorJob.Status status, boolean pending, boolean doneMatd, Date pausedTime) throws Exception {
    CoordinatorJobBean coordJob = createCoordJob(status, pending, doneMatd);
    coordJob.setPauseTime(pausedTime);
    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 2 with CoordJobInsertJPAExecutor

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

the class TestCoordChangeXCommand method addRecordToCoordJobTableForPauseTimeTest.

protected CoordinatorJobBean addRecordToCoordJobTableForPauseTimeTest(CoordinatorJob.Status status, Date start, Date end, Date lastActionTime, boolean pending, boolean doneMatd, int lastActionNum) throws Exception {
    CoordinatorJobBean coordJob = createCoordJob(status, start, end, pending, doneMatd, lastActionNum);
    coordJob.setFrequency("1");
    coordJob.setTimeUnit(Timeunit.HOUR);
    coordJob.setLastActionNumber(lastActionNum);
    coordJob.setLastActionTime(lastActionTime);
    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 3 with CoordJobInsertJPAExecutor

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

the class TestCoordCommandUtils method addRecordToCoordJobTable.

protected CoordinatorJobBean addRecordToCoordJobTable(CoordinatorJob.Status status, Date startTime, Date endTime, String freq) throws Exception {
    CoordinatorJobBean coordJob = createCoordJob(status, startTime, endTime, false, false, 0);
    coordJob.setStartTime(startTime);
    coordJob.setEndTime(endTime);
    coordJob.setFrequency(freq);
    coordJob.setTimeUnit(CoordinatorJob.Timeunit.MINUTE);
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);
        CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(coordJob);
        jpaService.execute(coordInsertCmd);
    } catch (JPAExecutorException ex) {
        ex.printStackTrace();
        fail("Unable to insert the test coord job record to table");
        throw ex;
    }
    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 4 with CoordJobInsertJPAExecutor

use of org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor 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 5 with CoordJobInsertJPAExecutor

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

the class TestBundleStartXCommand method testBundleStartWithFailedCoordinator.

public void testBundleStartWithFailedCoordinator() throws Exception {
    services.destroy();
    services = new Services();
    String[] excludeServices = { "org.apache.oozie.service.UUIDService", "org.apache.oozie.service.StatusTransitService" };
    Configuration conf = services.getConf();
    setClassesToBeExcluded(conf, excludeServices);
    conf.set(Services.CONF_SERVICE_CLASSES, conf.get(Services.CONF_SERVICE_CLASSES) + "," + DummyUUIDService.class.getName());
    services.init();
    CoordinatorJobBean coordJob = new CoordinatorJobBean();
    coordJob.setId("dummy-coord-id");
    JPAService jpaService = Services.get().get(JPAService.class);
    CoordJobInsertJPAExecutor coordInsertCmd = new CoordJobInsertJPAExecutor(coordJob);
    jpaService.execute(coordInsertCmd);
    BundleJobBean job = addRecordToBundleJobTable(Job.Status.PREP, false);
    BundleJobGetJPAExecutor bundleJobGetExecutor = new BundleJobGetJPAExecutor(job.getId());
    job = jpaService.execute(bundleJobGetExecutor);
    assertEquals(job.getStatus(), Job.Status.PREP);
    new BundleStartXCommand(job.getId()).call();
    job = jpaService.execute(bundleJobGetExecutor);
    assertEquals(job.getStatus(), Job.Status.RUNNING);
    sleep(2000);
    List<BundleActionBean> actions = BundleActionQueryExecutor.getInstance().getList(BundleActionQuery.GET_BUNDLE_ACTIONS_STATUS_UNIGNORED_FOR_BUNDLE, job.getId());
    assertNull(actions.get(0).getCoordId());
    assertEquals(Job.Status.FAILED, actions.get(0).getStatus());
    Runnable runnable = new StatusTransitRunnable();
    // 1st run of StatusTransitionService changes bundle to running
    runnable.run();
    sleep(2000);
    // 2nd run changes bundle to DoneWithError
    runnable.run();
    sleep(2000);
    job = jpaService.execute(bundleJobGetExecutor);
    assertEquals(job.getStatus(), Job.Status.DONEWITHERROR);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) BundleJobGetJPAExecutor(org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor) Services(org.apache.oozie.service.Services) BundleJobBean(org.apache.oozie.BundleJobBean) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) StatusTransitRunnable(org.apache.oozie.service.StatusTransitService.StatusTransitRunnable) CoordJobInsertJPAExecutor(org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService) BundleActionBean(org.apache.oozie.BundleActionBean)

Aggregations

CoordJobInsertJPAExecutor (org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor)22 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)21 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)20 JPAService (org.apache.oozie.service.JPAService)19 Date (java.util.Date)6 CommandException (org.apache.oozie.command.CommandException)3 StatusTransitRunnable (org.apache.oozie.service.StatusTransitService.StatusTransitRunnable)3 XConfiguration (org.apache.oozie.util.XConfiguration)3 IOException (java.io.IOException)2 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)2 Configuration (org.apache.hadoop.conf.Configuration)1 Path (org.apache.hadoop.fs.Path)1 BundleActionBean (org.apache.oozie.BundleActionBean)1 BundleJobBean (org.apache.oozie.BundleJobBean)1 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)1 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)1 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)1 Services (org.apache.oozie.service.Services)1 StoreException (org.apache.oozie.store.StoreException)1