You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cn...@apache.org on 2015/06/13 19:53:43 UTC
[1/2] hadoop git commit: HDFS-8593. Calculation of effective layout
version mishandles comparison to current layout version in storage.
Contributed by Chris Nauroth.
Repository: hadoop
Updated Branches:
refs/heads/branch-2 2776255ed -> 92144ca75
refs/heads/trunk eef7b50e2 -> b8341f1cd
HDFS-8593. Calculation of effective layout version mishandles comparison to current layout version in storage. Contributed by Chris Nauroth.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/b8341f1c
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/b8341f1c
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/b8341f1c
Branch: refs/heads/trunk
Commit: b8341f1cd89791c51b396ad531ec7fcc631be149
Parents: eef7b50
Author: cnauroth <cn...@apache.org>
Authored: Sat Jun 13 10:37:52 2015 -0700
Committer: cnauroth <cn...@apache.org>
Committed: Sat Jun 13 10:37:52 2015 -0700
----------------------------------------------------------------------
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++
.../hdfs/server/namenode/FSNamesystem.java | 17 ++++++++++++-----
.../hdfs/server/namenode/TestFSNamesystem.java | 20 ++++++++++++++++++++
3 files changed, 35 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/b8341f1c/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 51a0897..9aabd34 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -886,6 +886,9 @@ Release 2.8.0 - UNRELEASED
HDFS-8554. TestDatanodeLayoutUpgrade fails on Windows. (cnauroth)
+ HDFS-8593. Calculation of effective layout version mishandles comparison to
+ current layout version in storage. (cnauroth)
+
Release 2.7.1 - UNRELEASED
INCOMPATIBLE CHANGES
http://git-wip-us.apache.org/repos/asf/hadoop/blob/b8341f1c/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
index ef53692..f962373 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
@@ -7004,10 +7004,17 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
* @return layout version in effect
*/
public int getEffectiveLayoutVersion() {
- if (isRollingUpgrade()) {
- int storageLV = fsImage.getStorage().getLayoutVersion();
- if (storageLV >=
- NameNodeLayoutVersion.MINIMUM_COMPATIBLE_LAYOUT_VERSION) {
+ return getEffectiveLayoutVersion(isRollingUpgrade(),
+ fsImage.getStorage().getLayoutVersion(),
+ NameNodeLayoutVersion.MINIMUM_COMPATIBLE_LAYOUT_VERSION,
+ NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION);
+ }
+
+ @VisibleForTesting
+ static int getEffectiveLayoutVersion(boolean isRollingUpgrade, int storageLV,
+ int minCompatLV, int currentLV) {
+ if (isRollingUpgrade) {
+ if (storageLV <= minCompatLV) {
// The prior layout version satisfies the minimum compatible layout
// version of the current software. Keep reporting the prior layout
// as the effective one. Downgrade is possible.
@@ -7016,7 +7023,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
}
// The current software cannot satisfy the layout version of the prior
// software. Proceed with using the current layout version.
- return NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION;
+ return currentLV;
}
/**
http://git-wip-us.apache.org/repos/asf/hadoop/blob/b8341f1c/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystem.java
index 8b0662c..26bb4f7 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystem.java
@@ -213,4 +213,24 @@ public class TestFSNamesystem {
fsn.imageLoadComplete();
assertTrue(fsn.isImageLoaded());
}
+
+ @Test
+ public void testGetEffectiveLayoutVersion() {
+ assertEquals(-63,
+ FSNamesystem.getEffectiveLayoutVersion(true, -60, -61, -63));
+ assertEquals(-61,
+ FSNamesystem.getEffectiveLayoutVersion(true, -61, -61, -63));
+ assertEquals(-62,
+ FSNamesystem.getEffectiveLayoutVersion(true, -62, -61, -63));
+ assertEquals(-63,
+ FSNamesystem.getEffectiveLayoutVersion(true, -63, -61, -63));
+ assertEquals(-63,
+ FSNamesystem.getEffectiveLayoutVersion(false, -60, -61, -63));
+ assertEquals(-63,
+ FSNamesystem.getEffectiveLayoutVersion(false, -61, -61, -63));
+ assertEquals(-63,
+ FSNamesystem.getEffectiveLayoutVersion(false, -62, -61, -63));
+ assertEquals(-63,
+ FSNamesystem.getEffectiveLayoutVersion(false, -63, -61, -63));
+ }
}
[2/2] hadoop git commit: HDFS-8593. Calculation of effective layout
version mishandles comparison to current layout version in storage.
Contributed by Chris Nauroth.
Posted by cn...@apache.org.
HDFS-8593. Calculation of effective layout version mishandles comparison to current layout version in storage. Contributed by Chris Nauroth.
(cherry picked from commit b8341f1cd89791c51b396ad531ec7fcc631be149)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/92144ca7
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/92144ca7
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/92144ca7
Branch: refs/heads/branch-2
Commit: 92144ca75c274351572443b5035c050deb40077f
Parents: 2776255
Author: cnauroth <cn...@apache.org>
Authored: Sat Jun 13 10:37:52 2015 -0700
Committer: cnauroth <cn...@apache.org>
Committed: Sat Jun 13 10:38:03 2015 -0700
----------------------------------------------------------------------
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++
.../hdfs/server/namenode/FSNamesystem.java | 17 ++++++++++++-----
.../hdfs/server/namenode/TestFSNamesystem.java | 20 ++++++++++++++++++++
3 files changed, 35 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/92144ca7/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 e5f3f14..30affe5 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -549,6 +549,9 @@ Release 2.8.0 - UNRELEASED
HDFS-8554. TestDatanodeLayoutUpgrade fails on Windows. (cnauroth)
+ HDFS-8593. Calculation of effective layout version mishandles comparison to
+ current layout version in storage. (cnauroth)
+
Release 2.7.1 - UNRELEASED
INCOMPATIBLE CHANGES
http://git-wip-us.apache.org/repos/asf/hadoop/blob/92144ca7/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
index c9fc463..a2e921e 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
@@ -6998,10 +6998,17 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
* @return layout version in effect
*/
public int getEffectiveLayoutVersion() {
- if (isRollingUpgrade()) {
- int storageLV = fsImage.getStorage().getLayoutVersion();
- if (storageLV >=
- NameNodeLayoutVersion.MINIMUM_COMPATIBLE_LAYOUT_VERSION) {
+ return getEffectiveLayoutVersion(isRollingUpgrade(),
+ fsImage.getStorage().getLayoutVersion(),
+ NameNodeLayoutVersion.MINIMUM_COMPATIBLE_LAYOUT_VERSION,
+ NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION);
+ }
+
+ @VisibleForTesting
+ static int getEffectiveLayoutVersion(boolean isRollingUpgrade, int storageLV,
+ int minCompatLV, int currentLV) {
+ if (isRollingUpgrade) {
+ if (storageLV <= minCompatLV) {
// The prior layout version satisfies the minimum compatible layout
// version of the current software. Keep reporting the prior layout
// as the effective one. Downgrade is possible.
@@ -7010,7 +7017,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
}
// The current software cannot satisfy the layout version of the prior
// software. Proceed with using the current layout version.
- return NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION;
+ return currentLV;
}
/**
http://git-wip-us.apache.org/repos/asf/hadoop/blob/92144ca7/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystem.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystem.java
index 8b0662c..26bb4f7 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSNamesystem.java
@@ -213,4 +213,24 @@ public class TestFSNamesystem {
fsn.imageLoadComplete();
assertTrue(fsn.isImageLoaded());
}
+
+ @Test
+ public void testGetEffectiveLayoutVersion() {
+ assertEquals(-63,
+ FSNamesystem.getEffectiveLayoutVersion(true, -60, -61, -63));
+ assertEquals(-61,
+ FSNamesystem.getEffectiveLayoutVersion(true, -61, -61, -63));
+ assertEquals(-62,
+ FSNamesystem.getEffectiveLayoutVersion(true, -62, -61, -63));
+ assertEquals(-63,
+ FSNamesystem.getEffectiveLayoutVersion(true, -63, -61, -63));
+ assertEquals(-63,
+ FSNamesystem.getEffectiveLayoutVersion(false, -60, -61, -63));
+ assertEquals(-63,
+ FSNamesystem.getEffectiveLayoutVersion(false, -61, -61, -63));
+ assertEquals(-63,
+ FSNamesystem.getEffectiveLayoutVersion(false, -62, -61, -63));
+ assertEquals(-63,
+ FSNamesystem.getEffectiveLayoutVersion(false, -63, -61, -63));
+ }
}