HBASE-9106 Do not fail TestAcidGuarantees for exceptions on table flush
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1509535 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a2e1f4fa3c
commit
744fdf3d23
|
@ -37,6 +37,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;
|
||||
|
@ -47,7 +48,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)
|
||||
*/
|
||||
|
@ -87,7 +88,7 @@ public class TestAcidGuarantees implements Tool {
|
|||
ConstantSizeRegionSplitPolicy.class.getName());
|
||||
util = new HBaseTestingUtility(conf);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Thread that does random full-row writes into a table.
|
||||
*/
|
||||
|
@ -98,7 +99,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);
|
||||
|
@ -109,7 +110,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) {
|
||||
|
@ -122,7 +123,7 @@ public class TestAcidGuarantees implements Tool {
|
|||
numWritten.getAndIncrement();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Thread that does single-row reads in a table, looking for partially
|
||||
* completed rows.
|
||||
|
@ -152,7 +153,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);
|
||||
|
@ -181,7 +182,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.
|
||||
|
@ -205,10 +206,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);
|
||||
|
@ -255,12 +256,12 @@ public class TestAcidGuarantees implements Tool {
|
|||
final boolean systemTest) 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<AtomicityWriter> writers = Lists.newArrayList();
|
||||
for (int i = 0; i < numWriters; i++) {
|
||||
AtomicityWriter writer = new AtomicityWriter(
|
||||
|
@ -272,7 +273,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));
|
||||
}
|
||||
// Flushing has been a source of ACID violations previously (see HBASE-2856), so ideally,
|
||||
// we would flush as often as possible. On a running cluster, this isn't practical:
|
||||
// (1) we will cause a lot of load due to all the flushing and compacting
|
||||
|
@ -292,18 +297,18 @@ public class TestAcidGuarantees implements Tool {
|
|||
getters.add(getter);
|
||||
ctx.addThread(getter);
|
||||
}
|
||||
|
||||
|
||||
List<AtomicScanReader> 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());
|
||||
|
@ -326,7 +331,7 @@ public class TestAcidGuarantees implements Tool {
|
|||
runTestAtomicity(20000, 5, 5, 0, 3);
|
||||
} finally {
|
||||
util.shutdownMiniCluster();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -336,7 +341,7 @@ public class TestAcidGuarantees implements Tool {
|
|||
runTestAtomicity(20000, 5, 0, 5, 3);
|
||||
} finally {
|
||||
util.shutdownMiniCluster();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -346,7 +351,7 @@ public class TestAcidGuarantees implements Tool {
|
|||
runTestAtomicity(20000, 5, 2, 2, 3);
|
||||
} finally {
|
||||
util.shutdownMiniCluster();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue