This is an automated email from the ASF dual-hosted git repository. chinmayskulkarni pushed a commit to branch 4.x-HBase-1.3 in repository https://gitbox.apache.org/repos/asf/phoenix.git
The following commit(s) were added to refs/heads/4.x-HBase-1.3 by this push: new 5c49fd5 PHOENIX-5311 Fix distributed cluster test resource (hbase table) leak 5c49fd5 is described below commit 5c49fd54725a77b8f3540e610b49ba46d874916d Author: István Tóth <st...@cloudera.com> AuthorDate: Thu May 30 14:37:29 2019 +0200 PHOENIX-5311 Fix distributed cluster test resource (hbase table) leak Change-Id: Ie325febbdf613198e2c2037760d5d6cdc79e997e --- .../phoenix/end2end/ParallelStatsDisabledIT.java | 4 ++-- .../phoenix/end2end/ParallelStatsEnabledIT.java | 4 ++-- .../java/org/apache/phoenix/query/BaseTest.java | 25 ++++++++++++++++------ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsDisabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsDisabledIT.java index 2fcc3ea..ca2cff9 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsDisabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsDisabledIT.java @@ -52,8 +52,8 @@ public abstract class ParallelStatsDisabledIT extends BaseTest { } @AfterClass - public static void tearDownMiniCluster() throws Exception { - BaseTest.tearDownMiniClusterIfBeyondThreshold(); + public static void freeResources() throws Exception { + BaseTest.freeResourcesIfBeyondThreshold(); } protected ResultSet executeQuery(Connection conn, QueryBuilder queryBuilder) throws SQLException { diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsEnabledIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsEnabledIT.java index 7028db3..a383ea1 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsEnabledIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ParallelStatsEnabledIT.java @@ -48,7 +48,7 @@ public abstract class ParallelStatsEnabledIT extends BaseTest { } @AfterClass - public static void tearDownMiniCluster() throws Exception { - BaseTest.tearDownMiniClusterIfBeyondThreshold(); + public static void freeResources() throws Exception { + BaseTest.freeResourcesIfBeyondThreshold(); } } diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java index 329cde2..1197659 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java @@ -19,6 +19,7 @@ package org.apache.phoenix.query; import static org.apache.phoenix.hbase.index.write.ParallelWriterIndexCommitter.NUM_CONCURRENT_INDEX_WRITER_THREADS_CONF_KEY; import static org.apache.phoenix.query.QueryConstants.MILLIS_IN_DAY; +import static org.apache.phoenix.query.QueryServices.DROP_METADATA_ATTRIB; import static org.apache.phoenix.util.PhoenixRuntime.CURRENT_SCN_ATTRIB; import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL; import static org.apache.phoenix.util.PhoenixRuntime.JDBC_PROTOCOL_TERMINATOR; @@ -444,7 +445,7 @@ public abstract class BaseTest { boolean isDistributedCluster = isDistributedClusterModeEnabled(conf); if (!isDistributedCluster) { return initMiniCluster(conf, overrideProps); - } else { + } else { return initClusterDistributedMode(conf, overrideProps); } } @@ -629,6 +630,11 @@ public abstract class BaseTest { private static PhoenixTestDriver newTestDriver(ReadOnlyProps props) throws Exception { PhoenixTestDriver newDriver; String driverClassName = props.get(DRIVER_CLASS_NAME_ATTRIB); + if(isDistributedClusterModeEnabled(config)) { + HashMap<String, String> distPropMap = new HashMap<>(1); + distPropMap.put(DROP_METADATA_ATTRIB, Boolean.TRUE.toString()); + props = new ReadOnlyProps(props, distPropMap.entrySet().iterator()); + } if (driverClassName == null) { newDriver = new PhoenixTestDriver(props); } else { @@ -767,14 +773,21 @@ public abstract class BaseTest { return "S" + Integer.toString(MAX_SEQ_SUFFIX_VALUE + nextName).substring(1); } - public static void tearDownMiniClusterIfBeyondThreshold() throws Exception { + public static void freeResourcesIfBeyondThreshold() throws Exception { if (TABLE_COUNTER.get() > TEARDOWN_THRESHOLD) { int numTables = TABLE_COUNTER.get(); TABLE_COUNTER.set(0); - logger.info( - "Shutting down mini cluster because number of tables on this mini cluster is likely greater than " - + TEARDOWN_THRESHOLD); - tearDownMiniClusterAsync(numTables); + if(isDistributedClusterModeEnabled(config)) { + logger.info( + "Deleting old tables on distributed cluster because number of tables is likely greater than " + + TEARDOWN_THRESHOLD); + deletePriorMetaData(HConstants.LATEST_TIMESTAMP, url); + } else { + logger.info( + "Shutting down mini cluster because number of tables on this mini cluster is likely greater than " + + TEARDOWN_THRESHOLD); + tearDownMiniClusterAsync(numTables); + } } }