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