drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From par...@apache.org
Subject [2/9] drill git commit: DRILL-2579: 2-Hygiene: Renamed to match semantics; fixed, added, formatted doc.; basic whitespace.
Date Tue, 07 Apr 2015 02:14:56 GMT
DRILL-2579: 2-Hygiene: Renamed to match semantics; fixed, added, formatted doc.; basic whitespace.

- Renamed createConnection -> getConnection.
- Renamed close -> closeConnections
- Added documentation fixes, clarifications, formatting.
- Fixed some basic whitespace.


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

Branch: refs/heads/master
Commit: 31c9867ae36dab9873c8d02f50a75ce66b9e68c7
Parents: 1821f78
Author: dbarclay <dbarclay@maprtech.com>
Authored: Thu Mar 26 21:26:26 2015 -0700
Committer: Parth Chandra <pchandra@maprtech.com>
Committed: Mon Apr 6 18:24:05 2015 -0700

----------------------------------------------------------------------
 .../drill/jdbc/CachingConnectionFactory.java      |  4 ++--
 .../org/apache/drill/jdbc/ConnectionFactory.java  | 12 +++++++-----
 .../test/java/org/apache/drill/jdbc/JdbcTest.java |  8 ++++----
 .../drill/jdbc/MultiConnectionCachingFactory.java |  8 ++++----
 .../apache/drill/jdbc/NonClosableConnection.java  |  4 ++--
 .../jdbc/SingleConnectionCachingFactory.java      | 18 ++++++++++++++----
 .../org/apache/drill/jdbc/test/JdbcAssert.java    |  2 +-
 7 files changed, 34 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/31c9867a/exec/jdbc/src/test/java/org/apache/drill/jdbc/CachingConnectionFactory.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/CachingConnectionFactory.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/CachingConnectionFactory.java
