Repository: phoenix Updated Branches: refs/heads/5.x-HBase-2.0 fc562a3ba -> 9ddcd8637
PHOENIX-4685 Properly handle connection caching for Phoenix inside RegionServers(addendum) (James Taylor) Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/9ddcd863 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/9ddcd863 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/9ddcd863 Branch: refs/heads/5.x-HBase-2.0 Commit: 9ddcd8637f35cae114a4a487886ec52aa9da3a96 Parents: fc562a3 Author: Ankit Singhal <ankitsingha...@gmail.com> Authored: Wed May 16 17:53:46 2018 -0700 Committer: Ankit Singhal <ankitsingha...@gmail.com> Committed: Wed May 16 17:53:46 2018 -0700 ---------------------------------------------------------------------- .../java/org/apache/phoenix/util/ServerUtil.java | 16 ++++++++++++++++ .../java/org/apache/phoenix/query/BaseTest.java | 13 +++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/9ddcd863/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java index d34514d..334b65c 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ServerUtil.java @@ -32,6 +32,8 @@ import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.DoNotRetryIOException; import org.apache.hadoop.hbase.HConstants; @@ -60,6 +62,7 @@ import org.apache.phoenix.schema.StaleRegionBoundaryCacheException; public class ServerUtil { private static final int COPROCESSOR_SCAN_WORKS = VersionUtil.encodeVersion("0.98.6"); + private static final Log LOG = LogFactory.getLog(ServerUtil.class); private static final String FORMAT = "ERROR %d (%s): %s"; private static final Pattern PATTERN = Pattern.compile("ERROR (\\d+) \\((\\w+)\\): (.*)"); @@ -331,6 +334,19 @@ public class ServerUtil { return conf; } } + + public static void shutdown() { + synchronized (ConnectionFactory.class) { + for (Connection connection : connections.values()) { + try { + connection.close(); + } catch (IOException e) { + LOG.warn("Unable to close coprocessor connection", e); + } + } + connections.clear(); + } + } } public static Configuration getCompactionConfig(Configuration conf) { http://git-wip-us.apache.org/repos/asf/phoenix/blob/9ddcd863/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java ---------------------------------------------------------------------- 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 7e0408e..031d8bb 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 @@ -137,6 +137,7 @@ import org.apache.phoenix.util.PropertiesUtil; import org.apache.phoenix.util.QueryUtil; import org.apache.phoenix.util.ReadOnlyProps; import org.apache.phoenix.util.SchemaUtil; +import org.apache.phoenix.util.ServerUtil.ConnectionFactory; import org.junit.ClassRule; import org.junit.rules.TemporaryFolder; import org.slf4j.Logger; @@ -477,10 +478,14 @@ public abstract class BaseTest { } catch (Throwable t) { logger.error("Exception caught when shutting down mini cluster", t); } finally { - logger.info( - "Time in seconds spent in shutting down mini cluster with " - + numTables + " tables: " - + (System.currentTimeMillis() - startTime) / 1000); + try { + ConnectionFactory.shutdown(); + } finally { + logger.info( + "Time in seconds spent in shutting down mini cluster with " + + numTables + " tables: " + + (System.currentTimeMillis() - startTime) / 1000); + } } } }