Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6D7F2782C for ; Sat, 19 Nov 2011 22:11:30 +0000 (UTC) Received: (qmail 44342 invoked by uid 500); 19 Nov 2011 22:11:30 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 44310 invoked by uid 500); 19 Nov 2011 22:11:30 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 44303 invoked by uid 99); 19 Nov 2011 22:11:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Nov 2011 22:11:30 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Nov 2011 22:11:28 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A9CBF2388A02 for ; Sat, 19 Nov 2011 22:11:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1204093 - in /hbase/branches/0.90: CHANGES.txt src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java Date: Sat, 19 Nov 2011 22:11:08 -0000 To: commits@hbase.apache.org From: apurtell@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111119221108.A9CBF2388A02@eris.apache.org> Author: apurtell Date: Sat Nov 19 22:11:08 2011 New Revision: 1204093 URL: http://svn.apache.org/viewvc?rev=1204093&view=rev Log: HBASE-4827 TestAdmin should clean up resources after tests Modified: hbase/branches/0.90/CHANGES.txt hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java Modified: hbase/branches/0.90/CHANGES.txt URL: http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1204093&r1=1204092&r2=1204093&view=diff ============================================================================== --- hbase/branches/0.90/CHANGES.txt (original) +++ hbase/branches/0.90/CHANGES.txt Sat Nov 19 22:11:08 2011 @@ -94,6 +94,7 @@ Release 0.90.5 - Unreleased HBASE-4800 Result.compareResults is incorrect (James Taylor and Lars H) HBASE-4799 Catalog Janitor logic bug causes region leackage (Max Lapan) + HBASE-4827 TestAdmin should clean up resources after tests IMPROVEMENT HBASE-4205 Enhance HTable javadoc (Eric Charles) Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=1204093&r1=1204092&r2=1204093&view=diff ============================================================================== --- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original) +++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Sat Nov 19 22:11:08 2011 @@ -463,6 +463,11 @@ public class HConnectionManager { private final Set regionCachePrefetchDisabledTables = new CopyOnWriteArraySet(); + // region caching is enabled by default. this set contains all tables + // whose region locations should not be cached + private final Set regionCacheDisabledTables = + new CopyOnWriteArraySet(); + private boolean stopProxy; private int refCount; @@ -844,7 +849,9 @@ public class HConnectionManager { HRegionLocation loc = new HRegionLocation(regionInfo, new HServerAddress(serverAddress)); // cache this meta entry - cacheLocation(tableName, loc); + if (shouldCacheRegion(tableName)) { + cacheLocation(tableName, loc); + } } return true; } catch (RuntimeException e) { @@ -973,7 +980,9 @@ public class HConnectionManager { // instantiate the location location = new HRegionLocation(regionInfo, new HServerAddress(serverAddress)); - cacheLocation(tableName, location); + if (shouldCacheRegion(tableName)) { + cacheLocation(tableName, location); + } return location; } catch (TableNotFoundException e) { // if we got this error, probably means the table just plain doesn't @@ -1495,6 +1504,10 @@ public class HConnectionManager { return location != null; } + public boolean getRegionCachePrefetch(final byte[] tableName) { + return !regionCachePrefetchDisabledTables.contains(Bytes.mapKey(tableName)); + } + public void setRegionCachePrefetch(final byte[] tableName, final boolean enable) { if (!enable) { @@ -1505,15 +1518,27 @@ public class HConnectionManager { } } - public boolean getRegionCachePrefetch(final byte[] tableName) { - return !regionCachePrefetchDisabledTables.contains(Bytes.mapKey(tableName)); + public boolean shouldCacheRegion(final byte[] tableName) { + return !regionCacheDisabledTables.contains(Bytes.mapKey(tableName)); + } + + public void setRegionCaching(final byte[] tableName, + final boolean enable) { + if (!enable) { + regionCacheDisabledTables.add(Bytes.mapKey(tableName)); + } + else { + regionCacheDisabledTables.remove(Bytes.mapKey(tableName)); + } } public void prewarmRegionCache(final byte[] tableName, final Map regions) { for (Map.Entry e : regions.entrySet()) { - cacheLocation(tableName, + if (shouldCacheRegion(tableName)) { + cacheLocation(tableName, new HRegionLocation(e.getKey(), e.getValue())); + } } } Modified: hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java?rev=1204093&r1=1204092&r2=1204093&view=diff ============================================================================== --- hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java (original) +++ hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java Sat Nov 19 22:11:08 2011 @@ -54,6 +54,7 @@ import org.apache.hadoop.hbase.master.As import org.apache.hadoop.hbase.master.MasterServices; import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.hadoop.hbase.util.Bytes; +import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; @@ -88,6 +89,11 @@ public class TestAdmin { this.admin = new HBaseAdmin(TEST_UTIL.getConfiguration()); } + @After + public void tearDown() throws Exception { + this.admin.close(); + } + @Test public void testDisableAndEnableTable() throws IOException { final byte [] row = Bytes.toBytes("row");