Repository: phoenix Updated Branches: refs/heads/4.x-HBase-0.98 983f89f86 -> 928f5f80d
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/928f5f80 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/928f5f80 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/928f5f80 Branch: refs/heads/4.x-HBase-0.98 Commit: 928f5f80d6f434a914df544b28f0b7bbabc2e3d1 Parents: 983f89f Author: Ankit Singhal <ankitsingha...@gmail.com> Authored: Wed May 16 17:36:11 2018 -0700 Committer: Ankit Singhal <ankitsingha...@gmail.com> Committed: Wed May 16 17:36:11 2018 -0700 ---------------------------------------------------------------------- .../java/org/apache/phoenix/util/ServerUtil.java | 19 +++++++++++++++---- .../java/org/apache/phoenix/query/BaseTest.java | 13 +++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/928f5f80/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 fe27ab4..d0657f7 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 @@ -31,8 +31,6 @@ import java.util.concurrent.ExecutorService; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.annotation.concurrent.GuardedBy; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; @@ -323,8 +321,8 @@ public class ServerUtil { } @Override - public synchronized void shutdown() { - // We need not close the cached connections as they are shared across the server. + public void shutdown() { + ConnectionFactory.shutdown(); } @Override @@ -377,6 +375,19 @@ public class ServerUtil { return conf; } } + + public static void shutdown() { + synchronized (CoprocessorHConnectionTableFactory.class) { + for (HConnection 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/928f5f80/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 65600e0..74bb7ad 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; @@ -465,10 +466,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); + } } } }