hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1388620 - /hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMultiSlaveReplication.java
Date Fri, 21 Sep 2012 19:00:36 GMT
Author: stack
Date: Fri Sep 21 19:00:35 2012
New Revision: 1388620

URL: http://svn.apache.org/viewvc?rev=1388620&view=rev
Log:
HBASE-6714 TestMultiSlaveReplication#testMultiSlaveReplication may fail

Modified:
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMultiSlaveReplication.java

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMultiSlaveReplication.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMultiSlaveReplication.java?rev=1388620&r1=1388619&r2=1388620&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMultiSlaveReplication.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestMultiSlaveReplication.java
Fri Sep 21 19:00:35 2012
@@ -173,7 +173,10 @@ public class TestMultiSlaveReplication {
     deleteAndWait(row2, htable1, htable2, htable3);
     // Even if the log was rolled in the middle of the replication
     // "row" is still replication.
-    checkRow(row, 1, htable2, htable3);
+    checkRow(row, 1, htable2);
+    // Replication thread of cluster 2 may be sleeping, and since row2 is not there in it,

+    // we should wait before checking.
+    checkWithWait(row, 1, htable3);
 
     // cleanup the rest
     deleteAndWait(row, htable1, htable2, htable3);
@@ -183,7 +186,29 @@ public class TestMultiSlaveReplication {
     utility2.shutdownMiniCluster();
     utility1.shutdownMiniCluster();
   }
-
+ 
+  private void checkWithWait(byte[] row, int count, HTable table) throws Exception {
+    Get get = new Get(row);
+    for (int i = 0; i < NB_RETRIES; i++) {
+      if (i == NB_RETRIES - 1) {
+        fail("Waited too much time while getting the row.");
+      }
+      boolean rowReplicated = false;
+      Result res = table.get(get);
+      if (res.size() >= 1) {
+        LOG.info("Row is replicated");
+        rowReplicated = true;
+        assertEquals(count, res.size());
+        break;
+      }
+      if (rowReplicated) {
+        break;
+      } else {
+        Thread.sleep(SLEEP_TIME);
+      }
+    }
+  }
+  
   private void checkRow(byte[] row, int count, HTable... tables) throws IOException {
     Get get = new Get(row);
     for (HTable table : tables) {



Mime
View raw message