hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hair...@apache.org
Subject svn commit: r1102465 - in /hadoop/hdfs/trunk/src: java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java
Date Thu, 12 May 2011 21:17:17 GMT
Author: hairong
Date: Thu May 12 21:17:17 2011
New Revision: 1102465

URL: http://svn.apache.org/viewvc?rev=1102465&view=rev
Log:
Fix NullPointerException in Secondary NameNode. Contributed by Hairong Kuang.

Modified:
    hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java
    hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java

Modified: hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java?rev=1102465&r1=1102464&r2=1102465&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java
(original)
+++ hadoop/hdfs/trunk/src/java/org/apache/hadoop/hdfs/server/namenode/SecondaryNameNode.java
Thu May 12 21:17:17 2011
@@ -98,6 +98,7 @@ public class SecondaryNameNode implement
   private int imagePort;
   private String infoBindAddress;
 
+  private FSNamesystem namesystem;
   private Collection<URI> checkpointDirs;
   private Collection<URI> checkpointEditsDirs;
   private long checkpointPeriod;    // in seconds
@@ -481,8 +482,9 @@ public class SecondaryNameNode implement
    */
   private void doMerge(CheckpointSignature sig, boolean loadImage)
   throws IOException {
-    FSNamesystem namesystem = 
-            new FSNamesystem(checkpointImage, conf);
+    if (loadImage) {
+      namesystem = new FSNamesystem(checkpointImage, conf);
+    }
     assert namesystem.dir.fsImage == checkpointImage;
     checkpointImage.doMerge(sig, loadImage);
   }

Modified: hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java
URL: http://svn.apache.org/viewvc/hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java?rev=1102465&r1=1102464&r2=1102465&view=diff
==============================================================================
--- hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java
(original)
+++ hadoop/hdfs/trunk/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestCheckpoint.java
Thu May 12 21:17:17 2011
@@ -684,6 +684,7 @@ public class TestCheckpoint extends Test
     cluster = new MiniDFSCluster.Builder(conf).numDataNodes(numDatanodes).format(false).build();
     cluster.waitActive();
     fileSys = cluster.getFileSystem();
+    Path tmpDir = new Path("/tmp_tmp");
     try {
       // check that file1 still exists
       checkFile(fileSys, file1, replication);
@@ -698,6 +699,11 @@ public class TestCheckpoint extends Test
       //
       SecondaryNameNode secondary = startSecondaryNameNode(conf);
       secondary.doCheckpoint();
+      
+      fileSys.delete(tmpDir, true);
+      fileSys.mkdirs(tmpDir);
+      secondary.doCheckpoint();
+      
       secondary.shutdown();
     } finally {
       fileSys.close();
@@ -713,6 +719,7 @@ public class TestCheckpoint extends Test
     fileSys = cluster.getFileSystem();
 
     assertTrue(!fileSys.exists(file1));
+    assertTrue(fileSys.exists(tmpDir));
 
     try {
       // verify that file2 exists



Mime
View raw message