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;
}
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);
}
}
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());
}
}
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));
}
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());
}
}
Aggregations