zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zjf...@apache.org
Subject zeppelin git commit: [ZEPPELIN-3712] Add `maxConnLifetime` parameter to JDBC Interpreter
Date Tue, 18 Sep 2018 00:26:52 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/branch-0.8 4cb60f4a4 -> 7856e8859


[ZEPPELIN-3712] Add `maxConnLifetime` parameter to JDBC Interpreter

This parameter is necessary in that case:
1) Zeppelin open connection and keep it in pool;
2) Database close this connection after some time of inactivity;
3) User get an error and necessity to restart interpreter when he runs a paragraph.

The default value of this parameter is `-1` which means the connection has an infinite lifetime.

Improvement

[ZEPPELIN-3712](https://issues.apache.org/jira/browse/ZEPPELIN-3712)

* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Author: oxygen311 <alex39-09@mail.ru>

Closes #3139 from oxygen311/DW-17882 and squashes the following commits:

cbf6c8681 [oxygen311] Add `zeppelin.jdbc.maxConnLifetime` property description to docs
c86241147 [oxygen311] Add `maxConnLifetime` property

(cherry picked from commit 6fac6cd157a71c68f280efe7fd70793dd1f650c1)
Signed-off-by: Jeff Zhang <zjffdu@apache.org>


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

Branch: refs/heads/branch-0.8
Commit: 7856e8859f4e6cd12b904412981146dcd13399ee
Parents: 4cb60f4
Author: oxygen311 <alex39-09@mail.ru>
Authored: Wed Aug 15 17:00:55 2018 +0200
Committer: Jeff Zhang <zjffdu@apache.org>
Committed: Tue Sep 18 08:26:41 2018 +0800

----------------------------------------------------------------------
 docs/interpreter/jdbc.md                                      | 4 ++++
 .../main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java   | 5 ++++-
 jdbc/src/main/resources/interpreter-setting.json              | 7 +++++++
 3 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7856e885/docs/interpreter/jdbc.md
----------------------------------------------------------------------
diff --git a/docs/interpreter/jdbc.md b/docs/interpreter/jdbc.md
index 5a8ffc9..b0f5d6b 100644
--- a/docs/interpreter/jdbc.md
+++ b/docs/interpreter/jdbc.md
@@ -201,6 +201,10 @@ There are more JDBC interpreter properties you can specify like below.
     <td>zeppelin.jdbc.interpolation</td>
     <td>Enables ZeppelinContext variable interpolation into paragraph text. Default
value is false.</td>
   </tr>
+  <tr>
+    <td>zeppelin.jdbc.maxConnLifetime</td>
+    <td>Maximum of connection lifetime in milliseconds. A value of zero or less means
the connection has an infinite lifetime.</td>
+  </tr>
 </table>
 
 You can also add more properties by using this [method](http://docs.oracle.com/javase/7/docs/api/java/sql/DriverManager.html#getConnection%28java.lang.String,%20java.util.Properties%29).

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7856e885/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
----------------------------------------------------------------------
diff --git a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
index 7ccf749..95fe2db 100644
--- a/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
+++ b/jdbc/src/main/java/org/apache/zeppelin/jdbc/JDBCInterpreter.java
@@ -390,7 +390,10 @@ public class JDBCInterpreter extends KerberosInterpreter {
       new DriverManagerConnectionFactory(url, properties);
 
     PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(
-      connectionFactory, null);
+        connectionFactory, null);
+    final String maxConnectionLifetime =
+        StringUtils.defaultIfEmpty(getProperty("zeppelin.jdbc.maxConnLifetime"), "-1");
+    poolableConnectionFactory.setMaxConnLifetimeMillis(Long.parseLong(maxConnectionLifetime));
     ObjectPool connectionPool = new GenericObjectPool(poolableConnectionFactory);
 
     poolableConnectionFactory.setPool(connectionPool);

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/7856e885/jdbc/src/main/resources/interpreter-setting.json
----------------------------------------------------------------------
diff --git a/jdbc/src/main/resources/interpreter-setting.json b/jdbc/src/main/resources/interpreter-setting.json
index 04262d9..7e9dd66 100644
--- a/jdbc/src/main/resources/interpreter-setting.json
+++ b/jdbc/src/main/resources/interpreter-setting.json
@@ -114,6 +114,13 @@
         "defaultValue": false,
         "description": "Enable ZeppelinContext variable interpolation into paragraph text",
         "type": "checkbox"
+      },
+      "zeppelin.jdbc.maxConnLifetime": {
+        "envName": null,
+        "propertyName": "zeppelin.jdbc.maxConnLifetime",
+        "defaultValue": "-1",
+        "description": "Maximum of connection lifetime in milliseconds. A value of zero or
less means the connection has an infinite lifetime.",
+        "type": "number"
       }
     },
     "editor": {


Mime
View raw message