hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jl...@apache.org
Subject git commit: YARN-2484. FileSystemRMStateStore#readFile/writeFile should close FSData(In|Out)putStream in final block. Contributed by Tsuyoshi OZAWA (cherry picked from commit 78b048393a80a9bd1399d08525590bb211a32d8c)
Date Fri, 12 Sep 2014 14:12:02 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-2 466bdf79c -> 7e69dc877


YARN-2484. FileSystemRMStateStore#readFile/writeFile should close FSData(In|Out)putStream
in final block. Contributed by Tsuyoshi OZAWA
(cherry picked from commit 78b048393a80a9bd1399d08525590bb211a32d8c)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/7e69dc87
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/7e69dc87
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/7e69dc87

Branch: refs/heads/branch-2
Commit: 7e69dc8771726b347bc84640f7b311be2d67c3de
Parents: 466bdf7
Author: Jason Lowe <jlowe@apache.org>
Authored: Fri Sep 12 14:09:14 2014 +0000
Committer: Jason Lowe <jlowe@apache.org>
Committed: Fri Sep 12 14:10:51 2014 +0000

----------------------------------------------------------------------
 hadoop-yarn-project/CHANGES.txt                 |  3 ++
 .../recovery/FileSystemRMStateStore.java        | 30 +++++++++++++-------
 2 files changed, 23 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/7e69dc87/hadoop-yarn-project/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index b40db52..57ff8df 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -308,6 +308,9 @@ Release 2.6.0 - UNRELEASED
 
     YARN-2541. Fixed ResourceManagerRest.apt.vm table syntax error. (jianhe)
 
+    YARN-2484. FileSystemRMStateStore#readFile/writeFile should close
+    FSData(In|Out)putStream in final block (Tsuyoshi OZAWA via jlowe)
+
 Release 2.5.1 - 2014-09-05
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/7e69dc87/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/FileSystemRMStateStore.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/FileSystemRMStateStore.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/FileSystemRMStateStore.java
index 4c01a61..4d91831 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/FileSystemRMStateStore.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/recovery/FileSystemRMStateStore.java
@@ -39,6 +39,7 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.PathFilter;
 import org.apache.hadoop.io.DataInputByteBuffer;
+import org.apache.hadoop.io.IOUtils;
 import org.apache.hadoop.security.Credentials;
 import org.apache.hadoop.security.token.delegation.DelegationKey;
 import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
@@ -573,12 +574,16 @@ public class FileSystemRMStateStore extends RMStateStore {
   }
 
   private byte[] readFile(Path inputPath, long len) throws Exception {
-    FSDataInputStream fsIn = fs.open(inputPath);
-    // state data will not be that "long"
-    byte[] data = new byte[(int)len];
-    fsIn.readFully(data);
-    fsIn.close();
-    return data;
+    FSDataInputStream fsIn = null;
+    try {
+      fsIn = fs.open(inputPath);
+      // state data will not be that "long"
+      byte[] data = new byte[(int) len];
+      fsIn.readFully(data);
+      return data;
+    } finally {
+      IOUtils.cleanup(LOG, fsIn);
+    }
   }
 
   /*
@@ -592,10 +597,15 @@ public class FileSystemRMStateStore extends RMStateStore {
     FSDataOutputStream fsOut = null;
     // This file will be overwritten when app/attempt finishes for saving the
     // final status.
-    fsOut = fs.create(tempPath, true);
-    fsOut.write(data);
-    fsOut.close();
-    fs.rename(tempPath, outputPath);
+    try {
+      fsOut = fs.create(tempPath, true);
+      fsOut.write(data);
+      fsOut.close();
+      fsOut = null;
+      fs.rename(tempPath, outputPath);
+    } finally {
+      IOUtils.cleanup(LOG, fsOut);
+    }
   }
 
   /*


Mime
View raw message