Author: rkanter
Date: Tue Nov  5 00:56:20 2013
New Revision: 1538845

URL: http://svn.apache.org/r1538845
Log:
OOZIE-1600 map-reduce actions without configuration section in workflow.xml 
throws "IllegalArgumentException: element cannot be null" (bowenzhangusa via 
rkanter)

Modified:
    
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/MapReduceActionExecutor.java
    oozie/trunk/release-log.txt
    
oozie/trunk/sharelib/streaming/src/test/java/org/apache/oozie/action/hadoop/TestMapReduceActionExecutor.java

Modified: 
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/MapReduceActionExecutor.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/MapReduceActionExecutor.java?rev=1538845&r1=1538844&r2=1538845&view=diff
==============================================================================
--- 
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/MapReduceActionExecutor.java
 (original)
+++ 
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/MapReduceActionExecutor.java
 Tue Nov  5 00:56:20 2013
@@ -234,14 +234,17 @@ public class MapReduceActionExecutor ext
     // Return the value of the specified configuration property
     private String evaluateConfigurationProperty(Element actionConf, String 
key, String defaultValue) throws ActionExecutorException {
         try {
+            String ret = defaultValue;
             if (actionConf != null) {
                 Namespace ns = actionConf.getNamespace();
                 Element e = actionConf.getChild("configuration", ns);
-                String strConf = XmlUtils.prettyPrint(e).toString();
-                XConfiguration inlineConf = new XConfiguration(new 
StringReader(strConf));
-                return inlineConf.get(key, defaultValue);
+                if(e != null) {
+                    String strConf = XmlUtils.prettyPrint(e).toString();
+                    XConfiguration inlineConf = new XConfiguration(new 
StringReader(strConf));
+                    ret = inlineConf.get(key, defaultValue);
+                }
             }
-            return "";
+            return ret;
         }
         catch (IOException ex) {
             throw convertException(ex);

Modified: oozie/trunk/release-log.txt
URL: 
http://svn.apache.org/viewvc/oozie/trunk/release-log.txt?rev=1538845&r1=1538844&r2=1538845&view=diff
==============================================================================
--- oozie/trunk/release-log.txt (original)
+++ oozie/trunk/release-log.txt Tue Nov  5 00:56:20 2013
@@ -1,5 +1,6 @@
 -- Oozie 4.1.0 release (trunk - unreleased)
 
+OOZIE-1600 map-reduce actions without configuration section in workflow.xml 
throws "IllegalArgumentException: element cannot be null" (bowenzhangusa via 
rkanter)
 OOZIE-1580 EL variables don't get resolved in configurations imported from a 
<job-xml> (bowenzhangusa via rkanter)
 OOZIE-1562 Allow re-run of actions of killed coordinator (shwethags via virag)
 OOZIE-1597 Cleanup database before every test (rkanter)

Modified: 
oozie/trunk/sharelib/streaming/src/test/java/org/apache/oozie/action/hadoop/TestMapReduceActionExecutor.java
URL: 
http://svn.apache.org/viewvc/oozie/trunk/sharelib/streaming/src/test/java/org/apache/oozie/action/hadoop/TestMapReduceActionExecutor.java?rev=1538845&r1=1538844&r2=1538845&view=diff
==============================================================================
--- 
oozie/trunk/sharelib/streaming/src/test/java/org/apache/oozie/action/hadoop/TestMapReduceActionExecutor.java
 (original)
+++ 
oozie/trunk/sharelib/streaming/src/test/java/org/apache/oozie/action/hadoop/TestMapReduceActionExecutor.java
 Tue Nov  5 00:56:20 2013
@@ -785,6 +785,83 @@ public class TestMapReduceActionExecutor
         assertTrue(counters.contains("Counter"));
     }
 
+    public void testEndWithoutConfiguration() throws Exception {
+        FileSystem fs = getFileSystem();
+
+        Path inputDir = new Path(getFsTestCaseDir(), "input");
+        Path outputDir = new Path(getFsTestCaseDir(), "output");
+
+        Writer w = new OutputStreamWriter(fs.create(new Path(inputDir, 
"data.txt")));
+        w.write("dummy\n");
+        w.write("dummy\n");
+        w.close();
+
+        // set user stats write property as false explicitly in the
+        // configuration.
+        String actionXml = "<map-reduce>"
+                + "<job-tracker>"
+                + getJobTrackerUri()
+                + "</job-tracker>"
+                + "<name-node>"
+                + getNameNodeUri()
+                + "</name-node>"
+                + 
getOozieActionExternalStatsWriteProperty(inputDir.toString(), 
outputDir.toString(), "false")
+                .toXmlString(false) + "</map-reduce>";
+
+        Context context = createContext("map-reduce", actionXml);
+        final RunningJob launcherJob = submitAction(context);
+        String launcherId = context.getAction().getExternalId();
+        waitFor(120 * 2000, new Predicate() {
+            public boolean evaluate() throws Exception {
+                return launcherJob.isComplete();
+            }
+        });
+        assertTrue(launcherJob.isSuccessful());
+        Map<String, String> actionData = 
LauncherMapperHelper.getActionData(getFileSystem(), context.getActionDir(),
+                context.getProtoActionConf());
+        assertTrue(LauncherMapperHelper.hasIdSwap(actionData));
+
+        MapReduceActionExecutor ae = new MapReduceActionExecutor();
+        ae.check(context, context.getAction());
+        assertTrue(launcherId.equals(context.getAction().getExternalId()));
+
+        JobConf conf = ae.createBaseHadoopConf(context, 
XmlUtils.parseXml(actionXml));
+        String user = conf.get("user.name");
+        String group = conf.get("group.name");
+        JobClient jobClient = 
Services.get().get(HadoopAccessorService.class).createJobClient(user, conf);
+        final RunningJob mrJob = 
jobClient.getJob(JobID.forName(context.getAction().getExternalChildIDs()));
+
+        waitFor(120 * 1000, new Predicate() {
+            public boolean evaluate() throws Exception {
+                return mrJob.isComplete();
+            }
+        });
+        assertTrue(mrJob.isSuccessful());
+        ae.check(context, context.getAction());
+
+        assertEquals("SUCCEEDED", context.getAction().getExternalStatus());
+        assertNull(context.getAction().getData());
+
+        actionXml = "<map-reduce>"
+                + "<job-tracker>"
+                + getJobTrackerUri()
+                + "</job-tracker>"
+                + "<name-node>"
+                + getNameNodeUri()
+                + "</name-node></map-reduce>";
+
+        WorkflowActionBean action = (WorkflowActionBean) context.getAction();
+        action.setConf(actionXml);
+
+        try {
+            ae.end(context, context.getAction());
+        }
+        catch(Exception e)
+        {
+            fail("unexpected exception throwing " + e);
+        }
+    }
+
     /**
      * Test "oozie.launcher.mapred.job.name" and "mapred.job.name" can be set 
in
      * the action configuration and not overridden by the action executor


Reply via email to