hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chenh...@apache.org
Subject hbase git commit: HBASE-14897 TestTableLockManager.testReapAllTableLocks is flakey
Date Tue, 01 Dec 2015 02:31:30 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 756e6de2a -> 47082579a


HBASE-14897 TestTableLockManager.testReapAllTableLocks is flakey


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

Branch: refs/heads/master
Commit: 47082579a85fae1b3f7156963609819369b353d8
Parents: 756e6de
Author: chenheng <chenheng@apache.org>
Authored: Tue Dec 1 10:31:00 2015 +0800
Committer: chenheng <chenheng@apache.org>
Committed: Tue Dec 1 10:31:00 2015 +0800

----------------------------------------------------------------------
 .../hbase/master/TestTableLockManager.java      | 30 ++++++++++++++++++--
 1 file changed, 27 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/47082579/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java
index 5152b3e..14e4844 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestTableLockManager.java
@@ -41,6 +41,7 @@ import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.InterProcessLock;
 import org.apache.hadoop.hbase.NotServingRegionException;
 import org.apache.hadoop.hbase.ScheduledChore;
 import org.apache.hadoop.hbase.ServerName;
@@ -129,7 +130,7 @@ public class TestTableLockManager {
 
     HMaster master = TEST_UTIL.getHBaseCluster().getMaster();
     master.getMasterCoprocessorHost().load(TestAlterAndDisableMasterObserver.class,
-        0, TEST_UTIL.getConfiguration());
+            0, TEST_UTIL.getConfiguration());
 
     ExecutorService executor = Executors.newFixedThreadPool(2);
     Future<Object> alterTableFuture = executor.submit(new Callable<Object>()
{
@@ -233,6 +234,23 @@ public class TestTableLockManager {
 
   }
 
+  public class TableLockCounter implements InterProcessLock.MetadataHandler {
+
+    private int lockCount = 0;
+
+    @Override
+    public void handleMetadata(byte[] metadata) {
+      lockCount++;
+    }
+
+    public void reset() {
+      lockCount = 0;
+    }
+
+    public int getLockCount() {
+      return lockCount;
+    }
+  }
 
   @Test(timeout = 600000)
   public void testReapAllTableLocks() throws Exception {
@@ -257,7 +275,7 @@ public class TestTableLockManager {
           public Void call() throws Exception {
             writeLocksAttempted.countDown();
             lockManager.writeLock(TableName.valueOf(table),
-                "testReapAllTableLocks").acquire();
+                    "testReapAllTableLocks").acquire();
             writeLocksObtained.countDown();
             return null;
           }
@@ -268,9 +286,15 @@ public class TestTableLockManager {
     writeLocksObtained.await();
     writeLocksAttempted.await();
 
+    TableLockCounter counter = new TableLockCounter();
+    do {
+      counter.reset();
+      lockManager.visitAllLocks(counter);
+      Thread.sleep(10);
+    } while (counter.getLockCount() != 10);
+
     //now reap all table locks
     lockManager.reapWriteLocks();
-
     TEST_UTIL.getConfiguration().setInt(TableLockManager.TABLE_WRITE_LOCK_TIMEOUT_MS, 0);
     TableLockManager zeroTimeoutLockManager = TableLockManager.createTableLockManager(
           TEST_UTIL.getConfiguration(), TEST_UTIL.getZooKeeperWatcher(), serverName);


Mime
View raw message