You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by li...@apache.org on 2014/02/13 20:18:34 UTC

svn commit: r1568010 - /hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerFileSystemFailure.java

Author: liyin
Date: Thu Feb 13 19:18:33 2014
New Revision: 1568010

URL: http://svn.apache.org/r1568010
Log:
[HBASE-10512] Fix a race problem when using HTable in the TestHRegionServerFileSystemFailure

Author: daviddeng

Summary: Since HTable is not thread-safe, Create a HTable instance for each thread.

Test Plan: Run TestHRegionServerFileSystemFailure

Reviewers: liyintang, gauravm, manukranthk

Reviewed By: liyintang

CC: hbase-eng@, fan

Differential Revision: https://phabricator.fb.com/D1170920

Task ID: 3269413

Modified:
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerFileSystemFailure.java

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerFileSystemFailure.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerFileSystemFailure.java?rev=1568010&r1=1568009&r2=1568010&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerFileSystemFailure.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerFileSystemFailure.java Thu Feb 13 19:18:33 2014
@@ -1,5 +1,7 @@
 package org.apache.hadoop.hbase.regionserver;
 
+import static org.junit.Assert.assertFalse;
+
 import java.io.IOException;
 import java.util.List;
 
@@ -8,18 +10,14 @@ import org.apache.commons.logging.LogFac
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
-import org.apache.hadoop.hbase.MiniHBaseCluster;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.master.HMaster;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.HasThread;
 import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
-
-import static org.junit.Assert.*;
-
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.apache.hadoop.hbase.util.HasThread;
 
 public class TestHRegionServerFileSystemFailure {
   private static final Log LOG = LogFactory
@@ -32,7 +30,7 @@ public class TestHRegionServerFileSystem
 
   @BeforeClass
   public static void setUpBeforeClass() throws Exception {
-    conf = new HBaseConfiguration().create();
+    conf = HBaseConfiguration.create();
     conf.setBoolean("ipc.client.ping", true);
     conf.setInt("ipc.ping.interval", 5000);
     TEST_UTIL = new HBaseTestingUtility(conf);
@@ -47,8 +45,8 @@ public class TestHRegionServerFileSystem
   private static class TableLoader extends HasThread {
     private final HTable table;
 
-    public TableLoader(HTable table) {
-      this.table = table;
+    public TableLoader(byte[] tableName) throws IOException {
+      this.table = new HTable(TEST_UTIL.getConfiguration(), tableName);
     }
 
     @Override
@@ -71,10 +69,10 @@ public class TestHRegionServerFileSystem
   public void testHRegionServerFileSystemFailure() throws Exception {
     // Build some data.
     byte[] tableName = Bytes.toBytes("testCloseHRegion");
-    HTable table = TEST_UTIL.createTable(tableName, FAMILIES);
+    TEST_UTIL.createTable(tableName, FAMILIES);
 
     for (int i = 0; i < nLoaders; i++) {
-      new TableLoader(table).start();
+      new TableLoader(tableName).start();
     }
 
     // Wait for loaders to build up some data.