You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oozie.apache.org by ge...@apache.org on 2017/05/10 00:05:33 UTC

oozie git commit: Don't create local files in HadoopAccessorService

Repository: oozie
Updated Branches:
  refs/heads/oya 436232fc3 -> 8d5f9a76b


Don't create local files in HadoopAccessorService


Project: http://git-wip-us.apache.org/repos/asf/oozie/repo
Commit: http://git-wip-us.apache.org/repos/asf/oozie/commit/8d5f9a76
Tree: http://git-wip-us.apache.org/repos/asf/oozie/tree/8d5f9a76
Diff: http://git-wip-us.apache.org/repos/asf/oozie/diff/8d5f9a76

Branch: refs/heads/oya
Commit: 8d5f9a76beb4aa7026ea93e8c84b679c5073670a
Parents: 436232f
Author: Gezapeti Cseh <ge...@gmail.com>
Authored: Tue May 9 17:05:05 2017 -0700
Committer: Gezapeti Cseh <ge...@gmail.com>
Committed: Tue May 9 17:05:05 2017 -0700

----------------------------------------------------------------------
 .../oozie/service/HadoopAccessorService.java       | 17 +++++------------
 .../java/org/apache/oozie/service/Services.java    |  4 ++--
 2 files changed, 7 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/oozie/blob/8d5f9a76/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 99f2319..45f91a3 100644
--- a/core/src/main/java/org/apache/oozie/service/HadoopAccessorService.java
+++ b/core/src/main/java/org/apache/oozie/service/HadoopAccessorService.java
@@ -51,6 +51,7 @@ import java.io.FileOutputStream;
 import java.io.FilenameFilter;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.OutputStream;
 import java.lang.reflect.Method;
 import java.net.InetAddress;
 import java.net.URI;
@@ -770,19 +771,11 @@ public class HadoopAccessorService implements Service {
     public LocalResource createLocalResourceForConfigurationFile(String filename, String user, Configuration conf, URI uri,
                                                                  Path dir)
             throws IOException, HadoopAccessorException, URISyntaxException {
-        File f = File.createTempFile(filename, ".tmp");
-        FileOutputStream fos = null;
-        try {
-            fos = new FileOutputStream(f);
-            conf.writeXml(fos);
-        } finally {
-            if (fos != null) {
-                fos.close();
-            }
-        }
-        FileSystem fs = createFileSystem(user, uri, conf, false);
         Path dst = new Path(dir, filename);
-        fs.copyFromLocalFile(new Path(f.getAbsolutePath()), dst);
+        FileSystem fs = createFileSystem(user, uri, conf, false);
+        try (OutputStream os = fs.create(dst)){
+            conf.writeXml(os);
+        }
         LocalResource localResource = Records.newRecord(LocalResource.class);
         localResource.setType(LocalResourceType.FILE); localResource.setVisibility(LocalResourceVisibility.APPLICATION);
         localResource.setResource(ConverterUtils.getYarnUrlFromPath(dst));

http://git-wip-us.apache.org/repos/asf/oozie/blob/8d5f9a76/core/src/main/java/org/apache/oozie/service/Services.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/oozie/service/Services.java b/core/src/main/java/org/apache/oozie/service/Services.java
index f5c89b3..4e1775e 100644
--- a/core/src/main/java/org/apache/oozie/service/Services.java
+++ b/core/src/main/java/org/apache/oozie/service/Services.java
@@ -305,8 +305,8 @@ public class Services {
             }
         } catch (RuntimeException rex) {
             rex.printStackTrace();
-            log.fatal("Runtime Exception during Services Load. Check your list of '{0}' or '{1}'", CONF_SERVICE_CLASSES, CONF_SERVICE_EXT_CLASSES);
-            log.fatal("Runtime Exception during Services load: {0}", rex);
+            log.fatal("Runtime Exception during Services Load. Check your list of '{0}' or '{1}'",
+                    CONF_SERVICE_CLASSES, CONF_SERVICE_EXT_CLASSES, rex);
             throw new ServiceException(ErrorCode.E0103, rex.getMessage(), rex);
         }
     }