Repository: hbase
Updated Branches:
  refs/heads/branch-2.0 70e7e4866 -> e3e7569b0


HBASE-20237 Put back getClosestRowBefore and throw UnsupportedOperation 
instead... for asynchbase client Throw exception if an old client connects.


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/e3e7569b
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/e3e7569b
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/e3e7569b

Branch: refs/heads/branch-2.0
Commit: e3e7569b09fafe5207d975b34a075c2a354d1f6d
Parents: 70e7e48
Author: Michael Stack <st...@apache.org>
Authored: Tue Mar 20 22:56:41 2018 -0700
Committer: Michael Stack <st...@apache.org>
Committed: Wed Mar 21 21:50:56 2018 -0700

----------------------------------------------------------------------
 .../src/main/protobuf/Client.proto              |  6 ++++++
 hbase-protocol/src/main/protobuf/Client.proto   |  5 +++++
 .../hbase/regionserver/RSRpcServices.java       | 22 +++++++++++++++++++-
 3 files changed, 32 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/e3e7569b/hbase-protocol-shaded/src/main/protobuf/Client.proto
----------------------------------------------------------------------
diff --git a/hbase-protocol-shaded/src/main/protobuf/Client.proto 
b/hbase-protocol-shaded/src/main/protobuf/Client.proto
index 642eb61..325b9c1 100644
--- a/hbase-protocol-shaded/src/main/protobuf/Client.proto
+++ b/hbase-protocol-shaded/src/main/protobuf/Client.proto
@@ -81,6 +81,12 @@ message Get {
   // the existence.
   optional bool existence_only = 10 [default = false];
 
+  // If the row to get doesn't exist, return the
+  // closest row before. Deprecated. No longer used!
+  // Since hbase-2.0.0 but left in place so can test
+  // for Gets with this set and throw Exception.
+  optional bool closest_row_before = 11 [default = false];
+
   optional Consistency consistency = 12 [default = STRONG];
   repeated ColumnFamilyTimeRange cf_time_range = 13;
   optional bool load_column_families_on_demand = 14; /* DO NOT add defaults to 
load_column_families_on_demand. */

http://git-wip-us.apache.org/repos/asf/hbase/blob/e3e7569b/hbase-protocol/src/main/protobuf/Client.proto
----------------------------------------------------------------------
diff --git a/hbase-protocol/src/main/protobuf/Client.proto 
b/hbase-protocol/src/main/protobuf/Client.proto
index bc15aec..817c26e 100644
--- a/hbase-protocol/src/main/protobuf/Client.proto
+++ b/hbase-protocol/src/main/protobuf/Client.proto
@@ -82,6 +82,11 @@ message Get {
   // the existence.
   optional bool existence_only = 10 [default = false];
 
+  // If the row to get doesn't exist, return the
+  // closest row before. Deprecated. No longer used!
+  // Since hbase-2.0.0.
+  optional bool closest_row_before = 11 [default = false];
+
   optional Consistency consistency = 12 [default = STRONG];
   repeated ColumnFamilyTimeRange cf_time_range = 13;
   optional bool load_column_families_on_demand = 14; /* DO NOT add defaults to 
load_column_families_on_demand. */

http://git-wip-us.apache.org/repos/asf/hbase/blob/e3e7569b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
index 2e917d1..02d7e98 100644
--- 
a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
+++ 
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
@@ -86,6 +86,7 @@ import org.apache.hadoop.hbase.conf.ConfigurationObserver;
 import org.apache.hadoop.hbase.exceptions.FailedSanityCheckException;
 import org.apache.hadoop.hbase.exceptions.OutOfOrderScannerNextException;
 import org.apache.hadoop.hbase.exceptions.ScannerResetException;
+import org.apache.hadoop.hbase.exceptions.UnknownProtocolException;
 import org.apache.hadoop.hbase.filter.ByteArrayComparable;
 import org.apache.hadoop.hbase.ipc.HBaseRPCErrorHandler;
 import org.apache.hadoop.hbase.ipc.HBaseRpcController;
@@ -814,8 +815,18 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
         }
         if (action.hasGet()) {
           long before = EnvironmentEdgeManager.currentTime();
+          ClientProtos.Get pbGet = action.getGet();
+          // An asynchbase client, https://github.com/OpenTSDB/asynchbase, 
starts by trying to do
+          // a get closest before. Throwing the UnknownProtocolException 
signals it that it needs
+          // to switch and do hbase2 protocol (HBase servers do not tell 
clients what versions
+          // they are; its a problem for non-native clients like asynchbase. 
HBASE-20225.
+          if (pbGet.hasClosestRowBefore() && pbGet.getClosestRowBefore()) {
+            throw new UnknownProtocolException("Is this a pre-hbase-1.0.0 or 
asynchbase client? " +
+                "Client is invoking getClosestRowBefore removed in hbase-2.0.0 
replaced by " +
+                "reverse Scan.");
+          }
           try {
-            Get get = ProtobufUtil.toGet(action.getGet());
+            Get get = ProtobufUtil.toGet(pbGet);
             if (context != null) {
               r = get(get, (region), closeCallBack, context);
             } else {
@@ -2415,6 +2426,15 @@ public class RSRpcServices implements 
HBaseRPCErrorHandler,
 
       GetResponse.Builder builder = GetResponse.newBuilder();
       ClientProtos.Get get = request.getGet();
+      // An asynchbase client, https://github.com/OpenTSDB/asynchbase, starts 
by trying to do
+      // a get closest before. Throwing the UnknownProtocolException signals 
it that it needs
+      // to switch and do hbase2 protocol (HBase servers do not tell clients 
what versions
+      // they are; its a problem for non-native clients like asynchbase. 
HBASE-20225.
+      if (get.hasClosestRowBefore() && get.getClosestRowBefore()) {
+        throw new UnknownProtocolException("Is this a pre-hbase-1.0.0 or 
asynchbase client? " +
+            "Client is invoking getClosestRowBefore removed in hbase-2.0.0 
replaced by " +
+            "reverse Scan.");
+      }
       Boolean existence = null;
       Result r = null;
       RpcCallContext context = RpcServer.getCurrentCall().orElse(null);

Reply via email to