You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by td...@apache.org on 2015/12/01 05:18:42 UTC

[17/19] 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/f06f3534
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/f06f3534
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/f06f3534

Branch: refs/heads/4.x-HBase-0.98
Commit: f06f3534bbb67f938e5c17624f41dc9ae717649e
Parents: 49c2fd3
Author: James Taylor <jt...@salesforce.com>
Authored: Sun Nov 29 12:12:43 2015 -0800
Committer: Thomas D'Silva <td...@salesforce.com>
Committed: Mon Nov 30 20:15:39 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/f06f3534/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/f06f3534/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 c564524..45ecf80 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
@@ -219,6 +219,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;
 
@@ -304,7 +305,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/f06f3534/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;
             }
         }
     }