HBASE-21859 Add clearRegionLocationCache method for AsyncConnection
Signed-off-by: Guanghao Zhang <zghao@apache.org>
This commit is contained in:
parent
9ef6bc4323
commit
f1e5999ad2
|
@ -52,6 +52,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>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -159,4 +159,9 @@ class AsyncRegionLocator {
|
|||
nonMetaRegionLocator.clearCache(tableName);
|
||||
}
|
||||
}
|
||||
|
||||
void clearCache() {
|
||||
metaRegionLocator.clearCache();
|
||||
nonMetaRegionLocator.clearCache();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue