Search in sources :

Example 21 with WorkflowAction

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

the class TestHiveActionExecutor method submitAction.

private String submitAction(Context context, Namespace ns) throws Exception {
    HiveActionExecutor ae = new HiveActionExecutor();
    WorkflowAction action = context.getAction();
    ae.prepareActionDir(getFileSystem(), context);
    ae.submitLauncher(getFileSystem(), context, action);
    String jobId = action.getExternalId();
    String jobTracker = action.getTrackerUri();
    String consoleUrl = action.getConsoleUrl();
    assertNotNull(jobId);
    assertNotNull(jobTracker);
    assertNotNull(consoleUrl);
    return jobId;
}
Also used : WorkflowAction(org.apache.oozie.client.WorkflowAction)

Example 22 with WorkflowAction

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

the class OozieCLI method printJob.

@VisibleForTesting
void printJob(WorkflowJob job, String timeZoneId, boolean verbose) throws IOException {
    System.out.println("Job ID : " + maskIfNull(job.getId()));
    System.out.println(RULER);
    System.out.println("Workflow Name : " + maskIfNull(job.getAppName()));
    System.out.println("App Path      : " + maskIfNull(job.getAppPath()));
    System.out.println("Status        : " + job.getStatus());
    System.out.println("Run           : " + job.getRun());
    System.out.println("User          : " + maskIfNull(job.getUser()));
    System.out.println("Group         : " + maskIfNull(job.getGroup()));
    System.out.println("Created       : " + maskDate(job.getCreatedTime(), timeZoneId, verbose));
    System.out.println("Started       : " + maskDate(job.getStartTime(), timeZoneId, verbose));
    System.out.println("Last Modified : " + maskDate(job.getLastModifiedTime(), timeZoneId, verbose));
    System.out.println("Ended         : " + maskDate(job.getEndTime(), timeZoneId, verbose));
    System.out.println("CoordAction ID: " + maskIfNull(job.getParentId()));
    List<WorkflowAction> actions = job.getActions();
    if (actions != null && actions.size() > 0) {
        System.out.println();
        System.out.println("Actions");
        System.out.println(RULER);
        if (verbose) {
            System.out.println("ID" + VERBOSE_DELIMITER + "Console URL" + VERBOSE_DELIMITER + "Error Code" + VERBOSE_DELIMITER + "Error Message" + VERBOSE_DELIMITER + "External ID" + VERBOSE_DELIMITER + "External Status" + VERBOSE_DELIMITER + "Name" + VERBOSE_DELIMITER + "Retries" + VERBOSE_DELIMITER + "Tracker URI" + VERBOSE_DELIMITER + "Type" + VERBOSE_DELIMITER + "Started" + VERBOSE_DELIMITER + "Status" + VERBOSE_DELIMITER + "Ended");
            System.out.println(RULER);
            for (WorkflowAction action : job.getActions()) {
                System.out.println(maskIfNull(action.getId()) + VERBOSE_DELIMITER + maskIfNull(action.getConsoleUrl()) + VERBOSE_DELIMITER + maskIfNull(action.getErrorCode()) + VERBOSE_DELIMITER + maskIfNull(action.getErrorMessage()) + VERBOSE_DELIMITER + maskIfNull(action.getExternalId()) + VERBOSE_DELIMITER + maskIfNull(action.getExternalStatus()) + VERBOSE_DELIMITER + maskIfNull(action.getName()) + VERBOSE_DELIMITER + action.getRetries() + VERBOSE_DELIMITER + maskIfNull(action.getTrackerUri()) + VERBOSE_DELIMITER + maskIfNull(action.getType()) + VERBOSE_DELIMITER + maskDate(action.getStartTime(), timeZoneId, verbose) + VERBOSE_DELIMITER + action.getStatus() + VERBOSE_DELIMITER + maskDate(action.getEndTime(), timeZoneId, verbose));
                System.out.println(RULER);
            }
        } else {
            System.out.println(String.format(WORKFLOW_ACTION_FORMATTER, "ID", "Status", "Ext ID", "Ext Status", "Err Code"));
            System.out.println(RULER);
            for (WorkflowAction action : job.getActions()) {
                System.out.println(String.format(WORKFLOW_ACTION_FORMATTER, maskIfNull(action.getId()), action.getStatus(), maskIfNull(action.getExternalId()), maskIfNull(action.getExternalStatus()), maskIfNull(action.getErrorCode())));
                System.out.println(RULER);
            }
        }
    } else {
        System.out.println(RULER);
    }
    System.out.println();
}
Also used : WorkflowAction(org.apache.oozie.client.WorkflowAction) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 23 with WorkflowAction

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

the class TestOozieCLIMethods method createWorkflowAction.

private static WorkflowAction createWorkflowAction(DataObject dtObject) {
    WorkflowAction workflowActionMock = mock(WorkflowAction.class);
    when(workflowActionMock.getId()).thenReturn(dtObject.deamonName);
    when(workflowActionMock.getName()).thenReturn(dtObject.appName);
    return workflowActionMock;
}
Also used : WorkflowAction(org.apache.oozie.client.WorkflowAction)

Example 24 with WorkflowAction

use of org.apache.oozie.client.WorkflowAction 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 25 with WorkflowAction

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

the class TestJsonToBean method testParseWorkflowAction.

public void testParseWorkflowAction() {
    JSONObject json = createJsonWorkflowAction();
    WorkflowAction action = JsonToBean.createWorkflowAction(json);
    assertEquals("a", action.getId());
    assertEquals("b", action.getName());
    assertEquals("c", action.getType());
    assertEquals("d", action.getConf());
    assertEquals(WorkflowAction.Status.RUNNING, action.getStatus());
    assertEquals(1, action.getRetries());
    assertEquals(JsonUtils.parseDateRfc822(START_TIME), action.getStartTime());
    assertEquals(JsonUtils.parseDateRfc822(END_TIME), action.getEndTime());
    assertEquals("e", action.getTransition());
    assertEquals("ee", action.getData());
    assertEquals("f", action.getExternalId());
    assertEquals("g", action.getExternalStatus());
    assertEquals("h", action.getTrackerUri());
    assertEquals("i", action.getConsoleUrl());
    assertEquals("j", action.getErrorCode());
    assertEquals("k", action.getErrorMessage());
}
Also used : JSONObject(org.json.simple.JSONObject) WorkflowAction(org.apache.oozie.client.WorkflowAction)

Aggregations

WorkflowAction (org.apache.oozie.client.WorkflowAction)41 FileSystem (org.apache.hadoop.fs.FileSystem)9 Path (org.apache.hadoop.fs.Path)8 IOException (java.io.IOException)6 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)6 WorkflowJob (org.apache.oozie.client.WorkflowJob)6 Writer (java.io.Writer)5 Properties (java.util.Properties)5 OozieClient (org.apache.oozie.client.OozieClient)5 XConfiguration (org.apache.oozie.util.XConfiguration)5 OutputStreamWriter (java.io.OutputStreamWriter)4 Configuration (org.apache.hadoop.conf.Configuration)3 Element (org.jdom.Element)3 File (java.io.File)2 Reader (java.io.Reader)2 StringReader (java.io.StringReader)2 URISyntaxException (java.net.URISyntaxException)2 AccessControlException (org.apache.hadoop.security.AccessControlException)2 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)2 HadoopAccessorException (org.apache.oozie.service.HadoopAccessorException)2