Search in sources :

Example 16 with WorkflowAction

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

the class TestPigActionExecutor method testExternalChildIds.

/*
     * Test the Hadoop IDs obtained from the Pig job
     */
public void testExternalChildIds() throws Exception {
    // Set the action xml with the option for retrieving stats to false
    String actionXml = setPigActionXml(PIG_SCRIPT, false);
    Context context = createContext(actionXml);
    final String launcherId = submitAction(context);
    waitUntilYarnAppDoneAndAssertSuccess(launcherId);
    PigActionExecutor ae = new PigActionExecutor();
    WorkflowAction wfAction = context.getAction();
    ae.check(context, wfAction);
    ae.end(context, wfAction);
    assertEquals("SUCCEEDED", wfAction.getExternalStatus());
    String externalIds = wfAction.getExternalChildIDs();
    assertNotNull(externalIds);
    assertNotSame("", externalIds);
    // check for the expected prefix of hadoop jobIDs
    assertTrue(externalIds.contains("job_"));
}
Also used : WorkflowAction(org.apache.oozie.client.WorkflowAction)

Example 17 with WorkflowAction

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

the class TestPigActionExecutor method testExecutionStatsWithRetrieveStatsFalse.

/*
     * Test the stats with retrieve stats option set to false
     */
public void testExecutionStatsWithRetrieveStatsFalse() throws Exception {
    // Set the action xml with the option for retrieving stats to false
    String actionXml = setPigActionXml(PIG_SCRIPT, false);
    Context context = createContext(actionXml);
    final String launcherId = submitAction(context);
    waitUntilYarnAppDoneAndAssertSuccess(launcherId);
    Configuration conf = new XConfiguration();
    conf.set("user.name", getTestUser());
    Map<String, String> actionData = LauncherHelper.getActionData(getFileSystem(), context.getActionDir(), conf);
    assertFalse(LauncherHelper.hasStatsData(actionData));
    PigActionExecutor ae = new PigActionExecutor();
    WorkflowAction wfAction = context.getAction();
    ae.check(context, wfAction);
    ae.end(context, wfAction);
    assertEquals("SUCCEEDED", wfAction.getExternalStatus());
    assertNotNull(wfAction.getExternalChildIDs());
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) WorkflowAction(org.apache.oozie.client.WorkflowAction)

Example 18 with WorkflowAction

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

the class TestPigActionExecutor method submitAction.

private String submitAction(Context context) throws Exception {
    PigActionExecutor ae = new PigActionExecutor();
    WorkflowAction action = context.getAction();
    ae.prepareActionDir(getFileSystem(), context);
    ae.submitLauncher(getFileSystem(), context, action);
    String jobId = action.getExternalId();
    return jobId;
}
Also used : WorkflowAction(org.apache.oozie.client.WorkflowAction)

Example 19 with WorkflowAction

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

the class TestPigActionExecutor method testExecutionStats.

/*
     * Test the stats retrieved from a Pig job
     */
public void testExecutionStats() throws Exception {
    // Set the action xml with the option for retrieving stats to true
    String actionXml = setPigActionXml(PIG_SCRIPT, true);
    Context context = createContext(actionXml);
    final String launcherId = submitAction(context);
    waitUntilYarnAppDoneAndAssertSuccess(launcherId);
    Configuration conf = new XConfiguration();
    conf.set("user.name", getTestUser());
    Map<String, String> actionData = LauncherHelper.getActionData(getFileSystem(), context.getActionDir(), conf);
    assertTrue(LauncherHelper.hasStatsData(actionData));
    PigActionExecutor ae = new PigActionExecutor();
    WorkflowAction wfAction = context.getAction();
    ae.check(context, wfAction);
    ae.end(context, wfAction);
    assertEquals(JavaActionExecutor.SUCCEEDED, wfAction.getExternalStatus());
    String stats = wfAction.getStats();
    assertNotNull(stats);
    // check for some of the expected key values in the stats
    Map m = (Map) JSONValue.parse(stats);
    // check for expected 1st level JSON keys
    assertTrue(m.containsKey("PIG_VERSION"));
    String expectedChildIDs = wfAction.getExternalChildIDs();
    String[] childIDs = expectedChildIDs.split(",");
    assertTrue(m.containsKey(childIDs[0]));
    Map q = (Map) m.get(childIDs[0]);
    // check for expected 2nd level JSON keys
    assertTrue(q.containsKey("HADOOP_COUNTERS"));
}
Also used : XConfiguration(org.apache.oozie.util.XConfiguration) XConfiguration(org.apache.oozie.util.XConfiguration) Configuration(org.apache.hadoop.conf.Configuration) WorkflowAction(org.apache.oozie.client.WorkflowAction) Map(java.util.Map)

Example 20 with WorkflowAction

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

the class LocalOozieExample method printWorkflowInfo.

private static void printWorkflowInfo(WorkflowJob wf) {
    System.out.println("Application Path   : " + wf.getAppPath());
    System.out.println("Application Name   : " + wf.getAppName());
    System.out.println("Application Status : " + wf.getStatus());
    System.out.println("Application Actions:");
    for (WorkflowAction action : wf.getActions()) {
        System.out.println(MessageFormat.format("   Name: {0} Type: {1} Status: {2}", action.getName(), action.getType(), action.getStatus()));
    }
    System.out.println();
}
Also used : 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