This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch dev/1.3
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/dev/1.3 by this push:
new b83a32f6a91 [To dev/1.3] Print current trusted_uri_pattern is error msg
b83a32f6a91 is described below
commit b83a32f6a912bcbb7dde0182bce1ca9533f5a1e9
Author: Jackie Tien <[email protected]>
AuthorDate: Thu Dec 26 19:52:16 2024 +0800
[To dev/1.3] Print current trusted_uri_pattern is error msg
---
.../ainode/iotdb/ainode/model/model_factory.py | 2 -
.../org/apache/iotdb/db/conf/IoTDBDescriptor.java | 92 ++++++++++++----------
.../plan/execution/config/ConfigTaskVisitor.java | 10 ++-
.../db/queryengine/plan/parser/ASTVisitor.java | 2 +-
.../commons/executable/ExecutableManager.java | 6 ++
5 files changed, 65 insertions(+), 47 deletions(-)
diff --git a/iotdb-core/ainode/iotdb/ainode/model/model_factory.py
b/iotdb-core/ainode/iotdb/ainode/model/model_factory.py
index 8d02e9f0542..a163cf1fa84 100644
--- a/iotdb-core/ainode/iotdb/ainode/model/model_factory.py
+++ b/iotdb-core/ainode/iotdb/ainode/model/model_factory.py
@@ -44,8 +44,6 @@ def _parse_uri(uri):
is_network_path (bool): True if the url is a network path, False
otherwise
parsed_uri (str): parsed uri to get related file
"""
- # remove quotation mark in uri
- uri = uri[1:-1]
parse_result = urlparse(uri)
is_network_path = parse_result.scheme in ('http', 'https')
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
index d3a840959e6..578c494a9cf 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
@@ -1096,6 +1096,11 @@ public class IoTDBDescriptor {
loadIoTConsensusProps(properties);
loadPipeConsensusProps(properties);
+
+ // update query_sample_throughput_bytes_per_sec
+ loadQuerySampleThroughput(properties);
+ // update trusted_uri_pattern
+ loadTrustedUriPattern(properties);
}
private void reloadConsensusProps(TrimProperties properties) throws
IOException {
@@ -2019,47 +2024,9 @@ public class IoTDBDescriptor {
}
// update query_sample_throughput_bytes_per_sec
- String querySamplingRateLimitNumber =
- Optional.ofNullable(
- properties.getProperty(
- "query_sample_throughput_bytes_per_sec",
- ConfigurationFileUtils.getConfigurationDefaultValue(
- "query_sample_throughput_bytes_per_sec")))
- .map(String::trim)
- .orElse(
- ConfigurationFileUtils.getConfigurationDefaultValue(
- "query_sample_throughput_bytes_per_sec"));
- if (querySamplingRateLimitNumber != null) {
- try {
- int rateLimit = Integer.parseInt(querySamplingRateLimitNumber);
- commonDescriptor.getConfig().setQuerySamplingRateLimit(rateLimit);
- } catch (Exception e) {
- LOGGER.warn(
- "Failed to parse query_sample_throughput_bytes_per_sec {} to
integer",
- querySamplingRateLimitNumber);
- }
- }
-
+ loadQuerySampleThroughput(properties);
// update trusted_uri_pattern
- String trustedUriPattern =
- Optional.ofNullable(
- properties.getProperty(
- "trusted_uri_pattern",
-
ConfigurationFileUtils.getConfigurationDefaultValue("trusted_uri_pattern")))
- .map(String::trim)
-
.orElse(ConfigurationFileUtils.getConfigurationDefaultValue("trusted_uri_pattern"));
- Pattern pattern;
- if (trustedUriPattern != null) {
- try {
- pattern = Pattern.compile(trustedUriPattern);
- } catch (Exception e) {
- LOGGER.warn("Failed to parse trusted_uri_pattern {}",
trustedUriPattern);
- pattern = commonDescriptor.getConfig().getTrustedUriPattern();
- }
- } else {
- pattern = commonDescriptor.getConfig().getTrustedUriPattern();
- }
- commonDescriptor.getConfig().setTrustedUriPattern(pattern);
+ loadTrustedUriPattern(properties);
} catch (Exception e) {
if (e instanceof InterruptedException) {
@@ -2069,6 +2036,51 @@ public class IoTDBDescriptor {
}
}
+ private void loadQuerySampleThroughput(TrimProperties properties) throws
IOException {
+ String querySamplingRateLimitNumber =
+ Optional.ofNullable(
+ properties.getProperty(
+ "query_sample_throughput_bytes_per_sec",
+ ConfigurationFileUtils.getConfigurationDefaultValue(
+ "query_sample_throughput_bytes_per_sec")))
+ .map(String::trim)
+ .orElse(
+ ConfigurationFileUtils.getConfigurationDefaultValue(
+ "query_sample_throughput_bytes_per_sec"));
+ if (querySamplingRateLimitNumber != null) {
+ try {
+ int rateLimit = Integer.parseInt(querySamplingRateLimitNumber);
+ commonDescriptor.getConfig().setQuerySamplingRateLimit(rateLimit);
+ } catch (Exception e) {
+ LOGGER.warn(
+ "Failed to parse query_sample_throughput_bytes_per_sec {} to
integer",
+ querySamplingRateLimitNumber);
+ }
+ }
+ }
+
+ private void loadTrustedUriPattern(TrimProperties properties) throws
IOException {
+ String trustedUriPattern =
+ Optional.ofNullable(
+ properties.getProperty(
+ "trusted_uri_pattern",
+
ConfigurationFileUtils.getConfigurationDefaultValue("trusted_uri_pattern")))
+ .map(String::trim)
+
.orElse(ConfigurationFileUtils.getConfigurationDefaultValue("trusted_uri_pattern"));
+ Pattern pattern;
+ if (trustedUriPattern != null) {
+ try {
+ pattern = Pattern.compile(trustedUriPattern);
+ } catch (Exception e) {
+ LOGGER.warn("Failed to parse trusted_uri_pattern {}",
trustedUriPattern);
+ pattern = commonDescriptor.getConfig().getTrustedUriPattern();
+ }
+ } else {
+ pattern = commonDescriptor.getConfig().getTrustedUriPattern();
+ }
+ commonDescriptor.getConfig().setTrustedUriPattern(pattern);
+ }
+
public synchronized void loadHotModifiedProps() throws QueryProcessException
{
URL url = getPropsUrl(CommonConfig.SYSTEM_CONFIG_NAME);
if (url == null) {
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigTaskVisitor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigTaskVisitor.java
index 2f3b758e77a..91b539ee4ab 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigTaskVisitor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigTaskVisitor.java
@@ -172,6 +172,7 @@ import
org.apache.iotdb.db.queryengine.plan.statement.sys.quota.ShowThrottleQuot
import org.apache.tsfile.exception.NotImplementedException;
+import static
org.apache.iotdb.commons.executable.ExecutableManager.getUnTrustedUriErrorMsg;
import static
org.apache.iotdb.commons.executable.ExecutableManager.isUriTrusted;
public class ConfigTaskVisitor extends StatementVisitor<IConfigTask,
MPPQueryContext> {
@@ -327,7 +328,7 @@ public class ConfigTaskVisitor extends
StatementVisitor<IConfigTask, MPPQueryCon
return new CreateFunctionTask(createFunctionStatement);
} else {
// user specified uri and that uri is not trusted
- throw new SemanticException("Untrusted uri " +
createFunctionStatement.getUriString());
+ throw new
SemanticException(getUnTrustedUriErrorMsg(createFunctionStatement.getUriString()));
}
}
@@ -354,7 +355,7 @@ public class ConfigTaskVisitor extends
StatementVisitor<IConfigTask, MPPQueryCon
return new CreateTriggerTask(createTriggerStatement);
} else {
// user specified uri and that uri is not trusted
- throw new SemanticException("Untrusted uri " +
createTriggerStatement.getUriString());
+ throw new
SemanticException(getUnTrustedUriErrorMsg(createTriggerStatement.getUriString()));
}
}
@@ -380,7 +381,8 @@ public class ConfigTaskVisitor extends
StatementVisitor<IConfigTask, MPPQueryCon
return new CreatePipePluginTask(createPipePluginStatement);
} else {
// user specified uri and that uri is not trusted
- throw new SemanticException("Untrusted uri " +
createPipePluginStatement.getUriString());
+ throw new SemanticException(
+ getUnTrustedUriErrorMsg(createPipePluginStatement.getUriString()));
}
}
@@ -633,7 +635,7 @@ public class ConfigTaskVisitor extends
StatementVisitor<IConfigTask, MPPQueryCon
return new CreateModelTask(createModelStatement, context);
} else {
// user specified uri and that uri is not trusted
- throw new SemanticException("Untrusted uri " +
createModelStatement.getUri());
+ throw new
SemanticException(getUnTrustedUriErrorMsg(createModelStatement.getUri()));
}
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
index a498efbac47..570d9b00fe9 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
@@ -1327,7 +1327,7 @@ public class ASTVisitor extends
IoTDBSqlParserBaseVisitor<Statement> {
String modelName = ctx.modelName.getText();
validateModelName(modelName);
createModelStatement.setModelName(parseIdentifier(modelName));
- createModelStatement.setUri(ctx.uriClause().uri().getText());
+ createModelStatement.setUri(parseAndValidateURI(ctx.uriClause()));
return createModelStatement;
}
diff --git
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/executable/ExecutableManager.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/executable/ExecutableManager.java
index b00276db38a..093e09415ad 100644
---
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/executable/ExecutableManager.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/executable/ExecutableManager.java
@@ -287,4 +287,10 @@ public class ExecutableManager {
public static boolean isUriTrusted(String uri) {
return
CommonDescriptor.getInstance().getConfig().getTrustedUriPattern().matcher(uri).matches();
}
+
+ public static String getUnTrustedUriErrorMsg(String uri) {
+ return String.format(
+ "Untrusted uri %s, current trusted_uri_pattern is %s",
+ uri,
CommonDescriptor.getInstance().getConfig().getTrustedUriPattern());
+ }
}