Repository: oozie Updated Branches: refs/heads/master 326a58347 -> 546d185d2
Amend OOZIE-2347 Remove unnecessary new Configuration()/new jobConf() calls from oozie Project: http://git-wip-us.apache.org/repos/asf/oozie/repo Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/546d185d Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/546d185d Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/546d185d Branch: refs/heads/master Commit: 546d185d2a5e6ac34e88cabca98d1e4d935bf845 Parents: 326a583 Author: Purshotam Shah <[email protected]> Authored: Thu Oct 29 15:53:16 2015 -0700 Committer: Purshotam Shah <[email protected]> Committed: Thu Oct 29 15:53:16 2015 -0700 ---------------------------------------------------------------------- .../java/org/apache/oozie/util/JobUtils.java | 40 +++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/oozie/blob/546d185d/core/src/main/java/org/apache/oozie/util/JobUtils.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/oozie/util/JobUtils.java b/core/src/main/java/org/apache/oozie/util/JobUtils.java index 3975a3e..a3a5fc0 100644 --- a/core/src/main/java/org/apache/oozie/util/JobUtils.java +++ b/core/src/main/java/org/apache/oozie/util/JobUtils.java @@ -28,6 +28,7 @@ import org.apache.hadoop.filecache.DistributedCache; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.oozie.ErrorCode; +import org.apache.oozie.action.hadoop.JavaActionExecutor; import org.apache.oozie.client.OozieClient; import org.apache.oozie.client.XOozieClient; import org.apache.oozie.command.CommandException; @@ -145,23 +146,26 @@ public class JobUtils { * @throws IOException */ public static void addFileToClassPath(Path file, Configuration conf, FileSystem fs) throws IOException { - if (fs == null) { - fs = file.getFileSystem(conf); - } - // Hadoop 0.20/1.x. - if (Services.get().get(HadoopAccessorService.class).getCachedConf().get("yarn.resourcemanager.webapp.address") == null) { - // Duplicate hadoop 1.x code to workaround MAPREDUCE-2361 in Hadoop 0.20 - // Refer OOZIE-1806. - String filepath = file.toUri().getPath(); - String classpath = conf.get("mapred.job.classpath.files"); - conf.set("mapred.job.classpath.files", classpath == null - ? filepath - : classpath + System.getProperty("path.separator") + filepath); - URI uri = fs.makeQualified(file).toUri(); - DistributedCache.addCacheFile(uri, conf); - } - else { // Hadoop 0.23/2.x - DistributedCache.addFileToClassPath(file, conf, fs); - } + if (fs == null) { + Configuration defaultConf = Services.get().get(HadoopAccessorService.class) + .createJobConf(conf.get(JavaActionExecutor.HADOOP_JOB_TRACKER)); + XConfiguration.copy(conf, defaultConf); + // it fails with conf, therefore we pass defaultConf instead + fs = file.getFileSystem(defaultConf); + } + // Hadoop 0.20/1.x. + if (Services.get().get(HadoopAccessorService.class).getCachedConf().get("yarn.resourcemanager.webapp.address") == null) { + // Duplicate hadoop 1.x code to workaround MAPREDUCE-2361 in Hadoop 0.20 + // Refer OOZIE-1806. + String filepath = file.toUri().getPath(); + String classpath = conf.get("mapred.job.classpath.files"); + conf.set("mapred.job.classpath.files", + classpath == null ? filepath : classpath + System.getProperty("path.separator") + filepath); + URI uri = fs.makeQualified(file).toUri(); + DistributedCache.addCacheFile(uri, conf); + } + else { // Hadoop 0.23/2.x + DistributedCache.addFileToClassPath(file, conf, fs); + } } }
