From commits-return-21309-archive-asf-public=cust-asf.ponee.io@phoenix.apache.org Thu May 17 02:36:16 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id C3C4F180669 for ; Thu, 17 May 2018 02:36:15 +0200 (CEST) Received: (qmail 44739 invoked by uid 500); 17 May 2018 00:36:14 -0000 Mailing-List: contact commits-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list commits@phoenix.apache.org Received: (qmail 44730 invoked by uid 99); 17 May 2018 00:36:14 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 May 2018 00:36:14 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C5A90E09EC; Thu, 17 May 2018 00:36:14 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ankit@apache.org To: commits@phoenix.apache.org Message-Id: <83047d833e444c6d8af1b2ed7ec12174@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: phoenix git commit: PHOENIX-4685 Properly handle connection caching for Phoenix inside RegionServers(addendum) (James Taylor) Date: Thu, 17 May 2018 00:36:14 +0000 (UTC) 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 Authored: Wed May 16 17:36:11 2018 -0700 Committer: Ankit Singhal 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); + } } } }