You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by dl...@apache.org on 2021/10/12 16:04:44 UTC

[asterixdb-clients] branch master updated: [NO ISSUE][JDBC] Configurable running requests path

This is an automated email from the ASF dual-hosted git repository.

dlych pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb-clients.git


The following commit(s) were added to refs/heads/master by this push:
     new ea55292  [NO ISSUE][JDBC] Configurable running requests path
ea55292 is described below

commit ea5529264ba0fc115bf640721e9ae42272162ba5
Author: Dmitry Lychagin <dm...@couchbase.com>
AuthorDate: Mon Oct 11 15:40:15 2021 -0700

    [NO ISSUE][JDBC] Configurable running requests path
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Details:
    - Make running requests path configurable by JDBC driver property
    - The default path is /admin/requests/running
    
    Change-Id: Iffa9ea0c302f15c062719d360152fdad21a02bdd
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb-clients/+/13646
    Reviewed-by: Dmitry Lychagin <dm...@couchbase.com>
    Reviewed-by: Michael Blow <mb...@apache.org>
    Tested-by: Dmitry Lychagin <dm...@couchbase.com>
---
 .../apache/asterix/jdbc/core/ADBDriverBase.java    | 15 +++++++----
 .../asterix/jdbc/core/ADBDriverProperty.java       | 31 +++++++++++++++-------
 .../org/apache/asterix/jdbc/core/ADBProtocol.java  |  7 ++---
 asterixdb-jdbc/asterix-jdbc-taco/pom.xml           |  1 +
 .../plugins/asterixdb_jdbc/connectionProperties.js |  1 +
 5 files changed, 38 insertions(+), 17 deletions(-)

diff --git a/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBDriverBase.java b/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBDriverBase.java
index 315f270..46f9705 100644
--- a/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBDriverBase.java
+++ b/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBDriverBase.java
@@ -27,6 +27,7 @@ import java.sql.DriverManager;
 import java.sql.DriverPropertyInfo;
 import java.sql.SQLException;
 import java.sql.SQLWarning;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Enumeration;
