You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2019/02/13 02:31:51 UTC
[hbase] branch master updated: HBASE-21859 Add
clearRegionLocationCache method for AsyncConnection
This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/master by this push:
new f1e5999 HBASE-21859 Add clearRegionLocationCache method for AsyncConnection
f1e5999 is described below
commit f1e5999ad2c3ff9f3fec0b90b9a75de405a520b3
Author: zhangduo <zh...@apache.org>
AuthorDate: Fri Feb 8 15:29:11 2019 +0800
HBASE-21859 Add clearRegionLocationCache method for AsyncConnection
Signed-off-by: Guanghao Zhang <zg...@apache.org>
---
.../java/org/apache/hadoop/hbase/client/AsyncConnection.java | 10 ++++++++++
.../org/apache/hadoop/hbase/client/AsyncConnectionImpl.java | 5 +++++
.../apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java | 4 ++++
.../org/apache/hadoop/hbase/client/AsyncRegionLocator.java | 5 +++++
.../org/apache/hadoop/hbase/client/TestAsyncRegionLocator.java | 6 ++++++
5 files changed, 30 insertions(+)
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnection.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnection.java
index 5640eb3..564d4db 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnection.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnection.java
@@ -53,6 +53,16 @@ public interface AsyncConnection extends Closeable {
AsyncTableRegionLocator getRegionLocator(TableName tableName);
/**
+ * Clear all the entries in the region location cache, for all the tables.
+ * <p/>
+ * If you only want to clear the cache for a specific table, use
+ * {@link AsyncTableRegionLocator#clearRegionLocationCache()}.
+ * <p/>
+ * This may cause performance issue so use it with caution.
+ */
+ void clearRegionLocationCache();
+
+ /**
* Retrieve an {@link AsyncTable} implementation for accessing a table.
* <p>
* The returned instance will use default configs. Use {@link #getTableBuilder(TableName)} if
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java
index 4a32546..07f62a8 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncConnectionImpl.java
@@ -353,4 +353,9 @@ class AsyncConnectionImpl implements AsyncConnection {
return new HBaseHbck(MasterProtos.HbckService.newBlockingStub(
rpcClient.createBlockingRpcChannel(masterServer, user, rpcTimeout)), rpcControllerFactory);
}
+
+ @Override
+ public void clearRegionLocationCache() {
+ locator.clearCache();
+ }
}
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java
index 1a1f32a..5d5c7c3 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncNonMetaRegionLocator.java
@@ -569,6 +569,10 @@ class AsyncNonMetaRegionLocator {
}
}
+ void clearCache() {
+ cache.clear();
+ }
+
// only used for testing whether we have cached the location for a region.
@VisibleForTesting
RegionLocations getRegionLocationInCache(TableName tableName, byte[] row) {
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocator.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocator.java
index cc2a21b..3eb44b7 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocator.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionLocator.java
@@ -159,4 +159,9 @@ class AsyncRegionLocator {
nonMetaRegionLocator.clearCache(tableName);
}
}
+
+ void clearCache() {
+ metaRegionLocator.clearCache();
+ nonMetaRegionLocator.clearCache();
+ }
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionLocator.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionLocator.java
index 0b51ce8..0a94def 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionLocator.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAsyncRegionLocator.java
@@ -49,6 +49,7 @@ import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Threads;
+import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
@@ -109,6 +110,11 @@ public class TestAsyncRegionLocator {
TEST_UTIL.shutdownMiniCluster();
}
+ @After
+ public void tearDownAfterTest() {
+ LOCATOR.clearCache();
+ }
+
@Test
public void testTimeout() throws InterruptedException, ExecutionException {
SLEEP_MS = 1000;