hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From syuanji...@apache.org
Subject [41/50] [abbrv] hbase git commit: HBASE-17761: Test TestRemoveRegionMetrics.testMoveRegion fails intermittently because of race condition
Date Fri, 10 Mar 2017 22:10:21 GMT
HBASE-17761: Test TestRemoveRegionMetrics.testMoveRegion fails intermittently because of race
condition

Signed-off-by: Esteban Gutierrez <esteban@apache.org>


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

Branch: refs/heads/hbase-12439
Commit: 2b897484327a0afb1ad56101b43b811c851da403
Parents: 4ff838d
Author: Umesh Agashe <uagashe@cloudera.com>
Authored: Wed Mar 8 13:25:28 2017 -0800
Committer: Esteban Gutierrez <esteban@apache.org>
Committed: Wed Mar 8 21:18:05 2017 -0800

----------------------------------------------------------------------
 .../hadoop/hbase/HBaseTestingUtility.java       | 24 ++++++++++++++++++++
 .../regionserver/TestRemoveRegionMetrics.java   |  5 +---
 .../regionserver/wal/AbstractTestWALReplay.java | 23 ++-----------------
 3 files changed, 27 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/2b897484/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 47170b1..a6c7f68 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
@@ -3298,6 +3298,30 @@ public class HBaseTestingUtility extends HBaseCommonTestingUtility
{
   }
 
   /**
+   * Move region to destination server and wait till region is completely moved and online
+   *
+   * @param destRegion region to move
+   * @param destServer destination server of the region
+   * @throws InterruptedException
+   * @throws IOException
+   */
+  public void moveRegionAndWait(HRegionInfo destRegion, ServerName destServer)
+      throws InterruptedException, IOException {
+    HMaster master = getMiniHBaseCluster().getMaster();
+    getHBaseAdmin().move(destRegion.getEncodedNameAsBytes(),
+        Bytes.toBytes(destServer.getServerName()));
+    while (true) {
+      ServerName serverName = master.getAssignmentManager().getRegionStates()
+          .getRegionServerOfRegion(destRegion);
+      if (serverName != null && serverName.equals(destServer)) {
+        assertRegionOnServer(destRegion, serverName, 200);
+        break;
+      }
+      Thread.sleep(10);
+    }
+  }
+
+  /**
    * Wait until all regions for a table in hbase:meta have a non-empty
    * info:server, up to a configuable timeout value (default is 60 seconds)
    * This means all regions have been deployed,

http://git-wip-us.apache.org/repos/asf/hbase/blob/2b897484/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRemoveRegionMetrics.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRemoveRegionMetrics.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRemoveRegionMetrics.java
index eb7a1a1..85699ef 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRemoveRegionMetrics.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRemoveRegionMetrics.java
@@ -96,7 +96,6 @@ public class TestRemoveRegionMetrics {
       int destServerIdx = (currentServerIdx +1)% cluster.getLiveRegionServerThreads().size();
       HRegionServer currentServer = cluster.getRegionServer(currentServerIdx);
       HRegionServer destServer = cluster.getRegionServer(destServerIdx);
-      byte[] destServerName = Bytes.toBytes(destServer.getServerName().getServerName());
 
 
       // Do a put. The counters should be non-zero now
@@ -119,13 +118,11 @@ public class TestRemoveRegionMetrics {
 
 
       try {
-        admin.move(regionInfo.getEncodedNameAsBytes(), destServerName);
+        TEST_UTIL.moveRegionAndWait(regionInfo, destServer.getServerName());
         moved = true;
-        Thread.sleep(5000);
       } catch (IOException ioe) {
         moved = false;
       }
-      TEST_UTIL.waitUntilAllRegionsAssigned(t.getName());
 
       if (moved) {
         MetricsRegionAggregateSource destAgg = destServer.getRegion(regionInfo.getRegionName())

http://git-wip-us.apache.org/repos/asf/hbase/blob/2b897484/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestWALReplay.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestWALReplay.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestWALReplay.java
index 237d24a..e5e7c83 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestWALReplay.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/AbstractTestWALReplay.java
@@ -218,7 +218,7 @@ public abstract class AbstractTestWALReplay {
     HRegionServer originServer = hbaseCluster.getRegionServer(originServerNum);
     HRegionServer destServer = hbaseCluster.getRegionServer(destServerNum);
     // move region to destination regionserver
-    moveRegionAndWait(destRegion, destServer);
+    TEST_UTIL.moveRegionAndWait(destRegion.getRegionInfo(), destServer.getServerName());
 
     // delete the row
     Delete del = new Delete(Bytes.toBytes("r1"));
@@ -241,7 +241,7 @@ public abstract class AbstractTestWALReplay {
     region.compact(true);
 
     // move region to origin regionserver
-    moveRegionAndWait(destRegion, originServer);
+    TEST_UTIL.moveRegionAndWait(destRegion.getRegionInfo(), originServer.getServerName());
     // abort the origin regionserver
     originServer.abort("testing");
 
@@ -254,25 +254,6 @@ public abstract class AbstractTestWALReplay {
     resultScanner.close();
   }
 
-  private void moveRegionAndWait(Region destRegion, HRegionServer destServer)
-      throws InterruptedException, MasterNotRunningException,
-      ZooKeeperConnectionException, IOException {
-    HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
-    TEST_UTIL.getAdmin().move(
-        destRegion.getRegionInfo().getEncodedNameAsBytes(),
-        Bytes.toBytes(destServer.getServerName().getServerName()));
-    while (true) {
-      ServerName serverName = master.getAssignmentManager()
-        .getRegionStates().getRegionServerOfRegion(destRegion.getRegionInfo());
-      if (serverName != null && serverName.equals(destServer.getServerName())) {
-        TEST_UTIL.assertRegionOnServer(
-          destRegion.getRegionInfo(), serverName, 200);
-        break;
-      }
-      Thread.sleep(10);
-    }
-  }
-
   /**
    * Tests for hbase-2727.
    * @throws Exception


Mime
View raw message