@@ -182,13 +183,17 @@ public abstract class ADBDriverBase {
 
     public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) {
         Collection<ADBDriverProperty> supportedProperties = getOrCreateDriverContext().supportedProperties.values();
-        DriverPropertyInfo[] result = new DriverPropertyInfo[supportedProperties.size()];
-        int i = 0;
+        List<DriverPropertyInfo> result = new ArrayList<>(supportedProperties.size());
         for (ADBDriverProperty property : supportedProperties) {
-            result[i++] = new DriverPropertyInfo(property.getPropertyName(),
-                    property.getDefaultValue() != null ? property.getDefaultValue().toString() : null);
+            if (property.isHidden()) {
+                continue;
+            }
+            Object defaultValue = property.getDefaultValue();
+            DriverPropertyInfo propInfo = new DriverPropertyInfo(property.getPropertyName(),
+                    defaultValue != null ? defaultValue.toString() : null);
+            result.add(propInfo);
         }
-        return result;
+        return result.toArray(new DriverPropertyInfo[0]);
     }
 
     public int getMajorVersion() {
diff --git a/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBDriverProperty.java b/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBDriverProperty.java
index 37cf57e..7312861 100644
--- a/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBDriverProperty.java
+++ b/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBDriverProperty.java
@@ -31,16 +31,19 @@ public interface ADBDriverProperty {
 
     Object getDefaultValue();
 
+    boolean isHidden();
+
     enum Common implements ADBDriverProperty {
 
-        USER("user", Function.identity(), null),
-        PASSWORD("password", Function.identity(), null),
-        CONNECT_TIMEOUT("connectTimeout", Integer::parseInt, null),
-        SOCKET_TIMEOUT("socketTimeout", Integer::parseInt, null),
-        MAX_WARNINGS("maxWarnings", Integer::parseInt, 10),
-        CATALOG_DATAVERSE_MODE("catalogDataverseMode", Integer::parseInt, 1), // 1 -> CATALOG, 2 -> CATALOG_SCHEMA
-        CATALOG_INCLUDES_SCHEMALESS("catalogIncludesSchemaless", Boolean::parseBoolean, false),
-        SQL_COMPAT_MODE("sqlCompatMode", Boolean::parseBoolean, true); // Whether user statements are executed in 'SQL-compat' mode
+        USER("user", Function.identity(), null, false),
+        PASSWORD("password", Function.identity(), null, false),
+        CONNECT_TIMEOUT("connectTimeout", Integer::parseInt, null, false),
+        SOCKET_TIMEOUT("socketTimeout", Integer::parseInt, null, false),
+        MAX_WARNINGS("maxWarnings", Integer::parseInt, 10, false),
+        CATALOG_DATAVERSE_MODE("catalogDataverseMode", Integer::parseInt, 1, false), // 1 -> CATALOG, 2 -> CATALOG_SCHEMA
+        CATALOG_INCLUDES_SCHEMALESS("catalogIncludesSchemaless", Boolean::parseBoolean, false, false),
+        SQL_COMPAT_MODE("sqlCompatMode", Boolean::parseBoolean, true, false), // Whether user statements are executed in 'SQL-compat' mode
+        ACTIVE_REQUESTS_PATH("activeRequestsPath", Function.identity(), null, true);
 
         private final String propertyName;
 
@@ -48,10 +51,13 @@ public interface ADBDriverProperty {
 
         private final Object defaultValue;
 
-        Common(String propertyName, Function<String, ?> valueParser, Object defaultValue) {
+        private final boolean isHidden;
+
+        Common(String propertyName, Function<String, ?> valueParser, Object defaultValue, boolean isHidden) {
             this.propertyName = Objects.requireNonNull(propertyName);
             this.valueParser = Objects.requireNonNull(valueParser);
             this.defaultValue = defaultValue;
+            this.isHidden = isHidden;
         }
 
         @Override
@@ -59,15 +65,22 @@ public interface ADBDriverProperty {
             return propertyName;
         }
 
+        @Override
         public Function<String, ?> getValueParser() {
             return valueParser;
         }
 
+        @Override
         public Object getDefaultValue() {
             return defaultValue;
         }
 
         @Override
+        public boolean isHidden() {
+            return isHidden;
+        }
+
+        @Override
         public String toString() {
             return getPropertyName();
         }
diff --git a/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBProtocol.java b/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBProtocol.java
index 119b5bb..cc31c7f 100644
--- a/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBProtocol.java
+++ b/asterixdb-jdbc/asterix-jdbc-core/src/main/java/org/apache/asterix/jdbc/core/ADBProtocol.java
@@ -132,7 +132,7 @@ public class ADBProtocol {
         URI queryResultEndpoint =
                 createEndpointUri(host, port, getQueryResultEndpointPath(), driverContext.errorReporter);
         URI activeRequestsEndpoint =
-                createEndpointUri(host, port, getActiveRequestsEndpointPath(), driverContext.errorReporter);
+                createEndpointUri(host, port, getActiveRequestsEndpointPath(params), driverContext.errorReporter);
         PoolingHttpClientConnectionManager httpConnectionManager = new PoolingHttpClientConnectionManager();
         int maxConnections = Math.max(16, Runtime.getRuntime().availableProcessors());
         httpConnectionManager.setDefaultMaxPerRoute(maxConnections);
@@ -605,8 +605,9 @@ public class ADBProtocol {
         return QUERY_RESULT_ENDPOINT_PATH;
     }
 
-    protected String getActiveRequestsEndpointPath() {
-        return ACTIVE_REQUESTS_ENDPOINT_PATH;
+    protected String getActiveRequestsEndpointPath(Map<ADBDriverProperty, Object> params) {
+        String path = (String) ADBDriverProperty.Common.ACTIVE_REQUESTS_PATH.fetchPropertyValue(params);
+        return path != null ? path : ACTIVE_REQUESTS_ENDPOINT_PATH;
     }
 
     private static void closeQuietly(Exception mainExc, java.io.Closeable... closeableList) {
diff --git a/asterixdb-jdbc/asterix-jdbc-taco/pom.xml b/asterixdb-jdbc/asterix-jdbc-taco/pom.xml
index 240e525..552e444 100644
--- a/asterixdb-jdbc/asterix-jdbc-taco/pom.xml
+++ b/asterixdb-jdbc/asterix-jdbc-taco/pom.xml
@@ -60,6 +60,7 @@
     <taco.plugin.database.default>Default</taco.plugin.database.default>
     <taco.plugin.table.label>Dataset</taco.plugin.table.label>
     <taco.plugin.jdbc.scheme>jdbc:asterixdb://</taco.plugin.jdbc.scheme>
+    <taco.plugin.jdbc.properties.aux> </taco.plugin.jdbc.properties.aux>
     <taco.plugin.auth.none><![CDATA[<option value="auth-none" label="No Authentication"/>]]></taco.plugin.auth.none>
   </properties>
 
diff --git a/asterixdb-jdbc/asterix-jdbc-taco/src/main/taco/plugins/asterixdb_jdbc/connectionProperties.js b/asterixdb-jdbc/asterix-jdbc-taco/src/main/taco/plugins/asterixdb_jdbc/connectionProperties.js
index 92058c7..42265f7 100644
--- a/asterixdb-jdbc/asterix-jdbc-taco/src/main/taco/plugins/asterixdb_jdbc/connectionProperties.js
+++ b/asterixdb-jdbc/asterix-jdbc-taco/src/main/taco/plugins/asterixdb_jdbc/connectionProperties.js
@@ -20,5 +20,6 @@
     var props = {};
     props["user"] = attr[connectionHelper.attributeUsername];
     props["password"] = attr[connectionHelper.attributePassword];
+    ${taco.plugin.jdbc.properties.aux}
     return props;
 })