index df64366..65f993a 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/CachingConnectionFactory.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/CachingConnectionFactory.java
@@ -25,7 +25,7 @@ import java.sql.SQLException;
 public interface CachingConnectionFactory extends ConnectionFactory {
 
   /**
-   * Closes all active connections in the cache.
+   * Closes all open connections in this factory's cache.
    */
-  void close() throws SQLException;
+  void closeConnections() throws SQLException;
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/31c9867a/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionFactory.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionFactory.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionFactory.java
index 8491436..09366de 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionFactory.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/ConnectionFactory.java
@@ -20,14 +20,16 @@ package org.apache.drill.jdbc;
 import java.sql.Connection;
 
 /**
- * A factory used to create {@link java.sql.Connection} instances.
+ * A factory used to get open {@link Connection} instances.
  */
 public interface ConnectionFactory {
+
   /**
-   * Creates a new {@link java.sql.Connection} based on the given {@link org.apache.drill.jdbc.ConnectionInfo
info}
+   * Gets an open {@link Connection} based on given {@link ConnectionInfo
+   * connection parameters}.
    *
-   * @param info connection parameters
-   * @throws Exception if factory fails to create a connection.
+   * @param info the connection parameters
+   * @throws Exception if factory fails to get a connection.
    */
-  Connection createConnection(ConnectionInfo info) throws Exception;
+  Connection getConnection(ConnectionInfo info) throws Exception;
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/31c9867a/exec/jdbc/src/test/java/org/apache/drill/jdbc/JdbcTest.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/JdbcTest.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/JdbcTest.java
index 6d8d8e9..e486898 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/JdbcTest.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/JdbcTest.java
@@ -51,7 +51,7 @@ public class JdbcTest extends ExecTest {
   public static void setUpTestCase() {
     factory = new SingleConnectionCachingFactory(new ConnectionFactory() {
       @Override
-      public Connection createConnection(ConnectionInfo info) throws Exception {
+      public Connection getConnection(ConnectionInfo info) throws Exception {
         Class.forName("org.apache.drill.jdbc.Driver");
         return DriverManager.getConnection(info.getUrl(), info.getParamsAsProperties());
       }
@@ -76,7 +76,7 @@ public class JdbcTest extends ExecTest {
    * @throws Exception if connection fails
    */
   protected static Connection connect(String url, Properties info) throws Exception {
-    final Connection conn = factory.createConnection(new ConnectionInfo(url, info));
+    final Connection conn = factory.getConnection(new ConnectionInfo(url, info));
     changeSchemaIfSupplied(conn, info);
     return conn;
   }
@@ -120,7 +120,7 @@ public class JdbcTest extends ExecTest {
    */
   protected static void reset() {
     try {
-      factory.close();
+      factory.closeConnections();
     } catch (SQLException e) {
       throw new RuntimeException("error while closing connection factory", e);
     }
@@ -128,6 +128,6 @@ public class JdbcTest extends ExecTest {
 
   @AfterClass
   public static void tearDownTestCase() throws Exception {
-    factory.close();
+    factory.closeConnections();
   }
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/31c9867a/exec/jdbc/src/test/java/org/apache/drill/jdbc/MultiConnectionCachingFactory.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/MultiConnectionCachingFactory.java
b/exec/jdbc/src/test/java/org/apache/drill/jdbc/MultiConnectionCachingFactory.java
index 189942d..063b5a5 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/MultiConnectionCachingFactory.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/MultiConnectionCachingFactory.java
@@ -45,10 +45,10 @@ public class MultiConnectionCachingFactory implements CachingConnectionFactory
{
    * {@link java.sql.Connection#close()}. Consumer must call {#close} to close the cached
connections.
    */
   @Override
-  public Connection createConnection(ConnectionInfo info) throws Exception {
+  public Connection getConnection(ConnectionInfo info) throws Exception {
     Connection conn = cache.get(info);
     if (conn == null) {
-      conn = delegate.createConnection(info);
+      conn = delegate.getConnection(info);
       cache.put(info, conn);
     }
     return new NonClosableConnection(conn);
@@ -57,8 +57,8 @@ public class MultiConnectionCachingFactory implements CachingConnectionFactory
{
   /**
    * Closes all active connections in the cache.
    */
-  public void close() throws SQLException {
-    for (Connection conn:cache.values()) {
+  public void closeConnections() throws SQLException {
+    for (Connection conn : cache.values()) {
       conn.close();
     }
   }

http://git-wip-us.apache.org/repos/asf/drill/blob/31c9867a/exec/jdbc/src/test/java/org/apache/drill/jdbc/NonClosableConnection.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/NonClosableConnection.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/NonClosableConnection.java
index 1e37700..d119ec8 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/NonClosableConnection.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/NonClosableConnection.java
@@ -39,9 +39,9 @@ import java.util.concurrent.Executor;
 import parquet.Preconditions;
 
 /**
- * A connection decorator that ignores {@link java.sql.Connection#close} calls.
+ * A connection decorator that ignores {@link Connection#close} calls.
  *
- * All other calls are delegated to inner {@link java.sql.Connection connection}.
+ * All other calls are delegated to inner {@link Connection connection}.
  */
 public final class NonClosableConnection implements Connection {
   private final Connection delegate;

http://git-wip-us.apache.org/repos/asf/drill/blob/31c9867a/exec/jdbc/src/test/java/org/apache/drill/jdbc/SingleConnectionCachingFactory.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/SingleConnectionCachingFactory.java
b/exec/jdbc/src/test/java/org/apache/drill/jdbc/SingleConnectionCachingFactory.java
index e5be105..7e3a51b 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/SingleConnectionCachingFactory.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/SingleConnectionCachingFactory.java
@@ -23,7 +23,9 @@ import java.sql.SQLException;
 /**
  * A connection factory that creates and caches a single connection instance.
  *
- * Not thread safe.
+ * <p>
+ *   Not thread safe.
+ * </p>
  */
 public class SingleConnectionCachingFactory implements CachingConnectionFactory {
 
@@ -34,10 +36,18 @@ public class SingleConnectionCachingFactory implements CachingConnectionFactory
     this.delegate = delegate;
   }
 
+  /**
+   * {@inheritDoc}
+   * <p>
+   *   For this implementation, calls to {@code createConnection} without any
+   *   intervening calls to {@link closeConnection} return the same Connection
+   *   instance.
+   * </p>
+   */
   @Override
-  public Connection createConnection(ConnectionInfo info) throws Exception {
+  public Connection getConnection(ConnectionInfo info) throws Exception {
     if (connection == null) {
-      connection = delegate.createConnection(info);
+      connection = delegate.getConnection(info);
     } else {
       JdbcTest.changeSchemaIfSupplied(connection, info.getParamsAsProperties());
     }
@@ -45,7 +55,7 @@ public class SingleConnectionCachingFactory implements CachingConnectionFactory
   }
 
   @Override
-  public void close() throws SQLException {
+  public void closeConnections() throws SQLException {
     if (connection != null) {
       connection.close();
       connection = null;

http://git-wip-us.apache.org/repos/asf/drill/blob/31c9867a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcAssert.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcAssert.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcAssert.java
index f7ecf0a..84e05e6 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcAssert.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/JdbcAssert.java
@@ -160,7 +160,7 @@ public class JdbcAssert {
       this.info = info;
       this.adapter = new ConnectionFactoryAdapter() {
         public Connection createConnection() throws Exception {
-          return factory.createConnection(new ConnectionInfo("jdbc:drill:zk=local", ModelAndSchema.this.info));
+          return factory.getConnection(new ConnectionInfo("jdbc:drill:zk=local", ModelAndSchema.this.info));
         }
       };
     }


Mime
View raw message