From f7154e1ac9e6c0bd2dd3c39078a52d49d3485504 Mon Sep 17 00:00:00 2001 From: stack Date: Tue, 16 Dec 2014 21:09:52 -0800 Subject: [PATCH] HBASE-5162 Basic client pushback mechanism (Jesse Yates); ADDENDUM --- hbase-client/pom.xml | 44 +++++++++++++++---- .../client/RpcRetryingCallerFactory.java | 9 ++-- .../StatsTrackingRpcRetryingCaller.java | 2 +- .../hbase/client/TestClientPushback.java | 12 ++--- 4 files changed, 49 insertions(+), 18 deletions(-) diff --git a/hbase-client/pom.xml b/hbase-client/pom.xml index 5d21ea3204c..a1d9cefcccc 100644 --- a/hbase-client/pom.xml +++ b/hbase-client/pom.xml @@ -108,6 +108,16 @@ org.apache.hbase hbase-common + + + org.apache.hadoop + hadoop-mapreduce-client-core + + + com.google.guava + guava + + org.apache.hbase @@ -135,14 +145,6 @@ commons-logging commons-logging - - com.google.guava - guava - - - com.google.protobuf - protobuf-java - io.netty netty-all @@ -219,14 +221,38 @@ org.apache.hadoop hadoop-common + + com.google.code.findbugs + jsr305 + + + com.github.stephenc.findbugs + findbugs-annotations + + + net.java.dev.jets3t + jets3t + javax.servlet.jsp jsp-api + + org.mortbay.jetty + jetty + com.sun.jersey jersey-server + + com.sun.jersey + jersey-core + + + com.sun.jersey + jersey-json + javax.servlet servlet-api @@ -241,6 +267,7 @@ + diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerFactory.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerFactory.java index 6f2760fcfa1..0af8210f042 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerFactory.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/RpcRetryingCallerFactory.java @@ -90,11 +90,14 @@ public class RpcRetryingCallerFactory { String clazzName = RpcRetryingCallerFactory.class.getName(); String rpcCallerFactoryClazz = configuration.get(RpcRetryingCallerFactory.CUSTOM_CALLER_CONF_KEY, clazzName); + RpcRetryingCallerFactory factory; if (rpcCallerFactoryClazz.equals(clazzName)) { - return new RpcRetryingCallerFactory(configuration, interceptor); + factory = new RpcRetryingCallerFactory(configuration, interceptor); + } else { + factory = ReflectionUtils.instantiateWithCustomCtor( + rpcCallerFactoryClazz, new Class[] { Configuration.class }, + new Object[] { configuration }); } - RpcRetryingCallerFactory factory = ReflectionUtils.instantiateWithCustomCtor( - rpcCallerFactoryClazz, new Class[] { Configuration.class }, new Object[] { configuration }); // setting for backwards compat with existing caller factories, rather than in the ctor factory.setStatisticTracker(stats); diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/StatsTrackingRpcRetryingCaller.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/StatsTrackingRpcRetryingCaller.java index cec0ee59dec..e82f1e8b9f7 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/StatsTrackingRpcRetryingCaller.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/StatsTrackingRpcRetryingCaller.java @@ -64,7 +64,7 @@ public class StatsTrackingRpcRetryingCaller implements RpcRetryingCaller { // mutli-server callables span multiple regions, so they don't have a location, // but they are region server callables, so we have to handle them when we process the - // result, not in here + // result in AsyncProcess#receiveMultiAction, not in here if (callable instanceof MultiServerCallable) { return result; } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientPushback.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientPushback.java index dfb9a7078ea..76914e0be89 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientPushback.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientPushback.java @@ -50,8 +50,7 @@ public class TestClientPushback { conf.setBoolean(HConstants.ENABLE_CLIENT_BACKPRESSURE, true); // turn the memstore size way down so we don't need to write a lot to see changes in memstore // load - conf.setLong(HConstants.HREGION_MEMSTORE_FLUSH_SIZE, - flushSizeBytes); + conf.setLong(HConstants.HREGION_MEMSTORE_FLUSH_SIZE, flushSizeBytes); // ensure we block the flushes when we are double that flushsize conf.setLong("hbase.hregion.memstore.block.multiplier", 2); @@ -65,10 +64,11 @@ public class TestClientPushback { } @Test - public void testClientTrackesServerPushback() throws Exception{ + public void testClientTracksServerPushback() throws Exception{ Configuration conf = UTIL.getConfiguration(); TableName tablename = TableName.valueOf(tableName); - HTable table = new HTable(conf, tablename); + Connection conn = ConnectionFactory.createConnection(conf); + HTable table = (HTable) conn.getTable(tablename); //make sure we flush after each put table.setAutoFlushTo(true); @@ -78,8 +78,8 @@ public class TestClientPushback { table.put(p); // get the stats for the region hosting our table - ClusterConnection conn = ConnectionManager.getConnectionInternal(conf); - ServerStatisticTracker stats = conn.getStatisticsTracker(); + ClusterConnection connection = table.connection; + ServerStatisticTracker stats = connection.getStatisticsTracker(); assertNotNull( "No stats configured for the client!", stats); // get the names so we can query the stats ServerName server = UTIL.getHBaseCluster().getRegionServer(0).getServerName();