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);
}
}
}
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);
}
}
}
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;
}
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());
}
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());
}
Aggregations