You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by su...@apache.org on 2011/04/22 20:35:46 UTC

svn commit: r1095980 - in /hadoop/common/branches/branch-0.20-security-203: ./ src/hdfs/org/apache/hadoop/hdfs/protocol/ src/hdfs/org/apache/hadoop/hdfs/server/common/ src/test/org/apache/hadoop/hdfs/

Author: suresh
Date: Fri Apr 22 18:35:45 2011
New Revision: 1095980

URL: http://svn.apache.org/viewvc?rev=1095980&view=rev
Log:
HDFS-1842. Change the layout version to -31 to disallow upgrade from and to 0.21 release. Contributed by Suresh Srinivas.


Modified:
    hadoop/common/branches/branch-0.20-security-203/CHANGES.txt
    hadoop/common/branches/branch-0.20-security-203/src/hdfs/org/apache/hadoop/hdfs/protocol/FSConstants.java
    hadoop/common/branches/branch-0.20-security-203/src/hdfs/org/apache/hadoop/hdfs/server/common/Storage.java
    hadoop/common/branches/branch-0.20-security-203/src/test/org/apache/hadoop/hdfs/TestDFSUpgrade.java

Modified: hadoop/common/branches/branch-0.20-security-203/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-203/CHANGES.txt?rev=1095980&r1=1095979&r2=1095980&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-203/CHANGES.txt (original)
+++ hadoop/common/branches/branch-0.20-security-203/CHANGES.txt Fri Apr 22 18:35:45 2011
@@ -57,6 +57,9 @@ Release 0.20.203.0 - unreleased
     HADOOP-7215. RPC clients must use network interface corresponding to 
     the host in the client's kerberos principal key. (suresh)
 
+    HDFS-1842. Change the layout version to -31 to disallow upgrade from
+    and to 0.21 release. (suresh)
+
 Release 0.20.202.0 - unreleased
 
     MAPREDUCE-2355. Add a configuration knob 

Modified: hadoop/common/branches/branch-0.20-security-203/src/hdfs/org/apache/hadoop/hdfs/protocol/FSConstants.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-203/src/hdfs/org/apache/hadoop/hdfs/protocol/FSConstants.java?rev=1095980&r1=1095979&r2=1095980&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-203/src/hdfs/org/apache/hadoop/hdfs/protocol/FSConstants.java (original)
+++ hadoop/common/branches/branch-0.20-security-203/src/hdfs/org/apache/hadoop/hdfs/protocol/FSConstants.java Fri Apr 22 18:35:45 2011
@@ -77,8 +77,7 @@ public interface FSConstants {
   // Version is reflected in the data storage file.
   // Versions are negative.
   // Decrement LAYOUT_VERSION to define a new version.
-  public static final int LAYOUT_VERSION = -19;
+  public static final int LAYOUT_VERSION = -31;
   // Current version: 
-  // -19: added new OP_[GET|RENEW|CANCEL]_DELEGATION_TOKEN and
-  // OP_UPDATE_MASTER_KEY.
+  // -31: to disallow upgrade to release 0.21.
 }

Modified: hadoop/common/branches/branch-0.20-security-203/src/hdfs/org/apache/hadoop/hdfs/server/common/Storage.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-203/src/hdfs/org/apache/hadoop/hdfs/server/common/Storage.java?rev=1095980&r1=1095979&r2=1095980&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-203/src/hdfs/org/apache/hadoop/hdfs/server/common/Storage.java (original)
+++ hadoop/common/branches/branch-0.20-security-203/src/hdfs/org/apache/hadoop/hdfs/server/common/Storage.java Fri Apr 22 18:35:45 2011
@@ -73,6 +73,9 @@ public abstract class Storage extends St
    * any upgrade code that uses this constant should also be removed. */
   public static final int PRE_GENERATIONSTAMP_LAYOUT_VERSION = -13;
   
+  /** Layout version of 21 release */
+  public static final int LAYOUT_VERSION_21 = -24;
+  
   private   static final String STORAGE_FILE_LOCK     = "in_use.lock";
   protected static final String STORAGE_FILE_VERSION  = "VERSION";
   public static final String STORAGE_DIR_CURRENT   = "current";
@@ -688,8 +691,7 @@ public abstract class Storage extends St
    * 
    * @param oldVersion
    */
-  protected static void checkVersionUpgradable(int oldVersion) 
-                                     throws IOException {
+  public static void checkVersionUpgradable(int oldVersion) throws IOException {
     if (oldVersion > LAST_UPGRADABLE_LAYOUT_VERSION) {
       String msg = "*********** Upgrade is not supported from this older" +
                    " version of storage to the current version." + 
@@ -703,7 +705,16 @@ public abstract class Storage extends St
       LOG.error(msg);
       throw new IOException(msg); 
     }
-    
+    if (oldVersion == LAYOUT_VERSION_21) {
+      String msg = "*********** Upgrade is not supported from this " +
+                   " version of storage to the current version." + 
+                   " Please upgrade to release 0.22 " +
+                   " or a later version and then upgrade to current" +
+                   " version. Old layout version is " + oldVersion +
+                   ". ************";
+      LOG.error(msg);
+      throw new IOException(msg); 
+    }
   }
   
   /**

Modified: hadoop/common/branches/branch-0.20-security-203/src/test/org/apache/hadoop/hdfs/TestDFSUpgrade.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-203/src/test/org/apache/hadoop/hdfs/TestDFSUpgrade.java?rev=1095980&r1=1095979&r2=1095980&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-203/src/test/org/apache/hadoop/hdfs/TestDFSUpgrade.java (original)
+++ hadoop/common/branches/branch-0.20-security-203/src/test/org/apache/hadoop/hdfs/TestDFSUpgrade.java Fri Apr 22 18:35:45 2011
@@ -23,6 +23,7 @@ import junit.framework.TestCase;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hdfs.protocol.FSConstants;
 import org.apache.hadoop.hdfs.server.common.HdfsConstants.NodeType;
 import org.apache.hadoop.hdfs.server.common.HdfsConstants.StartupOption;
 
@@ -238,6 +239,21 @@ public class TestDFSUpgrade extends Test
     } // end numDir loop
   }
  
+  public void testCheckVersionUpgradable() throws Exception {
+    // Except for 0.21 layout version all previous layout versions 
+    // should be upgradable.
+    for (int i = Storage.LAST_UPGRADABLE_LAYOUT_VERSION; 
+         i < FSConstants.LAYOUT_VERSION; i++) {
+      if (i == Storage.LAYOUT_VERSION_21) {
+        try {
+          Storage.checkVersionUpgradable(i);
+          fail("Expected IOException is not thrown");
+        } catch (IOException expected) { }
+      }
+      Storage.checkVersionUpgradable(i);
+    }
+  }
+  
   protected void tearDown() throws Exception {
     LOG.info("Shutting down MiniDFSCluster");
     if (cluster != null) cluster.shutdown();