HDFS-16338. Correct fsimage error configuration message (#3684). Contributed by guophilipse.

Reviewed-by: cxorm <lianp964@gmail.com>
Reviewed-by: tomscut <litao@bigo.sg>
Signed-off-by: Ayush Saxena <ayushsaxena@apache.org>
This commit is contained in:
GuoPhilipse 2021-12-06 16:30:50 +08:00 committed by GitHub
parent e8e69de106
commit 1509ea5de2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -582,12 +582,12 @@ void doImportCheckpoint(FSNamesystem target) throws IOException {
if (checkpointDirs == null || checkpointDirs.isEmpty()) { if (checkpointDirs == null || checkpointDirs.isEmpty()) {
throw new IOException("Cannot import image from a checkpoint. " 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()) { if (checkpointEditsDirs == null || checkpointEditsDirs.isEmpty()) {
throw new IOException("Cannot import image from a checkpoint. " 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(); FSImage realImage = target.getFSImage();

View File

@ -80,6 +80,7 @@
import org.apache.hadoop.hdfs.util.MD5FileUtils; import org.apache.hadoop.hdfs.util.MD5FileUtils;
import org.apache.hadoop.test.GenericTestUtils; import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.test.PathUtils; import org.apache.hadoop.test.PathUtils;
import org.apache.hadoop.test.LambdaTestUtils;
import org.apache.hadoop.util.Time; import org.apache.hadoop.util.Time;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Assume; 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 * Test if a INodeFileUnderConstruction with BlockInfoStriped can be
* saved and loaded by FSImageSerialization * saved and loaded by FSImageSerialization