hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject [33/50] hbase git commit: HBASE-15674 HRegionLocator#getAllRegionLocations should put the results in cache
Date Tue, 01 Nov 2016 19:51:27 GMT
HBASE-15674 HRegionLocator#getAllRegionLocations should put the results in cache

Conflicts:
	hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionImplementation.java
	hbase-client/src/main/java/org/apache/hadoop/hbase/client/HRegionLocator.java
	hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/a74c495f
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a74c495f
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a74c495f

Branch: refs/heads/branch-1.0
Commit: a74c495f32ff5446377b2b5d6d4d190ca2f00457
Parents: 52f8ad9
Author: chenheng <chenheng@apache.org>
Authored: Thu Apr 21 14:16:06 2016 +0800
Committer: chenheng <chenheng@apache.org>
Committed: Thu Apr 21 15:00:27 2016 +0800

----------------------------------------------------------------------
 .../hadoop/hbase/client/ClusterConnection.java      |  3 +++
 .../hadoop/hbase/client/ConnectionAdapter.java      |  6 ++++++
 .../hadoop/hbase/client/ConnectionManager.java      |  3 ++-
 .../apache/hadoop/hbase/client/ConnectionUtils.java |  1 +
 .../java/org/apache/hadoop/hbase/client/HTable.java |  3 +++
 .../hadoop/hbase/client/TestFromClientSide.java     | 16 +++++++++++++++-
 6 files changed, 30 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/a74c495f/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClusterConnection.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClusterConnection.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClusterConnection.java
index 9ceb112..40c4462 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClusterConnection.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClusterConnection.java
@@ -83,6 +83,9 @@ public interface ClusterConnection extends HConnection {
   @Override
   void clearRegionCache();
 
+
+  void cacheLocation(final TableName tableName, final RegionLocations location);
+
   /**
    * Allows flushing the region cache of all locations that pertain to
    * <code>tableName</code>

http://git-wip-us.apache.org/repos/asf/hbase/blob/a74c495f/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionAdapter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionAdapter.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionAdapter.java
index d67df2a..fd56692 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionAdapter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionAdapter.java
@@ -238,6 +238,12 @@ abstract class ConnectionAdapter implements ClusterConnection {
     wrappedConnection.clearRegionCache(tableName);
   }
 
+
+  @Override
+  public void cacheLocation(TableName tableName, RegionLocations location) {
+    wrappedConnection.cacheLocation(tableName, location);
+  }
+
   @Override
   public void deleteCachedRegionLocation(HRegionLocation location) {
     wrappedConnection.deleteCachedRegionLocation(location);

http://git-wip-us.apache.org/repos/asf/hbase/blob/a74c495f/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
----------------------------------------------------------------------
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 78fb17f..ede3157 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
@@ -1296,7 +1296,8 @@ class ConnectionManager {
      * @param tableName The table name.
      * @param location the new location
      */
-    private void cacheLocation(final TableName tableName, final RegionLocations location)
{
+    @Override
+    public void cacheLocation(final TableName tableName, final RegionLocations location)
{
       metaCache.cacheLocation(tableName, location);
     }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/a74c495f/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
index b939b17..cd6b0e0 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
@@ -24,6 +24,7 @@ import java.util.concurrent.ExecutorService;
 import org.apache.commons.logging.Log;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.RegionLocations;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.classification.InterfaceAudience;

http://git-wip-us.apache.org/repos/asf/hbase/blob/a74c495f/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java
index 418183e..533cbab 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java
@@ -686,6 +686,9 @@ public class HTable implements HTableInterface, RegionLocator {
     for (Entry<HRegionInfo, ServerName> entry : locations.entrySet()) {
       regions.add(new HRegionLocation(entry.getKey(), entry.getValue()));
     }
+    if (regions.size() > 0) {
+      connection.cacheLocation(tableName, new RegionLocations(regions));
+    }
     return regions;
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/a74c495f/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
index b175c7a..4a0f37b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
@@ -44,7 +44,6 @@ import java.util.concurrent.Callable;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.atomic.AtomicReference;
-
 import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -6132,4 +6131,19 @@ public class TestFromClientSide {
       }
     }
   }
+
+  @Test
+  public void testRegionCache() throws IOException {
+    HTableDescriptor htd = new HTableDescriptor(TableName.valueOf("testRegionCache"));
+    HColumnDescriptor fam = new HColumnDescriptor(FAMILY);
+    htd.addFamily(fam);
+    byte[][] KEYS = HBaseTestingUtility.KEYS_FOR_HBA_CREATE_TABLE;
+    Admin admin = TEST_UTIL.getHBaseAdmin();
+    admin.createTable(htd, KEYS);
+    RegionLocator locator = admin.getConnection().getRegionLocator(htd.getTableName());
+    List<HRegionLocation> results = locator.getAllRegionLocations();
+    int number = ((ConnectionManager.HConnectionImplementation)admin.getConnection())
+      .getNumberOfCachedRegionLocations(htd.getTableName());
+    assertEquals(results.size(), number);
+  }
 }


Mime
View raw message