Skip to content

Commit

Permalink
Eager cleanup of parameterized mini cluster resources.
Browse files Browse the repository at this point in the history
Jenkins runs on the PR clearly shows that the peak thread usage
is dangerously close to the ulimits. Infact a bunch of failures
are with thread creation.

This patch eagerly cleans up the mini cluster resources from
previous parameterized runs so that they are not held up for longer
after each run.

Profiled the test runs using YourKit and I can see that the peak
thread usage substantially dropped.
  • Loading branch information
bharathv committed Dec 25, 2019
1 parent ed83579 commit 6b18bae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,6 @@ public class TestFromClientSide {
private static byte [] VALUE = Bytes.toBytes("testValue");
protected static int SLAVES = 3;

private static final List<HBaseTestingUtility> tearDownClusters = new ArrayList<>();

@Rule public TestTableName name = new TestTableName();

// To keep the child classes happy.
Expand Down Expand Up @@ -174,6 +172,11 @@ protected static final void initialize(Class registryImpl, int numHedgedReqs, Cl
// ((Log4JLogger)ScannerCallable.LOG).getLogger().setLevel(Level.ALL);
// make sure that we do not get the same ts twice, see HBASE-19731 for more details.
EnvironmentEdgeManager.injectEdge(new NonRepeatedEnvironmentEdge());
if (TEST_UTIL != null) {
// Belongs to another parameterized run. Currently, there is no clean way to cleanup test
// resources after each parametrized run. Something like @AfterParameterized.
TEST_UTIL.shutdownMiniCluster();
}
TEST_UTIL = new HBaseTestingUtility();
Configuration conf = TEST_UTIL.getConfiguration();
conf.setStrings(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
Expand All @@ -187,8 +190,6 @@ protected static final void initialize(Class registryImpl, int numHedgedReqs, Cl
conf.setBoolean(HConstants.MASTER_REGISTRY_ENABLE_HEDGED_READS_KEY, true);
conf.setInt(HConstants.HBASE_RPCS_HEDGED_REQS_FANOUT_KEY, numHedgedReqs);
}
// We need more than one region server in this test
tearDownClusters.add(TEST_UTIL);
StartMiniClusterOption.Builder builder = StartMiniClusterOption.builder();
// Multiple masters needed only when hedged reads for master registry are enabled.
builder.numMasters(numHedgedReqs > 1 ? 3 : 1).numRegionServers(SLAVES);
Expand All @@ -197,8 +198,8 @@ protected static final void initialize(Class registryImpl, int numHedgedReqs, Cl

@AfterClass
public static void tearDownAfterClass() throws Exception {
for (HBaseTestingUtility util: tearDownClusters) {
util.shutdownMiniCluster();
if (TEST_UTIL != null) {
TEST_UTIL.shutdownMiniCluster();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,13 @@ public class TestScannersFromClientSide {
private static byte [] QUALIFIER = Bytes.toBytes("testQualifier");
private static byte [] VALUE = Bytes.toBytes("testValue");

// Cleaned up after the entire test is run.
private static List<HBaseTestingUtility> tearDownClusters = new ArrayList<>();

@Rule
public TestTableName name = new TestTableName();

@AfterClass
public static void tearDownAfterClass() throws Exception {
for (HBaseTestingUtility testingUtility: tearDownClusters) {
testingUtility.shutdownMiniCluster();
if (TEST_UTIL != null) {
TEST_UTIL.shutdownMiniCluster();
}
}

Expand All @@ -114,8 +111,12 @@ public static Collection parameters() {
}

public TestScannersFromClientSide(Class registryImpl, int numHedgedReqs) throws Exception {
if (TEST_UTIL != null) {
// Might be a remnant of another parameterized run. JUnit does not provide a hook to run after
// each parameterized test run.
TEST_UTIL.shutdownMiniCluster();
}
TEST_UTIL = new HBaseTestingUtility();
tearDownClusters.add(TEST_UTIL);
Configuration conf = TEST_UTIL.getConfiguration();
conf.setLong(HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY, 10 * 1024 * 1024);
conf.setClass(HConstants.REGISTRY_IMPL_CONF_KEY, registryImpl, AsyncRegistry.class);
Expand Down

0 comments on commit 6b18bae

Please sign in to comment.