hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raw...@apache.org
Subject svn commit: r910316 - in /hadoop/hbase/trunk: ./ src/contrib/mdc_replication/src/java/org/apache/hadoop/hbase/ipc/ src/contrib/mdc_replication/src/java/org/apache/hadoop/hbase/regionserver/replication/ src/contrib/transactional/src/java/org/apache/hado...
Date Mon, 15 Feb 2010 19:47:15 GMT
Author: rawson
Date: Mon Feb 15 19:47:14 2010
New Revision: 910316

URL: http://svn.apache.org/viewvc?rev=910316&view=rev
Log:
HBASE-2219 stop using code mapping for method names in the RPC


Removed:
    hadoop/hbase/trunk/src/contrib/mdc_replication/src/java/org/apache/hadoop/hbase/ipc/ReplicationRPC.java
    hadoop/hbase/trunk/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionalRPC.java
Modified:
    hadoop/hbase/trunk/CHANGES.txt
    hadoop/hbase/trunk/src/contrib/mdc_replication/src/java/org/apache/hadoop/hbase/regionserver/replication/ReplicationRegionServer.java
    hadoop/hbase/trunk/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionManager.java
    hadoop/hbase/trunk/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionalTable.java
    hadoop/hbase/trunk/src/contrib/transactional/src/java/org/apache/hadoop/hbase/regionserver/transactional/TransactionalRegionServer.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java

Modified: hadoop/hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/CHANGES.txt?rev=910316&r1=910315&r2=910316&view=diff
==============================================================================
--- hadoop/hbase/trunk/CHANGES.txt (original)
+++ hadoop/hbase/trunk/CHANGES.txt Mon Feb 15 19:47:14 2010
@@ -10,6 +10,7 @@
    HBASE-1360  move up to Thrift 0.2.0 (Kay Kay and Lars Francke via Stack)
    HBASE-2212  Refactor out lucene dependencies from HBase
                (Kay Kay via Stack)
