From 1509ea5de2836a51e62a842eeda0b322c9a18934 Mon Sep 17 00:00:00 2001 From: GuoPhilipse <46367746+GuoPhilipse@users.noreply.github.com> Date: Mon, 6 Dec 2021 16:30:50 +0800 Subject: [PATCH] HDFS-16338. Correct fsimage error configuration message (#3684). Contributed by guophilipse. Reviewed-by: cxorm Reviewed-by: tomscut Signed-off-by: Ayush Saxena --- .../hadoop/hdfs/server/namenode/FSImage.java | 4 ++-- .../hdfs/server/namenode/TestFSImage.java | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java index b350ef1f98..7302596dc6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java @@ -582,12 +582,12 @@ void doImportCheckpoint(FSNamesystem target) throws IOException { if (checkpointDirs == null || checkpointDirs.isEmpty()) { throw new IOException("Cannot import image from a checkpoint. " - + "\"dfs.namenode.checkpoint.dir\" is not set." ); + + "\"dfs.namenode.checkpoint.dir\" is not set."); } if (checkpointEditsDirs == null || checkpointEditsDirs.isEmpty()) { throw new IOException("Cannot import image from a checkpoint. " - + "\"dfs.namenode.checkpoint.dir\" is not set." ); + + "\"dfs.namenode.checkpoint.edits.dir\" is not set."); } FSImage realImage = target.getFSImage(); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImage.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImage.java index 185db6916a..0445d211fe 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImage.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSImage.java @@ -80,6 +80,7 @@ import org.apache.hadoop.hdfs.util.MD5FileUtils; import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.test.PathUtils; +import org.apache.hadoop.test.LambdaTestUtils; import org.apache.hadoop.util.Time; import org.junit.Assert; import org.junit.Assume; @@ -275,6 +276,22 @@ public void testSaveAndLoadStripedINodeFile() throws IOException{ } } + @Test + public void testImportCheckpoint() throws Exception{ + Configuration conf = new Configuration(); + conf.set(DFSConfigKeys.DFS_NAMENODE_CHECKPOINT_EDITS_DIR_KEY, ""); + try(MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf).build()){ + cluster.waitActive(); + FSNamesystem fsn = cluster.getNamesystem(); + FSImage fsImage= new FSImage(conf); + LambdaTestUtils.intercept( + IOException.class, + "Cannot import image from a checkpoint. " + + "\"dfs.namenode.checkpoint.edits.dir\" is not set.", + () -> fsImage.doImportCheckpoint(fsn)); + } + } + /** * Test if a INodeFileUnderConstruction with BlockInfoStriped can be * saved and loaded by FSImageSerialization