hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject git commit: HBASE-11942 Fix TestHRegionBusyWait
Date Thu, 11 Sep 2014 02:56:04 GMT
Repository: hbase
Updated Branches:
  refs/heads/0.98 b8851309e -> 79ff36339


HBASE-11942 Fix TestHRegionBusyWait


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

Branch: refs/heads/0.98
Commit: 79ff36339de01e580d793cd65eff126b5a176d55
Parents: b885130
Author: Enis Soztutar <enis@apache.org>
Authored: Wed Sep 10 19:48:14 2014 -0700
Committer: Enis Soztutar <enis@apache.org>
Committed: Wed Sep 10 19:55:41 2014 -0700

----------------------------------------------------------------------
 .../hadoop/hbase/regionserver/TestHRegion.java  | 54 +++++++++++
 .../hbase/regionserver/TestHRegionBusyWait.java | 96 --------------------
 2 files changed, 54 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/79ff3633/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
index 08cc39f..214df2f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
@@ -75,6 +75,7 @@ import org.apache.hadoop.hbase.HBaseTestCase;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.RegionTooBusyException;
 import org.apache.hadoop.hbase.HConstants.OperationStatusCode;
 import org.apache.hadoop.hbase.HDFSBlocksDistribution;
 import org.apache.hadoop.hbase.HRegionInfo;
@@ -5020,6 +5021,59 @@ public class TestHRegion {
     this.region = null;
   }
 
+  /**
+   * Test RegionTooBusyException thrown when region is busy
+   */
+  @Test (timeout=24000)
+  public void testRegionTooBusy() throws IOException {
+    String method = "testRegionTooBusy";
+    byte[] tableName = Bytes.toBytes(method);
+    byte[] family = Bytes.toBytes("family");
+    long defaultBusyWaitDuration = CONF.getLong("hbase.busy.wait.duration",
+      HRegion.DEFAULT_BUSY_WAIT_DURATION);
+    CONF.setLong("hbase.busy.wait.duration", 1000);
+    region = initHRegion(tableName, method, CONF, family);
+    final AtomicBoolean stopped = new AtomicBoolean(true);
+    Thread t = new Thread(new Runnable() {
+      @Override
+      public void run() {
+        try {
+          region.lock.writeLock().lock();
+          stopped.set(false);
+          while (!stopped.get()) {
+            Thread.sleep(100);
+          }
+        } catch (InterruptedException ie) {
+        } finally {
+          region.lock.writeLock().unlock();
+        }
+      }
+    });
+    t.start();
+    Get get = new Get(row);
+    try {
+      while (stopped.get()) {
+        Thread.sleep(100);
+      }
+      region.get(get);
+      fail("Should throw RegionTooBusyException");
+    } catch (InterruptedException ie) {
+      fail("test interrupted");
+    } catch (RegionTooBusyException e) {
+      // Good, expected
+    } finally {
+      stopped.set(true);
+      try {
+        t.join();
+      } catch (Throwable e) {
+      }
+
+      HRegion.closeHRegion(region);
+      region = null;
+      CONF.setLong("hbase.busy.wait.duration", defaultBusyWaitDuration);
+    }
+  }
+
   private static HRegion initHRegion(byte[] tableName, String callingMethod,
       byte[]... families) throws IOException {
     return initHRegion(tableName, callingMethod, HBaseConfiguration.create(),

http://git-wip-us.apache.org/repos/asf/hbase/blob/79ff3633/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionBusyWait.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionBusyWait.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionBusyWait.java
deleted file mode 100644
index d641bdb..0000000
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionBusyWait.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.hbase.regionserver;
-
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.apache.hadoop.hbase.MediumTests;
-import org.apache.hadoop.hbase.RegionTooBusyException;
-import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-/**
- * TestHRegion with hbase.busy.wait.duration set to 1000 (1 second).
- * We can't use parameterized test since TestHRegion is old fashion.
- */
-@Category(MediumTests.class)
-public class TestHRegionBusyWait extends TestHRegion {
-  // TODO: This subclass runs all the tests in TestHRegion as well as the test below which
means
-  // all TestHRegion tests are run twice.
-  @Before
-  public void setup() throws IOException {
-    super.setup();
-    CONF.set("hbase.busy.wait.duration", "1000");
-  }
-
-  /**
-   * Test RegionTooBusyException thrown when region is busy
-   */
-  @Test (timeout=6000)
-  public void testRegionTooBusy() throws IOException {
-    String method = "testRegionTooBusy";
-    byte[] tableName = Bytes.toBytes(method);
-    byte[] family = Bytes.toBytes("family");
-    region = initHRegion(tableName, method, CONF, family);
-    final AtomicBoolean stopped = new AtomicBoolean(true);
-    Thread t = new Thread(new Runnable() {
-      @Override
-      public void run() {
-        try {
-          region.lock.writeLock().lock();
-          stopped.set(false);
-          while (!stopped.get()) {
-            Thread.sleep(100);
-          }
-        } catch (InterruptedException ie) {
-        } finally {
-          region.lock.writeLock().unlock();
-        }
-      }
-    });
-    t.start();
-    Get get = new Get(row);
-    try {
-      while (stopped.get()) {
-        Thread.sleep(100);
-      }
-      region.get(get);
-      fail("Should throw RegionTooBusyException");
-    } catch (InterruptedException ie) {
-      fail("test interrupted");
-    } catch (RegionTooBusyException e) {
-      // Good, expected
-    } finally {
-      stopped.set(true);
-      try {
-        t.join();
-      } catch (Throwable e) {
-      }
-
-      HRegion.closeHRegion(region);
-      region = null;
-    }
-  }
-}
\ No newline at end of file


Mime
View raw message