Search in sources :

Example 6 with CoordinatorJob

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

the class TestJsonToBean method testParseBulkResponse.

public void testParseBulkResponse() {
    JSONObject json = createJsonBulkResponse();
    BundleJob bulkBundle = JsonToBean.createBundleJob((JSONObject) json.get(JsonTags.BULK_RESPONSE_BUNDLE));
    CoordinatorJob bulkCoord = JsonToBean.createCoordinatorJob((JSONObject) json.get(JsonTags.BULK_RESPONSE_COORDINATOR));
    CoordinatorAction bulkAction = JsonToBean.createCoordinatorAction((JSONObject) json.get(JsonTags.BULK_RESPONSE_ACTION));
    assertNotNull(bulkBundle);
    assertNotNull(bulkCoord);
    assertNotNull(bulkAction);
    assertEquals("bundle-app", bulkBundle.getAppName());
    assertEquals("bundle-id", bulkBundle.getId());
    assertEquals(BundleJob.Status.RUNNING, bulkBundle.getStatus());
    assertEquals("coord-app", bulkCoord.getAppName());
    assertEquals(CoordinatorJob.Status.SUSPENDED, bulkCoord.getStatus());
    assertEquals("action-id", bulkAction.getId());
    assertEquals("coord-id", bulkAction.getJobId());
    assertEquals(1, bulkAction.getActionNumber());
    assertEquals("action-externalId", bulkAction.getExternalId());
    assertEquals(CoordinatorAction.Status.FAILED, bulkAction.getStatus());
    assertEquals("action-externalStatus", bulkAction.getExternalStatus());
    assertEquals("action-errorCode", bulkAction.getErrorCode());
    assertEquals("action-errorMessage", bulkAction.getErrorMessage());
    assertEquals(JsonUtils.parseDateRfc822(CREATED_TIME), bulkAction.getCreatedTime());
    assertEquals(JsonUtils.parseDateRfc822(NOMINAL_TIME), bulkAction.getNominalTime());
    assertEquals("action-missingDeps", bulkAction.getMissingDependencies());
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob) JSONObject(org.json.simple.JSONObject) CoordinatorAction(org.apache.oozie.client.CoordinatorAction) BundleJob(org.apache.oozie.client.BundleJob)

Example 7 with CoordinatorJob

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

the class OozieCLI method printBundleJob.

@VisibleForTesting
void printBundleJob(BundleJob bundleJob, String timeZoneId, boolean verbose) {
    System.out.println("Job ID : " + bundleJob.getId());
    System.out.println(RULER);
    List<CoordinatorJob> coordinators = bundleJob.getCoordinators();
    System.out.println("Job Name : " + maskIfNull(bundleJob.getAppName()));
    System.out.println("App Path : " + maskIfNull(bundleJob.getAppPath()));
    System.out.println("Status   : " + bundleJob.getStatus());
    System.out.println("Kickoff time   : " + bundleJob.getKickoffTime());
    System.out.println(RULER);
    System.out.println(String.format(BUNDLE_COORD_JOBS_FORMATTER, "Job ID", "Status", "Freq", "Unit", "Started", "Next Materialized"));
    System.out.println(RULER);
    for (CoordinatorJob job : coordinators) {
        System.out.println(String.format(BUNDLE_COORD_JOBS_FORMATTER, maskIfNull(job.getId()), job.getStatus(), job.getFrequency(), job.getTimeUnit(), maskDate(job.getStartTime(), timeZoneId, verbose), maskDate(job.getNextMaterializedTime(), timeZoneId, verbose)));
        System.out.println(RULER);
    }
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 8 with CoordinatorJob

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

the class TestFutureActionsTimeOut method _testTimeout.

/**
 * The catch-up mode time up has been setup in {@link CoordActionMaterializeXCommand}
 * @param jobId job id
 * @param createDate create date
 * @throws Exception thrown if failed
 */
private void _testTimeout(final String jobId, Date createDate) throws Exception {
    final CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
    waitFor(12000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJob job = ce.getCoordJob(jobId);
            return !(job.getStatus().equals(CoordinatorJob.Status.PREP));
        }
    });
    CoordinatorJob job = ce.getCoordJob(jobId);
    assertTrue(!(job.getStatus().equals(CoordinatorJob.Status.PREP)));
    waitFor(12000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJob job = ce.getCoordJob(jobId);
            List<CoordinatorAction> actions = job.getActions();
            return actions.size() > 0;
        }
    });
    job = ce.getCoordJob(jobId);
    List<CoordinatorAction> actions = job.getActions();
    assertTrue(actions.size() > 0);
    for (CoordinatorAction action : actions) {
        CoordinatorActionBean jsonAction = (CoordinatorActionBean) action;
        if (jsonAction.getNominalTime().before(createDate)) {
            assertEquals(10, jsonAction.getTimeOut());
        } else {
            assertEquals(10, jsonAction.getTimeOut());
        }
    }
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob) CoordinatorEngine(org.apache.oozie.CoordinatorEngine) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordinatorAction(org.apache.oozie.client.CoordinatorAction) List(java.util.List) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException) StoreException(org.apache.oozie.store.StoreException)

Example 9 with CoordinatorJob

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

the class TestPastActionsTimeOut method _testTimeout.

/**
 * The catch-up mode time up has been setup in {@link CoordActionMaterializeXCommand}
 * @param jobId job id
 * @throws Exception thrown if failed
 */
private void _testTimeout(final String jobId) throws Exception {
    final CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
    waitFor(6000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJob job = ce.getCoordJob(jobId);
            return !(job.getStatus().equals(CoordinatorJob.Status.PREP));
        }
    });
    CoordinatorJob job = ce.getCoordJob(jobId);
    assertTrue(!(job.getStatus().equals(CoordinatorJob.Status.PREP)));
    waitFor(6000, new Predicate() {

        public boolean evaluate() throws Exception {
            CoordinatorJob job = ce.getCoordJob(jobId);
            List<CoordinatorAction> actions = job.getActions();
            return actions.size() > 0;
        }
    });
    job = ce.getCoordJob(jobId);
    List<CoordinatorAction> actions = job.getActions();
    assertTrue(actions.size() > 0);
    for (CoordinatorAction action : actions) {
        CoordinatorActionBean json = (CoordinatorActionBean) action;
        assertEquals(10, json.getTimeOut());
    }
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob) CoordinatorEngine(org.apache.oozie.CoordinatorEngine) CoordinatorActionBean(org.apache.oozie.CoordinatorActionBean) CoordinatorAction(org.apache.oozie.client.CoordinatorAction) List(java.util.List) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) IOException(java.io.IOException) StoreException(org.apache.oozie.store.StoreException)

Example 10 with CoordinatorJob

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

the class TestCoordMaterializeTransitionXCommand method getStatus.

private CoordinatorJob.Status getStatus(String jobId) {
    CoordinatorJob job = null;
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        job = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
    } catch (JPAExecutorException se) {
        se.printStackTrace();
    }
    return job.getStatus();
}
Also used : CoordinatorJob(org.apache.oozie.client.CoordinatorJob) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) CoordJobGetJPAExecutor(org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor) JPAService(org.apache.oozie.service.JPAService)

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