Search in sources :

Example 31 with CoordinatorJobBean

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

the class TestCoordResumeXCommand method testCoordSuspendWithErrorAndResumeWithErrorForRunning.

/**
 * Test : suspend a RUNNINGWITHERROR coordinator job and check the status to RUNNINGWITHERROR on resume
 *
 * @throws Exception
 */
public void testCoordSuspendWithErrorAndResumeWithErrorForRunning() throws Exception {
    CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNINGWITHERROR, false, false);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
    job = jpaService.execute(coordJobGetCmd);
    assertEquals(job.getStatus(), CoordinatorJob.Status.RUNNINGWITHERROR);
    new CoordSuspendXCommand(job.getId()).call();
    job = jpaService.execute(coordJobGetCmd);
    assertEquals(job.getStatus(), CoordinatorJob.Status.SUSPENDEDWITHERROR);
    new CoordResumeXCommand(job.getId()).call();
    job = jpaService.execute(coordJobGetCmd);
    assertEquals(job.getStatus(), CoordinatorJob.Status.RUNNINGWITHERROR);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 32 with CoordinatorJobBean

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

the class TestCoordSubmitXCommand method testBasicSubmitWithCronFrequency.

private void testBasicSubmitWithCronFrequency(String appXml, Boolean isValidFrequency) throws Exception {
    Configuration conf = new XConfiguration();
    File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
    writeToFile(appXml, appPathFile);
    conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
    conf.set(OozieClient.USER_NAME, getTestUser());
    CoordSubmitXCommand sc = new CoordSubmitXCommand(conf);
    if (isValidFrequency) {
        String jobId = sc.call();
        assertEquals(jobId.substring(jobId.length() - 2), "-C");
        CoordinatorJobBean job = (CoordinatorJobBean) sc.getJob();
        assertEquals(job.getTimeUnitStr(), "CRON");
    } else {
        try {
            String jobId = sc.call();
        } catch (Exception ex) {
            assertTrue(ex.getMessage().contains("Invalid coordinator cron frequency"));
        }
    }
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) File(java.io.File) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CommandException(org.apache.oozie.command.CommandException)

Example 33 with CoordinatorJobBean

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

the class TestCoordSubmitXCommand method testSubmitWithTimeout.

/**
 * Test timeout setting
 *
 * @throws Exception
 */
public void testSubmitWithTimeout() throws Exception {
    Configuration conf = new XConfiguration();
    File appPathFile = new File(getTestCaseDir(), "coordinator.xml");
    // timeout unit = DAY
    String appXml1 = "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" " + "start=\"2009-02-01T01:00Z\" end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='uri:oozie:coordinator:0.2'> " + "<controls> <timeout>${coord:days(10)}</timeout> </controls> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows/</app-path> </workflow> " + "</action> </coordinator-app>";
    writeToFile(appXml1, appPathFile);
    conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
    conf.set(OozieClient.USER_NAME, getTestUser());
    CoordSubmitXCommand sc = new CoordSubmitXCommand(conf);
    String jobId = sc.call();
    assertEquals(jobId.substring(jobId.length() - 2), "-C");
    CoordinatorJobBean job = checkCoordJobs(jobId);
    assertEquals(job.getTimeout(), 14400);
    // timeout unit = HOUR
    String appXml2 = "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" " + "start=\"2009-02-01T01:00Z\" end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='uri:oozie:coordinator:0.2'> " + "<controls> <timeout>${coord:hours(10)}</timeout> </controls> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows/</app-path> </workflow> " + "</action> </coordinator-app>";
    writeToFile(appXml2, appPathFile);
    conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
    conf.set(OozieClient.USER_NAME, getTestUser());
    sc = new CoordSubmitXCommand(conf);
    jobId = sc.call();
    job = checkCoordJobs(jobId);
    assertEquals(job.getTimeout(), 600);
    // timeout unit = MINUTE
    String appXml3 = "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" " + "start=\"2009-02-01T01:00Z\" end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='uri:oozie:coordinator:0.2'> " + "<controls> <timeout>${coord:minutes(10)}</timeout> </controls> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows/</app-path> </workflow> " + "</action> </coordinator-app>";
    writeToFile(appXml3, appPathFile);
    conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
    conf.set(OozieClient.USER_NAME, getTestUser());
    sc = new CoordSubmitXCommand(conf);
    jobId = sc.call();
    job = checkCoordJobs(jobId);
    assertEquals(job.getTimeout(), 10);
    // timeout unit = MONTH
    String appXml4 = "<coordinator-app name=\"NAME\" frequency=\"${coord:months(1)}\" " + "start=\"2009-02-01T01:00Z\" end=\"2009-02-03T23:59Z\" timezone=\"UTC\" " + "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns='uri:oozie:coordinator:0.2'> " + "<controls> <timeout>${coord:months(1)}</timeout> </controls> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows/</app-path> </workflow> " + "</action> </coordinator-app>";
    writeToFile(appXml4, appPathFile);
    conf.set(OozieClient.COORDINATOR_APP_PATH, appPathFile.toURI().toString());
    conf.set(OozieClient.USER_NAME, getTestUser());
    sc = new CoordSubmitXCommand(conf);
    jobId = sc.call();
    job = checkCoordJobs(jobId);
    assertEquals(job.getTimeout(), 43200);
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) File(java.io.File)

Example 34 with CoordinatorJobBean

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

the class TestCoordSuspendXCommand method testCoordSuspendWithErrorPostive2.

/**
 * Test : suspend a PAUSEDWITHERROR coordinator job
 *
 * @throws Exception
 */
public void testCoordSuspendWithErrorPostive2() throws Exception {
    CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.PAUSEDWITHERROR, false, false);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
    job = jpaService.execute(coordJobGetCmd);
    assertEquals(job.getStatus(), CoordinatorJob.Status.PAUSEDWITHERROR);
    new CoordSuspendXCommand(job.getId()).call();
    job = jpaService.execute(coordJobGetCmd);
    assertEquals(job.getStatus(), CoordinatorJob.Status.SUSPENDEDWITHERROR);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

Example 35 with CoordinatorJobBean

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

the class TestCoordSuspendXCommand method testCoordSuspendNegative.

/**
 * Negative Test : suspend a SUCCEEDED coordinator job
 *
 * @throws Exception
 */
public void testCoordSuspendNegative() throws Exception {
    CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.SUCCEEDED, false, false);
    JPAService jpaService = Services.get().get(JPAService.class);
    assertNotNull(jpaService);
    CoordJobGetJPAExecutor coordJobGetCmd = new CoordJobGetJPAExecutor(job.getId());
    job = jpaService.execute(coordJobGetCmd);
    assertEquals(job.getStatus(), CoordinatorJob.Status.SUCCEEDED);
    new CoordSuspendXCommand(job.getId()).call();
    job = jpaService.execute(coordJobGetCmd);
    assertEquals(job.getStatus(), CoordinatorJob.Status.SUCCEEDED);
}
Also used : CoordinatorJobBean(org.apache.oozie.CoordinatorJobBean) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

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