You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by sh...@apache.org on 2025/08/29 02:22:27 UTC
(iotdb) branch showConfigurationSQL created (now 895410e5951)
This is an automated email from the ASF dual-hosted git repository.
shuwenwei pushed a change to branch showConfigurationSQL
in repository https://gitbox.apache.org/repos/asf/iotdb.git
at 895410e5951 add enum
This branch includes the following new commits:
new ccb68fef9a7 add sql
new 62aa4d6f79e Merge branch 'master' into showConfigurationSQL
new 895410e5951 add enum
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(iotdb) 01/03: add sql
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuwenwei pushed a commit to branch showConfigurationSQL
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit ccb68fef9a7d2bd55ab62c4214ff13f69a21edec
Author: shuwenwei <s1...@gmail.com>
AuthorDate: Thu Aug 28 21:57:09 2025 +0800
add sql
---
.../confignode/client/CnToCnNodeRequestType.java | 1 +
.../client/sync/CnToDnSyncRequestType.java | 1 +
.../client/sync/SyncConfigNodeClientPool.java | 2 +
.../client/sync/SyncDataNodeClientPool.java | 3 +
.../confignode/conf/ConfigNodeDescriptor.java | 6 +-
.../iotdb/confignode/manager/ConfigManager.java | 18 +++
.../apache/iotdb/confignode/manager/IManager.java | 4 +
.../iotdb/confignode/manager/node/NodeManager.java | 34 ++++++
.../thrift/ConfigNodeRPCServiceProcessor.java | 6 +
.../org/apache/iotdb/db/conf/IoTDBDescriptor.java | 3 +-
.../iotdb/db/protocol/client/ConfigNodeClient.java | 8 ++
.../impl/DataNodeInternalRPCServiceImpl.java | 14 +++
.../iotdb/db/queryengine/plan/Coordinator.java | 2 +
.../execution/config/TableConfigTaskVisitor.java | 10 ++
.../execution/config/TreeConfigTaskVisitor.java | 8 ++
.../config/executor/ClusterConfigTaskExecutor.java | 36 ++++++
.../config/executor/IConfigTaskExecutor.java | 4 +
.../config/sys/ShowConfigurationTask.java | 99 +++++++++++++++
.../plan/relational/sql/ast/AstVisitor.java | 4 +
.../relational/sql/ast/ShowConfiguration.java} | 28 ++---
.../plan/relational/sql/parser/AstBuilder.java | 16 +++
.../plan/statement/StatementVisitor.java | 6 +
.../statement/sys/ShowConfigurationStatement.java | 70 +++++++++++
.../iotdb/commons/conf/ConfigurationFileUtils.java | 133 ++++++++++++++++-----
.../schema/column/ColumnHeaderConstant.java | 18 +++
.../db/relational/grammar/sql/RelationalSql.g4 | 5 +
.../thrift-commons/src/main/thrift/common.thrift | 5 +
.../src/main/thrift/confignode.thrift | 3 +
.../src/main/thrift/datanode.thrift | 2 +
29 files changed, 503 insertions(+), 46 deletions(-)
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/CnToCnNodeRequestType.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/CnToCnNodeRequestType.java
index e422e45dff0..80941872320 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/CnToCnNodeRequestType.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/CnToCnNodeRequestType.java
@@ -30,6 +30,7 @@ public enum CnToCnNodeRequestType {
STOP_AND_CLEAR_CONFIG_NODE,
SET_CONFIGURATION,
SHOW_CONFIGURATION,
+ SHOW_APPLIED_CONFIGURATIONS,
SUBMIT_TEST_CONNECTION_TASK,
TEST_CONNECTION,
}
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/CnToDnSyncRequestType.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/CnToDnSyncRequestType.java
index 21263612af2..4055398ddb7 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/CnToDnSyncRequestType.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/CnToDnSyncRequestType.java
@@ -25,6 +25,7 @@ public enum CnToDnSyncRequestType {
STOP_AND_CLEAR_DATA_NODE,
SET_SYSTEM_STATUS,
SHOW_CONFIGURATION,
+ SHOW_APPLIED_CONFIGURATIONS,
// Region Maintenance
CREATE_DATA_REGION,
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java
index 6282924d0a0..96c9f775526 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncConfigNodeClientPool.java
@@ -98,6 +98,8 @@ public class SyncConfigNodeClientPool {
return client.submitTestConnectionTask((TNodeLocations) req);
case TEST_CONNECTION:
return client.testConnectionEmptyRPC();
+ case SHOW_APPLIED_CONFIGURATIONS:
+ return client.showAppliedConfigurations((int) req);
default:
return RpcUtils.getStatus(
TSStatusCode.EXECUTE_STATEMENT_ERROR, "Unknown request type: " + requestType);
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java
index 9a063900c0e..902793ffbb4 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/sync/SyncDataNodeClientPool.java
@@ -135,6 +135,9 @@ public class SyncDataNodeClientPool {
(req, client) -> client.resetPeerList((TResetPeerListReq) req));
actionMapBuilder.put(
CnToDnSyncRequestType.SHOW_CONFIGURATION, (req, client) -> client.showConfiguration());
+ actionMapBuilder.put(
+ CnToDnSyncRequestType.SHOW_APPLIED_CONFIGURATIONS,
+ (req, client) -> client.showAppliedConfigurations());
actionMap = actionMapBuilder.build();
}
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java
index f26ec199d8f..64b71199eb7 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java
@@ -147,7 +147,7 @@ public class ConfigNodeDescriptor {
}
private void loadProperties(TrimProperties properties) throws BadNodeUrlException, IOException {
- conf.setClusterName(properties.getProperty(IoTDBConstant.CLUSTER_NAME, conf.getClusterName()));
+ loadHotModifiedProps(properties);
conf.setInternalAddress(
properties.getProperty(IoTDBConstant.CN_INTERNAL_ADDRESS, conf.getInternalAddress()));
@@ -765,8 +765,8 @@ public class ConfigNodeDescriptor {
}
public void loadHotModifiedProps(TrimProperties properties) {
- Optional.ofNullable(properties.getProperty(IoTDBConstant.CLUSTER_NAME))
- .ifPresent(conf::setClusterName);
+ ConfigurationFileUtils.updateLastAppliedProperties(properties);
+ conf.setClusterName(properties.getProperty(IoTDBConstant.CLUSTER_NAME, conf.getClusterName()));
}
public static ConfigNodeDescriptor getInstance() {
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
index 3071830be60..d0f77f613d2 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/ConfigManager.java
@@ -37,6 +37,7 @@ import org.apache.iotdb.common.rpc.thrift.TSeriesPartitionSlot;
import org.apache.iotdb.common.rpc.thrift.TSetConfigurationReq;
import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq;
import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq;
+import org.apache.iotdb.common.rpc.thrift.TShowAppliedConfigurationsResp;
import org.apache.iotdb.common.rpc.thrift.TShowConfigurationResp;
import org.apache.iotdb.common.rpc.thrift.TTimePartitionSlot;
import org.apache.iotdb.commons.auth.AuthException;
@@ -1789,6 +1790,23 @@ public class ConfigManager implements IManager {
: new TShowConfigurationResp(status, "");
}
+ public TShowAppliedConfigurationsResp showAppliedConfigurations(int nodeId) {
+ if (ConfigNodeDescriptor.getInstance().getConf().getConfigNodeId() == nodeId) {
+ TShowAppliedConfigurationsResp resp = new TShowAppliedConfigurationsResp();
+ resp.setStatus(RpcUtils.SUCCESS_STATUS);
+ try {
+ resp.setData(ConfigurationFileUtils.getLastAppliedProperties());
+ } catch (Exception e) {
+ resp.setStatus(RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR, e.getMessage()));
+ }
+ return resp;
+ }
+ TSStatus status = confirmLeader();
+ return status.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
+ ? nodeManager.showAppliedConfigurations(nodeId)
+ : new TShowAppliedConfigurationsResp(status, null);
+ }
+
@Override
public TSStatus setSystemStatus(String systemStatus) {
TSStatus status = confirmLeader();
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java
index bc080198cb6..7402d29673d 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/IManager.java
@@ -27,6 +27,7 @@ import org.apache.iotdb.common.rpc.thrift.TSStatus;
import org.apache.iotdb.common.rpc.thrift.TSeriesPartitionSlot;
import org.apache.iotdb.common.rpc.thrift.TSetConfigurationReq;
import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq;
+import org.apache.iotdb.common.rpc.thrift.TShowAppliedConfigurationsResp;
import org.apache.iotdb.common.rpc.thrift.TShowConfigurationResp;
import org.apache.iotdb.commons.auth.entity.PrivilegeUnion;
import org.apache.iotdb.commons.cluster.NodeStatus;
@@ -598,6 +599,9 @@ public interface IManager {
/** Show content of configuration file on specified node */
TShowConfigurationResp showConfiguration(int nodeId);
+ /** Show configuration on specified node by TsBlock */
+ TShowAppliedConfigurationsResp showAppliedConfigurations(int nodeId);
+
/** Set system status on all DataNodes. */
TSStatus setSystemStatus(String status);
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java
index 15f05f2ba06..716722817ac 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java
@@ -27,6 +27,7 @@ import org.apache.iotdb.common.rpc.thrift.TFlushReq;
import org.apache.iotdb.common.rpc.thrift.TRegionReplicaSet;
import org.apache.iotdb.common.rpc.thrift.TSStatus;
import org.apache.iotdb.common.rpc.thrift.TSetConfigurationReq;
+import org.apache.iotdb.common.rpc.thrift.TShowAppliedConfigurationsResp;
import org.apache.iotdb.common.rpc.thrift.TShowConfigurationResp;
import org.apache.iotdb.commons.cluster.NodeStatus;
import org.apache.iotdb.commons.cluster.NodeType;
@@ -1124,6 +1125,39 @@ public class NodeManager {
return resp;
}
+ public TShowAppliedConfigurationsResp showAppliedConfigurations(int nodeId) {
+ TShowAppliedConfigurationsResp resp = new TShowAppliedConfigurationsResp();
+
+ // data node
+ Map<Integer, TDataNodeLocation> dataNodeLocationMap =
+ configManager.getNodeManager().getRegisteredDataNodeLocations();
+ if (dataNodeLocationMap.containsKey(nodeId)) {
+ TDataNodeLocation dataNodeLocation = dataNodeLocationMap.get(nodeId);
+ return (TShowAppliedConfigurationsResp)
+ SyncDataNodeClientPool.getInstance()
+ .sendSyncRequestToDataNodeWithRetry(
+ dataNodeLocation.getInternalEndPoint(),
+ null,
+ CnToDnSyncRequestType.SHOW_APPLIED_CONFIGURATIONS);
+ }
+
+ // other config node
+ for (TConfigNodeLocation registeredConfigNode : getRegisteredConfigNodes()) {
+ if (registeredConfigNode.getConfigNodeId() != nodeId) {
+ continue;
+ }
+ resp =
+ (TShowAppliedConfigurationsResp)
+ SyncConfigNodeClientPool.getInstance()
+ .sendSyncRequestToConfigNodeWithRetry(
+ registeredConfigNode.getInternalEndPoint(),
+ nodeId,
+ CnToCnNodeRequestType.SHOW_APPLIED_CONFIGURATIONS);
+ return resp;
+ }
+ return resp;
+ }
+
public List<TSStatus> setSystemStatus(String status) {
Map<Integer, TDataNodeLocation> dataNodeLocationMap =
configManager.getNodeManager().getRegisteredDataNodeLocations();
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java
index 958324c0b51..1267fb1dd30 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/service/thrift/ConfigNodeRPCServiceProcessor.java
@@ -30,6 +30,7 @@ import org.apache.iotdb.common.rpc.thrift.TSetConfigurationReq;
import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq;
import org.apache.iotdb.common.rpc.thrift.TSetTTLReq;
import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq;
+import org.apache.iotdb.common.rpc.thrift.TShowAppliedConfigurationsResp;
import org.apache.iotdb.common.rpc.thrift.TShowConfigurationResp;
import org.apache.iotdb.common.rpc.thrift.TShowTTLReq;
import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp;
@@ -989,6 +990,11 @@ public class ConfigNodeRPCServiceProcessor implements IConfigNodeRPCService.Ifac
return configManager.showConfiguration(nodeId);
}
+ @Override
+ public TShowAppliedConfigurationsResp showAppliedConfigurations(int nodeId) throws TException {
+ return configManager.showAppliedConfigurations(nodeId);
+ }
+
@Override
public TSStatus setSystemStatus(String status) {
return configManager.setSystemStatus(status);
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 738c8f58ec6..2b24ee972af 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
@@ -182,7 +182,7 @@ public class IoTDBDescriptor {
* @return url object if location exit, otherwise null.
*/
public static URL getPropsUrl(String configFileName) {
- String urlString = commonDescriptor.getConfDir();
+ String urlString = "/Users/shuww/IdeaProjects/iotdb2/iotdb-core/datanode/src/test/resources";
if (urlString == null) {
// If urlString wasn't provided, try to find a default config in the root of the classpath.
URL uri = IoTDBConfig.class.getResource("/" + configFileName);
@@ -1961,6 +1961,7 @@ public class IoTDBDescriptor {
public synchronized void loadHotModifiedProps(TrimProperties properties)
throws QueryProcessException {
+ ConfigurationFileUtils.updateLastAppliedProperties(properties);
try {
// update data dirs
String dataDirs = properties.getProperty("dn_data_dirs", null);
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java
index 6a27ad10f93..d977b829d4f 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeClient.java
@@ -31,6 +31,7 @@ import org.apache.iotdb.common.rpc.thrift.TSetConfigurationReq;
import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq;
import org.apache.iotdb.common.rpc.thrift.TSetTTLReq;
import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq;
+import org.apache.iotdb.common.rpc.thrift.TShowAppliedConfigurationsResp;
import org.apache.iotdb.common.rpc.thrift.TShowConfigurationResp;
import org.apache.iotdb.common.rpc.thrift.TShowTTLReq;
import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp;
@@ -818,6 +819,13 @@ public class ConfigNodeClient implements IConfigNodeRPCService.Iface, ThriftClie
() -> client.showConfiguration(nodeId), resp -> !updateConfigNodeLeader(resp.getStatus()));
}
+ @Override
+ public TShowAppliedConfigurationsResp showAppliedConfigurations(int nodeId) throws TException {
+ return executeRemoteCallWithRetry(
+ () -> client.showAppliedConfigurations(nodeId),
+ resp -> !updateConfigNodeLeader(resp.getStatus()));
+ }
+
@Override
public TSStatus setSystemStatus(String systemStatus) throws TException {
return executeRemoteCallWithRetry(
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
index a45bc9b18db..0d08cce15e2 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/DataNodeInternalRPCServiceImpl.java
@@ -35,6 +35,7 @@ import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq;
import org.apache.iotdb.common.rpc.thrift.TSetTTLReq;
import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq;
import org.apache.iotdb.common.rpc.thrift.TSettleReq;
+import org.apache.iotdb.common.rpc.thrift.TShowAppliedConfigurationsResp;
import org.apache.iotdb.common.rpc.thrift.TShowConfigurationResp;
import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp;
import org.apache.iotdb.common.rpc.thrift.TTestConnectionResult;
@@ -2403,6 +2404,19 @@ public class DataNodeInternalRPCServiceImpl implements IDataNodeRPCService.Iface
return resp;
}
+ @Override
+ public TShowAppliedConfigurationsResp showAppliedConfigurations() throws TException {
+ TShowAppliedConfigurationsResp resp = new TShowAppliedConfigurationsResp();
+ resp.setStatus(RpcUtils.SUCCESS_STATUS);
+ try {
+ resp.setData(ConfigurationFileUtils.getLastAppliedProperties());
+
+ } catch (Exception e) {
+ resp.setStatus(RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR, e.getMessage()));
+ }
+ return resp;
+ }
+
@Override
public TSStatus setSystemStatus(String status) throws TException {
try {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java
index ebb843735e9..e9f952f2eed 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java
@@ -97,6 +97,7 @@ import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowAINodes;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCluster;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowClusterId;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowConfigNodes;
+import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowConfiguration;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCurrentDatabase;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCurrentSqlDialect;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCurrentTimestamp;
@@ -436,6 +437,7 @@ public class Coordinator {
|| statement instanceof Flush
|| statement instanceof ClearCache
|| statement instanceof SetConfiguration
+ || statement instanceof ShowConfiguration
|| statement instanceof LoadConfiguration
|| statement instanceof SetSystemStatus
|| statement instanceof StartRepairData
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
index b40096a562d..72e07e6330d 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
@@ -101,6 +101,7 @@ import org.apache.iotdb.db.queryengine.plan.execution.config.sys.KillQueryTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.LoadConfigurationTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.SetConfigurationTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.SetSystemStatusTask;
+import org.apache.iotdb.db.queryengine.plan.execution.config.sys.ShowConfigurationTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.StartRepairDataTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.StopRepairDataTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.pipe.AlterPipeTask;
@@ -177,6 +178,7 @@ import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowAINodes;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCluster;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowClusterId;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowConfigNodes;
+import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowConfiguration;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCurrentDatabase;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCurrentSqlDialect;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCurrentTimestamp;
@@ -212,6 +214,7 @@ import org.apache.iotdb.db.queryengine.plan.statement.sys.FlushStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.LoadConfigurationStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.SetConfigurationStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.SetSystemStatusStatement;
+import org.apache.iotdb.db.queryengine.plan.statement.sys.ShowConfigurationStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.StartRepairDataStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.StopRepairDataStatement;
import org.apache.iotdb.db.utils.DataNodeAuthUtils;
@@ -914,6 +917,13 @@ public class TableConfigTaskVisitor extends AstVisitor<IConfigTask, MPPQueryCont
return new SetConfigurationTask(((SetConfigurationStatement) node.getInnerTreeStatement()));
}
+ @Override
+ protected IConfigTask visitShowConfigurations(ShowConfiguration node, MPPQueryContext context) {
+ context.setQueryType(QueryType.READ);
+ accessControl.checkUserIsAdmin(context.getSession().getUserName());
+ return new ShowConfigurationTask((ShowConfigurationStatement) node.getInnerTreeStatement());
+ }
+
@Override
protected IConfigTask visitStartRepairData(StartRepairData node, MPPQueryContext context) {
context.setQueryType(QueryType.WRITE);
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TreeConfigTaskVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TreeConfigTaskVisitor.java
index 5be65a433d8..b2ea4a2330f 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TreeConfigTaskVisitor.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TreeConfigTaskVisitor.java
@@ -93,6 +93,7 @@ import org.apache.iotdb.db.queryengine.plan.execution.config.sys.LoadConfigurati
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.MergeTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.SetConfigurationTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.SetSystemStatusTask;
+import org.apache.iotdb.db.queryengine.plan.execution.config.sys.ShowConfigurationTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.StartRepairDataTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.StopRepairDataTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.TestConnectionTask;
@@ -189,6 +190,7 @@ import org.apache.iotdb.db.queryengine.plan.statement.sys.MergeStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.SetConfigurationStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.SetSqlDialectStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.SetSystemStatusStatement;
+import org.apache.iotdb.db.queryengine.plan.statement.sys.ShowConfigurationStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.ShowCurrentSqlDialectStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.ShowCurrentUserStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.StartRepairDataStatement;
@@ -335,6 +337,12 @@ public class TreeConfigTaskVisitor extends StatementVisitor<IConfigTask, MPPQuer
return new SetConfigurationTask(setConfigurationStatement);
}
+ @Override
+ public IConfigTask visitShowConfiguration(
+ ShowConfigurationStatement showConfigurationStatement, MPPQueryContext context) {
+ return new ShowConfigurationTask(showConfigurationStatement);
+ }
+
@Override
public IConfigTask visitStartRepairData(
StartRepairDataStatement startRepairDataStatement, MPPQueryContext context) {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
index 9e57532ad26..3344453db51 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/ClusterConfigTaskExecutor.java
@@ -30,6 +30,7 @@ import org.apache.iotdb.common.rpc.thrift.TSetConfigurationReq;
import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq;
import org.apache.iotdb.common.rpc.thrift.TSetTTLReq;
import org.apache.iotdb.common.rpc.thrift.TSetThrottleQuotaReq;
+import org.apache.iotdb.common.rpc.thrift.TShowConfigurationResp;
import org.apache.iotdb.common.rpc.thrift.TShowTTLReq;
import org.apache.iotdb.common.rpc.thrift.TSpaceQuota;
import org.apache.iotdb.common.rpc.thrift.TTestConnectionResp;
@@ -220,6 +221,7 @@ import org.apache.iotdb.db.queryengine.plan.execution.config.session.ShowCurrent
import org.apache.iotdb.db.queryengine.plan.execution.config.session.ShowCurrentTimestampTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.session.ShowCurrentUserTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.session.ShowVersionTask;
+import org.apache.iotdb.db.queryengine.plan.execution.config.sys.ShowConfigurationTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.TestConnectionTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.pipe.ShowPipeTask;
import org.apache.iotdb.db.queryengine.plan.execution.config.sys.quota.ShowSpaceQuotaTask;
@@ -280,6 +282,7 @@ import org.apache.iotdb.db.queryengine.plan.statement.metadata.view.CreateLogica
import org.apache.iotdb.db.queryengine.plan.statement.metadata.view.DeleteLogicalViewStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.view.RenameLogicalViewStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.KillQueryStatement;
+import org.apache.iotdb.db.queryengine.plan.statement.sys.ShowConfigurationStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.quota.SetSpaceQuotaStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.quota.SetThrottleQuotaStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.quota.ShowSpaceQuotaStatement;
@@ -1269,6 +1272,39 @@ public class ClusterConfigTaskExecutor implements IConfigTaskExecutor {
return future;
}
+ @Override
+ public SettableFuture<ConfigTaskResult> showAppliedConfigurations(
+ ShowConfigurationStatement showConfigurationStatement) {
+ SettableFuture<ConfigTaskResult> future = SettableFuture.create();
+ int nodeId = showConfigurationStatement.getNodeId();
+ try {
+ boolean onLocal =
+ nodeId == -1 || IoTDBDescriptor.getInstance().getConfig().getDataNodeId() == nodeId;
+ Map<String, String> lastAppliedProperties;
+ if (onLocal) {
+ lastAppliedProperties = ConfigurationFileUtils.getLastAppliedProperties();
+ } else {
+ try (ConfigNodeClient client =
+ CONFIG_NODE_CLIENT_MANAGER.borrowClient(ConfigNodeInfo.CONFIG_REGION_ID)) {
+ TShowConfigurationResp resp = client.showConfiguration(nodeId);
+ if (resp.getStatus().getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
+ future.setException(new IoTDBException(resp.getStatus()));
+ return future;
+ }
+ lastAppliedProperties = client.showAppliedConfigurations(nodeId).getData();
+ }
+ }
+ ShowConfigurationTask.buildTsBlock(
+ lastAppliedProperties,
+ showConfigurationStatement.isShowAllConfigurations(),
+ showConfigurationStatement.withDescription(),
+ future);
+ } catch (Exception e) {
+ future.setException(e);
+ }
+ return future;
+ }
+
@Override
public SettableFuture<ConfigTaskResult> startRepairData(boolean onCluster) {
SettableFuture<ConfigTaskResult> future = SettableFuture.create();
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/IConfigTaskExecutor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/IConfigTaskExecutor.java
index 8ad06a41c51..781d704af51 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/IConfigTaskExecutor.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/executor/IConfigTaskExecutor.java
@@ -90,6 +90,7 @@ import org.apache.iotdb.db.queryengine.plan.statement.metadata.view.AlterLogical
import org.apache.iotdb.db.queryengine.plan.statement.metadata.view.DeleteLogicalViewStatement;
import org.apache.iotdb.db.queryengine.plan.statement.metadata.view.RenameLogicalViewStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.KillQueryStatement;
+import org.apache.iotdb.db.queryengine.plan.statement.sys.ShowConfigurationStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.quota.SetSpaceQuotaStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.quota.SetThrottleQuotaStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.quota.ShowSpaceQuotaStatement;
@@ -157,6 +158,9 @@ public interface IConfigTaskExecutor {
SettableFuture<ConfigTaskResult> setConfiguration(TSetConfigurationReq tSetConfigurationReq);
+ SettableFuture<ConfigTaskResult> showAppliedConfigurations(
+ ShowConfigurationStatement showConfigurationStatement);
+
SettableFuture<ConfigTaskResult> loadConfiguration(boolean onCluster);
SettableFuture<ConfigTaskResult> setSystemStatus(boolean onCluster, NodeStatus status);
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/ShowConfigurationTask.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/ShowConfigurationTask.java
new file mode 100644
index 00000000000..f37952cf345
--- /dev/null
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/sys/ShowConfigurationTask.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.queryengine.plan.execution.config.sys;
+
+import org.apache.iotdb.commons.conf.ConfigurationFileUtils;
+import org.apache.iotdb.commons.schema.column.ColumnHeader;
+import org.apache.iotdb.commons.schema.column.ColumnHeaderConstant;
+import org.apache.iotdb.db.queryengine.common.header.DatasetHeader;
+import org.apache.iotdb.db.queryengine.plan.execution.config.ConfigTaskResult;
+import org.apache.iotdb.db.queryengine.plan.execution.config.IConfigTask;
+import org.apache.iotdb.db.queryengine.plan.execution.config.executor.IConfigTaskExecutor;
+import org.apache.iotdb.db.queryengine.plan.statement.sys.ShowConfigurationStatement;
+import org.apache.iotdb.rpc.TSStatusCode;
+
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+import org.apache.tsfile.common.conf.TSFileConfig;
+import org.apache.tsfile.read.common.block.TsBlockBuilder;
+import org.apache.tsfile.utils.Binary;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+public class ShowConfigurationTask implements IConfigTask {
+ private final ShowConfigurationStatement showConfigurationStatement;
+
+ public ShowConfigurationTask(ShowConfigurationStatement showConfigurationStatement) {
+ this.showConfigurationStatement = showConfigurationStatement;
+ }
+
+ @Override
+ public ListenableFuture<ConfigTaskResult> execute(IConfigTaskExecutor configTaskExecutor)
+ throws InterruptedException {
+ return configTaskExecutor.showAppliedConfigurations(showConfigurationStatement);
+ }
+
+ public static void buildTsBlock(
+ Map<String, String> lastAppliedProperties,
+ boolean showAllConfigurations,
+ boolean withDescription,
+ SettableFuture<ConfigTaskResult> future)
+ throws IOException {
+ List<ColumnHeader> columnHeaders =
+ withDescription
+ ? ColumnHeaderConstant.SHOW_CONFIGURATIONS_COLUMN_HEADERS_WITH_DESCRIPTION
+ : ColumnHeaderConstant.SHOW_CONFIGURATIONS_COLUMN_HEADERS;
+ TsBlockBuilder builder =
+ new TsBlockBuilder(
+ columnHeaders.stream().map(ColumnHeader::getColumnType).collect(Collectors.toList()));
+ for (ConfigurationFileUtils.DefaultConfigurationItem item :
+ ConfigurationFileUtils.getConfigurationItemsFromTemplate(withDescription).values()) {
+ String name = item.name;
+ String value = lastAppliedProperties.get(name);
+ if (!showAllConfigurations && value == null) {
+ continue;
+ }
+ builder.getTimeColumnBuilder().writeLong(0L);
+ String defaultValue = item.value;
+ String description = item.description;
+ addValueToTsBlockBuilder(builder, 0, name);
+ addValueToTsBlockBuilder(builder, 1, value);
+ addValueToTsBlockBuilder(builder, 2, defaultValue);
+ if (withDescription) {
+ addValueToTsBlockBuilder(builder, 3, description);
+ }
+ builder.declarePosition();
+ }
+ future.set(
+ new ConfigTaskResult(
+ TSStatusCode.SUCCESS_STATUS, builder.build(), new DatasetHeader(columnHeaders, true)));
+ }
+
+ private static void addValueToTsBlockBuilder(TsBlockBuilder builder, int index, String value) {
+ if (value == null) {
+ builder.getColumnBuilder(index).appendNull();
+ } else {
+ builder.getColumnBuilder(index).writeBinary(new Binary(value, TSFileConfig.STRING_CHARSET));
+ }
+ }
+}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AstVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AstVisitor.java
index 80b5642fd6e..159f7573b72 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AstVisitor.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AstVisitor.java
@@ -477,6 +477,10 @@ public abstract class AstVisitor<R, C> {
return visitStatement(node, context);
}
+ protected R visitShowConfigurations(ShowConfiguration node, C context) {
+ return visitStatement(node, context);
+ }
+
protected R visitStartRepairData(StartRepairData node, C context) {
return visitStatement(node, context);
}
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/CnToCnNodeRequestType.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/ShowConfiguration.java
similarity index 60%
copy from iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/CnToCnNodeRequestType.java
copy to iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/ShowConfiguration.java
index e422e45dff0..fc9237d5fe9 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/CnToCnNodeRequestType.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/ShowConfiguration.java
@@ -17,19 +17,19 @@
* under the License.
*/
-package org.apache.iotdb.confignode.client;
+package org.apache.iotdb.db.queryengine.plan.relational.sql.ast;
-public enum CnToCnNodeRequestType {
- ADD_CONSENSUS_GROUP,
- NOTIFY_REGISTER_SUCCESS,
- REGISTER_CONFIG_NODE,
- RESTART_CONFIG_NODE,
- REMOVE_CONFIG_NODE,
- DELETE_CONFIG_NODE_PEER,
- REPORT_CONFIG_NODE_SHUTDOWN,
- STOP_AND_CLEAR_CONFIG_NODE,
- SET_CONFIGURATION,
- SHOW_CONFIGURATION,
- SUBMIT_TEST_CONNECTION_TASK,
- TEST_CONNECTION,
+import org.apache.iotdb.db.queryengine.common.MPPQueryContext;
+import org.apache.iotdb.db.queryengine.plan.statement.Statement;
+
+public class ShowConfiguration extends WrappedStatement {
+
+ public ShowConfiguration(Statement innerTreeStatement, MPPQueryContext context) {
+ super(innerTreeStatement, context);
+ }
+
+ @Override
+ public <R, C> R accept(AstVisitor<R, C> visitor, C context) {
+ return visitor.visitShowConfigurations(this, context);
+ }
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
index 215ee2b4715..d0f3100a85e 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
@@ -177,6 +177,7 @@ import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowAINodes;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCluster;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowClusterId;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowConfigNodes;
+import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowConfiguration;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCurrentDatabase;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCurrentSqlDialect;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ShowCurrentTimestamp;
@@ -244,6 +245,7 @@ import org.apache.iotdb.db.queryengine.plan.statement.sys.FlushStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.LoadConfigurationStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.SetConfigurationStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.SetSystemStatusStatement;
+import org.apache.iotdb.db.queryengine.plan.statement.sys.ShowConfigurationStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.StartRepairDataStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.StopRepairDataStatement;
import org.apache.iotdb.db.relational.grammar.sql.RelationalSqlBaseVisitor;
@@ -1647,6 +1649,20 @@ public class AstBuilder extends RelationalSqlBaseVisitor<Node> {
return new SetConfiguration(setConfigurationStatement, null);
}
+ @Override
+ public Node visitShowConfigurationStatement(
+ RelationalSqlParser.ShowConfigurationStatementContext ctx) {
+ ShowConfigurationStatement showConfigurationStatement;
+ boolean withDescription = ctx.DESC() != null;
+ if (ctx.ALL() != null) {
+ showConfigurationStatement = new ShowConfigurationStatement(true, -1, withDescription);
+ } else {
+ int nodeId = ctx.nodeId == null ? -1 : Integer.parseInt(ctx.nodeId.getText());
+ showConfigurationStatement = new ShowConfigurationStatement(false, nodeId, withDescription);
+ }
+ return new ShowConfiguration(showConfigurationStatement, null);
+ }
+
@Override
public Node visitStartRepairDataStatement(
RelationalSqlParser.StartRepairDataStatementContext ctx) {
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/StatementVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/StatementVisitor.java
index 588c4dd9892..3fb12232a97 100644
--- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/StatementVisitor.java
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/StatementVisitor.java
@@ -128,6 +128,7 @@ import org.apache.iotdb.db.queryengine.plan.statement.sys.MergeStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.SetConfigurationStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.SetSqlDialectStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.SetSystemStatusStatement;
+import org.apache.iotdb.db.queryengine.plan.statement.sys.ShowConfigurationStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.ShowCurrentSqlDialectStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.ShowCurrentUserStatement;
import org.apache.iotdb.db.queryengine.plan.statement.sys.ShowQueriesStatement;
@@ -436,6 +437,11 @@ public abstract class StatementVisitor<R, C> {
return visitStatement(setConfigurationStatement, context);
}
+ public R visitShowConfiguration(
+ ShowConfigurationStatement showConfigurationStatement, C context) {
+ return visitStatement(showConfigurationStatement, context);
+ }
+
public R visitStartRepairData(StartRepairDataStatement startRepairDataStatement, C context) {
return visitStatement(startRepairDataStatement, context);
}
diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/sys/ShowConfigurationStatement.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/sys/ShowConfigurationStatement.java
new file mode 100644
index 00000000000..7442ca44d7e
--- /dev/null
+++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/sys/ShowConfigurationStatement.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.iotdb.db.queryengine.plan.statement.sys;
+
+import org.apache.iotdb.commons.path.PartialPath;
+import org.apache.iotdb.db.queryengine.plan.analyze.QueryType;
+import org.apache.iotdb.db.queryengine.plan.statement.IConfigStatement;
+import org.apache.iotdb.db.queryengine.plan.statement.Statement;
+import org.apache.iotdb.db.queryengine.plan.statement.StatementVisitor;
+
+import java.util.Collections;
+import java.util.List;
+
+public class ShowConfigurationStatement extends Statement implements IConfigStatement {
+
+ private final boolean showAllConfigurations;
+ private final int nodeId;
+ private final boolean withDescription;
+
+ public ShowConfigurationStatement(
+ boolean showAllConfigurations, int nodeId, boolean withDescription) {
+ this.showAllConfigurations = showAllConfigurations;
+ this.nodeId = nodeId;
+ this.withDescription = withDescription;
+ }
+
+ public boolean isShowAllConfigurations() {
+ return showAllConfigurations;
+ }
+
+ public int getNodeId() {
+ return nodeId;
+ }
+
+ public boolean withDescription() {
+ return withDescription;
+ }
+
+ @Override
+ public QueryType getQueryType() {
+ return QueryType.READ;
+ }
+
+ @Override
+ public List<? extends PartialPath> getPaths() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public <R, C> R accept(StatementVisitor<R, C> visitor, C context) {
+ return visitor.visitShowConfiguration(this, context);
+ }
+}
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/ConfigurationFileUtils.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/ConfigurationFileUtils.java
index f5702143dd9..61ea506face 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/ConfigurationFileUtils.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/ConfigurationFileUtils.java
@@ -40,14 +40,13 @@ import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.StringJoiner;
import java.util.concurrent.TimeUnit;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
public class ConfigurationFileUtils {
@@ -75,7 +74,12 @@ public class ConfigurationFileUtils {
.add("# specific language governing permissions and limitations")
.add("# under the License.")
.toString();
- private static Map<String, String> configuration2DefaultValue;
+ private static final String EFFECTIVE_MODE = "effectiveMode:";
+ private static final String DATATYPE = "Datatype:";
+ private static final String EFFECTIVE_MODE_HOT_RELOAD = "hot_reload";
+ private static final String EFFECTIVE_MODE_RESTART = "restart";
+ private static final String EFFECTIVE_MODE_FIRST_START = "first_start";
+ private static Map<String, DefaultConfigurationItem> configuration2DefaultValue;
// This is a temporary implementations
private static final Set<String> ignoreConfigKeys =
@@ -107,6 +111,20 @@ public class ConfigurationFileUtils {
"iotdb_server_encrypt_decrypt_provider_parameter",
"pipe_lib_dir"));
+ private static final Map<String, String> lastAppliedProperties = new HashMap<>();
+
+ public static void updateLastAppliedProperties(TrimProperties properties) {
+ for (Map.Entry<Object, Object> entry : properties.entrySet()) {
+ String key = entry.getKey().toString();
+ String value = entry.getValue() == null ? null : entry.getValue().toString();
+ lastAppliedProperties.put(key, value);
+ }
+ }
+
+ public static Map<String, String> getLastAppliedProperties() {
+ return lastAppliedProperties;
+ }
+
public static void checkAndMayUpdate(
URL systemUrl, URL configNodeUrl, URL dataNodeUrl, URL commonUrl)
throws IOException, InterruptedException {
@@ -163,30 +181,9 @@ public class ConfigurationFileUtils {
if (configuration2DefaultValue != null) {
return;
}
- configuration2DefaultValue = new HashMap<>();
- try (InputStream inputStream =
- ConfigurationFileUtils.class
- .getClassLoader()
- .getResourceAsStream(CommonConfig.SYSTEM_CONFIG_TEMPLATE_NAME);
- InputStreamReader isr = new InputStreamReader(inputStream);
- BufferedReader reader = new BufferedReader(isr)) {
- String line;
- Pattern pattern = Pattern.compile("^[^#].*?=.*$");
- while ((line = reader.readLine()) != null) {
- Matcher matcher = pattern.matcher(line);
- if (matcher.find()) {
- String[] parts = line.split("=");
- if (parts.length == 2) {
- configuration2DefaultValue.put(parts[0].trim(), parts[1].trim());
- } else if (parts.length == 1) {
- configuration2DefaultValue.put(parts[0].trim(), null);
- } else {
- logger.error("Failed to parse configuration template: {}", line);
- }
- }
- }
+ try {
+ configuration2DefaultValue = getConfigurationItemsFromTemplate(false);
} catch (IOException e) {
- configuration2DefaultValue = null;
logger.warn("Failed to read configuration template", e);
throw e;
}
@@ -197,10 +194,12 @@ public class ConfigurationFileUtils {
public static String getConfigurationDefaultValue(String parameterName) throws IOException {
parameterName = parameterName.trim();
if (configuration2DefaultValue != null) {
- return configuration2DefaultValue.get(parameterName);
+ return configuration2DefaultValue.get(parameterName).value;
} else {
loadConfigurationDefaultValueFromTemplate();
- return configuration2DefaultValue.getOrDefault(parameterName, null);
+ DefaultConfigurationItem defaultConfigurationItem =
+ configuration2DefaultValue.get(parameterName);
+ return defaultConfigurationItem == null ? null : defaultConfigurationItem.value;
}
}
@@ -361,4 +360,82 @@ public class ConfigurationFileUtils {
void loadHotModifiedProperties(TrimProperties properties)
throws IOException, InterruptedException;
}
+
+ public static Map<String, DefaultConfigurationItem> getConfigurationItemsFromTemplate(
+ boolean withDesc) throws IOException {
+ if (configuration2DefaultValue != null && !withDesc) {
+ return configuration2DefaultValue;
+ }
+ Map<String, DefaultConfigurationItem> items = new LinkedHashMap<>();
+ try (InputStream inputStream =
+ ConfigurationFileUtils.class
+ .getClassLoader()
+ .getResourceAsStream(CommonConfig.SYSTEM_CONFIG_TEMPLATE_NAME);
+ InputStreamReader isr = new InputStreamReader(inputStream);
+ BufferedReader reader = new BufferedReader(isr)) {
+ String effectiveMode = null;
+ String dataType = null;
+ StringBuilder description = new StringBuilder();
+ String line;
+ while ((line = reader.readLine()) != null) {
+ line = line.trim();
+ if (line.isEmpty()) {
+ description = new StringBuilder();
+ dataType = null;
+ effectiveMode = null;
+ continue;
+ }
+ if (line.startsWith("#")) {
+ String comment = line.substring(1).trim();
+ if (description.length() > 0) {
+ if (comment.startsWith(EFFECTIVE_MODE)) {
+ effectiveMode = comment.substring(EFFECTIVE_MODE.length()).trim();
+ continue;
+ } else if (comment.startsWith(DATATYPE)) {
+ dataType = comment.substring(DATATYPE.length()).trim();
+ continue;
+ } else {
+ description.append(" ");
+ }
+ }
+ if (withDesc) {
+ description.append(comment);
+ }
+ } else {
+ int equalsIndex = line.indexOf('=');
+ String key = line.substring(0, equalsIndex).trim();
+ String value = line.substring(equalsIndex + 1).trim();
+ items.put(
+ key,
+ new DefaultConfigurationItem(
+ key,
+ value,
+ withDesc ? description.toString().trim() : null,
+ effectiveMode,
+ dataType));
+ }
+ }
+ } catch (IOException e) {
+ logger.warn("Failed to read configuration template", e);
+ throw e;
+ }
+ return items;
+ }
+
+ public static class DefaultConfigurationItem {
+ public String name;
+ public String value;
+ public String description;
+ public String effectiveMode;
+ public String dataType;
+
+ public DefaultConfigurationItem(
+ String name, String value, String description, String effectiveMode, String dataType) {
+ this.name = name;
+ this.value = value;
+ this.description = description;
+ this.effectiveMode = effectiveMode;
+ this.dataType = dataType;
+ }
+ }
}
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/column/ColumnHeaderConstant.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/column/ColumnHeaderConstant.java
index ff6e9bc42a6..567df04301d 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/column/ColumnHeaderConstant.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/column/ColumnHeaderConstant.java
@@ -315,6 +315,11 @@ public class ColumnHeaderConstant {
public static final String CURRENT_SQL_DIALECT = "CurrentSqlDialect";
+ public static final String SHOW_CONFIGURATIONS_NAME = "name";
+ public static final String SHOW_CONFIGURATIONS_VALUE = "value";
+ public static final String SHOW_CONFIGURATIONS_DEFAULT_VALUE = "default_value";
+ public static final String SHOW_CONFIGURATIONS_DESCRIPTION = "description";
+
public static final List<ColumnHeader> lastQueryColumnHeaders =
ImmutableList.of(
new ColumnHeader(TIMESERIES, TSDataType.TEXT),
@@ -704,4 +709,17 @@ public class ColumnHeaderConstant {
public static final List<ColumnHeader> SHOW_CURRENT_TIMESTAMP_COLUMN_HEADERS =
ImmutableList.of(new ColumnHeader(CURRENT_TIMESTAMP, TSDataType.TIMESTAMP));
+
+ public static final List<ColumnHeader> SHOW_CONFIGURATIONS_COLUMN_HEADERS =
+ ImmutableList.of(
+ new ColumnHeader(SHOW_CONFIGURATIONS_NAME, TSDataType.TEXT),
+ new ColumnHeader(SHOW_CONFIGURATIONS_VALUE, TSDataType.TEXT),
+ new ColumnHeader(SHOW_CONFIGURATIONS_DEFAULT_VALUE, TSDataType.TEXT));
+
+ public static final List<ColumnHeader> SHOW_CONFIGURATIONS_COLUMN_HEADERS_WITH_DESCRIPTION =
+ ImmutableList.of(
+ new ColumnHeader(SHOW_CONFIGURATIONS_NAME, TSDataType.TEXT),
+ new ColumnHeader(SHOW_CONFIGURATIONS_VALUE, TSDataType.TEXT),
+ new ColumnHeader(SHOW_CONFIGURATIONS_DEFAULT_VALUE, TSDataType.TEXT),
+ new ColumnHeader(SHOW_CONFIGURATIONS_DESCRIPTION, TSDataType.TEXT));
}
diff --git a/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4 b/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4
index 1d5d8dcecad..80a869d2644 100644
--- a/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4
+++ b/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4
@@ -140,6 +140,7 @@ statement
| killQueryStatement
| loadConfigurationStatement
| setConfigurationStatement
+ | showConfigurationStatement
| showCurrentSqlDialectStatement
| setSqlDialectStatement
| showCurrentUserStatement
@@ -676,6 +677,10 @@ showCurrentTimestampStatement
: SHOW CURRENT_TIMESTAMP
;
+showConfigurationStatement
+ : SHOW (ALL)? CONFIGURATION (ON nodeId=INTEGER_VALUE)? (WITH DESC)?
+ ;
+
// ------------------------------------------- Authority Statement -----------------------------------------------------
diff --git a/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift b/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift
index 26f621a6239..e34455034c1 100644
--- a/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift
+++ b/iotdb-protocol/thrift-commons/src/main/thrift/common.thrift
@@ -307,6 +307,11 @@ struct TShowConfigurationResp {
2: required string content
}
+struct TShowAppliedConfigurationsResp {
+ 1: required TSStatus status
+ 2: required map<string, string> data
+}
+
// for AINode
enum TrainingState {
PENDING,
diff --git a/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift b/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift
index 99e11d8116d..436687d0e94 100644
--- a/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift
+++ b/iotdb-protocol/thrift-confignode/src/main/thrift/confignode.thrift
@@ -1702,6 +1702,9 @@ service IConfigNodeRPCService {
/** Show content of configuration file */
common.TShowConfigurationResp showConfiguration(1: i32 nodeId)
+ /** Show applied configurations by TsBlock */
+ common.TShowAppliedConfigurationsResp showAppliedConfigurations(1: i32 nodeId)
+
/** Check and repair unsorted tsfile by compaction */
common.TSStatus startRepairData()
diff --git a/iotdb-protocol/thrift-datanode/src/main/thrift/datanode.thrift b/iotdb-protocol/thrift-datanode/src/main/thrift/datanode.thrift
index 5be8808db50..6b44d1a6ef2 100644
--- a/iotdb-protocol/thrift-datanode/src/main/thrift/datanode.thrift
+++ b/iotdb-protocol/thrift-datanode/src/main/thrift/datanode.thrift
@@ -989,6 +989,8 @@ service IDataNodeRPCService {
common.TShowConfigurationResp showConfiguration()
+ common.TShowAppliedConfigurationsResp showAppliedConfigurations()
+
common.TSStatus setConfiguration(common.TSetConfigurationReq req)
common.TSStatus loadConfiguration()
(iotdb) 02/03: Merge branch 'master' into showConfigurationSQL
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuwenwei pushed a commit to branch showConfigurationSQL
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 62aa4d6f79e458556fcaf93ff5eab9ab1af88191
Merge: ccb68fef9a7 0a2166fab5b
Author: shuwenwei <s1...@gmail.com>
AuthorDate: Thu Aug 28 21:57:54 2025 +0800
Merge branch 'master' into showConfigurationSQL
example/client-cpp-example/pom.xml | 4 +
example/client-cpp-example/src/CMakeLists.txt | 5 +-
.../client-cpp-example/src}/MultiSvrNodeClient.cpp | 0
.../it/env/cluster/config/MppCommonConfig.java | 6 -
.../env/cluster/config/MppSharedCommonConfig.java | 7 -
.../it/env/remote/config/RemoteCommonConfig.java | 5 -
.../org/apache/iotdb/itbase/env/CommonConfig.java | 2 -
.../org/apache/iotdb/db/it/utils/TestUtils.java | 65 ++
.../relational/it/db/it/IoTDBWindowTVFIT.java | 283 ++++++++-
.../scalar/IoTDBCastFunctionTableIT.java | 1 +
.../scalar/IoTDBFormatFunctionTableIT.java | 1 +
.../it/query/old/query/IoTDBArithmeticTableIT.java | 1 +
.../relational/it/query/recent/IoTDBCteIT.java | 332 ++++++++++
.../view/old/query/IoTDBArithmeticTableViewIT.java | 1 +
.../org/apache/iotdb/tool/common/Constants.java | 12 +-
.../org/apache/iotdb/tool/common/OptionsUtil.java | 59 +-
.../apache/iotdb/tool/data/AbstractDataTool.java | 4 +-
.../org/apache/iotdb/tool/data/ExportData.java | 8 +-
.../apache/iotdb/tool/data/ExportDataTable.java | 124 ++--
.../org/apache/iotdb/tool/data/ExportDataTree.java | 166 +++--
.../org/apache/iotdb/tool/data/ImportData.java | 20 +-
.../apache/iotdb/tool/data/ImportDataTable.java | 94 +--
iotdb-client/client-cpp/src/main/CMakeLists.txt | 5 +
iotdb-client/client-cpp/src/main/NodesSupplier.cpp | 4 +-
iotdb-client/client-cpp/src/main/Session.cpp | 6 +-
iotdb-client/client-cpp/src/main/SessionBuilder.h | 2 +-
iotdb-client/client-cpp/src/test/CMakeLists.txt | 5 +
iotdb-client/client-cpp/src/test/cpp/sessionIT.cpp | 29 +-
.../response/pipe/task/PipeTableResp.java | 11 +-
.../agent/runtime/PipeConfigNodeRuntimeAgent.java | 11 +-
.../pipe/agent/task/PipeConfigNodeSubtask.java | 51 +-
.../pipe/agent/task/PipeConfigNodeTaskAgent.java | 11 +-
.../pipe/agent/task/PipeConfigNodeTaskBuilder.java | 6 +-
.../PipeConfigPhysicalPlanTSStatusVisitor.java | 1 +
.../sink/protocol/IoTDBConfigRegionAirGapSink.java | 5 +
.../pipe/sink/protocol/IoTDBConfigRegionSink.java | 5 +
.../pipe/source/IoTDBConfigRegionSource.java | 2 +-
.../confignode/persistence/pipe/PipeInfo.java | 10 +-
.../confignode/persistence/pipe/PipeTaskInfo.java | 16 +-
.../impl/pipe/AbstractOperatePipeProcedureV2.java | 4 +-
.../impl/pipe/runtime/PipeMetaSyncProcedure.java | 4 +-
.../impl/pipe/task/CreatePipeProcedureV2.java | 4 +-
.../pipe/util/PipeExternalSourceLoadBalancer.java | 2 +-
.../org/apache/iotdb/db/conf/IoTDBStartCheck.java | 63 +-
.../db/pipe/agent/task/PipeDataNodeTaskAgent.java | 19 +-
.../agent/task/builder/PipeDataNodeBuilder.java | 2 +-
.../task/builder/PipeDataNodeTaskBuilder.java | 72 ++-
.../pipe/agent/task/stage/PipeTaskSourceStage.java | 9 +-
.../agent/task/subtask/sink/PipeSinkSubtask.java | 66 +-
.../task/subtask/sink/PipeSinkSubtaskManager.java | 6 +-
.../pipe/metric/overview/PipeResourceMetrics.java | 13 +
.../protocol/airgap/IoTDBDataRegionAirGapSink.java | 31 +
.../airgap/IoTDBSchemaRegionAirGapSink.java | 5 +
.../thrift/async/IoTDBDataRegionAsyncSink.java | 14 +
.../async/handler/PipeTransferTsFileHandler.java | 6 +
.../thrift/sync/IoTDBDataRegionSyncSink.java | 21 +
.../thrift/sync/IoTDBSchemaRegionSink.java | 5 +
.../source/dataregion/IoTDBDataRegionSource.java | 10 +-
...istoricalDataRegionTsFileAndDeletionSource.java | 6 +-
.../PipeRealtimeDataRegionHybridSource.java | 1 +
.../realtime/PipeRealtimeDataRegionLogSource.java | 1 +
.../realtime/PipeRealtimeDataRegionSource.java | 21 +-
.../PipeRealtimeDataRegionTsFileSource.java | 2 +
.../dataregion/realtime/epoch/TsFileEpoch.java | 28 +-
.../realtime/epoch/TsFileEpochManager.java | 3 -
.../db/pipe/source/mqtt/MQTTPublishHandler.java | 4 +-
.../iotdb/db/pipe/source/mqtt/MQTTSource.java | 6 +-
.../config/executor/ClusterConfigTaskExecutor.java | 14 +-
.../plan/planner/plan/node/PlanGraphPrinter.java | 7 +-
.../relational/analyzer/StatementAnalyzer.java | 15 +-
.../function/TableBuiltinTableFunction.java | 6 +-
.../function/tvf/PatternMatchTableFunction.java | 266 ++++++++
.../function/tvf/match/MatchConfig.java} | 23 +-
.../function/tvf/match/QetchAlgorithm.java | 683 +++++++++++++++++++++
.../function/tvf/match/model/MatchState.java | 233 +++++++
.../function/tvf/match/model/PatternSegment.java | 285 +++++++++
.../function/tvf/match/model/Point.java} | 27 +-
.../function/tvf/match/model/RegexMatchState.java | 396 ++++++++++++
.../function/tvf/match/model/Section.java | 238 +++++++
.../plan/relational/planner/RelationPlanner.java | 23 +
.../scalar/DateBinFunctionColumnTransformer.java | 21 +-
.../column/unary/scalar/ExtractTransformer.java | 12 +-
.../java/org/apache/iotdb/db/service/DataNode.java | 4 +
.../iotdb/db/service/DataNodeShutdownHook.java | 4 +
.../load/limiter/LoadTsFileRateLimiter.java | 64 +-
.../memory/LoadTsFileDataCacheMemoryBlock.java | 3 +-
.../load/memory/LoadTsFileMemoryBlock.java | 3 +-
.../subtask/SubscriptionSinkSubtaskManager.java | 2 +-
.../org/apache/iotdb/db/utils/DateTimeUtils.java | 75 ++-
.../agent/plugin/PipeDataNodePluginAgentTest.java | 4 +-
.../db/pipe/consensus/DeletionResourceTest.java | 4 +-
.../pattern/CachedSchemaPatternMatcherTest.java | 9 +-
.../db/pipe/source/PipeRealtimeExtractTest.java | 10 +-
.../relational/analyzer/ExtractExpressionTest.java | 7 +
.../apache/iotdb/commons/conf/CommonConfig.java | 28 +
.../iotdb/commons/conf/CommonDescriptor.java | 2 +
.../commons/pipe/agent/plugin/PipePluginAgent.java | 8 +-
.../commons/pipe/agent/task/PipeTaskAgent.java | 14 +-
.../pipe/agent/task/meta/PipeStaticMeta.java | 58 +-
.../task/subtask/PipeAbstractSinkSubtask.java | 16 +-
.../iotdb/commons/pipe/config/PipeConfig.java | 6 +
.../iotdb/commons/pipe/config/PipeDescriptor.java | 6 +
.../pipe/config/constant/PipeSinkConstant.java | 5 +
....java => PipeTaskSourceRuntimeEnvironment.java} | 9 +-
.../limiter/GlobalRPCRateLimiter.java} | 20 +-
.../pipe/sink/limiter/GlobalRateLimiter.java | 14 +-
.../limiter/TsFileSendRateLimiter.java} | 30 +-
.../pipe/sink/protocol/IoTDBAirGapSink.java | 3 +
.../commons/pipe/sink/protocol/IoTDBSink.java | 4 +-
.../pipe/sink/protocol/IoTDBSslSyncSink.java | 3 +
.../iotdb/commons/pipe/source/IoTDBSource.java | 6 +-
.../iotdb/commons/service/metric/enums/Metric.java | 1 +
.../iotdb/library/match/PatternExecutor.java | 9 +-
113 files changed, 3808 insertions(+), 680 deletions(-)
(iotdb) 03/03: add enum
Posted by sh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
shuwenwei pushed a commit to branch showConfigurationSQL
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 895410e595179aa572f7d098cd4ba3e52d367bd4
Author: shuwenwei <s1...@gmail.com>
AuthorDate: Fri Aug 29 10:22:01 2025 +0800
add enum
---
.../confignode/conf/ConfigNodeDescriptor.java | 7 +-
.../org/apache/iotdb/db/conf/IoTDBDescriptor.java | 5 +-
.../iotdb/commons/conf/ConfigurationFileUtils.java | 85 ++++++++++++++--------
3 files changed, 62 insertions(+), 35 deletions(-)
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java
index 64b71199eb7..3243c4634ae 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java
@@ -147,7 +147,8 @@ public class ConfigNodeDescriptor {
}
private void loadProperties(TrimProperties properties) throws BadNodeUrlException, IOException {
- loadHotModifiedProps(properties);
+ ConfigurationFileUtils.updateLastAppliedProperties(properties, false);
+ conf.setClusterName(properties.getProperty(IoTDBConstant.CLUSTER_NAME, conf.getClusterName()));
conf.setInternalAddress(
properties.getProperty(IoTDBConstant.CN_INTERNAL_ADDRESS, conf.getInternalAddress()));
@@ -764,8 +765,8 @@ public class ConfigNodeDescriptor {
}
}
- public void loadHotModifiedProps(TrimProperties properties) {
- ConfigurationFileUtils.updateLastAppliedProperties(properties);
+ public void loadHotModifiedProps(TrimProperties properties) throws IOException {
+ ConfigurationFileUtils.updateLastAppliedProperties(properties, true);
conf.setClusterName(properties.getProperty(IoTDBConstant.CLUSTER_NAME, conf.getClusterName()));
}
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 2b24ee972af..69081fe62be 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
@@ -255,6 +255,7 @@ public class IoTDBDescriptor {
}
public void loadProperties(TrimProperties properties) throws BadNodeUrlException, IOException {
+ ConfigurationFileUtils.updateLastAppliedProperties(properties, false);
conf.setClusterName(properties.getProperty(IoTDBConstant.CLUSTER_NAME, conf.getClusterName()));
conf.setRpcAddress(properties.getProperty(IoTDBConstant.DN_RPC_ADDRESS, conf.getRpcAddress()));
@@ -1960,8 +1961,8 @@ public class IoTDBDescriptor {
}
public synchronized void loadHotModifiedProps(TrimProperties properties)
- throws QueryProcessException {
- ConfigurationFileUtils.updateLastAppliedProperties(properties);
+ throws QueryProcessException, IOException {
+ ConfigurationFileUtils.updateLastAppliedProperties(properties, true);
try {
// update data dirs
String dataDirs = properties.getProperty("dn_data_dirs", null);
diff --git a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/ConfigurationFileUtils.java b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/ConfigurationFileUtils.java
index 61ea506face..5493a761709 100644
--- a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/ConfigurationFileUtils.java
+++ b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/ConfigurationFileUtils.java
@@ -53,7 +53,7 @@ public class ConfigurationFileUtils {
private static final String lockFileSuffix = ".lock";
private static final long maxTimeMillsToAcquireLock = TimeUnit.SECONDS.toMillis(20);
private static final long waitTimeMillsPerCheck = TimeUnit.MILLISECONDS.toMillis(100);
- private static Logger logger = LoggerFactory.getLogger(ConfigurationFileUtils.class);
+ private static final Logger logger = LoggerFactory.getLogger(ConfigurationFileUtils.class);
private static final String lineSeparator = "\n";
private static final String license =
new StringJoiner(lineSeparator)
@@ -74,11 +74,9 @@ public class ConfigurationFileUtils {
.add("# specific language governing permissions and limitations")
.add("# under the License.")
.toString();
- private static final String EFFECTIVE_MODE = "effectiveMode:";
- private static final String DATATYPE = "Datatype:";
- private static final String EFFECTIVE_MODE_HOT_RELOAD = "hot_reload";
- private static final String EFFECTIVE_MODE_RESTART = "restart";
- private static final String EFFECTIVE_MODE_FIRST_START = "first_start";
+ private static final String EFFECTIVE_MODE_PREFIX = "effectiveMode:";
+ private static final String EFFECTIVE_NODE_TYPE_PREFIX = "effectiveNodeType:";
+ private static final String DATATYPE_PREFIX = "Datatype:";
private static Map<String, DefaultConfigurationItem> configuration2DefaultValue;
// This is a temporary implementations
@@ -113,9 +111,19 @@ public class ConfigurationFileUtils {
private static final Map<String, String> lastAppliedProperties = new HashMap<>();
- public static void updateLastAppliedProperties(TrimProperties properties) {
+ public static void updateLastAppliedProperties(
+ TrimProperties properties, boolean isHotReloading) throws IOException {
+ loadConfigurationDefaultValueFromTemplate();
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
String key = entry.getKey().toString();
+ DefaultConfigurationItem defaultConfigurationItem = configuration2DefaultValue.get(key);
+ if (defaultConfigurationItem == null) {
+ continue;
+ }
+ if (isHotReloading
+ && defaultConfigurationItem.effectiveMode != EffectiveModeType.HOT_RELOAD) {
+ continue;
+ }
String value = entry.getValue() == null ? null : entry.getValue().toString();
lastAppliedProperties.put(key, value);
}
@@ -373,33 +381,37 @@ public class ConfigurationFileUtils {
.getResourceAsStream(CommonConfig.SYSTEM_CONFIG_TEMPLATE_NAME);
InputStreamReader isr = new InputStreamReader(inputStream);
BufferedReader reader = new BufferedReader(isr)) {
- String effectiveMode = null;
- String dataType = null;
+ EffectiveModeType effectiveMode = null;
StringBuilder description = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
line = line.trim();
if (line.isEmpty()) {
description = new StringBuilder();
- dataType = null;
effectiveMode = null;
continue;
}
if (line.startsWith("#")) {
String comment = line.substring(1).trim();
- if (description.length() > 0) {
- if (comment.startsWith(EFFECTIVE_MODE)) {
- effectiveMode = comment.substring(EFFECTIVE_MODE.length()).trim();
- continue;
- } else if (comment.startsWith(DATATYPE)) {
- dataType = comment.substring(DATATYPE.length()).trim();
- continue;
- } else {
- description.append(" ");
- }
+ if (comment.isEmpty()) {
+ continue;
+ }
+ boolean needSeperateLine = false;
+ if (comment.startsWith(EFFECTIVE_MODE_PREFIX)) {
+ effectiveMode =
+ EffectiveModeType.getEffectiveMode(
+ comment.substring(EFFECTIVE_MODE_PREFIX.length()).trim());
+ needSeperateLine = true;
+ } else if (comment.startsWith(DATATYPE_PREFIX)) {
+ needSeperateLine = true;
+ } else {
+ description.append(" ");
}
if (withDesc) {
description.append(comment);
+ if (needSeperateLine) {
+ description.append(lineSeparator);
+ }
}
} else {
int equalsIndex = line.indexOf('=');
@@ -408,11 +420,7 @@ public class ConfigurationFileUtils {
items.put(
key,
new DefaultConfigurationItem(
- key,
- value,
- withDesc ? description.toString().trim() : null,
- effectiveMode,
- dataType));
+ key, value, withDesc ? description.toString().trim() : null, effectiveMode));
}
}
} catch (IOException e) {
@@ -426,16 +434,33 @@ public class ConfigurationFileUtils {
public String name;
public String value;
public String description;
- public String effectiveMode;
- public String dataType;
+ public EffectiveModeType effectiveMode;
public DefaultConfigurationItem(
- String name, String value, String description, String effectiveMode, String dataType) {
+ String name, String value, String description, EffectiveModeType effectiveMode) {
this.name = name;
this.value = value;
this.description = description;
- this.effectiveMode = effectiveMode;
- this.dataType = dataType;
+ this.effectiveMode = effectiveMode == null ? EffectiveModeType.UNKNOWN : effectiveMode;
+ }
+ }
+
+ public enum EffectiveModeType {
+ HOT_RELOAD,
+ FIRST_START,
+ RESTART,
+ UNKNOWN;
+
+ public static EffectiveModeType getEffectiveMode(String effectiveMode) {
+ if (HOT_RELOAD.name().equalsIgnoreCase(effectiveMode)) {
+ return HOT_RELOAD;
+ } else if (FIRST_START.name().equalsIgnoreCase(effectiveMode)) {
+ return FIRST_START;
+ } else if (RESTART.name().equalsIgnoreCase(effectiveMode)) {
+ return RESTART;
+ } else {
+ return UNKNOWN;
+ }
}
}
}