HBASE-8346 Prefetching .META. rows in case only when useCache is set to true (Himanshu)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1478585 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2013-05-02 21:56:09 +00:00
parent 1a516ff5b7
commit bdd511c7c1
1 changed files with 13 additions and 11 deletions

View File

@ -1149,26 +1149,28 @@ public class HConnectionManager {
// region at the same time. The first will load the meta region and // region at the same time. The first will load the meta region and
// the second will use the value that the first one found. // the second will use the value that the first one found.
synchronized (regionLockObject) { synchronized (regionLockObject) {
// If the parent table is META, we may want to pre-fetch some
// region info into the global region cache for this table.
if (Bytes.equals(parentTable, HConstants.META_TABLE_NAME) &&
(getRegionCachePrefetch(tableName)) ) {
prefetchRegionCache(tableName, row);
}
// Check the cache again for a hit in case some other thread made the // Check the cache again for a hit in case some other thread made the
// same query while we were waiting on the lock. If not supposed to // same query while we were waiting on the lock.
// be using the cache, delete any existing cached location so it won't
// interfere.
if (useCache) { if (useCache) {
location = getCachedLocation(tableName, row); location = getCachedLocation(tableName, row);
if (location != null) { if (location != null) {
return location; return location;
} }
// If the parent table is META, we may want to pre-fetch some
// region info into the global region cache for this table.
if (Bytes.equals(parentTable, HConstants.META_TABLE_NAME)
&& (getRegionCachePrefetch(tableName))) {
prefetchRegionCache(tableName, row);
}
location = getCachedLocation(tableName, row);
if (location != null) {
return location;
}
} else { } else {
// If we are not supposed to be using the cache, delete any existing cached location
// so it won't interfere.
forceDeleteCachedLocation(tableName, row); forceDeleteCachedLocation(tableName, row);
} }
// Query the meta region for the location of the meta region // Query the meta region for the location of the meta region
regionInfoRow = ProtobufUtil.getRowOrBefore(server, regionInfoRow = ProtobufUtil.getRowOrBefore(server,
metaLocation.getRegionInfo().getRegionName(), metaKey, metaLocation.getRegionInfo().getRegionName(), metaKey,