hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r947707 - in /hbase/trunk: CHANGES.txt src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
Date Mon, 24 May 2010 16:36:08 GMT
Author: stack
Date: Mon May 24 16:36:08 2010
New Revision: 947707

URL: http://svn.apache.org/viewvc?rev=947707&view=rev
Log:
HBASE-2589 TestHRegion.testWritesWhileScanning flaky on trunk

Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=947707&r1=947706&r2=947707&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Mon May 24 16:36:08 2010
@@ -353,6 +353,8 @@ Release 0.21.0 - Unreleased
    HBASE-2519  StoreFileScanner.seek swallows IOEs (Todd Lipcon via Stack)
    HBASE-2516  Ugly IOE when region is being closed; rather, should NSRE
                (Daniel Ploeg via Stack)
+   HBASE-2589  TestHRegion.testWritesWhileScanning flaky on trunk
+               (Todd Lipcon via Stack)
 
   IMPROVEMENTS
    HBASE-1760  Cleanup TODOs in HTable

Modified: hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java?rev=947707&r1=947706&r2=947707&view=diff
==============================================================================
--- hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java (original)
+++ hbase/trunk/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java Mon May
24 16:36:08 2010
@@ -2134,9 +2134,11 @@ public class TestHRegion extends HBaseTe
     initHRegion(tableName, method, families);
     PutThread putThread = new PutThread(numRows, families, qualifiers);
     putThread.start();
+    putThread.waitForFirstPut();
+    
     FlushThread flushThread = new FlushThread();
     flushThread.start();
-
+    
     Scan scan = new Scan(Bytes.toBytes("row0"), Bytes.toBytes("row1"));
 //    scan.setFilter(new RowFilter(CompareFilter.CompareOp.EQUAL,
 //      new BinaryComparator(Bytes.toBytes("row0"))));
@@ -2183,6 +2185,8 @@ public class TestHRegion extends HBaseTe
 
   protected class PutThread extends Thread {
     private volatile boolean done;
+    private volatile int numPutsFinished = 0;
+    
     private Throwable error = null;
     private int numRows;
     private byte[][] families;
@@ -2195,6 +2199,17 @@ public class TestHRegion extends HBaseTe
       this.qualifiers = qualifiers;
     }
 
+    /**
+     * Block until this thread has put at least one row.
+     */
+    public void waitForFirstPut() throws InterruptedException {
+      // wait until put thread actually puts some data
+      while (numPutsFinished == 0) {
+        checkNoError();
+        Thread.sleep(50);
+      }
+    }
+
     public void done() {
       done = true;
       synchronized (this) {
@@ -2211,7 +2226,6 @@ public class TestHRegion extends HBaseTe
     @Override
     public void run() {
       done = false;
-      int val = 0;
       while (!done) {
         try {
           for (int r = 0; r < numRows; r++) {
@@ -2219,18 +2233,19 @@ public class TestHRegion extends HBaseTe
             Put put = new Put(row);
             for (byte[] family : families) {
               for (byte[] qualifier : qualifiers) {
-                put.add(family, qualifier, (long) val,
-                    Bytes.toBytes(val));
+                put.add(family, qualifier, (long) numPutsFinished,
+                    Bytes.toBytes(numPutsFinished));
               }
             }
 //            System.out.println("Putting of kvsetsize=" + put.size());
             region.put(put);
-            if (val > 0 && val % 47 == 0) {
-              System.out.println("put iteration = " + val);
-              Delete delete = new Delete(row, (long)val-30, null);
+            numPutsFinished++;
+            if (numPutsFinished > 0 && numPutsFinished % 47 == 0) {
+              System.out.println("put iteration = " + numPutsFinished);
+              Delete delete = new Delete(row, (long)numPutsFinished-30, null);
               region.delete(delete, null, true);
             }
-            val++;
+            numPutsFinished++;
           }
         } catch (IOException e) {
           LOG.error("error while putting records", e);
@@ -2274,6 +2289,8 @@ public class TestHRegion extends HBaseTe
     initHRegion(tableName, method, families);
     PutThread putThread = new PutThread(numRows, families, qualifiers);
     putThread.start();
+    putThread.waitForFirstPut();
+    
     FlushThread flushThread = new FlushThread();
     flushThread.start();
 



Mime
View raw message