hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject svn commit: r650329 - in /hadoop/core/trunk: CHANGES.txt src/test/org/apache/hadoop/dfs/TestCheckpoint.java
Date Tue, 22 Apr 2008 00:28:40 GMT
Author: shv
Date: Mon Apr 21 17:28:36 2008
New Revision: 650329

URL: http://svn.apache.org/viewvc?rev=650329&view=rev
Log:
HADOOP-3282. Port issues in TestCheckpoint resolved. Contributed by Konstantin Shvachko.

Modified:
    hadoop/core/trunk/CHANGES.txt
    hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestCheckpoint.java

Modified: hadoop/core/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=650329&r1=650328&r2=650329&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Mon Apr 21 17:28:36 2008
@@ -50,6 +50,8 @@
     HADOOP-3269.  Fix a case when namenode fails to restart
     while processing a lease record.  ((Tsz Wo (Nicholas), SZE via dhruba)
 
+    HADOOP-3282. Port issues in TestCheckpoint resolved. (shv)
+
 Release 0.17.0 - Unreleased
 
   INCOMPATIBLE CHANGES

Modified: hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestCheckpoint.java
URL: http://svn.apache.org/viewvc/hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestCheckpoint.java?rev=650329&r1=650328&r2=650329&view=diff
==============================================================================
--- hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestCheckpoint.java (original)
+++ hadoop/core/trunk/src/test/org/apache/hadoop/dfs/TestCheckpoint.java Mon Apr 21 17:28:36
2008
@@ -138,7 +138,7 @@
       //
       // Make the checkpoint fail after rolling the edits log.
       //
-      SecondaryNameNode secondary = new SecondaryNameNode(conf);
+      SecondaryNameNode secondary = startSecondaryNameNode(conf);
       ErrorSimulator.setErrorSimulation(0);
 
       try {
@@ -184,7 +184,7 @@
     try {
       checkFile(fileSys, file1, replication);
       cleanupFile(fileSys, file1);
-      SecondaryNameNode secondary = new SecondaryNameNode(conf);
+      SecondaryNameNode secondary = startSecondaryNameNode(conf);
       secondary.doCheckpoint();
       secondary.shutdown();
     } finally {
@@ -209,7 +209,7 @@
       //
       // Make the checkpoint fail after uploading the new fsimage.
       //
-      SecondaryNameNode secondary = new SecondaryNameNode(conf);
+      SecondaryNameNode secondary = startSecondaryNameNode(conf);
       ErrorSimulator.setErrorSimulation(1);
 
       try {
@@ -242,7 +242,7 @@
     try {
       checkFile(fileSys, file1, replication);
       cleanupFile(fileSys, file1);
-      SecondaryNameNode secondary = new SecondaryNameNode(conf);
+      SecondaryNameNode secondary = startSecondaryNameNode(conf);
       secondary.doCheckpoint();
       secondary.shutdown();
     } finally {
@@ -267,7 +267,7 @@
       //
       // Make the checkpoint fail after rolling the edit log.
       //
-      SecondaryNameNode secondary = new SecondaryNameNode(conf);
+      SecondaryNameNode secondary = startSecondaryNameNode(conf);
       ErrorSimulator.setErrorSimulation(0);
 
       try {
@@ -282,7 +282,7 @@
       // a new rollEditLog suceedes inspite of the fact that 
       // edits.new already exists.
       //
-      secondary = new SecondaryNameNode(conf);
+      secondary = startSecondaryNameNode(conf);
       secondary.doCheckpoint();  // this should work correctly
       secondary.shutdown();
 
@@ -308,7 +308,7 @@
     try {
       checkFile(fileSys, file1, replication);
       cleanupFile(fileSys, file1);
-      SecondaryNameNode secondary = new SecondaryNameNode(conf);
+      SecondaryNameNode secondary = startSecondaryNameNode(conf);
       secondary.doCheckpoint();
       secondary.shutdown();
     } finally {
@@ -337,7 +337,7 @@
       //
       // Make the checkpoint
       //
-      SecondaryNameNode secondary = new SecondaryNameNode(conf);
+      SecondaryNameNode secondary = startSecondaryNameNode(conf);
       ErrorSimulator.setErrorSimulation(2);
 
       try {
@@ -384,18 +384,13 @@
     System.out.println("Startup of the name-node in the checkpoint directory.");
     String primaryDirs = conf.get("dfs.name.dir");
     String checkpointDirs = conf.get("fs.checkpoint.dir");
-    conf.set("dfs.http.address", "0.0.0.0:0");  
-    conf.set("dfs.name.dir", checkpointDirs);
-    String[] args = new String[]{};
-    NameNode nn = NameNode.createNameNode(args, conf);
-    assertTrue(nn.isInSafeMode());
+    NameNode nn = startNameNode(conf, checkpointDirs, StartupOption.REGULAR);
 
     // Starting secondary node in the same directory as the primary
     System.out.println("Startup of secondary in the same dir as the primary.");
     SecondaryNameNode secondary = null;
     try {
-      conf.set("dfs.secondary.http.address", "0.0.0.0:0");
-      secondary = new SecondaryNameNode(conf);
+      secondary = startSecondaryNameNode(conf);
       assertFalse(secondary.getFSImage().isLockSupported(0));
       secondary.shutdown();
     } catch (IOException e) { // expected to fail
@@ -405,15 +400,12 @@
 
     // Starting primary node in the same directory as the secondary
     System.out.println("Startup of primary in the same dir as the secondary.");
-    conf.set("dfs.http.address", "0.0.0.0:0");  
-    conf.set("dfs.name.dir", primaryDirs);
     // secondary won't start without primary
-    nn = NameNode.createNameNode(args, conf);
-    conf.set("dfs.secondary.http.address", "0.0.0.0:0");
+    nn = startNameNode(conf, primaryDirs, StartupOption.REGULAR);
     boolean succeed = false;
     do {
       try {
-        secondary = new SecondaryNameNode(conf);
+        secondary = startSecondaryNameNode(conf);
         succeed = true;
       } catch(IOException ie) { // keep trying
         System.out.println("Try again: " + ie.getLocalizedMessage());
@@ -421,9 +413,7 @@
     } while(!succeed);
     nn.stop(); nn = null;
     try {
-      conf.set("dfs.http.address", "0.0.0.0:0");  
-      conf.set("dfs.name.dir", checkpointDirs);
-      nn = NameNode.createNameNode(args, conf);
+      nn = startNameNode(conf, checkpointDirs, StartupOption.REGULAR);
       assertFalse(nn.getFSImage().isLockSupported(0));
       nn.stop(); nn = null;
     } catch (IOException e) { // expected to fail
@@ -432,14 +422,11 @@
 
     // Try another secondary in the same directory
     System.out.println("Startup of two secondaries in the same dir.");
-    conf.set("dfs.http.address", "0.0.0.0:0");  
-    conf.set("dfs.name.dir", primaryDirs);
     // secondary won't start without primary
-    nn = NameNode.createNameNode(args, conf);
+    nn = startNameNode(conf, primaryDirs, StartupOption.REGULAR);
     SecondaryNameNode secondary2 = null;
     try {
-      conf.set("dfs.secondary.http.address", "0.0.0.0:0");
-      secondary2 = new SecondaryNameNode(conf);
+      secondary2 = startSecondaryNameNode(conf);
       assertFalse(secondary2.getFSImage().isLockSupported(0));
       secondary2.shutdown();
     } catch (IOException e) { // expected to fail
@@ -450,11 +437,8 @@
 
     // Import a checkpoint with existing primary image.
     System.out.println("Import a checkpoint with existing primary image.");
-    args = new String[]{StartupOption.IMPORT.getName()};
     try {
-      conf.set("dfs.http.address", "0.0.0.0:0");  
-      conf.set("dfs.name.dir", primaryDirs);
-      nn = NameNode.createNameNode(args, conf);
+      nn = startNameNode(conf, primaryDirs, StartupOption.IMPORT);
       assertTrue(false);
     } catch (IOException e) { // expected to fail
       assertTrue(nn == null);
@@ -472,9 +456,7 @@
       if (!dir.mkdirs())
         throw new IOException("Cannot create directory " + dir);
     }
-    conf.set("dfs.http.address", "0.0.0.0:0");  
-    conf.set("dfs.name.dir", primaryDirs);
-    nn = NameNode.createNameNode(args, conf);
+    nn = startNameNode(conf, primaryDirs, StartupOption.IMPORT);
     // Verify that image file sizes did not change.
     FSImage image = nn.getFSImage();
     int nrDirs = image.getNumStorageDirs();
@@ -485,17 +467,13 @@
     nn.stop();
 
     // recover failed checkpoint
-    conf.set("dfs.http.address", "0.0.0.0:0");  
-    conf.set("dfs.name.dir", primaryDirs);
-    args = new String[]{};
-    nn = NameNode.createNameNode(args, conf);
+    nn = startNameNode(conf, primaryDirs, StartupOption.REGULAR);
     Collection<File> secondaryDirs = FSImage.getCheckpointDirs(conf, null);
     for(File dir : secondaryDirs) {
       Storage.rename(new File(dir, "current"), 
                      new File(dir, "lastcheckpoint.tmp"));
     }
-    conf.set("dfs.secondary.http.address", "0.0.0.0:0");
-    secondary = new SecondaryNameNode(conf);
+    secondary = startSecondaryNameNode(conf);
     secondary.shutdown();
     for(File dir : secondaryDirs) {
       assertTrue(new File(dir, "current").exists()); 
@@ -507,8 +485,7 @@
       Storage.rename(new File(dir, "previous.checkpoint"), 
                      new File(dir, "lastcheckpoint.tmp"));
     }
-    conf.set("dfs.secondary.http.address", "0.0.0.0:0");
-    secondary = new SecondaryNameNode(conf);
+    secondary = startSecondaryNameNode(conf);
     secondary.shutdown();
     for(File dir : secondaryDirs) {
       assertTrue(new File(dir, "current").exists()); 
@@ -523,6 +500,24 @@
     cluster.shutdown();
   }
 
+  NameNode startNameNode( Configuration conf,
+                          String imageDirs,
+                          StartupOption start) throws IOException {
+    conf.set("fs.default.name", "hdfs://localhost:0");
+    conf.set("dfs.http.address", "0.0.0.0:0");  
+    conf.set("dfs.name.dir", imageDirs);
+    String[] args = new String[]{start.getName()};
+    NameNode nn = NameNode.createNameNode(args, conf);
+    assertTrue(nn.isInSafeMode());
+    return nn;
+  }
+
+  SecondaryNameNode startSecondaryNameNode(Configuration conf
+                                          ) throws IOException {
+    conf.set("dfs.secondary.http.address", "0.0.0.0:0");
+    return new SecondaryNameNode(conf);
+  }
+
   /**
    * Tests checkpoint in DFS.
    */
@@ -555,7 +550,7 @@
       //
       // Take a checkpoint
       //
-      SecondaryNameNode secondary = new SecondaryNameNode(conf);
+      SecondaryNameNode secondary = startSecondaryNameNode(conf);
       ErrorSimulator.initializeErrorSimulationEvent(3);
       secondary.doCheckpoint();
       secondary.shutdown();
@@ -582,7 +577,7 @@
       //
       // Take a checkpoint
       //
-      SecondaryNameNode secondary = new SecondaryNameNode(conf);
+      SecondaryNameNode secondary = startSecondaryNameNode(conf);
       secondary.doCheckpoint();
       secondary.shutdown();
     } finally {



Mime
View raw message