phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject git commit: PHOENIX-1109 PhoenixTestDriver needs to call shutdown on executor (SamarthJain)
Date Thu, 24 Jul 2014 22:04:26 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.0 d644365ca -> 690d8c02e


PHOENIX-1109 PhoenixTestDriver needs to call shutdown on executor (SamarthJain)


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

Branch: refs/heads/4.0
Commit: 690d8c02e6fbdd618f54e5c4fe913be9358242ad
Parents: d644365
Author: James Taylor <jtaylor@salesforce.com>
Authored: Thu Jul 24 15:03:56 2014 -0700
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Thu Jul 24 15:04:57 2014 -0700

----------------------------------------------------------------------
 .../phoenix/end2end/ExecuteStatementsIT.java    |  2 +-
 .../apache/phoenix/jdbc/PhoenixTestDriver.java  | 36 +++++++++++++++++---
 2 files changed, 32 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/690d8c02/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExecuteStatementsIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExecuteStatementsIT.java
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExecuteStatementsIT.java
index c2bf5c5..0d64f2e 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExecuteStatementsIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ExecuteStatementsIT.java
@@ -198,7 +198,7 @@ public class ExecuteStatementsIT extends BaseHBaseManagedTimeIT {
             
             // test upsert statement with padding
             String tenantId = getOrganizationId();
-            initATableValues(tenantId, getDefaultSplits(tenantId), null, nextTimestamp()-1,
getUrl());
+            initATableValues(tenantId, getDefaultSplits(tenantId), getUrl());
             
             upsert = "UPSERT INTO " + tableName + "(a_id, a_string, b_string) " +
                     "SELECT A_INTEGER, A_STRING, B_STRING FROM ATABLE WHERE a_string = ?";

http://git-wip-us.apache.org/repos/asf/phoenix/blob/690d8c02/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 cfa8c4b..1184fdf 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
@@ -20,6 +20,7 @@ package org.apache.phoenix.jdbc;
 import java.sql.SQLException;
 import java.util.Properties;
 
+import javax.annotation.concurrent.GuardedBy;
 import javax.annotation.concurrent.ThreadSafe;
 
 import org.apache.phoenix.end2end.ConnectionQueryServicesTestImpl;
@@ -42,9 +43,16 @@ import org.apache.phoenix.util.ReadOnlyProps;
 @ThreadSafe
 public class PhoenixTestDriver extends PhoenixEmbeddedDriver {
     
+    @GuardedBy("this")
     private ConnectionQueryServices connectionQueryServices;
     private final ReadOnlyProps overrideProps;
+    
+    @GuardedBy("this")
     private final QueryServices queryServices;
+    
+    //The only place it is modified is under a lock provided by "this". 
+    //So ok to have it just as volatile.
+    private volatile boolean closed = false;
 
     public PhoenixTestDriver() {
         this.overrideProps = ReadOnlyProps.EMPTY_PROPS;
@@ -58,18 +66,21 @@ public class PhoenixTestDriver extends PhoenixEmbeddedDriver {
     }
 
     @Override
-    public QueryServices getQueryServices() {
+    public synchronized QueryServices getQueryServices() {
+        checkClosed();
         return queryServices;
     }
 
     @Override
     public boolean acceptsURL(String url) throws SQLException {
+        checkClosed();
         // Accept the url only if test=true attribute set
         return super.acceptsURL(url) && isTestUrl(url);
     }
 
     @Override // public for testing
     public synchronized ConnectionQueryServices getConnectionQueryServices(String url, Properties
info) throws SQLException {
+        checkClosed();
         if (connectionQueryServices != null) { return connectionQueryServices; }
         ConnectionInfo connInfo = ConnectionInfo.create(url);
         if (connInfo.isConnectionless()) {
@@ -81,11 +92,26 @@ public class PhoenixTestDriver extends PhoenixEmbeddedDriver {
         return connectionQueryServices;
     }
     
+    private void checkClosed() {
+        if (closed) {
+            throw new IllegalStateException("The Phoenix jdbc test driver has been closed.");
+        }
+    }
+    
     @Override
     public synchronized void close() throws SQLException {
-        connectionQueryServices.close();
-        queryServices.close();
+        if (closed) {
+            return;
+        }
+        closed = true;
+        try {
+            connectionQueryServices.close();
+        } finally {
+            try {
+                queryServices.close();
+            } finally {
+                queryServices.getExecutor().shutdown();
+            }
+        }
     }
-    
-
 }


Mime
View raw message