You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2014/07/25 00:00:51 UTC
git commit: PHOENIX-1109 PhoenixTestDriver needs to call shutdown on
executor (SamarthJain)
Repository: phoenix
Updated Branches:
refs/heads/3.0 b2e4cd0ab -> 56d92bbd4
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/56d92bbd
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/56d92bbd
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/56d92bbd
Branch: refs/heads/3.0
Commit: 56d92bbd4b51e951211569a43c60f52d74230805
Parents: b2e4cd0
Author: James Taylor <jt...@salesforce.com>
Authored: Thu Jul 24 15:03:56 2014 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Thu Jul 24 15:03:56 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/56d92bbd/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/56d92bbd/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();
+ }
+ }
}
-
-
}