You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ma...@apache.org on 2015/12/11 03:43:58 UTC

[20/52] [abbrv] phoenix git commit: PHOENIX-2461 Tweak shutdown of ConnectionQueryService during testing

PHOENIX-2461 Tweak shutdown of ConnectionQueryService during testing


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/33ed7d9f
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/33ed7d9f
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/33ed7d9f

Branch: refs/heads/calcite
Commit: 33ed7d9f0c59d53d7d8666642d18eb38b2d9f7b1
Parents: 07ede93
Author: James Taylor <jt...@salesforce.com>
Authored: Sun Nov 29 12:12:43 2015 -0800
Committer: James Taylor <jt...@salesforce.com>
Committed: Sun Nov 29 12:12:43 2015 -0800

----------------------------------------------------------------------
 .../phoenix/end2end/ConnectionQueryServicesTestImpl.java  | 10 ++++++++--
 .../apache/phoenix/query/ConnectionQueryServicesImpl.java |  3 ++-
 .../java/org/apache/phoenix/jdbc/PhoenixTestDriver.java   |  2 +-
 3 files changed, 11 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/33ed7d9f/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionQueryServicesTestImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionQueryServicesTestImpl.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionQueryServicesTestImpl.java
index d4f7c16..63dfaf9 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionQueryServicesTestImpl.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ConnectionQueryServicesTestImpl.java
@@ -61,10 +61,16 @@ public class ConnectionQueryServicesTestImpl extends ConnectionQueryServicesImpl
     @Override
     public void close() throws SQLException {
         try {
-            // Attempt to fix apparent memory leak...
             clearCache();
         } finally {
-            super.close();
+            try {
+                // Since ConnectionQueryServicesTestImpl is a singleton
+                // during testing, attempt to stop the Zookeeper client
+                // service when the driver is closed.
+                if (zkClientService != null) zkClientService.stopAndWait();
+            } finally {
+                super.close();
+            }
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/33ed7d9f/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 17df42d..7e1aee0 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -220,6 +220,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
 
     private HConnection connection;
     private TransactionServiceClient txServiceClient;
+    protected volatile ZKClientService zkClientService;
     private volatile boolean initialized;
     private volatile int nSequenceSaltBuckets;
 
@@ -305,7 +306,7 @@ public class ConnectionQueryServicesImpl extends DelegateQueryServices implement
     
     private void initTxServiceClient() {
         String zkQuorumServersString = connectionInfo.getZookeeperQuorum()+":"+connectionInfo.getPort();
-        ZKClientService zkClientService = ZKClientServices.delegate(
+        zkClientService = ZKClientServices.delegate(
                   ZKClients.reWatchOnExpire(
                     ZKClients.retryOnFailure(
                       ZKClientService.Builder.of(zkQuorumServersString)

http://git-wip-us.apache.org/repos/asf/phoenix/blob/33ed7d9f/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixTestDriver.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixTestDriver.java b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixTestDriver.java
index f6df5c1..2591886 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixTestDriver.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixTestDriver.java
@@ -114,7 +114,7 @@ public class PhoenixTestDriver extends PhoenixEmbeddedDriver {
             try {
                 queryServices.close();
             } finally {
-                queryServices.getExecutor().shutdown();
+                connectionQueryServices = null;
             }
         }
     }