use of org.apache.oozie.client.WorkflowJob in project oozie by apache.
the class TestOozieCLIMethods method testValidatePrintJobOutput.
/**
* Create {@code WorkflowJob}, {@code WorkflowAction} mocks,
* call {@code new OozieCLI().printJob() },
* and validate {@code System.out} on match with expected pattern
* <p>
* Method do pass only if output matched with predefined pattern
* </p>
*/
@Test
public void testValidatePrintJobOutput() throws IOException {
final DataObject dtObject = new DataObject() {
{
this.deamonName = "testWorkflowJob";
this.appName = "testWorkflowJobApp";
this.appPath = "testWorkflowJobAppPath";
}
};
WorkflowJob workflowJob = createWorkflowJob(dtObject);
assertPrintWorkflowJobOutput1(readWorkflowJobOutput(workflowJob, true), dtObject);
assertPrintWorkflowJobOutput1(readWorkflowJobOutput(workflowJob, false), dtObject);
}
use of org.apache.oozie.client.WorkflowJob in project oozie by apache.
the class TestOozieCLIMethods method testValidatePrintJobsOutput.
/**
* Create {@code CoordinatorJob} mock,
* call {@code new OozieCLI().printJobs() }
* and validate {@code System.out} on match with expected pattern
* <p>
* Method do pass only if output matched with predefined pattern
* </p>
*/
@Test
public void testValidatePrintJobsOutput() throws IOException {
final DataObject dtObject1 = new DataObject() {
{
this.deamonName = "testWorkflowJob1";
this.appName = "testWorkflowJobApp1";
this.appPath = "testWorkflowJobAppPath1";
}
};
final DataObject dtObject2 = new DataObject() {
{
this.deamonName = "testWorkflowJob2";
this.appName = "testWorkflowJobApp2";
this.appPath = "testWorkflowJobAppPath2";
}
};
ImmutableList<WorkflowJob> workflowJobs = ImmutableList.of(createWorkflowJob(dtObject1), createWorkflowJob(dtObject2));
Pattern pattern = Pattern.compile(dtObject1.deamonName + "[\\s]+" + dtObject1.appName + "[\\s]+" + dtObject1.appPath);
assertPrintWorkflowJobOutput(readWorkflowJobsOutput(workflowJobs, true), pattern);
pattern = Pattern.compile(dtObject1.deamonName + "[\\s]+" + dtObject1.appName);
assertPrintWorkflowJobOutput(readWorkflowJobsOutput(workflowJobs, false), pattern);
}
use of org.apache.oozie.client.WorkflowJob in project oozie by apache.
the class OozieCLI method printJobs.
@VisibleForTesting
void printJobs(List<WorkflowJob> 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 + "Run" + VERBOSE_DELIMITER + "Created" + VERBOSE_DELIMITER + "Started" + VERBOSE_DELIMITER + "Status" + VERBOSE_DELIMITER + "Last Modified" + VERBOSE_DELIMITER + "Ended");
System.out.println(RULER);
for (WorkflowJob 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.getRun() + VERBOSE_DELIMITER + maskDate(job.getCreatedTime(), timeZoneId, verbose) + VERBOSE_DELIMITER + maskDate(job.getStartTime(), timeZoneId, verbose) + VERBOSE_DELIMITER + job.getStatus() + VERBOSE_DELIMITER + maskDate(job.getLastModifiedTime(), timeZoneId, verbose) + VERBOSE_DELIMITER + maskDate(job.getEndTime(), timeZoneId, verbose));
System.out.println(RULER);
}
} else {
System.out.println(String.format(WORKFLOW_JOBS_FORMATTER, "Job ID", "App Name", "Status", "User", "Group", "Started", "Ended"));
System.out.println(RULER);
for (WorkflowJob job : jobs) {
System.out.println(String.format(WORKFLOW_JOBS_FORMATTER, maskIfNull(job.getId()), maskIfNull(job.getAppName()), job.getStatus(), maskIfNull(job.getUser()), maskIfNull(job.getGroup()), maskDate(job.getStartTime(), timeZoneId, verbose), maskDate(job.getEndTime(), timeZoneId, verbose)));
System.out.println(RULER);
}
}
} else {
System.out.println("No Jobs match your criteria!");
}
}
use of org.apache.oozie.client.WorkflowJob in project oozie by apache.
the class FsELFunctions method getFileSystem.
private static FileSystem getFileSystem(URI uri) throws HadoopAccessorException {
WorkflowJob workflow = DagELFunctions.getWorkflow();
String user = workflow.getUser();
HadoopAccessorService has = Services.get().get(HadoopAccessorService.class);
Configuration conf = has.createConfiguration(uri.getAuthority());
return has.createFileSystem(user, uri, conf);
}
use of org.apache.oozie.client.WorkflowJob in project oozie by apache.
the class DagEngine method streamJobLog.
@Override
protected void streamJobLog(XLogStreamer logStreamer, String jobId, Writer writer) throws IOException, DagEngineException {
logStreamer.getXLogFilter().setParameter(DagXLogInfoService.JOB, jobId);
WorkflowJob job = getJob(jobId);
Date lastTime = job.getEndTime();
if (lastTime == null) {
lastTime = job.getLastModifiedTime();
}
Services.get().get(XLogStreamingService.class).streamLog(logStreamer, job.getCreatedTime(), lastTime, writer);
}
Aggregations