diff --git a/CHANGES.txt b/CHANGES.txt
index 7d6c1369d11..4ad38e625a0 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -274,6 +274,8 @@ Release 0.20.0 - Unreleased
HBASE-1058 Disable 1058 on catalog tables
HBASE-1583 Start/Stop of large cluster untenable
HBASE-1668 hbase-1609 broke TestHRegion.testScanSplitOnRegion unit test
+ HBASE-1669 need dynamic extensibility of HBaseRPC code maps and interface
+ lists (Clint Morgan via Stack)
IMPROVEMENTS
HBASE-1089 Add count of regions on filesystem to master UI; add percentage
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 842016cebfa..8dc23ae59f9 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
@@ -32,6 +32,7 @@ import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.ScannerCallable;
import org.apache.hadoop.hbase.client.ServerCallable;
+import org.apache.hadoop.hbase.ipc.HBaseRPC;
import org.apache.hadoop.hbase.ipc.TransactionalRegionInterface;
import org.apache.hadoop.hbase.util.Bytes;
@@ -41,6 +42,11 @@ import org.apache.hadoop.hbase.util.Bytes;
*/
public class TransactionalTable extends HTable {
+ private static final byte RPC_CODE = 100;
+ static {
+ HBaseRPC.addToMap(TransactionalRegionInterface.class, RPC_CODE);
+ }
+
/**
* @param conf
* @param tableName
diff --git a/src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java b/src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java
index d2872c25df8..983748cbc9c 100644
--- a/src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java
+++ b/src/java/org/apache/hadoop/hbase/ipc/HBaseRPC.java
@@ -84,24 +84,53 @@ 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 {
+ 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.
- private static final Map CODE_TO_METHODNAME =
+ static final Map CODE_TO_METHODNAME =
new HashMap();
private static final Map METHODNAME_TO_CODE =
new HashMap();
- // Special code that means 'not-encoded'.
- private static final byte NOT_ENCODED = 0;
- static {
- byte code = NOT_ENCODED + 1;
- code = addToMap(VersionedProtocol.class, code);
- code = addToMap(HMasterInterface.class, code);
- code = addToMap(HMasterRegionInterface.class, code);
- code = addToMap(HRegionInterface.class, code);
- }
+
// End of hbase modifications.
private String methodName;
@@ -180,7 +209,7 @@ public class HBaseRPC {
}
// Hbase additions.
- private static void addToMap(final String name, final byte code) {
+ static void addToMap(final String name, final byte code) {
if (METHODNAME_TO_CODE.containsKey(name)) {
return;
}
@@ -188,28 +217,6 @@ public class HBaseRPC {
CODE_TO_METHODNAME.put(Byte.valueOf(code), name);
}
- /*
- * @param c Class whose methods we'll add to the map of methods to codes
- * (and vice versa).
- * @param code Current state of the byte code.
- * @return State of code
when this method is done.
- */
- private static byte addToMap(final Class> c, final byte code) {
- byte localCode = code;
- 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++) {
- addToMap(methods[i].getName(), localCode++);
- }
- return localCode;
- }
/*
* Write out the code byte for passed Class.