瀏覽代碼

svn merge -c 160639 FIXES: YARN-2167. LeveldbIterator should get closed in NMLeveldbStateStoreService#loadLocalizationState() within finally block. Contributed by Junping Du

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1603040 13f79535-47bb-0310-9956-ffa450edef68
Jason Darrell Lowe 11 年之前
父節點
當前提交
0873304b90

+ 4 - 0
hadoop-yarn-project/CHANGES.txt

@@ -240,6 +240,10 @@ Release 2.5.0 - UNRELEASED
     to NMs where the completed applications previously ran in case of RM restart.
     to NMs where the completed applications previously ran in case of RM restart.
     (Wangda Tan via jianhe)
     (Wangda Tan via jianhe)
 
 
+    YARN-2167. LeveldbIterator should get closed in
+    NMLeveldbStateStoreService#loadLocalizationState() within finally block
+    (Junping Du via jlowe)
+
 Release 2.4.1 - 2014-06-23 
 Release 2.4.1 - 2014-06-23 
 
 
   INCOMPATIBLE CHANGES
   INCOMPATIBLE CHANGES

+ 6 - 1
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/recovery/NMLeveldbStateStoreService.java

@@ -95,8 +95,9 @@ public class NMLeveldbStateStoreService extends NMStateStoreService {
       throws IOException {
       throws IOException {
     RecoveredLocalizationState state = new RecoveredLocalizationState();
     RecoveredLocalizationState state = new RecoveredLocalizationState();
 
 
+    LeveldbIterator iter = null;
     try {
     try {
-      LeveldbIterator iter = new LeveldbIterator(db);
+      iter = new LeveldbIterator(db);
       iter.seek(bytes(LOCALIZATION_PUBLIC_KEY_PREFIX));
       iter.seek(bytes(LOCALIZATION_PUBLIC_KEY_PREFIX));
       state.publicTrackerState = loadResourceTrackerState(iter,
       state.publicTrackerState = loadResourceTrackerState(iter,
           LOCALIZATION_PUBLIC_KEY_PREFIX);
           LOCALIZATION_PUBLIC_KEY_PREFIX);
@@ -122,6 +123,10 @@ public class NMLeveldbStateStoreService extends NMStateStoreService {
       }
       }
     } catch (DBException e) {
     } catch (DBException e) {
       throw new IOException(e.getMessage(), e);
       throw new IOException(e.getMessage(), e);
+    } finally {
+      if (iter != null) {
+        iter.close();
+      }
     }
     }
 
 
     return state;
     return state;