hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject [1/5] hbase git commit: HBASE-13668 TestFlushRegionEntry is flaky
Date Sat, 16 May 2015 23:46:54 GMT
Repository: hbase
Updated Branches:
  refs/heads/0.98 122f73d99 -> a110c2a33
  refs/heads/branch-1 cb2c8701d -> 046d61962
  refs/heads/branch-1.0 31fb05839 -> 885b8708e
  refs/heads/branch-1.1 0aafae44e -> 135dc6a9d
  refs/heads/master 3fa0bf3cb -> f49111e5f


HBASE-13668 TestFlushRegionEntry is flaky

Conflicts:
	hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFlushRegionEntry.java


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

Branch: refs/heads/0.98
Commit: a110c2a33a956d12b913145477b07293f9bb242e
Parents: 122f73d
Author: Andrew Purtell <apurtell@apache.org>
Authored: Sat May 16 11:20:04 2015 -0700
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Sat May 16 16:22:42 2015 -0700

----------------------------------------------------------------------
 .../hbase/regionserver/MemStoreFlusher.java     | 14 ++++----
 .../regionserver/TestFlushRegionEntry.java      | 37 ++++++++++++--------
 2 files changed, 29 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/a110c2a3/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java
index f971677..7adc8be 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java
@@ -403,7 +403,7 @@ class MemStoreFlusher implements FlushRequester {
     if (!region.getRegionInfo().isMetaRegion() &&
         isTooManyStoreFiles(region)) {
       if (fqe.isMaximumWait(this.blockingWaitTime)) {
-        LOG.info("Waited " + (System.currentTimeMillis() - fqe.createTime) +
+        LOG.info("Waited " + (EnvironmentEdgeManager.currentTimeMillis() - fqe.createTime)
+
           "ms on a compaction to clean up 'too many store files'; waited " +
           "long enough... proceeding with flush of " +
           region.getRegionNameAsString());
@@ -532,7 +532,7 @@ class MemStoreFlusher implements FlushRequester {
       if (Trace.isTracing()) {
         scope.getSpan().addTimelineAnnotation("Force Flush. We're above high water mark.");
       }
-      long start = System.currentTimeMillis();
+      long start = EnvironmentEdgeManager.currentTimeMillis();
       synchronized (this.blockSignal) {
         boolean blocked = false;
         long startTime = 0;
@@ -554,7 +554,7 @@ class MemStoreFlusher implements FlushRequester {
           } catch (InterruptedException ie) {
             Thread.currentThread().interrupt();
           }
-          long took = System.currentTimeMillis() - start;
+          long took = EnvironmentEdgeManager.currentTimeMillis() - start;
           LOG.warn("Memstore is above high water mark and block " + took + "ms");
         }
         if(blocked){
@@ -630,7 +630,7 @@ class MemStoreFlusher implements FlushRequester {
 
     FlushRegionEntry(final HRegion r) {
       this.region = r;
-      this.createTime = System.currentTimeMillis();
+      this.createTime = EnvironmentEdgeManager.currentTimeMillis();
       this.whenToExpire = this.createTime;
     }
 
@@ -639,7 +639,7 @@ class MemStoreFlusher implements FlushRequester {
      * @return True if we have been delayed > <code>maximumWait</code> milliseconds.
      */
     public boolean isMaximumWait(final long maximumWait) {
-      return (System.currentTimeMillis() - this.createTime) > maximumWait;
+      return (EnvironmentEdgeManager.currentTimeMillis() - this.createTime) > maximumWait;
     }
 
     /**
@@ -657,14 +657,14 @@ class MemStoreFlusher implements FlushRequester {
      * @return This.
      */
     public FlushRegionEntry requeue(final long when) {
-      this.whenToExpire = System.currentTimeMillis() + when;
+      this.whenToExpire = EnvironmentEdgeManager.currentTimeMillis() + when;
       this.requeueCount++;
       return this;
     }
 
     @Override
     public long getDelay(TimeUnit unit) {
-      return unit.convert(this.whenToExpire - System.currentTimeMillis(),
+      return unit.convert(this.whenToExpire - EnvironmentEdgeManager.currentTimeMillis(),
           TimeUnit.MILLISECONDS);
     }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/a110c2a3/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFlushRegionEntry.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFlushRegionEntry.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFlushRegionEntry.java
index 470ff60..f94df86 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFlushRegionEntry.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFlushRegionEntry.java
@@ -10,30 +10,41 @@
  */
 package org.apache.hadoop.hbase.regionserver;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.*;
 
-import org.apache.hadoop.hbase.testclassification.SmallTests;
-import org.apache.hadoop.hbase.regionserver.MemStoreFlusher.FlushRegionEntry;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.testclassification.MediumTests;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.hadoop.hbase.util.ManualEnvironmentEdge;
-import org.junit.After;
-import org.junit.Before;
+import org.apache.hadoop.hbase.regionserver.MemStoreFlusher.FlushRegionEntry;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
-import org.mockito.Mockito;
 
-@Category(SmallTests.class)
+@Category(MediumTests.class)
 public class TestFlushRegionEntry {
-  @Before
-  public void setUp() throws Exception {
+
+  @BeforeClass
+  public static void setUp() throws Exception {
     ManualEnvironmentEdge edge = new ManualEnvironmentEdge();
     edge.setValue(12345);
     EnvironmentEdgeManager.injectEdge(edge);
   }
 
+  @AfterClass
+  public static void teardown() {
+    EnvironmentEdgeManager.reset();
+  }
+
   @Test
-  public void test() {
-    HRegion r = Mockito.mock(HRegion.class);
+  public void testFlushRegionEntryEquality() {
+    HRegionInfo hri = new HRegionInfo(TableName.valueOf("TestTable"));
+    HRegion r = mock(HRegion.class);
+    doReturn(hri.getRegionName()).when(r).getRegionName();
+
     FlushRegionEntry entry = new FlushRegionEntry(r);
     FlushRegionEntry other = new FlushRegionEntry(r);
 
@@ -41,8 +52,4 @@ public class TestFlushRegionEntry {
     assertEquals(entry, other);
   }
 
-  @After
-  public void teardown() {
-    EnvironmentEdgeManager.reset();
-  }
 }


Mime
View raw message