Skip to content

Commit

Permalink
HBASE-22180 Make TestBlockEvictionFromClient.testBlockRefCountAfterSp…
Browse files Browse the repository at this point in the history
…lits more stable
  • Loading branch information
Apache9 committed Apr 7, 2019
1 parent 0247466 commit b3f62a7
Showing 1 changed file with 6 additions and 12 deletions.
Expand Up @@ -23,7 +23,6 @@


import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
Expand Down Expand Up @@ -72,6 +71,8 @@
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;


import org.apache.hbase.thirdparty.com.google.common.collect.Iterables;

@Category({ LargeTests.class, ClientTests.class }) @Category({ LargeTests.class, ClientTests.class })
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class TestBlockEvictionFromClient { public class TestBlockEvictionFromClient {
Expand Down Expand Up @@ -577,7 +578,7 @@ public void testBlockRefCountAfterSplits() throws IOException, InterruptedExcept
table = TEST_UTIL.createTable(tableName, FAMILIES_1, 1, 1024); table = TEST_UTIL.createTable(tableName, FAMILIES_1, 1, 1024);
// get the block cache and region // get the block cache and region
RegionLocator locator = TEST_UTIL.getConnection().getRegionLocator(tableName); RegionLocator locator = TEST_UTIL.getConnection().getRegionLocator(tableName);
String regionName = locator.getAllRegionLocations().get(0).getRegionInfo().getEncodedName(); String regionName = locator.getAllRegionLocations().get(0).getRegion().getEncodedName();
HRegion region = HRegion region =
TEST_UTIL.getRSForFirstRegionInTable(tableName).getRegion(regionName); TEST_UTIL.getRSForFirstRegionInTable(tableName).getRegion(regionName);
HStore store = region.getStores().iterator().next(); HStore store = region.getStores().iterator().next();
Expand All @@ -601,19 +602,12 @@ public void testBlockRefCountAfterSplits() throws IOException, InterruptedExcept
put.addColumn(FAMILY, QUALIFIER2, data2); put.addColumn(FAMILY, QUALIFIER2, data2);
table.put(put); table.put(put);
region.flush(true); region.flush(true);
ServerName rs = Iterables.getOnlyElement(TEST_UTIL.getAdmin().getRegionServers());
int regionCount = TEST_UTIL.getAdmin().getRegions(rs).size();
LOG.info("About to SPLIT on " + Bytes.toString(ROW1)); LOG.info("About to SPLIT on " + Bytes.toString(ROW1));
TEST_UTIL.getAdmin().split(tableName, ROW1); TEST_UTIL.getAdmin().split(tableName, ROW1);
// Wait for splits // Wait for splits
Collection<ServerName> regionServers = TEST_UTIL.getAdmin().getRegionServers(); TEST_UTIL.waitFor(60000, () -> TEST_UTIL.getAdmin().getRegions(rs).size() > regionCount);
Iterator<ServerName> serverItr = regionServers.iterator();
serverItr.hasNext();
ServerName rs = serverItr.next();
List<RegionInfo> onlineRegions = TEST_UTIL.getAdmin().getRegions(rs);
while (onlineRegions.size() != 2) {
onlineRegions = TEST_UTIL.getAdmin().getRegions(rs);
Thread.sleep(100);
LOG.info("Waiting on SPLIT to complete...");
}
region.compact(true); region.compact(true);
Iterator<CachedBlock> iterator = cache.iterator(); Iterator<CachedBlock> iterator = cache.iterator();
// Though the split had created the HalfStorefileReader - the firstkey and lastkey scanners // Though the split had created the HalfStorefileReader - the firstkey and lastkey scanners
Expand Down

0 comments on commit b3f62a7

Please sign in to comment.