+   HBASE-2219  stop using code mapping for method names in the RPC
 
   BUG FIXES
    HBASE-1791  Timeout in IndexRecordWriter (Bradford Stephens via Andrew

Modified: hadoop/hbase/trunk/src/contrib/mdc_replication/src/java/org/apache/hadoop/hbase/regionserver/replication/ReplicationRegionServer.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/contrib/mdc_replication/src/java/org/apache/hadoop/hbase/regionserver/replication/ReplicationRegionServer.java?rev=910316&r1=910315&r2=910316&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/contrib/mdc_replication/src/java/org/apache/hadoop/hbase/regionserver/replication/ReplicationRegionServer.java
(original)
+++ hadoop/hbase/trunk/src/contrib/mdc_replication/src/java/org/apache/hadoop/hbase/regionserver/replication/ReplicationRegionServer.java
Mon Feb 15 19:47:14 2010
@@ -26,7 +26,6 @@
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.ipc.HBaseRPCProtocolVersion;
-import org.apache.hadoop.hbase.ipc.ReplicationRPC;
 import org.apache.hadoop.hbase.ipc.ReplicationRegionInterface;
 import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.regionserver.HRegionServer;
@@ -43,10 +42,6 @@
 public class ReplicationRegionServer extends HRegionServer
     implements ReplicationRegionInterface {
 
-  static {
-    ReplicationRPC.initialize();
-  }
-
   protected static final Log LOG =
       LogFactory.getLog(ReplicationRegionServer.class);
 

Modified: hadoop/hbase/trunk/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionManager.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionManager.java?rev=910316&r1=910315&r2=910316&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionManager.java
(original)
+++ hadoop/hbase/trunk/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionManager.java
Mon Feb 15 19:47:14 2010
@@ -36,10 +36,6 @@
  * 
  */
 public class TransactionManager {
-  static {
-    TransactionalRPC.initialize();
-  }
-
   static final Log LOG = LogFactory.getLog(TransactionManager.class);
 
   private final HConnection connection;

Modified: hadoop/hbase/trunk/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionalTable.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionalTable.java?rev=910316&r1=910315&r2=910316&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionalTable.java
(original)
+++ hadoop/hbase/trunk/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionalTable.java
Mon Feb 15 19:47:14 2010
@@ -41,10 +41,6 @@
  */
 public class TransactionalTable extends HTable {
   
-  static {
-    TransactionalRPC.initialize();
-  }
-  
   /**
    * @param conf
    * @param tableName

Modified: hadoop/hbase/trunk/src/contrib/transactional/src/java/org/apache/hadoop/hbase/regionserver/transactional/TransactionalRegionServer.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/contrib/transactional/src/java/org/apache/hadoop/hbase/regionserver/transactional/TransactionalRegionServer.java?rev=910316&r1=910315&r2=910316&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/contrib/transactional/src/java/org/apache/hadoop/hbase/regionserver/transactional/TransactionalRegionServer.java
(original)
+++ hadoop/hbase/trunk/src/contrib/transactional/src/java/org/apache/hadoop/hbase/regionserver/transactional/TransactionalRegionServer.java
Mon Feb 15 19:47:14 2010
@@ -36,7 +36,6 @@
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.client.transactional.TransactionalRPC;
 import org.apache.hadoop.hbase.ipc.HBaseRPCProtocolVersion;
 import org.apache.hadoop.hbase.ipc.TransactionalRegionInterface;
 import org.apache.hadoop.hbase.regionserver.wal.HLog;
@@ -54,10 +53,6 @@
  */
 public class TransactionalRegionServer extends HRegionServer implements
     TransactionalRegionInterface {
-  
-  static {
-    TransactionalRPC.initialize();
-  }
 
   private static final String LEASE_TIME = "hbase.transaction.leasetime";
   private static final int DEFAULT_LEASE_TIME = 60 * 1000;

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java?rev=910316&r1=910315&r2=910316&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java Mon Feb 15 19:47:14
2010
@@ -85,59 +85,8 @@
     super();
   }                                  // no public ctor
 
-  // Special code that means 'not-encoded'.
-  private static final byte NOT_ENCODED = 0;
-  private static byte code = NOT_ENCODED + 1;
-  
-  /** Add a new interface to the ipc map.
-   * @param c Class whose methods we'll add to the map of methods to codes
-   * (and vice versa).
-   * @param startCode Current state of the byte code.
-   * @return State of <code>code</code> when this method is done.
-   */
-  public static byte addToMap(final Class<?> c, final byte startCode) {
-    if (Invocation.CODE_TO_METHODNAME.get(startCode) != null) {
-      throw new IllegalArgumentException("Code " + startCode +
-        "already had entry");
-    }
-    byte localCode = startCode;
-    Method [] methods = c.getMethods();
-    // There are no guarantees about the order in which items are returned in
-    // so do a sort (Was seeing that sort was one way on one server and then
-    // another on different server).
-    Arrays.sort(methods, new Comparator<Method>() {
-      public int compare(Method left, Method right) {
-        return left.getName().compareTo(right.getName());
-      }
-    });
-    for (int i = 0; i < methods.length; i++) {
-      Invocation.addToMap(methods[i].getName(), localCode++);
-    }
-    return localCode;
-  }
-  
-  static Collection<String> getMappedMethodNames() {
-    return Invocation.CODE_TO_METHODNAME.values();
-  }
-
-  static {
-    code = HBaseRPC.addToMap(VersionedProtocol.class, code);
-    code = HBaseRPC.addToMap(HMasterInterface.class, code);
-    code = HBaseRPC.addToMap(HMasterRegionInterface.class, code);
-    code = HBaseRPC.addToMap(HRegionInterface.class, code);
-  }
-
   /** A method invocation, including the method name and its parameters.*/
   private static class Invocation implements Writable, Configurable {
-    // Here, for hbase, we maintain two static maps of method names to code and
-    // vice versa.
-    static final Map<Byte, String> CODE_TO_METHODNAME =
-      new HashMap<Byte, String>();
-    private static final Map<String, Byte> METHODNAME_TO_CODE =
-      new HashMap<String, Byte>();
-    
-    // End of hbase modifications.
-
     private String methodName;
     @SuppressWarnings("unchecked")
     private Class[] parameterClasses;
@@ -170,8 +119,7 @@
     public Object[] getParameters() { return parameters; }
 
     public void readFields(DataInput in) throws IOException {
-      byte code = in.readByte();
-      methodName = CODE_TO_METHODNAME.get(Byte.valueOf(code));
+      methodName = in.readUTF();
       parameters = new Object[in.readInt()];
       parameterClasses = new Class[parameters.length];
       HbaseObjectWritable objectWritable = new HbaseObjectWritable();
@@ -183,7 +131,7 @@
     }
 
     public void write(DataOutput out) throws IOException {
-      writeMethodNameCode(out, this.methodName);
+      out.writeUTF(this.methodName);
       out.writeInt(parameterClasses.length);
       for (int i = 0; i < parameterClasses.length; i++) {
         HbaseObjectWritable.writeObject(out, parameters[i], parameterClasses[i],
@@ -212,34 +160,6 @@
     public Configuration getConf() {
       return this.conf;
     }
-    
-    // Hbase additions.
-    static void addToMap(final String name, final byte code) {
-      if (METHODNAME_TO_CODE.containsKey(name)) {
-        return;
-      }
-      METHODNAME_TO_CODE.put(name, Byte.valueOf(code));
-      CODE_TO_METHODNAME.put(Byte.valueOf(code), name);
-    }
-    
-
-    /*
-     * Write out the code byte for passed Class.
-     * @param out
-     * @param c
-     * @throws IOException
-     */
-    static void writeMethodNameCode(final DataOutput out, final String methodname)
-    throws IOException {
-      Byte code = METHODNAME_TO_CODE.get(methodname);
-      if (code == null) {
-        LOG.error("Unsupported type " + methodname);
-        throw new UnsupportedOperationException("No code for unexpected " +
-          methodname);
-      }
-      out.writeByte(code.byteValue());
-    }
-    // End of hbase additions.
   }
 
   /* Cache a client using its socket factory as the hash key */

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java?rev=910316&r1=910315&r2=910316&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java Mon Feb 15
19:47:14 2010
@@ -54,7 +54,6 @@
 
     context.registerUpdater(this);
     
-    this.initMethods();
     rpcStatistics = new HBaseRPCStatistics(this.registry, hostName, port);
   }
   
@@ -71,16 +70,6 @@
 
   //public Map <String, MetricsTimeVaryingRate> metricsList = Collections.synchronizedMap(new
HashMap<String, MetricsTimeVaryingRate>());
 
-  /**
-   * Register metrics for all know RPC methods ahead of time.  This helps with
-   * JMX usage, where trying to retrieve the RPC-method metrics before they're
-   * incremented could otherwise cause spurious AttributeNotFoundExceptions.
-   */
-  private void initMethods() {
-    for (String name : HBaseRPC.getMappedMethodNames()) {
-      create(name);
-    }
-  }
 
   private MetricsTimeVaryingRate get(String key) {
     return (MetricsTimeVaryingRate) registry.get(key);



Mime
View raw message