hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject [48/49] git commit: HBASE-11332 Fix for metas location cache from HBASE-10785
Date Sat, 28 Jun 2014 00:31:34 GMT
HBASE-11332 Fix for metas location cache from HBASE-10785


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/14a09e79
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/14a09e79
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/14a09e79

Branch: refs/heads/master
Commit: 14a09e79bdb9b925ce9548b45fc4e26caadaec07
Parents: 8e40fa0
Author: Enis Soztutar <enis@apache.org>
Authored: Wed Jun 25 00:58:40 2014 -0700
Committer: Enis Soztutar <enis@apache.org>
Committed: Fri Jun 27 16:39:41 2014 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/client/ConnectionManager.java  | 10 ++++----
 .../org/apache/hadoop/hbase/client/TestHCM.java | 24 ++++++++++++++++++++
 2 files changed, 30 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/14a09e79/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
index 92b99b4..2059f91 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionManager.java
@@ -1092,7 +1092,6 @@ class ConnectionManager {
         throw new IllegalArgumentException(
             "table name cannot be null or zero length");
       }
-
       if (tableName.equals(TableName.META_TABLE_NAME)) {
         return locateMeta(tableName, useCache, replicaId);
       } else {
@@ -1119,10 +1118,13 @@ class ConnectionManager {
       synchronized (metaRegionLock) {
         // Check the cache again for a hit in case some other thread made the
         // same query while we were waiting on the lock.
-        locations = getCachedLocation(tableName, metaCacheKey);
-        if (locations != null) {
-          return locations;
+        if (useCache) {
+          locations = getCachedLocation(tableName, metaCacheKey);
+          if (locations != null) {
+            return locations;
+          }
         }
+
         // Look up from zookeeper
         locations = this.registry.getMetaRegionLocation();
         if (locations != null) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/14a09e79/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java
index bc1b5f5..e0f1dfb 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestHCM.java
@@ -356,6 +356,7 @@ public class TestHCM {
 
     final AtomicReference<Throwable> failed = new AtomicReference<Throwable>(null);
     Thread t = new Thread("testConnectionCloseThread") {
+      @Override
       public void run() {
         int done = 0;
         try {
@@ -1263,5 +1264,28 @@ public class TestHCM {
     }
     pool.shutdownNow();
   }
+
+  @Test(timeout = 60000)
+  public void testConnectionRideOverClusterRestart() throws IOException, InterruptedException
{
+    Configuration config = new Configuration(TEST_UTIL.getConfiguration());
+
+    TableName tableName = TableName.valueOf("testConnectionRideOverClusterRestart");
+    TEST_UTIL.createTable(tableName.getName(), new byte[][] {FAM_NAM}, config).close();
+
+    HConnection connection = HConnectionManager.createConnection(config);
+    HTableInterface table = connection.getTable(tableName);
+
+    // this will cache the meta location and table's region location
+    table.get(new Get(Bytes.toBytes("foo")));
+
+    // restart HBase
+    TEST_UTIL.shutdownMiniHBaseCluster();
+    TEST_UTIL.restartHBaseCluster(2);
+    // this should be able to discover new locations for meta and table's region
+    table.get(new Get(Bytes.toBytes("foo")));
+    TEST_UTIL.deleteTable(tableName);
+    table.close();
+    connection.close();
+  }
 }
 


Mime
View raw message