Repository: hadoop
Updated Branches:
  refs/heads/branch-2 acc172e37 -> 7f18176cd


HDFS-7753. Fix Multithreaded correctness Warnings in BackupImage. Contributed 
by Rakesh R and Konstantin Shvachko.

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

Branch: refs/heads/branch-2
Commit: 7f18176cd76b76328910febf0037f0e3d54bc4ae
Parents: acc172e
Author: Konstantin V Shvachko <s...@apache.org>
Authored: Wed Feb 11 00:52:12 2015 -0800
Committer: Konstantin V Shvachko <s...@apache.org>
Committed: Wed Feb 11 00:52:12 2015 -0800

----------------------------------------------------------------------
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt     |  3 +++
 .../hdfs/server/namenode/BackupImage.java       | 21 +++++++++++++-------
 2 files changed, 17 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/7f18176c/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt 
b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index ca15e7a..a7c178d 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -604,6 +604,9 @@ Release 2.7.0 - UNRELEASED
     HDFS-7769. TestHDFSCLI should not create files in hdfs project root dir.
     (szetszwo)
 
+    HDFS-7753. Fix Multithreaded correctness Warnings in BackupImage.
+    (Rakesh R and shv)
+
 Release 2.6.1 - UNRELEASED
 
   INCOMPATIBLE CHANGES

http://git-wip-us.apache.org/repos/asf/hadoop/blob/7f18176c/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupImage.java
----------------------------------------------------------------------
diff --git 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupImage.java
 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupImage.java
index 83e3de9..ede72cf 100644
--- 
a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupImage.java
+++ 
b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupImage.java
@@ -93,9 +93,16 @@ public class BackupImage extends FSImage {
     storage.setDisablePreUpgradableLayoutCheck(true);
     bnState = BNState.DROP_UNTIL_NEXT_ROLL;
   }
-  
-  void setNamesystem(FSNamesystem fsn) {
-    this.namesystem = fsn;
+
+  synchronized FSNamesystem getNamesystem() {
+    return namesystem;
+  }
+
+  synchronized void setNamesystem(FSNamesystem fsn) {
+    // Avoids overriding this.namesystem object
+    if (namesystem == null) {
+      this.namesystem = fsn;
+    }
   }
 
   /**
@@ -208,7 +215,7 @@ public class BackupImage extends FSImage {
       }
 
       FSEditLogLoader logLoader =
-          new FSEditLogLoader(namesystem, lastAppliedTxId);
+          new FSEditLogLoader(getNamesystem(), lastAppliedTxId);
       int logVersion = storage.getLayoutVersion();
       backupInputStream.setBytes(data, logVersion);
 
@@ -222,7 +229,7 @@ public class BackupImage extends FSImage {
       }
       lastAppliedTxId = logLoader.getLastAppliedTxId();
 
-      FSImage.updateCountForQuota(namesystem.dir.rootDir); // inefficient!
+      FSImage.updateCountForQuota(getNamesystem().dir.getRoot()); // 
inefficient!
     } finally {
       backupInputStream.clear();
     }
@@ -271,7 +278,7 @@ public class BackupImage extends FSImage {
           editStreams.add(s);
         }
       }
-      loadEdits(editStreams, namesystem);
+      loadEdits(editStreams, getNamesystem());
     }
     
     // now, need to load the in-progress file
@@ -306,7 +313,7 @@ public class BackupImage extends FSImage {
             + " txns from in-progress stream " + stream);
         
         FSEditLogLoader loader =
-            new FSEditLogLoader(namesystem, lastAppliedTxId);
+            new FSEditLogLoader(getNamesystem(), lastAppliedTxId);
         loader.loadFSEdits(stream, lastAppliedTxId + 1);
         lastAppliedTxId = loader.getLastAppliedTxId();
         assert lastAppliedTxId == getEditLog().getLastWrittenTxId();

Reply via email to