diff --git a/distribution/src/assembly/all.xml b/distribution/src/assembly/all.xml
index 028af358eac42..9a236d5725a10 100644
--- a/distribution/src/assembly/all.xml
+++ b/distribution/src/assembly/all.xml
@@ -57,6 +57,15 @@
conf
${maven.multiModuleProjectDirectory}/iotdb-core/node-commons/src/assembly/resources/conf
+
+ **/*.sh
+ **/*.bat
+ **/iotdb-system.properties
+
+
+
+ conf
+ ${maven.multiModuleProjectDirectory}/iotdb-core/node-commons/target/conf
sbin
diff --git a/distribution/src/assembly/confignode.xml b/distribution/src/assembly/confignode.xml
index 502b90758cae2..3944c62325ef8 100644
--- a/distribution/src/assembly/confignode.xml
+++ b/distribution/src/assembly/confignode.xml
@@ -54,6 +54,15 @@
conf
${maven.multiModuleProjectDirectory}/iotdb-core/node-commons/src/assembly/resources/conf
+
+ **/*.sh
+ **/*.bat
+ **/iotdb-system.properties
+
+
+
+ conf
+ ${maven.multiModuleProjectDirectory}/iotdb-core/node-commons/target/conf
diff --git a/distribution/src/assembly/datanode.xml b/distribution/src/assembly/datanode.xml
index 84697fda6d742..9b0ae34a2bbb5 100644
--- a/distribution/src/assembly/datanode.xml
+++ b/distribution/src/assembly/datanode.xml
@@ -45,6 +45,15 @@
conf
${maven.multiModuleProjectDirectory}/iotdb-core/node-commons/src/assembly/resources/conf
+
+ **/*.sh
+ **/*.bat
+ **/iotdb-system.properties
+
+
+
+ conf
+ ${maven.multiModuleProjectDirectory}/iotdb-core/node-commons/target/conf
sbin
diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBRepairDataIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBRepairDataIT.java
index 550b0d7744b0c..cac76888f3362 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBRepairDataIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBRepairDataIT.java
@@ -60,7 +60,7 @@ public static void setUp() throws Exception {
@AfterClass
public static void tearDown() throws Exception {
- EnvFactory.getEnv().initClusterEnvironment();
+ EnvFactory.getEnv().cleanClusterEnvironment();
}
@Test
diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSetConfigurationIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSetConfigurationIT.java
new file mode 100644
index 0000000000000..3ab24dd94f70a
--- /dev/null
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSetConfigurationIT.java
@@ -0,0 +1,89 @@
+/*
+ * 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.it;
+
+import org.apache.iotdb.commons.conf.CommonConfig;
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.env.cluster.node.ConfigNodeWrapper;
+import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.LocalStandaloneIT;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.sql.Connection;
+import java.sql.Statement;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({LocalStandaloneIT.class})
+public class IoTDBSetConfigurationIT {
+ @BeforeClass
+ public static void setUp() throws Exception {
+ EnvFactory.getEnv().initClusterEnvironment();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ EnvFactory.getEnv().cleanClusterEnvironment();
+ }
+
+ @Test
+ public void testSetConfiguration() throws Exception {
+ try (Connection connection = EnvFactory.getEnv().getConnection();
+ Statement statement = connection.createStatement()) {
+ statement.execute("set configuration \"enable_seq_space_compaction\"=\"false\"");
+ statement.execute("set configuration \"enable_unseq_space_compaction\"=\"false\" on 0");
+ statement.execute("set configuration \"enable_cross_space_compaction\"=\"false\" on 1");
+ } catch (Exception e) {
+ Assert.fail(e.getMessage());
+ }
+ for (ConfigNodeWrapper configNodeWrapper : EnvFactory.getEnv().getConfigNodeWrapperList()) {
+ String systemPropertiesPath =
+ configNodeWrapper.getNodePath()
+ + File.separator
+ + "conf"
+ + File.separator
+ + CommonConfig.SYSTEM_CONFIG_NAME;
+ File f = new File(systemPropertiesPath);
+ String content = new String(Files.readAllBytes(f.toPath()));
+ Assert.assertTrue(content.contains("enable_seq_space_compaction=false"));
+ Assert.assertTrue(content.contains("enable_unseq_space_compaction=false"));
+ }
+ for (DataNodeWrapper dataNodeWrapper : EnvFactory.getEnv().getDataNodeWrapperList()) {
+ String systemPropertiesPath =
+ dataNodeWrapper.getNodePath()
+ + File.separator
+ + "conf"
+ + File.separator
+ + CommonConfig.SYSTEM_CONFIG_NAME;
+ File f = new File(systemPropertiesPath);
+ String content = new String(Files.readAllBytes(f.toPath()));
+ Assert.assertTrue(content.contains("enable_seq_space_compaction=false"));
+ Assert.assertTrue(content.contains("enable_cross_space_compaction=false"));
+ }
+ }
+}
diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSettleIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSettleIT.java
index f173e2ff9d600..d800bb8a054a7 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSettleIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSettleIT.java
@@ -56,7 +56,7 @@ public static void setUp() throws Exception {
@AfterClass
public static void tearDown() throws Exception {
close();
- EnvFactory.getEnv().initClusterEnvironment();
+ EnvFactory.getEnv().cleanClusterEnvironment();
}
@Test
diff --git a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
index c2086e8de8919..6d3ffe0b837d8 100644
--- a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
+++ b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
@@ -82,7 +82,7 @@ dclStatement
;
utilityStatement
- : flush | clearCache | settle | startRepairData | stopRepairData | explain
+ : flush | clearCache | setConfiguration | settle | startRepairData | stopRepairData | explain
| setSystemStatus | showVersion | showFlushInfo | showLockInfo | showQueryResource
| showQueries | showCurrentTimestamp | killQuery | grantWatermarkEmbedding
| revokeWatermarkEmbedding | loadConfiguration | loadTimeseries | loadFile
@@ -973,6 +973,15 @@ clearCache
: CLEAR CACHE (ON (LOCAL | CLUSTER))?
;
+// Set Configuration
+setConfiguration
+ : SET CONFIGURATION setConfigurationEntry+ (ON INTEGER_LITERAL)?
+ ;
+
+setConfigurationEntry
+ : STRING_LITERAL OPERATOR_SEQ STRING_LITERAL
+ ;
+
// Settle
settle
: SETTLE (prefixPath|tsFilePath=STRING_LITERAL)
diff --git a/iotdb-core/confignode/src/assembly/resources/sbin/stop-confignode.bat b/iotdb-core/confignode/src/assembly/resources/sbin/stop-confignode.bat
index e697642668876..8c0e392f71bd0 100644
--- a/iotdb-core/confignode/src/assembly/resources/sbin/stop-confignode.bat
+++ b/iotdb-core/confignode/src/assembly/resources/sbin/stop-confignode.bat
@@ -22,10 +22,15 @@
set current_dir=%~dp0
set superior_dir=%current_dir%\..\
-IF EXIST "%superior%\conf\iotdb-system.properties" (
+IF EXIST "%superior_dir%\conf\iotdb-system.properties" (
set config_file="%superior_dir%\conf\iotdb-system.properties"
) ELSE (
- set config_file="%superior_dir%\conf\iotdb-confignode.properties"
+ IF EXIST "%superior_dir%\conf\iotdb-confignode.properties" (
+ set config_file="%superior_dir%\conf\iotdb-confignode.properties"
+ ) ELSE (
+ echo "No configuration file found. Exiting."
+ exit /b 1
+ )
)
for /f "eol=; tokens=2,2 delims==" %%i in ('findstr /i "^cn_internal_port"
@@ -33,6 +38,11 @@ for /f "eol=; tokens=2,2 delims==" %%i in ('findstr /i "^cn_internal_port"
set cn_internal_port=%%i
)
+if not defined cn_internal_port (
+ echo "cn_internal_port not found in the configuration file. Exiting."
+ exit /b 1
+)
+
echo "check whether the cn_internal_port is used..., port is %cn_internal_port%"
for /f "eol=; tokens=2,2 delims==" %%i in ('findstr /i "cn_internal_address"
@@ -40,6 +50,11 @@ for /f "eol=; tokens=2,2 delims==" %%i in ('findstr /i "cn_internal_address"
set cn_internal_address=%%i
)
+if not defined cn_internal_address (
+ echo "cn_internal_address not found in the configuration file. Exiting."
+ exit /b 1
+)
+
for /f "tokens=5" %%a in ('netstat /ano ^| findstr %cn_internal_address%:%cn_internal_port% ^| findstr LISTENING ') do (
taskkill /f /pid %%a
echo "close ConfigNode, PID:" %%a
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeRequestType.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeRequestType.java
index e9aa1e93f9d72..5f3064b4eed73 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeRequestType.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/ConfigNodeRequestType.java
@@ -27,5 +27,7 @@ public enum ConfigNodeRequestType {
REMOVE_CONFIG_NODE,
DELETE_CONFIG_NODE_PEER,
REPORT_CONFIG_NODE_SHUTDOWN,
- STOP_CONFIG_NODE
+ STOP_CONFIG_NODE,
+ SET_CONFIGURATION,
+ SHOW_CONFIGURATION,
}
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/DataNodeRequestType.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/DataNodeRequestType.java
index 1eb2500eb83d1..6f22341e3958b 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/DataNodeRequestType.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/DataNodeRequestType.java
@@ -32,6 +32,8 @@ public enum DataNodeRequestType {
STOP_REPAIR_DATA,
LOAD_CONFIGURATION,
SET_SYSTEM_STATUS,
+ SET_CONFIGURATION,
+ SHOW_CONFIGURATION,
// Region Maintenance
CREATE_DATA_REGION,
diff --git a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java
index dd201a66b5745..155597ceb43d1 100644
--- a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java
+++ b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/client/async/AsyncDataNodeClientPool.java
@@ -23,6 +23,7 @@
import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
import org.apache.iotdb.common.rpc.thrift.TFlushReq;
+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;
@@ -341,6 +342,12 @@ private void sendAsyncRequestToDataNode(
(AsyncTSStatusRPCHandler)
clientHandler.createAsyncRPCHandler(requestId, targetDataNode));
break;
+ case SET_CONFIGURATION:
+ client.setConfiguration(
+ (TSetConfigurationReq) clientHandler.getRequest(requestId),
+ (AsyncTSStatusRPCHandler)
+ clientHandler.createAsyncRPCHandler(requestId, targetDataNode));
+ break;
case START_REPAIR_DATA:
client.startRepairData(
(AsyncTSStatusRPCHandler)
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 04d2c0917698d..ab85a9badcb9e 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
@@ -22,6 +22,7 @@
import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
import org.apache.iotdb.common.rpc.thrift.TEndPoint;
import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.common.rpc.thrift.TSetConfigurationReq;
import org.apache.iotdb.commons.client.ClientPoolFactory;
import org.apache.iotdb.commons.client.IClientManager;
import org.apache.iotdb.commons.client.exception.ClientManagerException;
@@ -88,6 +89,8 @@ public Object sendSyncRequestToConfigNodeWithRetry(
case STOP_CONFIG_NODE:
// Only use stopConfigNode when the ConfigNode is removed.
return client.stopConfigNode((TConfigNodeLocation) req);
+ case SET_CONFIGURATION:
+ return client.setConfiguration((TSetConfigurationReq) 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 1d0e564e43cd1..9628bc805094e 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
@@ -64,7 +64,7 @@ private SyncDataNodeClientPool() {
new ClientPoolFactory.SyncDataNodeInternalServiceClientPoolFactory());
}
- public TSStatus sendSyncRequestToDataNodeWithRetry(
+ public Object sendSyncRequestToDataNodeWithRetry(
TEndPoint endPoint, Object req, DataNodeRequestType requestType) {
Throwable lastException = new TException();
for (int retry = 0; retry < DEFAULT_RETRY_NUM; retry++) {
@@ -83,7 +83,7 @@ public TSStatus sendSyncRequestToDataNodeWithRetry(
.setMessage("All retry failed due to: " + lastException.getMessage());
}
- public TSStatus sendSyncRequestToDataNodeWithGivenRetry(
+ public Object sendSyncRequestToDataNodeWithGivenRetry(
TEndPoint endPoint, Object req, DataNodeRequestType requestType, int retryNum) {
Throwable lastException = new TException();
for (int retry = 0; retry < retryNum; retry++) {
@@ -102,7 +102,7 @@ public TSStatus sendSyncRequestToDataNodeWithGivenRetry(
.setMessage("All retry failed due to: " + lastException.getMessage());
}
- private TSStatus executeSyncRequest(
+ private Object executeSyncRequest(
DataNodeRequestType requestType, SyncDataNodeInternalServiceClient client, Object req)
throws TException {
switch (requestType) {
@@ -138,6 +138,8 @@ private TSStatus executeSyncRequest(
return client.deleteOldRegionPeer((TMaintainPeerReq) req);
case RESET_PEER_LIST:
return client.resetPeerList((TResetPeerListReq) req);
+ case SHOW_CONFIGURATION:
+ return client.showConfiguration();
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/conf/ConfigNodeDescriptor.java b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/ConfigNodeDescriptor.java
index 94ed04849ecc3..e73ab25debe42 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
@@ -21,7 +21,7 @@
import org.apache.iotdb.commons.conf.CommonConfig;
import org.apache.iotdb.commons.conf.CommonDescriptor;
-import org.apache.iotdb.commons.conf.ConfigFileAutoUpdateTool;
+import org.apache.iotdb.commons.conf.ConfigurationFileUtils;
import org.apache.iotdb.commons.conf.IoTDBConstant;
import org.apache.iotdb.commons.exception.BadNodeUrlException;
import org.apache.iotdb.commons.schema.SchemaConstant;
@@ -55,13 +55,13 @@ public class ConfigNodeDescriptor {
private final ConfigNodeConfig conf = new ConfigNodeConfig();
static {
- ConfigFileAutoUpdateTool updateTool = new ConfigFileAutoUpdateTool();
URL systemConfigUrl = getPropsUrl(CommonConfig.SYSTEM_CONFIG_NAME);
URL configNodeUrl = getPropsUrl(CommonConfig.OLD_CONFIG_NODE_CONFIG_NAME);
URL dataNodeUrl = getPropsUrl(CommonConfig.OLD_DATA_NODE_CONFIG_NAME);
URL commonConfigUrl = getPropsUrl(CommonConfig.OLD_COMMON_CONFIG_NAME);
try {
- updateTool.checkAndMayUpdate(systemConfigUrl, configNodeUrl, dataNodeUrl, commonConfigUrl);
+ ConfigurationFileUtils.checkAndMayUpdate(
+ systemConfigUrl, configNodeUrl, dataNodeUrl, commonConfigUrl);
} catch (Exception e) {
LOGGER.error("Failed to update config file", e);
}
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 8238598e651b7..c3e97c960908a 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
@@ -28,14 +28,17 @@
import org.apache.iotdb.common.rpc.thrift.TSStatus;
import org.apache.iotdb.common.rpc.thrift.TSchemaNode;
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.TShowConfigurationResp;
import org.apache.iotdb.common.rpc.thrift.TTimePartitionSlot;
import org.apache.iotdb.commons.auth.AuthException;
import org.apache.iotdb.commons.cluster.NodeStatus;
import org.apache.iotdb.commons.cluster.NodeType;
import org.apache.iotdb.commons.conf.CommonConfig;
import org.apache.iotdb.commons.conf.CommonDescriptor;
+import org.apache.iotdb.commons.conf.ConfigurationFileUtils;
import org.apache.iotdb.commons.conf.IoTDBConstant;
import org.apache.iotdb.commons.exception.IllegalPathException;
import org.apache.iotdb.commons.exception.MetadataException;
@@ -208,7 +211,9 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.File;
import java.io.IOException;
+import java.net.URL;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
@@ -219,6 +224,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -1496,6 +1502,33 @@ public TSStatus clearCache() {
: status;
}
+ @Override
+ public TSStatus setConfiguration(TSetConfigurationReq req) {
+ TSStatus tsStatus = new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
+ int currentNodeId = CONF.getConfigNodeId();
+ if (req.getNodeId() < 0 || currentNodeId == req.getNodeId()) {
+ URL url = ConfigNodeDescriptor.getPropsUrl(CommonConfig.SYSTEM_CONFIG_NAME);
+ if (url == null || !new File(url.getFile()).exists()) {
+ return tsStatus;
+ }
+ File file = new File(url.getFile());
+ Properties properties = new Properties();
+ properties.putAll(req.getConfigs());
+ try {
+ ConfigurationFileUtils.updateConfigurationFile(file, properties);
+ } catch (Exception e) {
+ return RpcUtils.getStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR, e.getMessage());
+ }
+ if (CONF.getConfigNodeId() == req.getNodeId()) {
+ return tsStatus;
+ }
+ }
+ tsStatus = confirmLeader();
+ return tsStatus.getCode() == TSStatusCode.SUCCESS_STATUS.getStatusCode()
+ ? RpcUtils.squashResponseStatusList(nodeManager.setConfiguration(req))
+ : tsStatus;
+ }
+
@Override
public TSStatus startRepairData() {
TSStatus status = confirmLeader();
@@ -1520,6 +1553,25 @@ public TSStatus loadConfiguration() {
: status;
}
+ @Override
+ public TShowConfigurationResp showConfiguration(int nodeId) {
+ if (ConfigNodeDescriptor.getInstance().getConf().getConfigNodeId() == nodeId) {
+ TShowConfigurationResp resp =
+ new TShowConfigurationResp(RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS), "");
+ try {
+ URL propsUrl = ConfigNodeDescriptor.getPropsUrl(CommonConfig.SYSTEM_CONFIG_NAME);
+ resp.setContent(ConfigurationFileUtils.readConfigFileContent(propsUrl));
+ } 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.showConfiguration(nodeId)
+ : new TShowConfigurationResp(status, "");
+ }
+
@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 3ac0ee6ade41f..919e876bac213 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
@@ -23,7 +23,9 @@
import org.apache.iotdb.common.rpc.thrift.TDataNodeLocation;
import org.apache.iotdb.common.rpc.thrift.TFlushReq;
import org.apache.iotdb.common.rpc.thrift.TSStatus;
+import org.apache.iotdb.common.rpc.thrift.TSetConfigurationReq;
import org.apache.iotdb.common.rpc.thrift.TSetSpaceQuotaReq;
+import org.apache.iotdb.common.rpc.thrift.TShowConfigurationResp;
import org.apache.iotdb.commons.cluster.NodeStatus;
import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.path.PathPatternTree;
@@ -479,6 +481,9 @@ TDataPartitionTableResp getOrCreateDataPartition(
/** Clear cache on all DataNodes. */
TSStatus clearCache();
+ /** Set Configuration. */
+ TSStatus setConfiguration(TSetConfigurationReq req);
+
/** Check and repair unsorted tsfile by compaction. */
TSStatus startRepairData();
@@ -488,6 +493,9 @@ TDataPartitionTableResp getOrCreateDataPartition(
/** Load configuration on all DataNodes. */
TSStatus loadConfiguration();
+ /** Show content of configuration file on specified node */
+ TShowConfigurationResp showConfiguration(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 3c3c9358f81de..c85f0fbaba5a2 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
@@ -26,6 +26,8 @@
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.TShowConfigurationResp;
import org.apache.iotdb.commons.cluster.NodeStatus;
import org.apache.iotdb.commons.cluster.NodeType;
import org.apache.iotdb.commons.cluster.RegionRoleType;
@@ -33,9 +35,11 @@
import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.iotdb.commons.consensus.ConsensusGroupId;
import org.apache.iotdb.commons.service.metric.MetricService;
+import org.apache.iotdb.confignode.client.ConfigNodeRequestType;
import org.apache.iotdb.confignode.client.DataNodeRequestType;
import org.apache.iotdb.confignode.client.async.AsyncDataNodeClientPool;
import org.apache.iotdb.confignode.client.async.handlers.AsyncClientHandler;
+import org.apache.iotdb.confignode.client.sync.SyncConfigNodeClientPool;
import org.apache.iotdb.confignode.client.sync.SyncDataNodeClientPool;
import org.apache.iotdb.confignode.conf.ConfigNodeConfig;
import org.apache.iotdb.confignode.conf.ConfigNodeDescriptor;
@@ -725,6 +729,54 @@ public List clearCache() {
return clientHandler.getResponseList();
}
+ public List setConfiguration(TSetConfigurationReq req) {
+ List responseList = new ArrayList<>();
+
+ Map dataNodeLocationMap =
+ configManager.getNodeManager().getRegisteredDataNodeLocations();
+ Map targetDataNodes = new HashMap<>();
+ int nodeId = req.getNodeId();
+ // send to datanode
+ if (dataNodeLocationMap.containsKey(nodeId)) {
+ targetDataNodes.put(nodeId, dataNodeLocationMap.get(nodeId));
+ } else if (nodeId < 0) {
+ targetDataNodes.putAll(dataNodeLocationMap);
+ }
+ if (!targetDataNodes.isEmpty()) {
+ AsyncClientHandler