Repository: oozie
Updated Branches:
  refs/heads/master 39e2ed5d9 -> 90257ad8e


amendments patch to 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/90257ad8
Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/90257ad8
Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/90257ad8

Branch: refs/heads/master
Commit: 90257ad8e78ed44543abf29f1d87bc856591737a
Parents: 39e2ed5
Author: Purshotam Shah <[email protected]>
Authored: Mon Sep 14 18:04:07 2015 -0700
Committer: Purshotam Shah <[email protected]>
Committed: Mon Sep 14 18:04:07 2015 -0700

----------------------------------------------------------------------
 .../oozie/service/HadoopAccessorService.java    | 21 +++++++++++++++-----
 .../java/org/apache/oozie/util/JobUtils.java    |  2 +-
 2 files changed, 17 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oozie/blob/90257ad8/core/src/main/java/org/apache/oozie/service/HadoopAccessorService.java
----------------------------------------------------------------------
diff --git 
a/core/src/main/java/org/apache/oozie/service/HadoopAccessorService.java 
b/core/src/main/java/org/apache/oozie/service/HadoopAccessorService.java
index 116f382..f099df8 100644
--- a/core/src/main/java/org/apache/oozie/service/HadoopAccessorService.java
+++ b/core/src/main/java/org/apache/oozie/service/HadoopAccessorService.java
@@ -53,6 +53,7 @@ import java.util.Set;
 import java.util.HashSet;
 import java.util.concurrent.ConcurrentHashMap;
 
+
 /**
  * The HadoopAccessorService returns HadoopAccessor instances configured to 
work on behalf of a user-group. <p> The
  * default accessor used is the base accessor which just injects the UGI into 
the configuration instance used to
@@ -83,7 +84,7 @@ public class HadoopAccessorService implements Service {
     protected static final String HADOOP_YARN_RM = 
"yarn.resourcemanager.address";
     private static final Map<String, Text> mrTokenRenewers = new 
HashMap<String, Text>();
 
-    private static JobConf cachedJobConf;
+    private static Configuration cachedConf;
 
     private static final String DEFAULT_ACTIONNAME = "default";
 
@@ -147,9 +148,6 @@ public class HadoopAccessorService implements Service {
 
         loadHadoopConfigs(conf);
         preLoadActionConfigs(conf);
-        cachedJobConf = new JobConf();
-        //calling .size to invoke lazy loading of hadoop properties
-        cachedJobConf.size();
 
         supportedSchemes = new HashSet<String>();
         String[] schemesFromConf = ConfigurationService.getStrings(conf, 
SUPPORTED_FILESYSTEMS);
@@ -298,12 +296,25 @@ public class HadoopAccessorService implements Service {
      * @return a JobConf with the corresponding site configuration for 
hostPort.
      */
     public JobConf createJobConf(String hostPort) {
-        JobConf jobConf = new JobConf(cachedJobConf);
+        JobConf jobConf = new JobConf(getCachedConf());
         XConfiguration.copy(getConfiguration(hostPort), jobConf);
         jobConf.setBoolean(OOZIE_HADOOP_ACCESSOR_SERVICE_CREATED, true);
         return jobConf;
     }
 
+    public Configuration getCachedConf() {
+        if (cachedConf == null) {
+            loadCachedConf();
+        }
+        return cachedConf;
+    }
+
+    private void loadCachedConf() {
+        cachedConf = new Configuration();
+        //for lazy loading
+        cachedConf.size();
+    }
+
     private XConfiguration loadActionConf(String hostPort, String action) {
         File dir = actionConfigDirs.get(hostPort);
         XConfiguration actionConf = new XConfiguration();

http://git-wip-us.apache.org/repos/asf/oozie/blob/90257ad8/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 79edcd4..3975a3e 100644
--- a/core/src/main/java/org/apache/oozie/util/JobUtils.java
+++ b/core/src/main/java/org/apache/oozie/util/JobUtils.java
@@ -149,7 +149,7 @@ public class JobUtils {
         fs = file.getFileSystem(conf);
       }
       // Hadoop 0.20/1.x.
-      if (conf.get("yarn.resourcemanager.webapp.address") == null) {
+      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();

Reply via email to