Search in sources :

Example 1 with WorkflowJob

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);
}
Also used : WorkflowJob(org.apache.oozie.client.WorkflowJob) Test(org.junit.Test)

Example 2 with WorkflowJob

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);
}
Also used : Pattern(java.util.regex.Pattern) WorkflowJob(org.apache.oozie.client.WorkflowJob) Test(org.junit.Test)

Example 3 with WorkflowJob

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!");
    }
}
Also used : WorkflowJob(org.apache.oozie.client.WorkflowJob) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 4 with WorkflowJob

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);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) WorkflowJob(org.apache.oozie.client.WorkflowJob) HadoopAccessorService(org.apache.oozie.service.HadoopAccessorService)

Example 5 with WorkflowJob

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);
}
Also used : XLogStreamingService(org.apache.oozie.service.XLogStreamingService) WorkflowJob(org.apache.oozie.client.WorkflowJob) Date(java.util.Date)

Aggregations

WorkflowJob (org.apache.oozie.client.WorkflowJob)35 OozieClient (org.apache.oozie.client.OozieClient)18 Path (org.apache.hadoop.fs.Path)14 Properties (java.util.Properties)12 FileSystem (org.apache.hadoop.fs.FileSystem)12 Configuration (org.apache.hadoop.conf.Configuration)11 XConfiguration (org.apache.oozie.util.XConfiguration)11 IOException (java.io.IOException)10 Writer (java.io.Writer)6 WorkflowAction (org.apache.oozie.client.WorkflowAction)6 OutputStreamWriter (java.io.OutputStreamWriter)5 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)5 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)5 OozieClientException (org.apache.oozie.client.OozieClientException)5 Reader (java.io.Reader)4 StringReader (java.io.StringReader)4 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)4 Element (org.jdom.Element)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 File (java.io.File)2