Skip to content

HDFS-16338. Correct fsimage error configuration message #3684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw checkpointDirs and checkpointEditsDirs will not be null as they are assigned values returned by FSImage.getCheckpointDirs and FSImage.getCheckpointEditsDirs respectively.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, my IntelliJ was giving that warning as well, but that was something not touched here....
I thought Todd added it just for future safety, Didn't research why there was a null check considering it harmless.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it seems fine, just an additional null check, not a big deal. Also good to keep it for future safety as you predicted correctly, just in case if the methods themselves start returning null (less likely but still doable).

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down