Search in sources :

Example 21 with CoordinatorJob

use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.

the class TestOozieCLIMethods method createBulkResponse.

private static BulkResponse createBulkResponse(DataObject dtObject) {
    BulkResponse bulkResponse = mock(BulkResponse.class);
    BundleJob bundleJob = createBundleJob(dtObject);
    when(bulkResponse.getBundle()).thenReturn(bundleJob);
    CoordinatorAction coordinatorAction = createCoordinatorAction(dtObject);
    when(bulkResponse.getAction()).thenReturn(coordinatorAction);
    CoordinatorJob coordinatorJob = createCoordinatorJob(dtObject);
    when(bulkResponse.getCoordinator()).thenReturn(coordinatorJob);
    return bulkResponse;
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob) CoordinatorAction(org.apache.oozie.client.CoordinatorAction) BulkResponse(org.apache.oozie.client.BulkResponse) BundleJob(org.apache.oozie.client.BundleJob)

Example 22 with CoordinatorJob

use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.

the class LocalOozieClientCoord method getCoordJobsInfo.

/**
 * Return the info of the coordinator jobs that match the filter.
 *
 * @param filter job filter. Refer to the {@link OozieClient} for the filter
 *        syntax.
 * @param start jobs offset, base 1.
 * @param len number of jobs to return.
 * @return a list with the coordinator jobs info
 * @throws OozieClientException thrown if the jobs info could not be
 *         retrieved.
 */
@Override
public List<CoordinatorJob> getCoordJobsInfo(String filter, int start, int len) throws OozieClientException {
    try {
        CoordinatorJobInfo info = coordEngine.getCoordJobs(filter, start, len);
        List<CoordinatorJob> jobs = new ArrayList<CoordinatorJob>();
        List<CoordinatorJobBean> jobBeans = info.getCoordJobs();
        for (CoordinatorJobBean jobBean : jobBeans) {
            jobs.add(jobBean);
        }
        return jobs;
    } catch (CoordinatorEngineException ex) {
        throw new OozieClientException(ex.getErrorCode().toString(), ex);
    }
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob) OozieClientException(org.apache.oozie.client.OozieClientException) ArrayList(java.util.ArrayList)

Example 23 with CoordinatorJob

use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.

the class TestCoordinatorEngine method _testGetJobs.

/**
 * Test to validate frequency and time unit filters for jobs
 *
 * @throws Exception
 */
public void _testGetJobs(String jobId) throws Exception {
    CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
    // Test with no job filter specified
    CoordinatorJobInfo jobInfo = ce.getCoordJobs("", 1, 10);
    assertEquals(1, jobInfo.getCoordJobs().size());
    CoordinatorJob job = jobInfo.getCoordJobs().get(0);
    assertEquals(jobId, job.getId());
    // Test specifying the value for unit but leaving out the value for frequency
    try {
        jobInfo = ce.getCoordJobs("unit=minutes", 1, 10);
    } catch (CoordinatorEngineException ex) {
        assertEquals("E0420: Invalid jobs filter [unit=minutes], time unit should be added only when " + "frequency is specified. Either specify frequency also or else remove the time unit", ex.getMessage());
    }
    // Test for invalid frequency value(Non-numeric value)
    try {
        jobInfo = ce.getCoordJobs("frequency=ghj;unit=minutes", 1, 10);
    } catch (CoordinatorEngineException ex) {
        assertEquals("E0420: Invalid jobs filter [frequency=ghj;unit=minutes], " + "invalid value [ghj] for frequency. A numerical value is expected", ex.getMessage());
    }
    // Test for invalid unit value(Other than months, days, minutes or hours)
    try {
        jobInfo = ce.getCoordJobs("frequency=60;unit=min", 1, 10);
    } catch (CoordinatorEngineException ex) {
        assertEquals("E0420: Invalid jobs filter [frequency=60;unit=min], invalid value [min] for time unit. " + "Valid value is one of months, days, hours or minutes", ex.getMessage());
    }
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob)

Example 24 with CoordinatorJob

use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.

the class TestCoordinatorEngine method _testStatus.

private void _testStatus(final String jobId) throws Exception {
    waitFor(6000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
            CoordinatorJob job = ce.getCoordJob(jobId);
            return !job.getStatus().equals(CoordinatorJob.Status.PREP);
        }
    });
    CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
    CoordinatorJob job = ce.getCoordJob(jobId);
    assertFalse(job.getStatus().equals(CoordinatorJob.Status.PREP));
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException) StoreException(org.apache.oozie.store.StoreException)

Example 25 with CoordinatorJob

use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.

the class TestBundleEngineSimple method testGetCoordJob4.

public void testGetCoordJob4() {
    BundleEngine be = new BundleEngine();
    try {
        CoordinatorJob cj = be.getCoordJob("foo", "filter", 0, 1, false);
        fail("Expected BundleEngineException was not thrown.");
    } catch (BundleEngineException bee) {
        assertEquals(ErrorCode.E0301, bee.getErrorCode());
    }
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob)

Aggregations

CoordinatorJob (org.apache.oozie.client.CoordinatorJob)30 CoordinatorAction (org.apache.oozie.client.CoordinatorAction)9 IOException (java.io.IOException)8 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)8 BundleJob (org.apache.oozie.client.BundleJob)5 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 OozieClientException (org.apache.oozie.client.OozieClientException)3 StoreException (org.apache.oozie.store.StoreException)3 JSONObject (org.json.simple.JSONObject)3 File (java.io.File)2 List (java.util.List)2 Properties (java.util.Properties)2 CoordinatorEngine (org.apache.oozie.CoordinatorEngine)2 BulkResponse (org.apache.oozie.client.BulkResponse)2 OozieClient (org.apache.oozie.client.OozieClient)2 CommandException (org.apache.oozie.command.CommandException)2 CoordActionInputCheckXCommand (org.apache.oozie.command.coord.CoordActionInputCheckXCommand)2 CoordActionStartXCommand (org.apache.oozie.command.coord.CoordActionStartXCommand)2 CoordMaterializeTransitionXCommand (org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand)2