diff --git src/test/java/org/apache/hadoop/hbase/TestAcidGuarantees.java src/test/java/org/apache/hadoop/hbase/TestAcidGuarantees.java index 227d243..e0595c8 100644 --- src/test/java/org/apache/hadoop/hbase/TestAcidGuarantees.java +++ src/test/java/org/apache/hadoop/hbase/TestAcidGuarantees.java @@ -38,6 +38,7 @@ import org.apache.hadoop.hbase.client.ResultScanner; import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.regionserver.ConstantSizeRegionSplitPolicy; import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.util.StringUtils; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; import org.junit.Test; @@ -48,7 +49,7 @@ import com.google.common.collect.Lists; /** * Test case that uses multiple threads to read and write multifamily rows * into a table, verifying that reads never see partially-complete writes. - * + * * This can run as a junit test, or with a main() function which runs against * a real cluster (eg for testing with failures, region movement, etc) */ @@ -88,7 +89,7 @@ public class TestAcidGuarantees implements Tool { ConstantSizeRegionSplitPolicy.class.getName()); util = new HBaseTestingUtility(conf); } - + /** * Thread that does random full-row writes into a table. */ @@ -99,7 +100,7 @@ public class TestAcidGuarantees implements Tool { byte targetFamilies[][]; HTable table; AtomicLong numWritten = new AtomicLong(); - + public AtomicityWriter(TestContext ctx, byte targetRows[][], byte targetFamilies[][]) throws IOException { super(ctx); @@ -110,7 +111,7 @@ public class TestAcidGuarantees implements Tool { public void doAnAction() throws Exception { // Pick a random row to write into byte[] targetRow = targetRows[rand.nextInt(targetRows.length)]; - Put p = new Put(targetRow); + Put p = new Put(targetRow); rand.nextBytes(data); for (byte[] family : targetFamilies) { @@ -123,7 +124,7 @@ public class TestAcidGuarantees implements Tool { numWritten.getAndIncrement(); } } - + /** * Thread that does single-row reads in a table, looking for partially * completed rows. @@ -153,7 +154,7 @@ public class TestAcidGuarantees implements Tool { // ignore this action return; } - + for (byte[] family : targetFamilies) { for (int i = 0; i < NUM_COLS_TO_CHECK; i++) { byte qualifier[] = Bytes.toBytes("col" + i); @@ -182,7 +183,7 @@ public class TestAcidGuarantees implements Tool { throw new RuntimeException(msg.toString()); } } - + /** * Thread that does full scans of the table looking for any partially completed * rows. @@ -206,10 +207,10 @@ public class TestAcidGuarantees implements Tool { s.addFamily(family); } ResultScanner scanner = table.getScanner(s); - + for (Result res : scanner) { byte[] gotValue = null; - + for (byte[] family : targetFamilies) { for (int i = 0; i < NUM_COLS_TO_CHECK; i++) { byte qualifier[] = Bytes.toBytes("col" + i); @@ -248,12 +249,12 @@ public class TestAcidGuarantees implements Tool { int numUniqueRows) throws Exception { createTableIfMissing(); TestContext ctx = new TestContext(util.getConfiguration()); - + byte rows[][] = new byte[numUniqueRows][]; for (int i = 0; i < numUniqueRows; i++) { rows[i] = Bytes.toBytes("test_row_" + i); } - + List writers = Lists.newArrayList(); for (int i = 0; i < numWriters; i++) { AtomicityWriter writer = new AtomicityWriter( @@ -265,7 +266,11 @@ public class TestAcidGuarantees implements Tool { ctx.addThread(new RepeatingTestThread(ctx) { HBaseAdmin admin = new HBaseAdmin(util.getConfiguration()); public void doAnAction() throws Exception { - admin.flush(TABLE_NAME); + try { + admin.flush(TABLE_NAME); + } catch(IOException ioe) { + LOG.warn("Ignoring exception while flushing: " + StringUtils.stringifyException(ioe)); + } } }); @@ -276,18 +281,18 @@ public class TestAcidGuarantees implements Tool { getters.add(getter); ctx.addThread(getter); } - + List scanners = Lists.newArrayList(); for (int i = 0; i < numScanners; i++) { AtomicScanReader scanner = new AtomicScanReader(ctx, FAMILIES); scanners.add(scanner); ctx.addThread(scanner); } - + ctx.startThreads(); ctx.waitFor(millisToRun); ctx.stop(); - + LOG.info("Finished test. Writers:"); for (AtomicityWriter writer : writers) { LOG.info(" wrote " + writer.numWritten.get()); @@ -310,7 +315,7 @@ public class TestAcidGuarantees implements Tool { runTestAtomicity(20000, 5, 5, 0, 3); } finally { util.shutdownMiniCluster(); - } + } } @Test @@ -320,7 +325,7 @@ public class TestAcidGuarantees implements Tool { runTestAtomicity(20000, 5, 0, 5, 3); } finally { util.shutdownMiniCluster(); - } + } } @Test @@ -330,7 +335,7 @@ public class TestAcidGuarantees implements Tool { runTestAtomicity(20000, 5, 2, 2, 3); } finally { util.shutdownMiniCluster(); - } + } } ////////////////////////////////////////////////////////////////////////////