Author: angeloh
Date: Sat Dec 10 04:15:24 2011
New Revision: 1212729
URL: http://svn.apache.org/viewvc?rev=1212729&view=rev
Log:
OOZIE-628 Add libraries which can be used by all actions in oozie [Virag
Kothari via angeloh]
Modified:
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestShellActionExecutor.java
Modified:
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java?rev=1212729&r1=1212728&r2=1212729&view=diff
==============================================================================
---
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java
(original)
+++
incubator/oozie/trunk/core/src/main/java/org/apache/oozie/action/hadoop/JavaActionExecutor.java
Sat Dec 10 04:15:24 2011
@@ -18,7 +18,6 @@
package org.apache.oozie.action.hadoop;
import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -77,6 +76,7 @@ public class JavaActionExecutor extends
private static final String HADOOP_UGI = "hadoop.job.ugi";
private static final String HADOOP_JOB_TRACKER = "mapred.job.tracker";
private static final String HADOOP_NAME_NODE = "fs.default.name";
+ public static final String OOZIE_COMMON_LIBDIR = "oozie";
public static final int MAX_EXTERNAL_STATS_SIZE_DEFAULT =
Integer.MAX_VALUE;
private static final Set<String> DISALLOWED_PROPERTIES = new
HashSet<String>();
public final static String MAX_EXTERNAL_STATS_SIZE =
"oozie.external.stats.max.size";
@@ -366,36 +366,32 @@ public class JavaActionExecutor extends
}
}
- protected void addActionShareLib(Context context, Element actionXml, Path
appPath, Configuration conf)
- throws ActionExecutorException {
- String actionShareLibPostfix = getShareLibPostFix(context, actionXml);
+ protected void addShareLib(Path appPath, Configuration conf, String
actionShareLibPostfix)
+ throws ActionExecutorException {
if (actionShareLibPostfix != null) {
try {
Path systemLibPath =
Services.get().get(WorkflowAppService.class).getSystemLibPath();
if (systemLibPath != null) {
Path actionLibPath = new Path(systemLibPath,
actionShareLibPostfix);
- XConfiguration wfJobConf = new XConfiguration(new
StringReader(context.getWorkflow().getConf()));
- if (wfJobConf.getBoolean(OozieClient.USE_SYSTEM_LIBPATH,
false)) {
- String user = conf.get("user.name");
- String group = conf.get("group.name");
- FileSystem fs =
-
Services.get().get(HadoopAccessorService.class).createFileSystem(user, group,
conf);
- if (fs.exists(actionLibPath)) {
- FileStatus[] files = fs.listStatus(actionLibPath);
- for (FileStatus file : files) {
- addToCache(conf, appPath,
file.getPath().toUri().getPath(), false);
- }
+ String user = conf.get("user.name");
+ String group = conf.get("group.name");
+ FileSystem fs =
+
Services.get().get(HadoopAccessorService.class).createFileSystem(user, group,
conf);
+ if (fs.exists(actionLibPath)) {
+ FileStatus[] files = fs.listStatus(actionLibPath);
+ for (FileStatus file : files) {
+ addToCache(conf, appPath,
file.getPath().toUri().getPath(), false);
}
}
}
}
catch (HadoopAccessorException ex){
throw new
ActionExecutorException(ActionExecutorException.ErrorType.FAILED,
-
ex.getErrorCode().toString(), ex.getMessage());
+ ex.getErrorCode().toString(), ex.getMessage());
}
catch (IOException ex){
throw new
ActionExecutorException(ActionExecutorException.ErrorType.FAILED,
- "It should never happen",
ex.getMessage());
+ "It should never happen", ex.getMessage());
}
}
}
@@ -430,10 +426,35 @@ public class JavaActionExecutor extends
}
}
- // Oozie sharelib (for the action)
- addActionShareLib(context, actionXml, appPath, conf);
+ addAllShareLibs(appPath, conf, context, actionXml);
}
+ // Adds action specific share libs and common share libs
+ private void addAllShareLibs(Path appPath, Configuration conf, Context
context, Element actionXml)
+ throws ActionExecutorException {
+ // Add action specific share libs
+ addActionShareLib(appPath, conf, context, actionXml);
+ // Add common sharelibs for Oozie
+ addShareLib(appPath, conf, JavaActionExecutor.OOZIE_COMMON_LIBDIR);
+ }
+
+ private void addActionShareLib(Path appPath, Configuration conf, Context
context, Element actionXml) throws ActionExecutorException {
+ XConfiguration wfJobConf = null;
+ try {
+ wfJobConf = new XConfiguration(new
StringReader(context.getWorkflow().getConf()));
+ }
+ catch (IOException ioe) {
+ throw new
ActionExecutorException(ActionExecutorException.ErrorType.FAILED, "It should
never happen",
+ ioe.getMessage());
+ }
+ // Action sharelibs are only added if user has specified to use system
libpath
+ if (wfJobConf.getBoolean(OozieClient.USE_SYSTEM_LIBPATH, false)) {
+ // add action specific sharelibs
+ addShareLib(appPath, conf, getShareLibPostFix(context, actionXml));
+ }
+ }
+
+
protected String getLauncherMain(Configuration launcherConf, Element
actionXml) {
Namespace ns = actionXml.getNamespace();
Element e = actionXml.getChild("main-class", ns);
Modified:
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestShellActionExecutor.java
URL:
http://svn.apache.org/viewvc/incubator/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestShellActionExecutor.java?rev=1212729&r1=1212728&r2=1212729&view=diff
==============================================================================
---
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestShellActionExecutor.java
(original)
+++
incubator/oozie/trunk/core/src/test/java/org/apache/oozie/action/hadoop/TestShellActionExecutor.java
Sat Dec 10 04:15:24 2011
@@ -82,6 +82,8 @@ public class TestShellActionExecutor ext
classes.add(LauncherSecurityManager.class);
classes.add(LauncherException.class);
classes.add(LauncherMainException.class);
+ classes.add(ActionStats.class);
+ classes.add(ActionType.class);
classes.add(LauncherMain.class);
classes.add(MapReduceMain.class);
classes.add(ShellMain.class);