[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 <dmitry.lychagin@couchbase.com>
Reviewed-by: Michael Blow <mblow@apache.org>
Tested-by: Dmitry Lychagin <dmitry.lychagin@couchbase.com>
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.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 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 @@
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 @@
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 @@
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 @@
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 @@
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;
})