From 069e6b389e486bc85b17d0cf0d10b521fd58fd56 Mon Sep 17 00:00:00 2001 From: Jing Zhao Date: Mon, 24 Mar 2014 21:26:24 +0000 Subject: [PATCH] HDFS-6135. Merge r1581070 from trunk. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1581071 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hadoop/hdfs/qjournal/server/JNStorage.java | 13 +++++++++++++ .../hadoop/hdfs/server/common/StorageInfo.java | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 0fa946e7cf2..b227c5528b4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -438,6 +438,9 @@ Release 2.4.0 - UNRELEASED HDFS-6140. WebHDFS cannot create a file with spaces in the name after HA failover changes. (cnauroth) + HDFS-6135. In HDFS upgrade with HA setup, JournalNode cannot handle layout + version bump when rolling back. (jing9) + BREAKDOWN OF HDFS-5698 SUBTASKS AND RELATED JIRAS HDFS-5717. Save FSImage header in protobuf. (Haohui Mai via jing9) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JNStorage.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JNStorage.java index e972fe03af1..097633ed60a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JNStorage.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/qjournal/server/JNStorage.java @@ -20,6 +20,7 @@ package org.apache.hadoop.hdfs.qjournal.server; import java.io.File; import java.io.IOException; import java.util.List; +import java.util.Properties; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -27,6 +28,8 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileUtil; import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.NodeType; import org.apache.hadoop.hdfs.server.common.HdfsServerConstants.StartupOption; +import org.apache.hadoop.hdfs.server.common.InconsistentFSStateException; +import org.apache.hadoop.hdfs.server.common.IncorrectVersionException; import org.apache.hadoop.hdfs.server.common.Storage; import org.apache.hadoop.hdfs.server.common.StorageErrorReporter; import org.apache.hadoop.hdfs.server.namenode.FileJournalManager; @@ -203,6 +206,16 @@ class JNStorage extends Storage { } } + @Override + protected void setLayoutVersion(Properties props, StorageDirectory sd) + throws IncorrectVersionException, InconsistentFSStateException { + int lv = Integer.parseInt(getProperty(props, sd, "layoutVersion")); + // For journal node, since it now does not decode but just scan through the + // edits, it can handle edits with future version in most of the cases. + // Thus currently we may skip the layoutVersion check here. + layoutVersion = lv; + } + void checkConsistentNamespace(NamespaceInfo nsInfo) throws IOException { if (nsInfo.getNamespaceID() != getNamespaceID()) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/StorageInfo.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/StorageInfo.java index c87baee959c..2cb6340e50d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/StorageInfo.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/common/StorageInfo.java @@ -202,7 +202,7 @@ public class StorageInfo { : NameNodeLayoutVersion.FEATURES; } - static String getProperty(Properties props, StorageDirectory sd, + protected static String getProperty(Properties props, StorageDirectory sd, String name) throws InconsistentFSStateException { String property = props.getProperty(name); if (property == null) {