hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1231986 - in /hbase/branches/0.92: CHANGES.txt src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java src/main/java/org/apache/hadoop/hbase/ipc/Invocation.java
Date Mon, 16 Jan 2012 13:10:11 GMT
Author: stack
Date: Mon Jan 16 13:10:11 2012
New Revision: 1231986

URL: http://svn.apache.org/viewvc?rev=1231986&view=rev
Log:
HBASE-5204 Backward compatibility fixes for 0.92

Modified:
    hbase/branches/0.92/CHANGES.txt
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java
    hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/ipc/Invocation.java

Modified: hbase/branches/0.92/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/CHANGES.txt?rev=1231986&r1=1231985&r2=1231986&view=diff
==============================================================================
--- hbase/branches/0.92/CHANGES.txt (original)
+++ hbase/branches/0.92/CHANGES.txt Mon Jan 16 13:10:11 2012
@@ -521,6 +521,7 @@ Release 0.92.0 - Unreleased
                ("The directory is already locked.") (N Keywal)
    HBASE-5143  Fix config typo in pluggable load balancer factory (Harsh J)
    HBASE-5196  Failure in region split after PONR could cause region hole (Jimmy Xiang)
+   HBASE-5204  Backward compatibility fixes for 0.92 (Benoît Sigoure)
 
   TESTS
    HBASE-4492  TestRollingRestart fails intermittently

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java?rev=1231986&r1=1231985&r2=1231986&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java
(original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java
Mon Jan 16 13:10:11 2012
@@ -121,6 +121,14 @@ public class HbaseObjectWritable impleme
   // sending of the class name using reflection, etc.
   private static final byte NOT_ENCODED = 0;
   static {
+    ////////////////////////////////////////////////////////////////////////////
+    // WARNING: Please do not insert, remove or swap any line in this static  //
+    // block.  Doing so would change or shift all the codes used to serialize //
+    // objects, which makes backwards compatibility very hard for clients.    //
+    // New codes should always be added at the end. Code removal is           //
+    // discouraged because code is a short now.                               //
+    ////////////////////////////////////////////////////////////////////////////
+
     int code = NOT_ENCODED + 1;
     // Primitive types.
     addToMap(Boolean.TYPE, code++);
@@ -163,7 +171,6 @@ public class HbaseObjectWritable impleme
     addToMap(HServerAddress.class, code++);
     addToMap(HServerInfo.class, code++);
     addToMap(HTableDescriptor.class, code++);
-    addToMap(HTableDescriptor[].class, code++);
     addToMap(MapWritable.class, code++);
 
     //
@@ -220,7 +227,7 @@ public class HbaseObjectWritable impleme
     addToMap(Increment.class, code++);
 
     addToMap(KeyOnlyFilter.class, code++);
-    
+
     // serializable
     addToMap(Serializable.class, code++);
 
@@ -231,9 +238,10 @@ public class HbaseObjectWritable impleme
     addToMap(ColumnRangeFilter.class, code++);
 
     addToMap(HServerLoad.class, code++);
-    
+
     addToMap(RegionOpeningState.class, code++);
-    
+
+    addToMap(HTableDescriptor[].class, code++);
   }
 
   private Class<?> declaredClass;
@@ -588,7 +596,7 @@ public class HbaseObjectWritable impleme
         in.readFully(objectBytes);
         ByteArrayInputStream bis = null;
         ObjectInputStream ois = null;
-        try { 
+        try {
           bis = new ByteArrayInputStream(objectBytes);
           ois = new ObjectInputStream(bis);
           instance = ois.readObject();

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java?rev=1231986&r1=1231985&r2=1231986&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java (original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/ipc/HBaseServer.java Mon Jan
16 13:10:11 2012
@@ -1213,9 +1213,10 @@ public abstract class HBaseServer implem
       header.readFields(in);
       try {
         String protocolClassName = header.getProtocol();
-        if (protocolClassName != null) {
-          protocol = getProtocolClass(header.getProtocol(), conf);
+        if (protocolClassName == null) {
+          protocolClassName = "org.apache.hadoop.hbase.ipc.HRegionInterface";
         }
+        protocol = getProtocolClass(protocolClassName, conf);
       } catch (ClassNotFoundException cnfe) {
         throw new IOException("Unknown protocol: " + header.getProtocol());
       }

Modified: hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/ipc/Invocation.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/ipc/Invocation.java?rev=1231986&r1=1231985&r2=1231986&view=diff
==============================================================================
--- hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/ipc/Invocation.java (original)
+++ hbase/branches/0.92/src/main/java/org/apache/hadoop/hbase/ipc/Invocation.java Mon Jan
16 13:10:11 2012
@@ -22,6 +22,7 @@ package org.apache.hadoop.hbase.ipc;
 import org.apache.hadoop.conf.Configurable;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.io.HbaseObjectWritable;
+import org.apache.hadoop.io.VersionMismatchException;
 import org.apache.hadoop.io.VersionedWritable;
 
 import java.io.DataInput;
@@ -94,10 +95,29 @@ public class Invocation extends Versione
   }
 
   public void readFields(DataInput in) throws IOException {
-    super.readFields(in);
-    methodName = in.readUTF();
-    clientVersion = in.readLong();
-    clientMethodsHash = in.readInt();
+    try {
+      super.readFields(in);
+      methodName = in.readUTF();
+      clientVersion = in.readLong();
+      clientMethodsHash = in.readInt();
+    } catch (VersionMismatchException e) {
+      // VersionMismatchException doesn't provide an API to access
+      // expectedVersion and foundVersion.  This is really sad.
+      if (e.toString().endsWith("found v0")) {
+        // Try to be a bit backwards compatible.  In previous versions of
+        // HBase (before HBASE-3939 in 0.92) Invocation wasn't a
+        // VersionedWritable and thus the first thing on the wire was always
+        // the 2-byte length of the method name.  Because no method name is
+        // longer than 255 characters, and all method names are in ASCII,
+        // The following code is equivalent to `in.readUTF()', which we can't
+        // call again here, because `super.readFields(in)' already consumed
+        // the first byte of input, which can't be "unread" back into `in'.
+        final short len = (short) (in.readByte() & 0xFF);  // Unsigned byte.
+        final byte[] buf = new byte[len];
+        in.readFully(buf, 0, len);
+        methodName = new String(buf);
+      }
+    }
     parameters = new Object[in.readInt()];
     parameterClasses = new Class[parameters.length];
     HbaseObjectWritable objectWritable = new HbaseObjectWritable();



Mime
View raw message