use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.
the class AppInfoCollector method getBundleJob.
private void getBundleJob(final File outputDir, final String jobId, int maxChildActions) {
if (jobId == null || !isBundle(jobId)) {
return;
}
try {
System.out.print("Getting Details for " + jobId + "...");
final File bundleOutputDir = new File(outputDir, jobId);
if (!createOutputDirectory(bundleOutputDir)) {
return;
}
final BundleJob job = client.getBundleJobInfo(jobId);
try (DiagBundleEntryWriter bundleEntryWriter = new DiagBundleEntryWriter(bundleOutputDir, "info.txt")) {
persistBundleJobInfo(job, bundleEntryWriter);
}
storeCommonDetails(bundleOutputDir, jobId, "bundle", job.getConf());
System.out.println("Done");
for (CoordinatorJob coordJob : job.getCoordinators()) {
getCoordJob(outputDir, coordJob.getId(), maxChildActions);
}
} catch (IOException | OozieClientException e) {
System.err.printf(String.format("Exception occurred during the retrieval of bundle information: %s%n", e.getMessage()));
}
}
use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.
the class AppInfoCollector method getCoordJob.
private void getCoordJob(final File outputDir, final String jobId, int maxChildActions) {
if (jobId == null || !isCoordinator(jobId)) {
return;
}
try {
System.out.print("Getting Details for " + jobId + "...");
final File coordOutputDir = new File(outputDir, jobId);
if (!createOutputDirectory(coordOutputDir)) {
return;
}
final CoordinatorJob job = client.getCoordJobInfo(jobId);
try (DiagBundleEntryWriter bundleEntryWriter = new DiagBundleEntryWriter(coordOutputDir, "info.txt")) {
persistCoordinatorJobInfo(maxChildActions, job, bundleEntryWriter);
}
storeCommonDetails(coordOutputDir, jobId, "coordinator", job.getConf());
System.out.println("Done");
final List<CoordinatorAction> coordinatorActions = job.getActions();
for (int i = 0; i != coordinatorActions.size() && i < maxChildActions; ++i) {
storeWorkflowJobDetails(outputDir, coordinatorActions.get(i).getExternalId(), maxChildActions);
}
} catch (IOException | OozieClientException e) {
System.err.printf(String.format("Exception occurred during the retrieval of coordinator information:%s%n", e.getMessage()));
}
}
use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.
the class OozieCLI method printBulkJobs.
@VisibleForTesting
void printBulkJobs(List<BulkResponse> jobs, String timeZoneId, boolean verbose) throws IOException {
if (jobs != null && jobs.size() > 0) {
for (BulkResponse response : jobs) {
BundleJob bundle = response.getBundle();
CoordinatorJob coord = response.getCoordinator();
CoordinatorAction action = response.getAction();
if (verbose) {
System.out.println();
System.out.println("Bundle Name : " + maskIfNull(bundle.getAppName()));
System.out.println(RULER);
System.out.println("Bundle ID : " + maskIfNull(bundle.getId()));
System.out.println("Coordinator Name : " + maskIfNull(coord.getAppName()));
System.out.println("Coord Action ID : " + maskIfNull(action.getId()));
System.out.println("Action Status : " + action.getStatus());
System.out.println("External ID : " + maskIfNull(action.getExternalId()));
System.out.println("Created Time : " + maskDate(action.getCreatedTime(), timeZoneId, false));
System.out.println("User : " + maskIfNull(bundle.getUser()));
System.out.println("Error Message : " + maskIfNull(action.getErrorMessage()));
System.out.println(RULER);
} else {
System.out.println(String.format(BULK_RESPONSE_FORMATTER, "Bundle Name", "Bundle ID", "Coord Name", "Coord Action ID", "Status", "External ID", "Created Time", "Error Message"));
System.out.println(RULER);
System.out.println(String.format(BULK_RESPONSE_FORMATTER, maskIfNull(bundle.getAppName()), maskIfNull(bundle.getId()), maskIfNull(coord.getAppName()), maskIfNull(action.getId()), action.getStatus(), maskIfNull(action.getExternalId()), maskDate(action.getCreatedTime(), timeZoneId, false), maskIfNull(action.getErrorMessage())));
System.out.println(RULER);
}
}
} else {
System.out.println("Bulk request criteria did not match any coordinator actions");
}
}
use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.
the class OozieCLI method printCoordJobs.
@VisibleForTesting
void printCoordJobs(List<CoordinatorJob> jobs, String timeZoneId, boolean verbose) throws IOException {
if (jobs != null && jobs.size() > 0) {
if (verbose) {
System.out.println("Job ID" + VERBOSE_DELIMITER + "App Name" + VERBOSE_DELIMITER + "App Path" + VERBOSE_DELIMITER + "Console URL" + VERBOSE_DELIMITER + "User" + VERBOSE_DELIMITER + "Group" + VERBOSE_DELIMITER + "Concurrency" + VERBOSE_DELIMITER + "Frequency" + VERBOSE_DELIMITER + "Time Unit" + VERBOSE_DELIMITER + "Time Zone" + VERBOSE_DELIMITER + "Time Out" + VERBOSE_DELIMITER + "Started" + VERBOSE_DELIMITER + "Next Materialize" + VERBOSE_DELIMITER + "Status" + VERBOSE_DELIMITER + "Last Action" + VERBOSE_DELIMITER + "Ended");
System.out.println(RULER);
for (CoordinatorJob job : jobs) {
System.out.println(maskIfNull(job.getId()) + VERBOSE_DELIMITER + maskIfNull(job.getAppName()) + VERBOSE_DELIMITER + maskIfNull(job.getAppPath()) + VERBOSE_DELIMITER + maskIfNull(job.getConsoleUrl()) + VERBOSE_DELIMITER + maskIfNull(job.getUser()) + VERBOSE_DELIMITER + maskIfNull(job.getGroup()) + VERBOSE_DELIMITER + job.getConcurrency() + VERBOSE_DELIMITER + job.getFrequency() + VERBOSE_DELIMITER + job.getTimeUnit() + VERBOSE_DELIMITER + maskIfNull(job.getTimeZone()) + VERBOSE_DELIMITER + job.getTimeout() + VERBOSE_DELIMITER + maskDate(job.getStartTime(), timeZoneId, verbose) + VERBOSE_DELIMITER + maskDate(job.getNextMaterializedTime(), timeZoneId, verbose) + VERBOSE_DELIMITER + job.getStatus() + VERBOSE_DELIMITER + maskDate(job.getLastActionTime(), timeZoneId, verbose) + VERBOSE_DELIMITER + maskDate(job.getEndTime(), timeZoneId, verbose));
System.out.println(RULER);
}
} else {
System.out.println(String.format(COORD_JOBS_FORMATTER, "Job ID", "App Name", "Status", "Freq", "Unit", "Started", "Next Materialized"));
System.out.println(RULER);
for (CoordinatorJob job : jobs) {
System.out.println(String.format(COORD_JOBS_FORMATTER, maskIfNull(job.getId()), maskIfNull(job.getAppName()), job.getStatus(), job.getFrequency(), job.getTimeUnit(), maskDate(job.getStartTime(), timeZoneId, verbose), maskDate(job.getNextMaterializedTime(), timeZoneId, verbose)));
System.out.println(RULER);
}
}
} else {
System.out.println("No Jobs match your criteria!");
}
}
use of org.apache.oozie.client.CoordinatorJob in project oozie by apache.
the class TestOozieCLIMethods method testValidatePrintCoordJobMethodOutput.
/**
* Create {@code CoordinatorJob} and {@code CoordinatorActions} mocks,
* call {@code new OozieCLI().printCoordJob() },
* and validate {@code System.out} output on match with
* expected pattern.
* <p>
* Method do pass only if output matched with predefined pattern
* </p>
*/
@Test
public void testValidatePrintCoordJobMethodOutput() throws IOException {
final DataObject dtObject = new DataObject() {
{
this.deamonName = "testCoordJob";
this.appName = "testCoordinatorJobApp";
this.appPath = "testCoordinatorJobAppPath";
}
};
CoordinatorJob coordJob = createCoordinatorJob(dtObject);
assertPrintCoordJobOutput(readCoordJobOutput(coordJob, true), dtObject);
assertPrintCoordJobOutput(readCoordJobOutput(coordJob, false), dtObject);
}
Aggregations