You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by la...@apache.org on 2013/11/15 19:29:51 UTC
svn commit: r1542360 -
/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
Author: larsh
Date: Fri Nov 15 18:29:50 2013
New Revision: 1542360
URL: http://svn.apache.org/r1542360
Log:
HBASE-9971 Port part of HBASE-9958 to 0.94 - change lock scope in locateRegion (original patch by Nicolas Liochon)
Modified:
hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=1542360&r1=1542359&r2=1542360&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Fri Nov 15 18:29:50 2013
@@ -73,7 +73,6 @@ import org.apache.hadoop.hbase.ipc.HBase
import org.apache.hadoop.hbase.ipc.HMasterInterface;
import org.apache.hadoop.hbase.ipc.HRegionInterface;
import org.apache.hadoop.hbase.ipc.RpcEngine;
-import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.util.Addressing;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair;
@@ -1104,38 +1103,38 @@ public class HConnectionManager {
getHRegionConnection(metaLocation.getHostname(), metaLocation.getPort());
Result regionInfoRow = null;
- // This block guards against two threads trying to load the meta
- // region at the same time. The first will load the meta region and
- // the second will use the value that the first one found.
- synchronized (regionLockObject) {
- // Check the cache again for a hit in case some other thread made the
- // same query while we were waiting on the lock.
- if (useCache) {
- location = getCachedLocation(tableName, row);
- if (location != null) {
- 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))) {
+ if (useCache) {
+ if (Bytes.equals(parentTable, HConstants.META_TABLE_NAME)
+ && (getRegionCachePrefetch(tableName))) {
+ // This block guards against two threads trying to load the meta
+ // region at the same time. The first will load the meta region and
+ // the second will use the value that the first one found.
+ synchronized (regionLockObject) {
+ // Check the cache again for a hit in case some other thread made the
+ // same query while we were waiting on the lock.
+ location = getCachedLocation(tableName, row);
+ if (location != null) {
+ 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.
prefetchRegionCache(tableName, row);
}
- location = getCachedLocation(tableName, row);
- if (location != null) {
- return location;
- }
- } else {
- // If we are not supposed to be using the cache, delete any existing cached location
- // so it won't interfere.
- deleteCachedLocation(tableName, row);
}
-
- // Query the root or meta region for the location of the meta region
- regionInfoRow = server.getClosestRowBefore(
- metaLocation.getRegionInfo().getRegionName(), metaKey,
- HConstants.CATALOG_FAMILY);
+ location = getCachedLocation(tableName, row);
+ if (location != null) {
+ return location;
+ }
+ } else {
+ // If we are not supposed to be using the cache, delete any existing cached location
+ // so it won't interfere.
+ deleteCachedLocation(tableName, row);
}
+
+ // Query the root or meta region for the location of the meta region
+ regionInfoRow = server.getClosestRowBefore(
+ metaLocation.getRegionInfo().getRegionName(), metaKey,
+ HConstants.CATALOG_FAMILY);
if (regionInfoRow == null) {
throw new TableNotFoundException(Bytes.toString(tableName));
}