diff --git a/CHANGES.txt b/CHANGES.txt index 479069dc85d..f41af9fc33d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -69,6 +69,9 @@ Release 0.91.0 - Unreleased HBASE-3305 Allow round-robin distribution for table created with multiple regions (ted yu via jgray) HBASE-3496 HFile CLI Improvements + HBASE-3522 Unbundle our RPC versioning; rather than a global for all 4 + Interfaces -- region, master, region to master, and + coprocesssors -- instead version each individually NEW FEATURES diff --git a/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java b/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java index 80b00a73803..1456b71d12a 100644 --- a/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java +++ b/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java @@ -349,7 +349,7 @@ public class HConnectionManager { } HMasterInterface tryMaster = (HMasterInterface)HBaseRPC.getProxy( - HMasterInterface.class, HBaseRPCProtocolVersion.versionID, + HMasterInterface.class, HMasterInterface.VERSION, masterLocation.getInetSocketAddress(), this.conf, this.rpcTimeout); if (tryMaster.isMasterRunning()) { @@ -945,7 +945,7 @@ public class HConnectionManager { if (server == null) { // Get a connection try { server = (HRegionInterface)HBaseRPC.waitForProxy( - serverInterfaceClass, HBaseRPCProtocolVersion.versionID, + serverInterfaceClass, HRegionInterface.VERSION, regionServer.getInetSocketAddress(), this.conf, this.maxRPCAttempts, this.rpcTimeout, this.rpcTimeout); } catch (RemoteException e) { diff --git a/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseEndpointCoprocessor.java b/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseEndpointCoprocessor.java index 34e78e1a9d5..2fc8f393528 100644 --- a/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseEndpointCoprocessor.java +++ b/src/main/java/org/apache/hadoop/hbase/coprocessor/BaseEndpointCoprocessor.java @@ -19,8 +19,7 @@ package org.apache.hadoop.hbase.coprocessor; import java.io.IOException; import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; -import org.apache.hadoop.hbase.ipc.HBaseRPCProtocolVersion; -import org.apache.hadoop.hbase.regionserver.HRegion; +import org.apache.hadoop.ipc.VersionedProtocol; /** * This abstract class provides default implementation of an Endpoint. @@ -33,15 +32,17 @@ import org.apache.hadoop.hbase.regionserver.HRegion; * the region related resource, i.e., CoprocessorEnvironment. */ public abstract class BaseEndpointCoprocessor implements Coprocessor, - CoprocessorProtocol { - private CoprocessorEnvironment env; - + CoprocessorProtocol, VersionedProtocol { /** - * @param e Coprocessor environment. + * This Interfaces' version. Version changes when the Interface changes. */ - private void setEnvironment(CoprocessorEnvironment e) { - env = e; - } + // All HBase Interfaces used derive from HBaseRPCProtocolVersion. It + // maintained a single global version number on all HBase Interfaces. This + // meant all HBase RPC was broke though only one of the three RPC Interfaces + // had changed. This has since been undone. + public static final long VERSION = 28L; + + private CoprocessorEnvironment env; /** * @return env Coprocessor environment. @@ -59,7 +60,8 @@ public abstract class BaseEndpointCoprocessor implements Coprocessor, public void stop(CoprocessorEnvironment env) { } @Override - public long getProtocolVersion(String protocol, long clientVersion) throws IOException { - return HBaseRPCProtocolVersion.versionID; + public long getProtocolVersion(String protocol, long clientVersion) + throws IOException { + return VERSION; } } diff --git a/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java b/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java index 127624aa1d6..882cbc4258b 100644 --- a/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java +++ b/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcMetrics.java @@ -22,6 +22,7 @@ package org.apache.hadoop.hbase.ipc; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.hadoop.ipc.VersionedProtocol; import org.apache.hadoop.metrics.MetricsContext; import org.apache.hadoop.metrics.MetricsRecord; import org.apache.hadoop.metrics.MetricsUtil; @@ -79,7 +80,7 @@ public class HBaseRpcMetrics implements Updater { //public Map metricsList = Collections.synchronizedMap(new HashMap()); - private void initMethods(Class protocol) { + private void initMethods(Class protocol) { for (Method m : protocol.getDeclaredMethods()) { if (get(m.getName()) == null) create(m.getName()); diff --git a/src/main/java/org/apache/hadoop/hbase/ipc/HMasterInterface.java b/src/main/java/org/apache/hadoop/hbase/ipc/HMasterInterface.java index a4f09f364ee..143ce5f9ec5 100644 --- a/src/main/java/org/apache/hadoop/hbase/ipc/HMasterInterface.java +++ b/src/main/java/org/apache/hadoop/hbase/ipc/HMasterInterface.java @@ -25,6 +25,7 @@ import org.apache.hadoop.hbase.ClusterStatus; import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.UnknownRegionException; +import org.apache.hadoop.ipc.VersionedProtocol; /** * Clients interact with the HMasterInterface to gain access to meta-level @@ -35,7 +36,15 @@ import org.apache.hadoop.hbase.UnknownRegionException; * number in HBaseRPCProtocolVersion * */ -public interface HMasterInterface extends HBaseRPCProtocolVersion { +public interface HMasterInterface extends VersionedProtocol { + /** + * This Interfaces' version. Version changes when the Interface changes. + */ + // All HBase Interfaces used derive from HBaseRPCProtocolVersion. It + // maintained a single global version number on all HBase Interfaces. This + // meant all HBase RPC was broke though only one of the three RPC Interfaces + // had changed. This has since been undone. + public static final long VERSION = 28L; /** @return true if master is available */ public boolean isMasterRunning(); diff --git a/src/main/java/org/apache/hadoop/hbase/ipc/HMasterRegionInterface.java b/src/main/java/org/apache/hadoop/hbase/ipc/HMasterRegionInterface.java index 660c475aa4f..25139b300a1 100644 --- a/src/main/java/org/apache/hadoop/hbase/ipc/HMasterRegionInterface.java +++ b/src/main/java/org/apache/hadoop/hbase/ipc/HMasterRegionInterface.java @@ -23,6 +23,7 @@ import org.apache.hadoop.hbase.HMsg; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HServerInfo; import org.apache.hadoop.io.MapWritable; +import org.apache.hadoop.ipc.VersionedProtocol; import java.io.IOException; @@ -35,7 +36,15 @@ import java.io.IOException; * number in HBaseRPCProtocolVersion * */ -public interface HMasterRegionInterface extends HBaseRPCProtocolVersion { +public interface HMasterRegionInterface extends VersionedProtocol { + /** + * This Interfaces' version. Version changes when the Interface changes. + */ + // All HBase Interfaces used derive from HBaseRPCProtocolVersion. It + // maintained a single global version number on all HBase Interfaces. This + // meant all HBase RPC was broke though only one of the three RPC Interfaces + // had changed. This has since been undone. + public static final long VERSION = 28L; /** * Called when a region server first starts diff --git a/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java b/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java index b98bc71bf91..be8abc1be90 100644 --- a/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java +++ b/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java @@ -22,7 +22,6 @@ package org.apache.hadoop.hbase.ipc; import java.io.IOException; import java.net.ConnectException; import java.util.List; -import java.util.NavigableSet; import org.apache.hadoop.hbase.Abortable; import org.apache.hadoop.hbase.HRegionInfo; @@ -30,8 +29,6 @@ import org.apache.hadoop.hbase.HServerInfo; import org.apache.hadoop.hbase.NotServingRegionException; import org.apache.hadoop.hbase.Stoppable; import org.apache.hadoop.hbase.client.Delete; -import org.apache.hadoop.hbase.client.coprocessor.Exec; -import org.apache.hadoop.hbase.client.coprocessor.ExecResult; import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.Increment; import org.apache.hadoop.hbase.client.MultiAction; @@ -41,8 +38,11 @@ import org.apache.hadoop.hbase.client.MultiResponse; 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.coprocessor.Exec; +import org.apache.hadoop.hbase.client.coprocessor.ExecResult; import org.apache.hadoop.hbase.regionserver.wal.HLog; import org.apache.hadoop.ipc.RemoteException; +import org.apache.hadoop.ipc.VersionedProtocol; /** * Clients interact with HRegionServers using a handle to the HRegionInterface. @@ -50,7 +50,16 @@ import org.apache.hadoop.ipc.RemoteException; *

NOTE: if you change the interface, you must change the RPC version * number in HBaseRPCProtocolVersion */ -public interface HRegionInterface extends HBaseRPCProtocolVersion, Stoppable, Abortable { +public interface HRegionInterface extends VersionedProtocol, Stoppable, Abortable { + /** + * This Interfaces' version. Version changes when the Interface changes. + */ + // All HBase Interfaces used derive from HBaseRPCProtocolVersion. It + // maintained a single global version number on all HBase Interfaces. This + // meant all HBase RPC was broke though only one of the three RPC Interfaces + // had changed. This has since been undone. + public static final long VERSION = 28L; + /** * Get metainfo about an HRegion * diff --git a/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/src/main/java/org/apache/hadoop/hbase/master/HMaster.java index e936f35ba7b..3f3b696cdc6 100644 --- a/src/main/java/org/apache/hadoop/hbase/master/HMaster.java +++ b/src/main/java/org/apache/hadoop/hbase/master/HMaster.java @@ -60,7 +60,6 @@ import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitor; import org.apache.hadoop.hbase.executor.ExecutorService; import org.apache.hadoop.hbase.executor.ExecutorService.ExecutorType; import org.apache.hadoop.hbase.ipc.HBaseRPC; -import org.apache.hadoop.hbase.ipc.HBaseRPCProtocolVersion; import org.apache.hadoop.hbase.ipc.HBaseServer; import org.apache.hadoop.hbase.ipc.HMasterInterface; import org.apache.hadoop.hbase.ipc.HMasterRegionInterface; @@ -472,7 +471,7 @@ implements HMasterInterface, HMasterRegionInterface, MasterServices, Server { } public long getProtocolVersion(String protocol, long clientVersion) { - return HBaseRPCProtocolVersion.versionID; + return HMasterInterface.VERSION; } /** @return InfoServer object. Maybe null.*/ diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index 2350f9f2f9f..b3f47d48a9c 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -101,7 +101,6 @@ import org.apache.hadoop.hbase.io.hfile.LruBlockCache.CacheStats; import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; import org.apache.hadoop.hbase.ipc.HBaseRPC; import org.apache.hadoop.hbase.ipc.HBaseRPCErrorHandler; -import org.apache.hadoop.hbase.ipc.HBaseRPCProtocolVersion; import org.apache.hadoop.hbase.ipc.HBaseRpcMetrics; import org.apache.hadoop.hbase.ipc.HMasterRegionInterface; import org.apache.hadoop.hbase.ipc.HRegionInterface; @@ -1447,7 +1446,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, // Do initial RPC setup. The final argument indicates that the RPC // should retry indefinitely. master = (HMasterRegionInterface) HBaseRPC.waitForProxy( - HMasterRegionInterface.class, HBaseRPCProtocolVersion.versionID, + HMasterRegionInterface.class, HMasterRegionInterface.VERSION, masterAddress.getInetSocketAddress(), this.conf, -1, this.rpcTimeout, this.rpcTimeout); } catch (IOException e) { @@ -2452,7 +2451,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, public long getProtocolVersion(final String protocol, final long clientVersion) throws IOException { if (protocol.equals(HRegionInterface.class.getName())) { - return HBaseRPCProtocolVersion.versionID; + return HRegionInterface.VERSION; } throw new IOException("Unknown protocol to name node: " + protocol); } diff --git a/src/test/java/org/apache/hadoop/hbase/master/TestHMasterRPCException.java b/src/test/java/org/apache/hadoop/hbase/master/TestHMasterRPCException.java index 388d4078684..a1bb6af1943 100644 --- a/src/test/java/org/apache/hadoop/hbase/master/TestHMasterRPCException.java +++ b/src/test/java/org/apache/hadoop/hbase/master/TestHMasterRPCException.java @@ -28,7 +28,6 @@ import org.apache.hadoop.hbase.HBaseTestingUtility; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HServerAddress; import org.apache.hadoop.hbase.ipc.HBaseRPC; -import org.apache.hadoop.hbase.ipc.HBaseRPCProtocolVersion; import org.apache.hadoop.hbase.ipc.HMasterInterface; import org.apache.hadoop.ipc.RemoteException; import org.junit.Test; @@ -48,7 +47,7 @@ public class TestHMasterRPCException { try { HMasterInterface inf = (HMasterInterface) HBaseRPC.getProxy( - HMasterInterface.class, HBaseRPCProtocolVersion.versionID, + HMasterInterface.class, HMasterInterface.VERSION, hma.getInetSocketAddress(), conf, 100); inf.isMasterRunning(); fail(); diff --git a/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java b/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java index 93245a6f9c4..3f430a6ff48 100644 --- a/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java +++ b/src/test/java/org/apache/hadoop/hbase/regionserver/TestServerCustomProtocol.java @@ -19,22 +19,35 @@ */ package org.apache.hadoop.hbase.regionserver; -import com.google.common.collect.Lists; -import org.apache.hadoop.hbase.*; -import org.apache.hadoop.hbase.client.*; -import org.apache.hadoop.hbase.client.coprocessor.Batch; -import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; -import org.apache.hadoop.hbase.ipc.HBaseRPCProtocolVersion; -import org.apache.hadoop.hbase.util.Bytes; -import org.apache.hadoop.hbase.util.JVMClusterUtil; -import org.junit.*; - -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.List; import java.util.Map; +import org.apache.hadoop.hbase.HBaseTestingUtility; +import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.HRegionInfo; +import org.apache.hadoop.hbase.HRegionLocation; +import org.apache.hadoop.hbase.MiniHBaseCluster; +import org.apache.hadoop.hbase.client.Get; +import org.apache.hadoop.hbase.client.HTable; +import org.apache.hadoop.hbase.client.Put; +import org.apache.hadoop.hbase.client.Row; +import org.apache.hadoop.hbase.client.coprocessor.Batch; +import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; +import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.hbase.util.JVMClusterUtil; +import org.apache.hadoop.ipc.VersionedProtocol; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +import com.google.common.collect.Lists; + public class TestServerCustomProtocol { /* Test protocol */ private static interface PingProtocol extends CoprocessorProtocol { @@ -45,8 +58,9 @@ public class TestServerCustomProtocol { } /* Test protocol implementation */ - private static class PingHandler implements PingProtocol, - HBaseRPCProtocolVersion { + private static class PingHandler implements PingProtocol, VersionedProtocol { + static int VERSION = 1; + private int counter = 0; @Override public String ping() { @@ -72,7 +86,7 @@ public class TestServerCustomProtocol { @Override public long getProtocolVersion(String s, long l) throws IOException { - return versionID; + return VERSION; } }