hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
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 GMT
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<Integer> regionCachePrefetchDisabledTables =
       new CopyOnWriteArraySet<Integer>();
 
+    // region caching is enabled by default. this set contains all tables
+    // whose region locations should not be cached
+    private final Set<Integer> regionCacheDisabledTables =
+      new CopyOnWriteArraySet<Integer>();
+
     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<HRegionInfo, HServerAddress> regions) {
       for (Map.Entry<HRegionInfo, HServerAddress> 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");



Mime
View raw message