phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject phoenix git commit: PHOENIX-2552 Fix hanging Jenkins builds
Date Thu, 31 Dec 2015 19:18:31 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 9cd520a34 -> be1f48066


PHOENIX-2552 Fix hanging Jenkins builds


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

Branch: refs/heads/4.x-HBase-0.98
Commit: be1f48066a970c79b4856dd184ae06c6e1329d42
Parents: 9cd520a
Author: James Taylor <jtaylor@salesforce.com>
Authored: Thu Dec 31 09:55:38 2015 -0800
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Thu Dec 31 11:16:48 2015 -0800

----------------------------------------------------------------------
 .../ConnectionQueryServicesTestImpl.java        | 20 ++++++++++++++++++++
 .../phoenix/iterate/ScanningResultIterator.java | 10 +++++++---
 .../apache/phoenix/jdbc/PhoenixConnection.java  |  2 +-
 3 files changed, 28 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/be1f4806/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 2028223..d941fd5 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
@@ -19,10 +19,15 @@ package org.apache.phoenix.end2end;
 
 import java.sql.SQLException;
 import java.util.Properties;
+import java.util.Set;
 
+import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.jdbc.PhoenixEmbeddedDriver.ConnectionInfo;
 import org.apache.phoenix.query.ConnectionQueryServicesImpl;
 import org.apache.phoenix.query.QueryServices;
+import org.apache.phoenix.util.SQLCloseables;
+
+import com.google.common.collect.Sets;
 
 /**
  * 
@@ -34,12 +39,24 @@ import org.apache.phoenix.query.QueryServices;
  */
 public class ConnectionQueryServicesTestImpl extends ConnectionQueryServicesImpl {
     protected int NUM_SLAVES_BASE = 1; // number of slaves for the cluster
+    // Track open connections to free them on close as unit tests don't always do this.
+    private Set<PhoenixConnection> connections = Sets.newHashSet();
     
     public ConnectionQueryServicesTestImpl(QueryServices services, ConnectionInfo info, Properties
props) throws SQLException {
         super(services, info, props);
     }
     
     @Override
+    public void addConnection(PhoenixConnection connection) throws SQLException {
+        connections.add(connection);
+    }
+    
+    @Override
+    public void removeConnection(PhoenixConnection connection) throws SQLException {
+        connections.remove(connection);
+    }
+
+    @Override
     public void init(String url, Properties props) throws SQLException {
         try {
             super.init(url, props);
@@ -61,6 +78,9 @@ public class ConnectionQueryServicesTestImpl extends ConnectionQueryServicesImpl
     @Override
     public void close() throws SQLException {
         try {
+            Set<PhoenixConnection> connections = this.connections;
+            this.connections = Sets.newHashSet();
+            SQLCloseables.closeAll(connections);
             clearCache();
         } finally {
             super.close();

http://git-wip-us.apache.org/repos/asf/phoenix/blob/be1f4806/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java
b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java
index b722794..604e1a7 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/iterate/ScanningResultIterator.java
@@ -28,9 +28,9 @@ import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.KeyValueUtil;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.ResultScanner;
+import org.apache.phoenix.monitoring.CombinableMetric;
 import org.apache.phoenix.monitoring.CombinableMetric.NoOpRequestMetric;
 import org.apache.phoenix.monitoring.GlobalClientMetrics;
-import org.apache.phoenix.monitoring.CombinableMetric;
 import org.apache.phoenix.schema.tuple.ResultTuple;
 import org.apache.phoenix.schema.tuple.Tuple;
 import org.apache.phoenix.util.ServerUtil;
@@ -53,10 +53,14 @@ public class ScanningResultIterator implements ResultIterator {
     public Tuple next() throws SQLException {
         try {
             Result result = scanner.next();
+            if (result == null) {
+                close(); // Free up resources early
+                return null;
+            }
             calculateScanSize(result);
-            // TODO: use ResultTuple.setResult(result)
+            // TODO: use ResultTuple.setResult(result)?
             // Need to create a new one if holding on to it (i.e. OrderedResultIterator)
-            return result == null ? null : new ResultTuple(result);
+            return new ResultTuple(result);
         } catch (IOException e) {
             throw ServerUtil.parseServerException(e);
         }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/be1f4806/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java
index 04016c0..dc97341 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java
@@ -122,7 +122,7 @@ import co.cask.tephra.TransactionContext;
  * 
  * @since 0.1
  */
-public class PhoenixConnection implements Connection, MetaDataMutated {
+public class PhoenixConnection implements Connection, MetaDataMutated, SQLCloseable {
     private final String url;
     private final ConnectionQueryServices services;
     private final Properties info;


Mime
View raw message