diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java index 1dbb4f5..9122549 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java @@ -1146,7 +1146,7 @@ class ConnectionManager { public RegionLocations locateRegion(final TableName tableName, final byte [] row, boolean useCache, boolean retry, int replicaId) throws IOException { - if (this.closed) throw new IOException(toString() + " closed"); + if (this.closed) throw new IOException(toString() + " to " + tableName + " is closed"); if (tableName== null || tableName.getName().length == 0) { throw new IllegalArgumentException( "table name cannot be null or zero length"); diff --git a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java index 71e88d5..538e32c 100644 --- a/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java +++ b/hbase-thrift/src/test/java/org/apache/hadoop/hbase/thrift/TestThriftServer.java @@ -42,10 +42,12 @@ import org.apache.hadoop.hbase.filter.ParseFilter; import org.apache.hadoop.hbase.security.UserProvider; import org.apache.hadoop.hbase.test.MetricsAssertHelper; import org.apache.hadoop.hbase.thrift.ThriftServerRunner.HBaseHandler; +import org.apache.hadoop.hbase.thrift.generated.AlreadyExists; import org.apache.hadoop.hbase.thrift.generated.BatchMutation; import org.apache.hadoop.hbase.thrift.generated.ColumnDescriptor; import org.apache.hadoop.hbase.thrift.generated.Hbase; import org.apache.hadoop.hbase.thrift.generated.IOError; +import org.apache.hadoop.hbase.thrift.generated.IllegalArgument; import org.apache.hadoop.hbase.thrift.generated.Mutation; import org.apache.hadoop.hbase.thrift.generated.TAppend; import org.apache.hadoop.hbase.thrift.generated.TCell; @@ -95,6 +97,8 @@ public class TestThriftServer { @BeforeClass public static void beforeClass() throws Exception { + UTIL.getConfiguration().setInt(ThriftServerRunner.HBaseHandler.MAX_IDLETIME, 1000); + UTIL.getConfiguration().setInt(ThriftServerRunner.HBaseHandler.CLEANUP_INTERVAL, 1000); UTIL.getConfiguration().setBoolean(ThriftServerRunner.COALESCE_INC_KEY, true); UTIL.getConfiguration().setBoolean("hbase.table.sanity.checks", false); UTIL.startMiniCluster(); @@ -105,6 +109,29 @@ public class TestThriftServer { UTIL.shutdownMiniCluster(); } + @Test + public void testConnectionCache() + throws IOException, IOError, IllegalArgument, AlreadyExists, InterruptedException { + ThriftServerRunner.HBaseHandler handler = + new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration(), + UserProvider.instantiate(UTIL.getConfiguration())); + final ByteBuffer tn = asByteBuffer("tn"); + handler.createTable(tn, getColumnDescriptors()); + List mutations = new ArrayList(1); + mutations.add(new Mutation(false, columnAAname, valueEname, true)); + final int count = 10; + for (int i = 0; i < count; i++) { + try { + handler.mutateRow(tn, rowAname, mutations, null); + LOG.info("Mutate " + i); + } catch (IOError e) { + throw new RuntimeException(e); + } catch (IllegalArgument e) { + throw new RuntimeException(e); + } + } + } + /** * Runs all of the tests under a single JUnit test method. We * consolidate all testing to one method because HBaseClusterTestCase