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

This commit is contained in:
Michael Stack 2018-03-20 22:56:41 -07:00
parent 68008356ae
commit 2bc99e4b5e
3 changed files with 32 additions and 1 deletions

View File

@ -81,6 +81,12 @@ message Get {
// the existence. // the existence.
optional bool existence_only = 10 [default = false]; 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]; optional Consistency consistency = 12 [default = STRONG];
repeated ColumnFamilyTimeRange cf_time_range = 13; repeated ColumnFamilyTimeRange cf_time_range = 13;
optional bool load_column_families_on_demand = 14; /* DO NOT add defaults to load_column_families_on_demand. */ optional bool load_column_families_on_demand = 14; /* DO NOT add defaults to load_column_families_on_demand. */

View File

@ -82,6 +82,11 @@ message Get {
// the existence. // the existence.
optional bool existence_only = 10 [default = false]; 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]; optional Consistency consistency = 12 [default = STRONG];
repeated ColumnFamilyTimeRange cf_time_range = 13; repeated ColumnFamilyTimeRange cf_time_range = 13;
optional bool load_column_families_on_demand = 14; /* DO NOT add defaults to load_column_families_on_demand. */ optional bool load_column_families_on_demand = 14; /* DO NOT add defaults to load_column_families_on_demand. */

View File

@ -85,6 +85,7 @@ import org.apache.hadoop.hbase.conf.ConfigurationObserver;
import org.apache.hadoop.hbase.exceptions.FailedSanityCheckException; import org.apache.hadoop.hbase.exceptions.FailedSanityCheckException;
import org.apache.hadoop.hbase.exceptions.OutOfOrderScannerNextException; import org.apache.hadoop.hbase.exceptions.OutOfOrderScannerNextException;
import org.apache.hadoop.hbase.exceptions.ScannerResetException; 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.filter.ByteArrayComparable;
import org.apache.hadoop.hbase.ipc.HBaseRPCErrorHandler; import org.apache.hadoop.hbase.ipc.HBaseRPCErrorHandler;
import org.apache.hadoop.hbase.ipc.HBaseRpcController; import org.apache.hadoop.hbase.ipc.HBaseRpcController;
@ -816,8 +817,18 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
} }
if (action.hasGet()) { if (action.hasGet()) {
long before = EnvironmentEdgeManager.currentTime(); 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 { try {
Get get = ProtobufUtil.toGet(action.getGet()); Get get = ProtobufUtil.toGet(pbGet);
if (context != null) { if (context != null) {
r = get(get, (region), closeCallBack, context); r = get(get, (region), closeCallBack, context);
} else { } else {
@ -2422,6 +2433,15 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
GetResponse.Builder builder = GetResponse.newBuilder(); GetResponse.Builder builder = GetResponse.newBuilder();
ClientProtos.Get get = request.getGet(); 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; Boolean existence = null;
Result r = null; Result r = null;
RpcCallContext context = RpcServer.getCurrentCall().orElse(null); RpcCallContext context = RpcServer.getCurrentCall().orElse(null);