diff --git a/src/contrib/mdc_replication/src/java/org/apache/hadoop/hbase/ipc/ReplicationRPC.java b/src/contrib/mdc_replication/src/java/org/apache/hadoop/hbase/ipc/ReplicationRPC.java deleted file mode 100644 index 57ab93c..0000000 --- a/src/contrib/mdc_replication/src/java/org/apache/hadoop/hbase/ipc/ReplicationRPC.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright 2010 The Apache Software Foundation - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.hadoop.hbase.ipc; - -/** - * Helper class to add RPC-related configs for replication - */ -public class ReplicationRPC { - - private static final byte RPC_CODE = 110; - - private static boolean initialized = false; - - public synchronized static void initialize() { - if (initialized) { - return; - } - HBaseRPC.addToMap(ReplicationRegionInterface.class, RPC_CODE); - initialized = true; - } - - private ReplicationRPC() { - // Static helper class; - } -} diff --git a/src/contrib/mdc_replication/src/java/org/apache/hadoop/hbase/regionserver/replication/ReplicationRegionServer.java b/src/contrib/mdc_replication/src/java/org/apache/hadoop/hbase/regionserver/replication/ReplicationRegionServer.java index 93fdecf..00ea9d3 100644 --- a/src/contrib/mdc_replication/src/java/org/apache/hadoop/hbase/regionserver/replication/ReplicationRegionServer.java +++ b/src/contrib/mdc_replication/src/java/org/apache/hadoop/hbase/regionserver/replication/ReplicationRegionServer.java @@ -26,7 +26,6 @@ import org.apache.hadoop.fs.Path; 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 @@ import java.util.concurrent.atomic.AtomicBoolean; public class ReplicationRegionServer extends HRegionServer implements ReplicationRegionInterface { - static { - ReplicationRPC.initialize(); - } - protected static final Log LOG = LogFactory.getLog(ReplicationRegionServer.class); diff --git a/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionManager.java b/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionManager.java index 04c5a43..8bf1040 100644 --- a/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionManager.java +++ b/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionManager.java @@ -36,10 +36,6 @@ import org.apache.hadoop.hbase.ipc.TransactionalRegionInterface; * */ public class TransactionManager { - static { - TransactionalRPC.initialize(); - } - static final Log LOG = LogFactory.getLog(TransactionManager.class); private final HConnection connection; diff --git a/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionalRPC.java b/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionalRPC.java deleted file mode 100644 index bb18588..0000000 --- a/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionalRPC.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.apache.hadoop.hbase.client.transactional; - -import org.apache.hadoop.hbase.ipc.HBaseRPC; -import org.apache.hadoop.hbase.ipc.TransactionalRegionInterface; - -/** Simple class for registering the transactional RPC codes. - * - */ -public final class TransactionalRPC { - - private static final byte RPC_CODE = 100; - - private static boolean initialized = false; - - public synchronized static void initialize() { - if (initialized) { - return; - } - HBaseRPC.addToMap(TransactionalRegionInterface.class, RPC_CODE); - initialized = true; - } - - private TransactionalRPC() { - // Static helper class; - } - -} diff --git a/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionalTable.java b/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionalTable.java index 462f7fa..72cc5e8 100644 --- a/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionalTable.java +++ b/src/contrib/transactional/src/java/org/apache/hadoop/hbase/client/transactional/TransactionalTable.java @@ -41,10 +41,6 @@ import org.apache.hadoop.hbase.util.Bytes; */ public class TransactionalTable extends HTable { - static { - TransactionalRPC.initialize(); - } - /** * @param conf * @param tableName diff --git a/src/contrib/transactional/src/java/org/apache/hadoop/hbase/regionserver/transactional/TransactionalRegionServer.java b/src/contrib/transactional/src/java/org/apache/hadoop/hbase/regionserver/transactional/TransactionalRegionServer.java index ff6b678..05dec2d 100644 --- a/src/contrib/transactional/src/java/org/apache/hadoop/hbase/regionserver/transactional/TransactionalRegionServer.java +++ b/src/contrib/transactional/src/java/org/apache/hadoop/hbase/regionserver/transactional/TransactionalRegionServer.java @@ -36,7 +36,6 @@ import org.apache.hadoop.hbase.client.Get; 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 @@ import org.apache.hadoop.util.Progressable; */ 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; diff --git a/src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java b/src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java index b3c297f..d30e884 100644 --- a/src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java +++ b/src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java @@ -85,59 +85,8 @@ public class HBaseRPC { 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 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() { - 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 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 CODE_TO_METHODNAME = - new HashMap(); - private static final Map METHODNAME_TO_CODE = - new HashMap(); - - // End of hbase modifications. - private String methodName; @SuppressWarnings("unchecked") private Class[] parameterClasses; @@ -170,8 +119,7 @@ public class HBaseRPC { 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 class HBaseRPC { } 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 class HBaseRPC { 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 */ diff --git a/src/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java b/src/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java index cb9715a..63d5f5c 100644 --- a/src/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java +++ b/src/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java @@ -54,7 +54,6 @@ public class HBaseRpcMetrics implements Updater { context.registerUpdater(this); - this.initMethods(); rpcStatistics = new HBaseRPCStatistics(this.registry, hostName, port); } @@ -71,16 +70,6 @@ public class HBaseRpcMetrics implements Updater { //public Map metricsList = Collections.synchronizedMap(new HashMap()); - /** - * 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);