HBASE-12772 TestPerColumnFamilyFlush failing

This commit is contained in:
stack 2014-12-29 15:45:23 -08:00
parent b2eea8cac6
commit 02b0332650
1 changed files with 146 additions and 134 deletions

View File

@ -334,6 +334,7 @@ public class TestPerColumnFamilyFlush {
conf.set(FlushPolicyFactory.HBASE_FLUSH_POLICY_KEY, FlushLargeStoresPolicy.class.getName());
conf.setLong(FlushLargeStoresPolicy.HREGION_COLUMNFAMILY_FLUSH_SIZE_LOWER_BOUND, 10000);
final int numRegionServers = 4;
try {
TEST_UTIL.startMiniCluster(numRegionServers);
TEST_UTIL.getHBaseAdmin().createNamespace(
NamespaceDescriptor.create(TABLENAME.getNamespaceAsString()).build());
@ -404,9 +405,10 @@ public class TestPerColumnFamilyFlush {
verifyEdit(3, i, table);
}
}
} finally {
TEST_UTIL.shutdownMiniCluster();
}
}
// Test Log Replay with Distributed Replay on.
// In distributed log replay, the log splitters ask the master for the
@ -426,6 +428,7 @@ public class TestPerColumnFamilyFlush {
*/
@Test
public void testFlushingWhenLogRolling() throws Exception {
TableName tableName = TableName.valueOf("testFlushingWhenLogRolling");
Configuration conf = TEST_UTIL.getConfiguration();
conf.setLong(HConstants.HREGION_MEMSTORE_FLUSH_SIZE, 300000);
conf.set(FlushPolicyFactory.HBASE_FLUSH_POLICY_KEY, FlushLargeStoresPolicy.class.getName());
@ -439,20 +442,12 @@ public class TestPerColumnFamilyFlush {
int maxLogs = conf.getInt("hbase.regionserver.maxlogs", 32);
final int numRegionServers = 4;
try {
TEST_UTIL.startMiniCluster(numRegionServers);
TEST_UTIL.getHBaseAdmin().createNamespace(
NamespaceDescriptor.create(TABLENAME.getNamespaceAsString()).build());
HTable table = TEST_UTIL.createTable(TABLENAME, families);
HTableDescriptor htd = table.getTableDescriptor();
for (byte[] family : families) {
if (!htd.hasFamily(family)) {
htd.addFamily(new HColumnDescriptor(family));
}
}
HRegion desiredRegion = getRegionWithName(TABLENAME).getFirst();
HTable table = TEST_UTIL.createTable(tableName, families);
HRegion desiredRegion = getRegionWithName(tableName).getFirst();
assertTrue("Could not find a region which hosts the new region.", desiredRegion != null);
LOG.info("Writing to region=" + desiredRegion);
// Add some edits. Most will be for CF1, some for CF2 and CF3.
for (int i = 1; i <= 10000; i++) {
@ -474,21 +469,26 @@ public class TestPerColumnFamilyFlush {
table.close();
// Wait for some time till the flush caused by log rolling happens.
Thread.sleep(4000);
LOG.info("Finished waiting on flush after too many WALs...");
// We have artificially created the conditions for a log roll. When a
// log roll happens, we should flush all the column families. Testing that
// case here.
// Individual families should have been flushed.
assertEquals(DefaultMemStore.DEEP_OVERHEAD, desiredRegion.getStore(FAMILY1).getMemStoreSize());
assertEquals(DefaultMemStore.DEEP_OVERHEAD, desiredRegion.getStore(FAMILY2).getMemStoreSize());
assertEquals(DefaultMemStore.DEEP_OVERHEAD, desiredRegion.getStore(FAMILY3).getMemStoreSize());
assertEquals(DefaultMemStore.DEEP_OVERHEAD,
desiredRegion.getStore(FAMILY1).getMemStoreSize());
assertEquals(DefaultMemStore.DEEP_OVERHEAD,
desiredRegion.getStore(FAMILY2).getMemStoreSize());
assertEquals(DefaultMemStore.DEEP_OVERHEAD,
desiredRegion.getStore(FAMILY3).getMemStoreSize());
// And of course, the total memstore should also be clean.
assertEquals(0, desiredRegion.getMemstoreSize().get());
} finally {
TEST_UTIL.shutdownMiniCluster();
}
}
private void doPut(Table table, long memstoreFlushSize) throws IOException, InterruptedException {
HRegion region = getRegionWithName(table.getName()).getFirst();
@ -535,6 +535,13 @@ public class TestPerColumnFamilyFlush {
htd.addFamily(new HColumnDescriptor(FAMILY3));
LOG.info("==============Test with selective flush disabled===============");
int cf1StoreFileCount = -1;
int cf2StoreFileCount = -1;
int cf3StoreFileCount = -1;
int cf1StoreFileCount1 = -1;
int cf2StoreFileCount1 = -1;
int cf3StoreFileCount1 = -1;
try {
TEST_UTIL.startMiniCluster(1);
TEST_UTIL.getHBaseAdmin().createNamespace(
NamespaceDescriptor.create(TABLENAME.getNamespaceAsString()).build());
@ -547,28 +554,33 @@ public class TestPerColumnFamilyFlush {
conn.close();
HRegion region = getRegionWithName(TABLENAME).getFirst();
int cf1StoreFileCount = region.getStore(FAMILY1).getStorefilesCount();
int cf2StoreFileCount = region.getStore(FAMILY2).getStorefilesCount();
int cf3StoreFileCount = region.getStore(FAMILY3).getStorefilesCount();
cf1StoreFileCount = region.getStore(FAMILY1).getStorefilesCount();
cf2StoreFileCount = region.getStore(FAMILY2).getStorefilesCount();
cf3StoreFileCount = region.getStore(FAMILY3).getStorefilesCount();
} finally {
TEST_UTIL.shutdownMiniCluster();
}
LOG.info("==============Test with selective flush enabled===============");
conf.set(FlushPolicyFactory.HBASE_FLUSH_POLICY_KEY, FlushLargeStoresPolicy.class.getName());
try {
TEST_UTIL.startMiniCluster(1);
TEST_UTIL.getHBaseAdmin().createNamespace(
NamespaceDescriptor.create(TABLENAME.getNamespaceAsString()).build());
TEST_UTIL.getHBaseAdmin().createTable(htd);
conn = ConnectionFactory.createConnection(conf);
table = conn.getTable(TABLENAME);
Connection conn = ConnectionFactory.createConnection(conf);
Table table = conn.getTable(TABLENAME);
doPut(table, memstoreFlushSize);
table.close();
conn.close();
region = getRegionWithName(TABLENAME).getFirst();
int cf1StoreFileCount1 = region.getStore(FAMILY1).getStorefilesCount();
int cf2StoreFileCount1 = region.getStore(FAMILY2).getStorefilesCount();
int cf3StoreFileCount1 = region.getStore(FAMILY3).getStorefilesCount();
cf1StoreFileCount1 = region.getStore(FAMILY1).getStorefilesCount();
cf2StoreFileCount1 = region.getStore(FAMILY2).getStorefilesCount();
cf3StoreFileCount1 = region.getStore(FAMILY3).getStorefilesCount();
} finally {
TEST_UTIL.shutdownMiniCluster();
}
LOG.info("disable selective flush: " + Bytes.toString(FAMILY1) + "=>" + cf1StoreFileCount
+ ", " + Bytes.toString(FAMILY2) + "=>" + cf2StoreFileCount + ", "