From 85842f019ebe8e49d4e6ca69c22f55e4472b2eb8 Mon Sep 17 00:00:00 2001 From: Zhihong Yu Date: Fri, 20 Apr 2012 01:07:29 +0000 Subject: [PATCH] HBASE-5824 addendum fixes coprocessor tests (Jimmy) git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1328166 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/hadoop/hbase/client/HTable.java | 3 ++- .../hadoop/hbase/constraint/TestConstraint.java | 13 ++----------- ...tRegionServerCoprocessorExceptionWithRemove.java | 5 ++--- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/apache/hadoop/hbase/client/HTable.java b/src/main/java/org/apache/hadoop/hbase/client/HTable.java index 5dbfa2ff079..17ab93f88dd 100644 --- a/src/main/java/org/apache/hadoop/hbase/client/HTable.java +++ b/src/main/java/org/apache/hadoop/hbase/client/HTable.java @@ -852,7 +852,8 @@ public class HTable implements HTableInterface { writeBuffer.add(put); currentWriteBufferSize += put.heapSize(); - // we need to periodically see if the writebuffer is full instead of waiting until the end of the List + // we need to periodically see if the writebuffer is full + // instead of waiting until the end of the List n++; if (n % DOPUT_WB_CHECK == 0 && currentWriteBufferSize > writeBufferSize) { flushCommits(); diff --git a/src/test/java/org/apache/hadoop/hbase/constraint/TestConstraint.java b/src/test/java/org/apache/hadoop/hbase/constraint/TestConstraint.java index 47f7e33427d..0659b6b1d49 100644 --- a/src/test/java/org/apache/hadoop/hbase/constraint/TestConstraint.java +++ b/src/test/java/org/apache/hadoop/hbase/constraint/TestConstraint.java @@ -17,13 +17,10 @@ */ package org.apache.hadoop.hbase.constraint; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import java.util.List; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.HBaseTestingUtility; @@ -32,7 +29,6 @@ import org.apache.hadoop.hbase.HTableDescriptor; import org.apache.hadoop.hbase.MediumTests; import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.Put; -import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException; import org.apache.hadoop.hbase.util.Bytes; import org.junit.After; import org.junit.AfterClass; @@ -118,13 +114,8 @@ public class TestConstraint { try { table.put(put); fail("This put should not have suceeded - AllFailConstraint was not run!"); - } catch (RetriesExhaustedWithDetailsException e) { - List causes = e.getCauses(); - assertEquals( - "More than one failure cause - should only be the failure constraint exception", - 1, causes.size()); - Throwable t = causes.get(0); - assertEquals(ConstraintException.class, t.getClass()); + } catch (Throwable t) { + assertTrue(t instanceof ConstraintException); } table.close(); } diff --git a/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java b/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java index 10f44a6eb3f..66ed0e1a185 100644 --- a/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java +++ b/src/test/java/org/apache/hadoop/hbase/coprocessor/TestRegionServerCoprocessorExceptionWithRemove.java @@ -26,7 +26,6 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.*; import org.apache.hadoop.hbase.client.HTable; import org.apache.hadoop.hbase.client.Put; -import org.apache.hadoop.hbase.client.RetriesExhaustedWithDetailsException; import org.apache.hadoop.hbase.regionserver.HRegionServer; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.regionserver.wal.WALEdit; @@ -112,12 +111,12 @@ public class TestRegionServerCoprocessorExceptionWithRemove { Put put = new Put(ROW); put.add(TEST_FAMILY, ROW, ROW); table.put(put); - } catch (RetriesExhaustedWithDetailsException e) { + } catch (Throwable t) { // below, could call instead : // startsWith("Failed 1 action: DoNotRetryIOException.") // But that might be too brittle if client-side // DoNotRetryIOException-handler changes its message. - assertTrue(e.getMessage().contains("DoNotRetryIOException")); + assertTrue(t instanceof DoNotRetryIOException); threwDNRE = true; } finally { assertTrue(threwDNRE);