use of org.apache.oozie.client.CoordinatorAction in project oozie by apache.
the class OozieCLI method printCoordActions.
private void printCoordActions(List<CoordinatorAction> actions) {
if (actions != null && actions.size() > 0) {
System.out.println("Action ID" + VERBOSE_DELIMITER + "Nominal Time");
System.out.println(RULER);
for (CoordinatorAction action : actions) {
System.out.println(maskIfNull(action.getId()) + VERBOSE_DELIMITER + maskDate(action.getNominalTime(), null, false));
}
} else {
System.out.println("No Actions match your criteria!");
}
}
use of org.apache.oozie.client.CoordinatorAction 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.CoordinatorAction in project oozie by apache.
the class CoordStatusTransitXCommand method loadState.
@Override
protected void loadState() throws CommandException {
try {
coordJob = CoordJobQueryExecutor.getInstance().get(CoordJobQuery.GET_COORD_JOB, jobId);
List<CoordinatorActionBean> coordActionStatusList = CoordActionQueryExecutor.getInstance().getList(CoordActionQuery.GET_COORD_ACTIONS_STATUS_UNIGNORED, jobId);
long count = (Long) CoordActionQueryExecutor.getInstance().getSingleValue(CoordActionQuery.GET_COORD_ACTIONS_PENDING_COUNT, jobId);
if (count > 0) {
isPending = true;
}
for (CoordinatorAction coordAction : coordActionStatusList) {
int counter = 0;
if (coordActionStatus.containsKey(coordAction.getStatus())) {
counter = getStatusCount(coordAction.getStatus()) + 1;
} else {
++counter;
}
coordActionStatus.put(coordAction.getStatus(), counter);
}
coordActionCount = coordActionStatusList.size();
} catch (JPAExecutorException jpae) {
throw new CommandException(ErrorCode.E1025, jpae);
}
LogUtils.setLogInfo(this.coordJob);
}
use of org.apache.oozie.client.CoordinatorAction in project oozie by apache.
the class TestCoordinatorEngine method testDoneFlag.
/**
* Test Missing Dependencies with No Done Flag in Schema
*
* @throws Exception
*/
public void testDoneFlag() throws Exception {
Configuration conf = new XConfiguration();
String appPath = getTestCaseFileUri("coordinator.xml");
String appXml = "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" start=\"2009-02-01T01:00Z\" end=" + "\"2009-02-01T02:00Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.1\"> <controls> <timeout>10</timeout> <concurrency>2</concurrency> " + "<execution>LIFO</execution> </controls> <datasets> " + "<dataset name=\"local_a\" frequency=\"${coord:days(1)}\" initial-instance=\"2009-02-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("workflows/${YEAR}/${DAY}") + "</uri-template> " + "</dataset>" + "</datasets> <input-events> " + "<data-in name=\"A\" dataset=\"local_a\"> <instance>${coord:current(0)}</instance> </data-in> " + "</input-events> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows2/</app-path> " + "<configuration> <property> <name>inputA</name> <value>${coord:dataIn('A')}</value> </property> " + "</configuration> </workflow> </action> </coordinator-app>";
writeToFile(appXml, appPath);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPath);
conf.set(OozieClient.USER_NAME, getTestUser());
final CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
final String jobId = ce.submitJob(conf, true);
waitFor(5000, new Predicate() {
public boolean evaluate() throws Exception {
try {
List<CoordinatorAction> actions = ce.getCoordJob(jobId).getActions();
for (CoordinatorAction action : actions) {
CoordinatorAction.Status actionStatus = action.getStatus();
if (actionStatus == CoordinatorAction.Status.WAITING) {
return true;
}
}
} catch (Exception ex) {
return false;
}
return false;
}
});
List<CoordinatorAction> actions = ce.getCoordJob(jobId).getActions();
assertTrue(actions.size() > 0);
CoordinatorAction action = actions.get(0);
String missingDeps = action.getMissingDependencies();
System.out.println("Missing deps=" + missingDeps);
// done flag is not added to the missing dependency list
assertEquals(getTestCaseFileUri("workflows/2009/01/_SUCCESS"), missingDeps);
}
use of org.apache.oozie.client.CoordinatorAction in project oozie by apache.
the class TestCoordinatorEngine method testDoneFlagCreation.
/**
* Test Missing Dependencies with Done Flag in Schema
*
* @throws Exception
*/
public void testDoneFlagCreation() throws Exception {
Configuration conf = new XConfiguration();
String appPath = getTestCaseFileUri("coordinator.xml");
String appXml = "<coordinator-app name=\"NAME\" frequency=\"${coord:days(1)}\" start=\"2009-02-01T01:00Z\" end=" + "\"2009-02-01T02:00Z\" timezone=\"UTC\" " + "xmlns=\"uri:oozie:coordinator:0.1\"> <controls> <timeout>10</timeout> <concurrency>2</concurrency> " + "<execution>LIFO</execution> </controls> <datasets> " + "<dataset name=\"local_a\" frequency=\"${coord:days(1)}\" initial-instance=\"2009-02-01T01:00Z\" " + "timezone=\"UTC\"> <uri-template>" + getTestCaseFileUri("workflows/${YEAR}/${MONTH}/${DAY}") + "</uri-template> " + "<done-flag>consume_me</done-flag> </dataset>" + "</datasets> <input-events> " + "<data-in name=\"A\" dataset=\"local_a\"> <instance>${coord:current(0)}</instance> </data-in> " + "</input-events> " + "<action> <workflow> <app-path>hdfs:///tmp/workflows2/</app-path> " + "<configuration> <property> <name>inputA</name> <value>${coord:dataIn('A')}</value> </property> " + "</configuration> </workflow> </action> </coordinator-app>";
writeToFile(appXml, appPath);
conf.set(OozieClient.COORDINATOR_APP_PATH, appPath);
conf.set(OozieClient.USER_NAME, getTestUser());
final CoordinatorEngine ce = new CoordinatorEngine(getTestUser());
final String jobId = ce.submitJob(conf, true);
// create done flag
new File(getTestCaseDir(), "workflows/2009/02/01/consume_me").mkdirs();
waitFor(10000, new Predicate() {
public boolean evaluate() throws Exception {
try {
List<CoordinatorAction> actions = ce.getCoordJob(jobId).getActions();
for (CoordinatorAction action : actions) {
CoordinatorAction.Status actionStatus = action.getStatus();
if (actionStatus == CoordinatorAction.Status.SUBMITTED) {
return true;
}
}
} catch (Exception ex) {
return false;
}
return false;
}
});
List<CoordinatorAction> actions = ce.getCoordJob(jobId).getActions();
assertTrue(actions.size() > 0);
CoordinatorAction action = actions.get(0);
System.out.println("status=" + action.getStatus());
String missingDeps = action.getMissingDependencies();
System.out.println("..Missing deps=" + missingDeps);
if (!(missingDeps == null || missingDeps.equals(""))) {
fail();
}
}
Aggregations