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 we...@apache.org on 2019/08/13 00:38:42 UTC
[hadoop] branch branch-3.1 updated: HDFS-14148. HDFS OIV ReverseXML
SnapshotSection parser throws exception when there are more than one
snapshottable directory (#1274) Contributed by Siyao Meng.
This is an automated email from the ASF dual-hosted git repository.
weichiu pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new b040eb9 HDFS-14148. HDFS OIV ReverseXML SnapshotSection parser throws exception when there are more than one snapshottable directory (#1274) Contributed by Siyao Meng.
b040eb9 is described below
commit b040eb91c7d2625aa0864a7392830d83670fb51e
Author: Siyao Meng <50...@users.noreply.github.com>
AuthorDate: Mon Aug 12 17:26:20 2019 -0700
HDFS-14148. HDFS OIV ReverseXML SnapshotSection parser throws exception when there are more than one snapshottable directory (#1274) Contributed by Siyao Meng.
(cherry picked from commit c92b49876a078ce7fb4e2a852e315de5b6410082)
(cherry picked from commit c5f433b11fe7409cb59d86e410bc2f7135cde7ca)
---
.../tools/offlineImageViewer/OfflineImageReconstructor.java | 8 +++++---
.../hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java | 10 ++++++++++
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java
index 7d0a492..65abc6f 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/OfflineImageReconstructor.java
@@ -1353,9 +1353,11 @@ class OfflineImageReconstructor {
if (sd == null) {
break;
}
- Long dir = sd.removeChildLong(SNAPSHOT_SECTION_DIR);
- sd.verifyNoRemainingKeys("<dir>");
- bld.addSnapshottableDir(dir);
+ Long dir;
+ while ((dir = sd.removeChildLong(SNAPSHOT_SECTION_DIR)) != null) {
+ // Add all snapshottable directories, one by one
+ bld.addSnapshottableDir(dir);
+ }
}
header.verifyNoRemainingKeys("SnapshotSection");
bld.build().writeDelimitedTo(out);
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java
index 2fdba75..8a3e3d0 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/TestOfflineImageViewer.java
@@ -251,6 +251,16 @@ public class TestOfflineImageViewer {
hdfs.truncate(file1, 1);
writtenFiles.put(file1.toString(), hdfs.getFileStatus(file1));
+ // HDFS-14148: Create a second snapshot-enabled directory. This can cause
+ // TestOfflineImageViewer#testReverseXmlRoundTrip to fail before the patch
+ final Path snapshotDir2 = new Path("/snapshotDir2");
+ hdfs.mkdirs(snapshotDir2);
+ // Simply enable snapshot on it, no need to create one
+ hdfs.allowSnapshot(snapshotDir2);
+ dirCount++;
+ writtenFiles.put(snapshotDir2.toString(),
+ hdfs.getFileStatus(snapshotDir2));
+
// Set XAttrs so the fsimage contains XAttr ops
final Path xattr = new Path("/xattr");
hdfs.mkdirs(xattr);
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org