hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1437851 - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/client/HConnectionManager.java test/java/org/apache/hadoop/hbase/client/TestHCM.java
Date Thu, 24 Jan 2013 03:19:29 GMT
Author: tedyu
Date: Thu Jan 24 03:19:29 2013
New Revision: 1437851

URL: http://svn.apache.org/viewvc?rev=1437851&view=rev
Log:
HBASE-7268 correct local region location cache information can be overwritten (or deleted)
w/stale information from an old server, Addendum (Sergey)


Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=1437851&r1=1437850&r2=1437851&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
Thu Jan 24 03:19:29 2013
@@ -1085,7 +1085,7 @@ public class HConnectionManager {
                 return location;
               }
             } else {
-              deleteCachedLocation(tableName, row);
+              forceDeleteCachedLocation(tableName, row);
             }
 
             // Query the root or meta region for the location of the meta region
@@ -1221,11 +1221,11 @@ public class HConnectionManager {
     }
 
     /**
-     * Delete a cached location
+     * Delete a cached location, no matter what it is. Called when we were told to not use
cache.
      * @param tableName tableName
      * @param row
      */
-    void deleteCachedLocation(final byte [] tableName, final byte [] row) {
+    void forceDeleteCachedLocation(final byte [] tableName, final byte [] row) {
       HRegionLocation rl = null;
       synchronized (this.cachedRegionLocations) {
         Map<byte[], HRegionLocation> tableLocations =
@@ -1243,7 +1243,7 @@ public class HConnectionManager {
         LOG.debug("Removed " + rl.getHostname() + ":" + rl.getPort()
           + " as a location of " + rl.getRegionInfo().getRegionNameAsString() +
           " for tableName=" + Bytes.toString(tableName) +
-          " from cache because of " + Bytes.toStringBinary(row));
+          " from cache to make sure we don't use cache for " + Bytes.toStringBinary(row));
       }
     }
 
@@ -1772,6 +1772,11 @@ public class HConnectionManager {
       }
     }
 
+   /**
+    * Deletes the cached location of the region if necessary, based on some error from source.
+    * @param hri The region in question.
+    * @param source The source of the error that prompts us to invalidate cache.
+    */
     void deleteCachedLocation(HRegionInfo hri, HRegionLocation source) {
       boolean isStaleDelete = false;
       HRegionLocation oldLocation = null;
@@ -1779,10 +1784,12 @@ public class HConnectionManager {
         Map<byte[], HRegionLocation> tableLocations =
           getTableLocations(hri.getTableName());
         oldLocation = tableLocations.get(hri.getStartKey());
-         // Do not delete the cache entry if it's not for the same server that gave us the
error.
-        isStaleDelete = (source != null) && !oldLocation.equals(source);
-        if (!isStaleDelete) {
-          tableLocations.remove(hri.getStartKey());
+        if (oldLocation != null) {
+           // Do not delete the cache entry if it's not for the same server that gave us
the error.
+          isStaleDelete = (source != null) && !oldLocation.equals(source);
+          if (!isStaleDelete) {
+            tableLocations.remove(hri.getStartKey());
+          }
         }
       }
       if (isStaleDelete) {

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java?rev=1437851&r1=1437850&r2=1437851&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java Thu
Jan 24 03:19:29 2013
@@ -155,7 +155,7 @@ public class TestHCM {
       HConstants.LATEST_TIMESTAMP);
     Assert.assertEquals(conn.getCachedLocation(TABLE_NAME, ROW).getPort(), nextPort);
 
-    conn.deleteCachedLocation(TABLE_NAME.clone(), ROW.clone());
+    conn.forceDeleteCachedLocation(TABLE_NAME.clone(), ROW.clone());
     HRegionLocation rl = conn.getCachedLocation(TABLE_NAME, ROW);
     assertNull("What is this location?? " + rl, rl);
 



Mime
View raw message