Search in sources :

Example 21 with WorkflowJob

use of org.apache.oozie.client.WorkflowJob in project oozie by apache.

the class OozieCLI method printWfsForCoordAction.

void printWfsForCoordAction(List<WorkflowJob> jobs, String timeZoneId) throws IOException {
    if (jobs != null && jobs.size() > 0) {
        System.out.println(String.format("%-41s%-10s%-24s%-24s", "Job ID", "Status", "Started", "Ended"));
        System.out.println(RULER);
        for (WorkflowJob job : jobs) {
            System.out.println(String.format("%-41s%-10s%-24s%-24s", maskIfNull(job.getId()), job.getStatus(), maskDate(job.getStartTime(), timeZoneId, false), maskDate(job.getEndTime(), timeZoneId, false)));
            System.out.println(RULER);
        }
    }
}
Also used : WorkflowJob(org.apache.oozie.client.WorkflowJob)

Example 22 with WorkflowJob

use of org.apache.oozie.client.WorkflowJob in project oozie by apache.

the class OozieCLI method printBulkModifiedJobs.

@VisibleForTesting
void printBulkModifiedJobs(JSONObject json, String timeZoneId, String action) throws IOException {
    if (json.containsKey(JsonTags.WORKFLOWS_JOBS)) {
        JSONArray workflows = (JSONArray) json.get(JsonTags.WORKFLOWS_JOBS);
        if (workflows == null) {
            workflows = new JSONArray();
        }
        List<WorkflowJob> wfs = JsonToBean.createWorkflowJobList(workflows);
        if (wfs.isEmpty()) {
            System.out.println("bulk modify command did not modify any jobs");
        } else {
            System.out.println("the following jobs have been " + action);
            printJobs(wfs, timeZoneId, false);
        }
    } else if (json.containsKey(JsonTags.COORDINATOR_JOBS)) {
        JSONArray coordinators = (JSONArray) json.get(JsonTags.COORDINATOR_JOBS);
        if (coordinators == null) {
            coordinators = new JSONArray();
        }
        List<CoordinatorJob> coords = JsonToBean.createCoordinatorJobList(coordinators);
        if (coords.isEmpty()) {
            System.out.println("bulk modify command did not modify any jobs");
        } else {
            System.out.println("the following jobs have been " + action);
            printCoordJobs(coords, timeZoneId, false);
        }
    } else {
        JSONArray bundles = (JSONArray) json.get(JsonTags.BUNDLE_JOBS);
        if (bundles == null) {
            bundles = new JSONArray();
        }
        List<BundleJob> bundleJobs = JsonToBean.createBundleJobList(bundles);
        if (bundleJobs.isEmpty()) {
            System.out.println("bulk modify command did not modify any jobs");
        } else {
            System.out.println("the following jobs have been " + action);
            printBundleJobs(bundleJobs, timeZoneId, false);
        }
    }
}
Also used : JSONArray(org.json.simple.JSONArray) List(java.util.List) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) WorkflowJob(org.apache.oozie.client.WorkflowJob) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 23 with WorkflowJob

use of org.apache.oozie.client.WorkflowJob in project oozie by apache.

the class TestOozieCLIMethods method createWorkflowJob.

private WorkflowJob createWorkflowJob(DataObject dtObject) {
    WorkflowJob workflowJobMock = mock(WorkflowJob.class);
    when(workflowJobMock.getId()).thenReturn(dtObject.deamonName);
    when(workflowJobMock.getAppName()).thenReturn(dtObject.appName);
    when(workflowJobMock.getAppPath()).thenReturn(dtObject.appPath);
    when(workflowJobMock.getStatus()).thenReturn(WorkflowJob.Status.RUNNING);
    WorkflowAction ac = createWorkflowAction(dtObject);
    WorkflowAction ac0 = createWorkflowAction(dtObject);
    when(workflowJobMock.getActions()).thenReturn(Arrays.asList(ac, ac0));
    return workflowJobMock;
}
Also used : WorkflowAction(org.apache.oozie.client.WorkflowAction) WorkflowJob(org.apache.oozie.client.WorkflowJob)

Example 24 with WorkflowJob

use of org.apache.oozie.client.WorkflowJob in project oozie by apache.

the class TestJsonToBean method testParseWorkflowJob.

@SuppressWarnings("unchecked")
public void testParseWorkflowJob() {
    JSONObject json = createJsonWorkflowJob();
    WorkflowJob wf = JsonToBean.createWorkflowJob(json);
    assertEquals("a", wf.getAppPath());
    assertEquals("b", wf.getAppName());
    assertEquals("c", wf.getId());
    assertEquals("d", wf.getConf());
    assertEquals(WorkflowJob.Status.PREP, wf.getStatus());
    assertEquals(JsonUtils.parseDateRfc822(CREATED_TIME), wf.getCreatedTime());
    assertEquals(JsonUtils.parseDateRfc822(START_TIME), wf.getStartTime());
    assertEquals(JsonUtils.parseDateRfc822(END_TIME), wf.getEndTime());
    assertEquals("e", wf.getUser());
    assertEquals("f", wf.getGroup());
    assertEquals(1, wf.getRun());
    assertEquals("g", wf.getConsoleUrl());
    assertEquals(2, wf.getActions().size());
    assertEquals("a1", wf.getActions().get(0).getId());
    assertEquals("a2", wf.getActions().get(1).getId());
}
Also used : JSONObject(org.json.simple.JSONObject) WorkflowJob(org.apache.oozie.client.WorkflowJob)

Example 25 with WorkflowJob

use of org.apache.oozie.client.WorkflowJob in project oozie by apache.

the class TestJsonToBean method testParseWorkflowJobs.

@SuppressWarnings("unchecked")
public void testParseWorkflowJobs() {
    JSONArray array = createJsonWorkflowJobList();
    List<WorkflowJob> list = JsonToBean.createWorkflowJobList(array);
    assertEquals(2, list.size());
    assertEquals("j1", list.get(0).getId());
    assertEquals("j2", list.get(1).getId());
}
Also used : JSONArray(org.json.simple.JSONArray) WorkflowJob(org.apache.oozie.client.WorkflowJob)

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