Repository: hbase
Updated Branches:
  refs/heads/branch-2 38d9125cc -> 4fad3d96c


HBASE-19554 For debug: Modify HTU.waitUntilAllRegionsAssigned to handle the 
case where we do not have entries for the given table


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

Branch: refs/heads/branch-2
Commit: 4fad3d96c9947b4e392641d8334f1a02c580f1c6
Parents: 38d9125
Author: zhangduo <[email protected]>
Authored: Tue Dec 19 21:21:46 2017 +0800
Committer: Michael Stack <[email protected]>
Committed: Wed Dec 20 10:22:08 2017 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/HBaseTestingUtility.java       | 94 ++++++++++----------
 .../hadoop/hbase/master/AbstractTestDLS.java    |  5 +-
 2 files changed, 48 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/4fad3d96/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
index e03298a..c30245a 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
@@ -3231,7 +3231,7 @@ public class HBaseTestingUtility extends 
HBaseZKTestingUtility {
    * @throws IOException
    */
   public void waitUntilAllRegionsAssigned(final TableName tableName) throws 
IOException {
-    waitUntilAllRegionsAssigned( tableName,
+    waitUntilAllRegionsAssigned(tableName,
       this.conf.getLong("hbase.client.sync.wait.timeout.msec", 60000));
   }
 
@@ -3255,59 +3255,59 @@ public class HBaseTestingUtility extends 
HBaseZKTestingUtility {
    */
   public void waitUntilAllRegionsAssigned(final TableName tableName, final 
long timeout)
       throws IOException {
-    final Table meta = getConnection().getTable(TableName.META_TABLE_NAME);
-    try {
-      LOG.debug("Waiting until all regions of table " + tableName + " get 
assigned. Timeout = " +
-          timeout + "ms");
-      waitFor(timeout, 200, true, new ExplainingPredicate<IOException>() {
-        @Override
-        public String explainFailure() throws IOException {
-          return explainTableAvailability(tableName);
-        }
+    if (!TableName.isMetaTableName(tableName)) {
+      try (final Table meta = 
getConnection().getTable(TableName.META_TABLE_NAME)) {
+        LOG.debug("Waiting until all regions of table " + tableName + " get 
assigned. Timeout = " +
+            timeout + "ms");
+        waitFor(timeout, 200, true, new ExplainingPredicate<IOException>() {
+          @Override
+          public String explainFailure() throws IOException {
+            return explainTableAvailability(tableName);
+          }
 
-        @Override
-        public boolean evaluate() throws IOException {
-          Scan scan = new Scan();
-          scan.addFamily(HConstants.CATALOG_FAMILY);
-          ResultScanner s = meta.getScanner(scan);
-          try {
-            Result r;
-            while ((r = s.next()) != null) {
-              byte[] b = r.getValue(HConstants.CATALOG_FAMILY, 
HConstants.REGIONINFO_QUALIFIER);
-              HRegionInfo info = HRegionInfo.parseFromOrNull(b);
-              if (info != null && info.getTable().equals(tableName)) {
-                // Get server hosting this region from catalog family. Return 
false if no server
-                // hosting this region, or if the server hosting this region 
was recently killed
-                // (for fault tolerance testing).
-                byte[] server =
-                    r.getValue(HConstants.CATALOG_FAMILY, 
HConstants.SERVER_QUALIFIER);
-                if (server == null) {
-                  return false;
-                } else {
-                  byte[] startCode =
-                      r.getValue(HConstants.CATALOG_FAMILY, 
HConstants.STARTCODE_QUALIFIER);
-                  ServerName serverName =
-                      
ServerName.valueOf(Bytes.toString(server).replaceFirst(":", ",") + "," +
-                          Bytes.toLong(startCode));
-                  if (!getHBaseClusterInterface().isDistributedCluster()
-                      && getHBaseCluster().isKilledRS(serverName)) {
+          @Override
+          public boolean evaluate() throws IOException {
+            Scan scan = new Scan();
+            scan.addFamily(HConstants.CATALOG_FAMILY);
+            boolean tableFound = false;
+            try (ResultScanner s = meta.getScanner(scan)) {
+              for (Result r; (r = s.next()) != null;) {
+                byte[] b = r.getValue(HConstants.CATALOG_FAMILY, 
HConstants.REGIONINFO_QUALIFIER);
+                HRegionInfo info = HRegionInfo.parseFromOrNull(b);
+                if (info != null && info.getTable().equals(tableName)) {
+                  // Get server hosting this region from catalog family. 
Return false if no server
+                  // hosting this region, or if the server hosting this region 
was recently killed
+                  // (for fault tolerance testing).
+                  tableFound = true;
+                  byte[] server =
+                      r.getValue(HConstants.CATALOG_FAMILY, 
HConstants.SERVER_QUALIFIER);
+                  if (server == null) {
+                    return false;
+                  } else {
+                    byte[] startCode =
+                        r.getValue(HConstants.CATALOG_FAMILY, 
HConstants.STARTCODE_QUALIFIER);
+                    ServerName serverName =
+                        
ServerName.valueOf(Bytes.toString(server).replaceFirst(":", ",") + "," +
+                            Bytes.toLong(startCode));
+                    if (!getHBaseClusterInterface().isDistributedCluster() &&
+                        getHBaseCluster().isKilledRS(serverName)) {
+                      return false;
+                    }
+                  }
+                  if (RegionStateStore.getRegionState(r,
+                    info.getReplicaId()) != RegionState.State.OPEN) {
                     return false;
                   }
-                }
-                if (RegionStateStore.getRegionState(r, info.getReplicaId())
-                    != RegionState.State.OPEN) {
-                  return false;
                 }
               }
             }
-          } finally {
-            s.close();
+            if (!tableFound) {
+              LOG.warn("Didn't find the entries for table " + tableName + " in 
meta, already deleted?");
+            }
+            return tableFound;
           }
-          return true;
-        }
-      });
-    } finally {
-      meta.close();
+        });
+      }
     }
     LOG.info("All regions for table " + tableName + " assigned to meta. 
Checking AM states.");
     // check from the master state if we are using a mini cluster

http://git-wip-us.apache.org/repos/asf/hbase/blob/4fad3d96/hbase-server/src/test/java/org/apache/hadoop/hbase/master/AbstractTestDLS.java
----------------------------------------------------------------------
diff --git 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/AbstractTestDLS.java
 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/AbstractTestDLS.java
index f8ef1e1..36624e8 100644
--- 
a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/AbstractTestDLS.java
+++ 
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/AbstractTestDLS.java
@@ -89,7 +89,6 @@ import org.junit.After;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TestName;
@@ -274,15 +273,13 @@ public abstract class AbstractTestDLS {
 
       // abort RS
       LOG.info("Aborting region server: " + hrs.getServerName());
-      int countBefore = cluster.getLiveRegionServerThreads().size();
       hrs.abort("testing");
 
       // wait for abort completes
       TEST_UTIL.waitFor(120000, 200, new Waiter.Predicate<Exception>() {
         @Override
         public boolean evaluate() throws Exception {
-          int count = cluster.getLiveRegionServerThreads().size();
-          return count <= (NUM_RS - 1);
+          return cluster.getLiveRegionServerThreads().size() <= NUM_RS - 1;
         }
       });
 

Reply via email to