Author: rkanter
Date: Thu May 9 21:30:32 2013
New Revision: 1480787
URL: http://svn.apache.org/r1480787
Log:
OOZIE-1318 Action Main classes should be overridable via action configuration
settings (rkanter)
Modified:
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/LauncherMapper.java
oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestLauncher.java
oozie/trunk/docs/src/site/twiki/WorkflowFunctionalSpec.twiki
oozie/trunk/release-log.txt
Modified:
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/LauncherMapper.java
URL:
http://svn.apache.org/viewvc/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/LauncherMapper.java?rev=1480787&r1=1480786&r2=1480787&view=diff
==============================================================================
---
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/LauncherMapper.java
(original)
+++
oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/LauncherMapper.java
Thu May 9 21:30:32 2013
@@ -150,7 +150,11 @@ public class LauncherMapper<K1, V1, K2,
}
public static void setupMainClass(Configuration launcherConf, String
javaMainClass) {
- launcherConf.set(CONF_OOZIE_ACTION_MAIN_CLASS, javaMainClass);
+ // Only set the javaMainClass if its not null or empty string (should
be the case except for java action), this way the user
+ // can override the action's main class via <configuration> property
+ if (javaMainClass != null && !javaMainClass.equals("")) {
+ launcherConf.set(CONF_OOZIE_ACTION_MAIN_CLASS, javaMainClass);
+ }
}
public static void setupLauncherURIHandlerConf(Configuration launcherConf)
{
Modified:
oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestLauncher.java
URL:
http://svn.apache.org/viewvc/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestLauncher.java?rev=1480787&r1=1480786&r2=1480787&view=diff
==============================================================================
---
oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestLauncher.java
(original)
+++
oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestLauncher.java
Thu May 9 21:30:32 2013
@@ -295,6 +295,27 @@ public class TestLauncher extends XFsTes
assertTrue(jobConf.get("oozie.action.prepare.xml").equals(prepareBlock));
}
+ public void testSetupMainClass() throws Exception {
+ Configuration conf = new Configuration(false);
+ LauncherMapper.setupMainClass(conf, "");
+ assertNull(conf.get("oozie.launcher.action.main.class"));
+
+ conf = new Configuration(false);
+ LauncherMapper.setupMainClass(conf, "org.blah.myclass1");
+ assertEquals(conf.get("oozie.launcher.action.main.class"),
"org.blah.myclass1");
+
+ conf = new Configuration(false);
+ conf.set("oozie.launcher.action.main.class", "org.blah.myclass2");
+ LauncherMapper.setupMainClass(conf, "");
+ assertEquals(conf.get("oozie.launcher.action.main.class"),
"org.blah.myclass2");
+
+ // the passed argument (myclass1) should have priority
+ conf = new Configuration(false);
+ conf.set("oozie.launcher.action.main.class", "org.blah.myclass2");
+ LauncherMapper.setupMainClass(conf, "org.blah.myclass1");
+ assertEquals(conf.get("oozie.launcher.action.main.class"),
"org.blah.myclass1");
+ }
+
// Test to ensure that the property value "oozie.action.prepare.xml" in the
configuration of the job is properly set
// when there is prepare block in workflow XML
public void testSetupLauncherInfoHadoop2_0_2_alphaWorkaround() throws
Exception {
Modified: oozie/trunk/docs/src/site/twiki/WorkflowFunctionalSpec.twiki
URL:
http://svn.apache.org/viewvc/oozie/trunk/docs/src/site/twiki/WorkflowFunctionalSpec.twiki?rev=1480787&r1=1480786&r2=1480787&view=diff
==============================================================================
--- oozie/trunk/docs/src/site/twiki/WorkflowFunctionalSpec.twiki (original)
+++ oozie/trunk/docs/src/site/twiki/WorkflowFunctionalSpec.twiki Thu May 9
21:30:32 2013
@@ -1445,6 +1445,25 @@ All the above elements can be parameteri
</workflow-app>
</verbatim>
+---+++++ 3.2.7.1 Overriding an action's Main class
+
+This feature is useful for developers to change the Main classes without
having to recompile or redeploy Oozie.
+
+For most actions (not just the Java action), you can override the Main class
it uses by specifying the following =configuration=
+property and making sure that your class is included in the workflow's
classpath. If you specify this in the Java action,
+the main-class element has priority.
+
+<verbatim>
+<property>
+ <name>oozie.launcher.action.main.class</name>
+ <value>org.my.CustomMain</value>
+</property>
+</verbatim>
+
+*Note:* Most actions typically pass information to their corresponding Main in
specific ways; you should look at the action's
+existing Main to see how it works before creating your own. In fact, its
probably simplest to just subclass the existing Main and
+add/modify/overwrite any behavior you want to change.
+
#WorkflowParameterization
---++ 4 Parameterization of Workflows
Modified: oozie/trunk/release-log.txt
URL:
http://svn.apache.org/viewvc/oozie/trunk/release-log.txt?rev=1480787&r1=1480786&r2=1480787&view=diff
==============================================================================
--- oozie/trunk/release-log.txt (original)
+++ oozie/trunk/release-log.txt Thu May 9 21:30:32 2013
@@ -1,5 +1,6 @@
-- Oozie 4.1.0 release (trunk - unreleased)
+OOZIE-1318 Action Main classes should be overridable via action configuration
settings (rkanter)
OOZIE-1347 Additions to JMS topic API (virag)
OOZIE-1231 Provide access to launcher job URL from web console when using Map
Reduce action (ryota via virag)
OOZIE-1335 The launcher job should use uber mode in Hadoop 2 by default
(rkanter)