HDFS-6032. -rollingUpgrade query hits NPE after the NN restarts. Contributed by Haohui Mai.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-5535@1572801 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jing Zhao 2014-02-28 01:23:52 +00:00
parent e9a17c8ce0
commit 5409908026
3 changed files with 33 additions and 1 deletions

View File

@ -120,3 +120,6 @@ HDFS-5535 subtasks:
HDFS-6029. Secondary NN fails to checkpoint after -rollingUpgrade prepare. HDFS-6029. Secondary NN fails to checkpoint after -rollingUpgrade prepare.
(jing9) (jing9)
HDFS-6032. -rollingUpgrade query hits NPE after the NN restarts. (Haohui Mai
via jing9)

View File

@ -881,9 +881,12 @@ public class FSImage implements Closeable {
*/ */
private void loadFSImage(File curFile, MD5Hash expectedMd5, private void loadFSImage(File curFile, MD5Hash expectedMd5,
FSNamesystem target, MetaRecoveryContext recovery) throws IOException { FSNamesystem target, MetaRecoveryContext recovery) throws IOException {
// BlockPoolId is required when the FsImageLoader loads the rolling upgrade
// information. Make sure the ID is properly set.
target.setBlockPoolId(this.getBlockPoolID());
FSImageFormat.LoaderDelegator loader = FSImageFormat.newLoader(conf, target); FSImageFormat.LoaderDelegator loader = FSImageFormat.newLoader(conf, target);
loader.load(curFile); loader.load(curFile);
target.setBlockPoolId(this.getBlockPoolID());
// Check that the image digest we loaded matches up with what // Check that the image digest we loaded matches up with what
// we expected // we expected

View File

@ -432,6 +432,32 @@ public class TestRollingUpgrade {
} }
} }
@Test (timeout = 300000)
public void testQueryAfterRestart() throws IOException, InterruptedException {
final Configuration conf = new Configuration();
MiniDFSCluster cluster = null;
try {
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build();
cluster.waitActive();
DistributedFileSystem dfs = cluster.getFileSystem();
dfs.setSafeMode(SafeModeAction.SAFEMODE_ENTER);
// start rolling upgrade
dfs.rollingUpgrade(RollingUpgradeAction.PREPARE);
queryForPreparation(dfs);
dfs.setSafeMode(SafeModeAction.SAFEMODE_ENTER);
dfs.saveNamespace();
dfs.setSafeMode(SafeModeAction.SAFEMODE_LEAVE);
cluster.restartNameNodes();
dfs.rollingUpgrade(RollingUpgradeAction.QUERY);
} finally {
if (cluster != null) {
cluster.shutdown();
}
}
}
@Test(timeout = 300000) @Test(timeout = 300000)
public void testCheckpoint() throws IOException, InterruptedException { public void testCheckpoint() throws IOException, InterruptedException {
final Configuration conf = new Configuration(); final Configuration conf = new Configuration();