Search in sources :

Example 6 with CoordinatorAction

use of org.apache.oozie.client.CoordinatorAction 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 CoordinatorAction

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

the class OozieCLI method printCoordActionsStatus.

private void printCoordActionsStatus(List<CoordinatorAction> actions) {
    if (actions != null && actions.size() > 0) {
        System.out.println("Action ID" + VERBOSE_DELIMITER + "Nominal Time" + VERBOSE_DELIMITER + "Status");
        System.out.println(RULER);
        for (CoordinatorAction action : actions) {
            System.out.println(maskIfNull(action.getId()) + VERBOSE_DELIMITER + maskDate(action.getNominalTime(), null, false) + VERBOSE_DELIMITER + maskIfNull(action.getStatus().name()));
        }
    }
}
Also used : CoordinatorAction(org.apache.oozie.client.CoordinatorAction)

Example 8 with CoordinatorAction

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

the class TestRecoveryService method testCoordActionRecoveryServiceForWaitingRegisterPartition.

public void testCoordActionRecoveryServiceForWaitingRegisterPartition() throws Exception {
    services.destroy();
    services = super.setupServicesForHCatalog();
    services.getConf().set(URIHandlerService.URI_HANDLERS, FSURIHandler.class.getName() + "," + HCatURIHandler.class.getName());
    services.getConf().setLong(RecoveryService.CONF_PUSH_DEPENDENCY_INTERVAL, 1);
    services.init();
    String db = "default";
    String table = "tablename";
    // dep1 is not available and dep2 is available
    String newHCatDependency1 = "hcat://" + server + "/" + db + "/" + table + "/dt=20120430;country=brazil";
    String newHCatDependency2 = "hcat://" + server + "/" + db + "/" + table + "/dt=20120430;country=usa";
    String newHCatDependency = newHCatDependency1 + CoordELFunctions.INSTANCE_SEPARATOR + newHCatDependency2;
    HCatAccessorService hcatService = services.get(HCatAccessorService.class);
    JMSAccessorService jmsService = services.get(JMSAccessorService.class);
    PartitionDependencyManagerService pdms = services.get(PartitionDependencyManagerService.class);
    assertFalse(jmsService.isListeningToTopic(hcatService.getJMSConnectionInfo(new URI(newHCatDependency1)), db + "." + table));
    populateTable(db, table);
    String actionId = addInitRecords(newHCatDependency);
    CoordinatorAction ca = checkCoordActionDependencies(actionId, newHCatDependency);
    assertEquals(CoordinatorAction.Status.WAITING, ca.getStatus());
    // Register the missing dependencies to PDMS assuming CoordPushDependencyCheckCommand did this.
    pdms.addMissingDependency(new HCatURI(newHCatDependency1), actionId);
    pdms.addMissingDependency(new HCatURI(newHCatDependency2), actionId);
    sleep(2000);
    Runnable recoveryRunnable = new RecoveryRunnable(0, 1, 1);
    recoveryRunnable.run();
    sleep(2000);
    // Recovery service should have discovered newHCatDependency2 and JMS Connection should exist
    // and newHCatDependency1 should be in PDMS waiting list
    assertTrue(jmsService.isListeningToTopic(hcatService.getJMSConnectionInfo(new URI(newHCatDependency2)), "hcat." + db + "." + table));
    checkCoordActionDependencies(actionId, newHCatDependency1);
    assertNull(pdms.getWaitingActions(new HCatURI(newHCatDependency2)));
    Collection<String> waitingActions = pdms.getWaitingActions(new HCatURI(newHCatDependency1));
    assertEquals(1, waitingActions.size());
    assertTrue(waitingActions.contains(actionId));
}
Also used : RecoveryRunnable(org.apache.oozie.service.RecoveryService.RecoveryRunnable) RecoveryRunnable(org.apache.oozie.service.RecoveryService.RecoveryRunnable) CoordinatorAction(org.apache.oozie.client.CoordinatorAction) FSURIHandler(org.apache.oozie.dependency.FSURIHandler) HCatURI(org.apache.oozie.util.HCatURI) URI(java.net.URI) HCatURI(org.apache.oozie.util.HCatURI)

Example 9 with CoordinatorAction

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

the class LocalOozieClientCoord method getCoordinatorActions.

private List<CoordinatorAction> getCoordinatorActions(String jobId, String rerunType, String scope, boolean refresh, boolean noCleanup, boolean failed, Properties prop) throws OozieClientException {
    try {
        XConfiguration conf = null;
        if (prop != null) {
            conf = new XConfiguration(prop);
        }
        if (!(rerunType.equals(RestConstants.JOB_COORD_SCOPE_DATE) || rerunType.equals(RestConstants.JOB_COORD_SCOPE_ACTION))) {
            throw new CommandException(ErrorCode.E1018, "date or action expected.");
        }
        CoordinatorActionInfo coordInfo = coordEngine.reRun(jobId, rerunType, scope, Boolean.valueOf(refresh), Boolean.valueOf(noCleanup), Boolean.valueOf(failed), conf);
        List<CoordinatorActionBean> actionBeans;
        if (coordInfo != null) {
            actionBeans = coordInfo.getCoordActions();
        } else {
            actionBeans = CoordUtils.getCoordActions(rerunType, jobId, scope, false);
        }
        List<CoordinatorAction> actions = new ArrayList<CoordinatorAction>();
        for (CoordinatorActionBean actionBean : actionBeans) {
            actions.add(actionBean);
        }
        return actions;
    } catch (CommandException ce) {
        throw new OozieClientException(ce.getErrorCode().toString(), ce);
    } catch (BaseEngineException ex) {
        throw new OozieClientException(ex.getErrorCode().toString(), ex);
    }
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) OozieClientException(org.apache.oozie.client.OozieClientException) CoordinatorAction(org.apache.oozie.client.CoordinatorAction) ArrayList(java.util.ArrayList) CommandException(org.apache.oozie.command.CommandException)

Example 10 with CoordinatorAction

use of org.apache.oozie.client.CoordinatorAction 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)

Aggregations

CoordinatorAction (org.apache.oozie.client.CoordinatorAction)28 IOException (java.io.IOException)11 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)11 CoordinatorJob (org.apache.oozie.client.CoordinatorJob)9 XConfiguration (org.apache.oozie.util.XConfiguration)8 Configuration (org.apache.hadoop.conf.Configuration)7 List (java.util.List)6 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)6 CommandException (org.apache.oozie.command.CommandException)6 StoreException (org.apache.oozie.store.StoreException)6 CoordActionInputCheckXCommand (org.apache.oozie.command.coord.CoordActionInputCheckXCommand)4 CoordMaterializeTransitionXCommand (org.apache.oozie.command.coord.CoordMaterializeTransitionXCommand)4 File (java.io.File)3 BundleJob (org.apache.oozie.client.BundleJob)3 JDOMException (org.jdom.JDOMException)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 URI (java.net.URI)2 CoordinatorEngine (org.apache.oozie.CoordinatorEngine)2 BulkResponse (org.apache.oozie.client.BulkResponse)2 OozieClientException (org.apache.oozie.client.OozieClientException)2