hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r677011 - /hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestBloomFilters.java
Date Tue, 15 Jul 2008 19:07:57 GMT
Author: jimk
Date: Tue Jul 15 12:07:57 2008
New Revision: 677011

URL: http://svn.apache.org/viewvc?rev=677011&view=rev
Log:
HBASE-744 BloomFilter serialization/deserialization broken

Added:
    hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestBloomFilters.java
      - copied, changed from r676725, hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestBloomFilters.java

Copied: hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestBloomFilters.java
(from r676725, hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestBloomFilters.java)
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestBloomFilters.java?p2=hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestBloomFilters.java&p1=hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestBloomFilters.java&r1=676725&r2=677011&rev=677011&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/TestBloomFilters.java (original)
+++ hadoop/hbase/trunk/src/test/org/apache/hadoop/hbase/regionserver/TestBloomFilters.java
Tue Jul 15 12:07:57 2008
@@ -17,11 +17,19 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.hadoop.hbase;
+package org.apache.hadoop.hbase.regionserver;
 
 import java.io.IOException;
+import java.util.Map;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.HServerAddress;
+import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.HColumnDescriptor;
+import org.apache.hadoop.hbase.HBaseClusterTestCase;
 import org.apache.hadoop.hbase.io.Cell;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
@@ -145,11 +153,19 @@
       Bytes.toBytes("yzabcdef")
   };
   
+//  /** {@inheritDoc} */
+//  @Override
+//  public void setUp() throws Exception {
+//    conf.set("hbase.hregion.memcache.flush.size", "100");// flush cache every 100 bytes
+//  }
+//  
   /**
    * Test that uses automatic bloom filter
    * @throws IOException
    */
+  @SuppressWarnings("null")
   public void testComputedParameters() throws IOException {
+    try {
     HTable table = null;
 
     // Setup
@@ -185,10 +201,25 @@
       b.put(CONTENTS, value.getBytes(HConstants.UTF8_ENCODING));
       table.commit(b);
     }
+    
+    // Get HRegionInfo for our table
+    Map<HRegionInfo, HServerAddress> regions = table.getRegionsInfo();
+    assertEquals(1, regions.size());
+    HRegionInfo info = null;
+    for (HRegionInfo hri: regions.keySet()) {
+      info = hri;
+      break;
+    }
+    
+    // Request a cache flush
+    HRegionServer hrs = cluster.getRegionServer(0);
+    
+    hrs.getFlushRequester().request(hrs.getOnlineRegion(info.getRegionName()));
+
     try {
       // Give cache flusher and log roller a chance to run
       // Otherwise we'll never hit the bloom filter, just the memcache
-      Thread.sleep(conf.getLong(HConstants.THREAD_WAKE_FREQUENCY, 10 * 1000) * 2);
+      Thread.sleep(conf.getLong(HConstants.THREAD_WAKE_FREQUENCY, 10 * 1000) * 10);
       
     } catch (InterruptedException e) {
       // ignore
@@ -197,9 +228,26 @@
     for(int i = 0; i < testKeys.length; i++) {
       Cell value = table.get(testKeys[i], CONTENTS);
       if(value != null && value.getValue().length != 0) {
-        LOG.info("non existant key: " + testKeys[i] + " returned value: " +
+        LOG.error("non existant key: " + testKeys[i] + " returned value: " +
             new String(value.getValue(), HConstants.UTF8_ENCODING));
+        fail();
+      }
+    }
+    
+    for (int i = 0; i < rows.length; i++) {
+      Cell value = table.get(rows[i], CONTENTS);
+      if (value == null || value.getValue().length == 0) {
+        LOG.error("No value returned for row " + Bytes.toString(rows[i]));
+        fail();
+      }
+    }
+    } catch (Exception e) {
+      e.printStackTrace();
+      if (e instanceof IOException) {
+        IOException i = (IOException) e;
+        throw i;
       }
+      fail();
     }
   }
 }



Mime
View raw message