Author: rkanter
Date: Thu Oct 31 18:46:57 2013
New Revision: 1537582
URL: http://svn.apache.org/r1537582
Log:
OOZIE-1580 EL variables don't get resolved in configurations imported from a
<job-xml> (bowenzhangusa via rkanter)
Modified:
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java
oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/ActionExecutorTestCase.java
oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestJavaActionExecutor.java
oozie/trunk/release-log.txt
Modified:
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java
URL:
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java?rev=1537582&r1=1537581&r2=1537582&view=diff
==============================================================================
---
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java
(original)
+++
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java
Thu Oct 31 18:46:57 2013
@@ -66,6 +66,7 @@ import org.apache.oozie.util.PropertiesU
import org.apache.oozie.util.XConfiguration;
import org.apache.oozie.util.XLog;
import org.apache.oozie.util.XmlUtils;
+import org.apache.oozie.util.ELEvaluationException;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.Namespace;
@@ -343,6 +344,19 @@ public class JavaActionExecutor extends
Path path = new Path(appPath, jobXml);
FileSystem fs = context.getAppFileSystem();
Configuration jobXmlConf = new XConfiguration(fs.open(path));
+ try {
+ String jobXmlConfString =
XmlUtils.prettyPrint(jobXmlConf).toString();
+ jobXmlConfString = XmlUtils.removeComments(jobXmlConfString);
+ jobXmlConfString =
context.getELEvaluator().evaluate(jobXmlConfString, String.class);
+ jobXmlConf = new XConfiguration(new
StringReader(jobXmlConfString));
+ }
+ catch (ELEvaluationException ex) {
+ throw new
ActionExecutorException(ActionExecutorException.ErrorType.TRANSIENT,
"EL_EVAL_ERROR", ex
+ .getMessage(), ex);
+ }
+ catch (Exception ex) {
+ context.setErrorInfo("EL_ERROR", ex.getMessage());
+ }
checkForDisallowedProps(jobXmlConf, "job-xml");
XConfiguration.copy(jobXmlConf, conf);
}
Modified:
oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/ActionExecutorTestCase.java
URL:
http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/ActionExecutorTestCase.java?rev=1537582&r1=1537581&r2=1537582&view=diff
==============================================================================
---
oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/ActionExecutorTestCase.java
(original)
+++
oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/ActionExecutorTestCase.java
Thu Oct 31 18:46:57 2013
@@ -20,6 +20,7 @@ package org.apache.oozie.action.hadoop;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
+import org.apache.oozie.DagELFunctions;
import org.apache.oozie.WorkflowActionBean;
import org.apache.oozie.WorkflowJobBean;
import org.apache.oozie.action.ActionExecutor;
@@ -27,6 +28,7 @@ import org.apache.oozie.client.OozieClie
import org.apache.oozie.client.WorkflowAction;
import org.apache.oozie.client.WorkflowJob;
import org.apache.oozie.service.CallbackService;
+import org.apache.oozie.service.ELService;
import org.apache.oozie.service.LiteWorkflowStoreService;
import org.apache.oozie.service.Services;
import org.apache.oozie.service.UUIDService;
@@ -109,7 +111,18 @@ public abstract class ActionExecutorTest
}
public ELEvaluator getELEvaluator() {
- throw new UnsupportedOperationException();
+ ELEvaluator evaluator =
Services.get().get(ELService.class).createEvaluator("workflow");
+ DagELFunctions.configureEvaluator(evaluator, workflow, action);
+ try {
+ XConfiguration xconf = new XConfiguration(new
StringReader(action.getConf()));
+ for (Map.Entry<String, String> entry : xconf){
+ evaluator.setVariable(entry.getKey(), entry.getValue());
+ }
+ }
+ catch (IOException ex) {
+ throw new RuntimeException(ex);
+ }
+ return evaluator;
}
public void setVar(String name, String value) {
Modified:
oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestJavaActionExecutor.java
URL:
http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestJavaActionExecutor.java?rev=1537582&r1=1537581&r2=1537582&view=diff
==============================================================================
---
oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestJavaActionExecutor.java
(original)
+++
oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestJavaActionExecutor.java
Thu Oct 31 18:46:57 2013
@@ -1431,6 +1431,51 @@ public class TestJavaActionExecutor exte
assertEquals("v4", conf.get("p4"));
}
+ public void testParseJobXmlAndConfigurationWithELExpression() throws
Exception {
+ String str = "<java>"
+ + "<job-xml>job1.xml</job-xml>"
+ + "<job-xml>job2.xml</job-xml>"
+ + "<configuration>"
+ + "<property><name>p1</name><value>v1a</value></property>"
+ + "<property><name>p2</name><value>v2</value></property>"
+ + "</configuration>"
+ + "</java>";
+ Element xml = XmlUtils.parseXml(str);
+ Path appPath = new Path(getFsTestCaseDir(), "app");
+ getFileSystem().mkdirs(appPath);
+
+ XConfiguration jConf = new XConfiguration();
+ jConf.set("p3", "${v3}");
+ jConf.set("p4", "${v4}");
+ jConf.set("user", "${wf:user()}");
+ OutputStream os = getFileSystem().create(new Path(appPath,
"job1.xml"));
+ jConf.writeXml(os);
+ os.close();
+
+ jConf = new XConfiguration();
+ jConf.set("p5", "v5");
+ jConf.set("p6", "v6");
+ os = getFileSystem().create(new Path(appPath, "job2.xml"));
+ jConf.writeXml(os);
+ os.close();
+
+ Configuration conf = new XConfiguration();
+ assertEquals(0, conf.size());
+
+
JavaActionExecutor.parseJobXmlAndConfiguration(createContext("<configuration>" +
+ "<property><name>v3</name><value>v3a</value></property>" +
+ "<property><name>v4</name><value>v4a</value></property>" +
+ "</configuration>", null), xml, appPath, conf);
+ assertEquals(7, conf.size());
+ assertEquals("v1a", conf.get("p1"));
+ assertEquals("v2", conf.get("p2"));
+ assertEquals("v3a", conf.get("p3"));
+ assertEquals("v4a", conf.get("p4"));
+ assertEquals("v5", conf.get("p5"));
+ assertEquals("v6", conf.get("p6"));
+ assertEquals("test", conf.get("user"));
+ }
+
public void testInjectLauncherUseUberMode() throws Exception {
// TODO: Delete these two lines once uber mode is set back to the
// default (OOZIE-1385)
Modified: oozie/trunk/release-log.txt
URL:
http://svn.apache.org/viewvc/oozie/trunk/release-log.txt?rev=1537582&r1=1537581&r2=1537582&view=diff
==============================================================================
--- oozie/trunk/release-log.txt (original)
+++ oozie/trunk/release-log.txt Thu Oct 31 18:46:57 2013
@@ -1,5 +1,6 @@
-- Oozie 4.1.0 release (trunk - unreleased)
+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)
OOZIE-1589 TestZKLocksService is flakey (rkanter)