Skip to content

Commit 274fc9e

Browse files
authored
Use the correct value in showConfiguration to override the value read from the configuration file (apache#16681)
1 parent 26ca344 commit 274fc9e

File tree

5 files changed

+73
-1
lines changed

5 files changed

+73
-1
lines changed

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/conf/SystemPropertiesUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.apache.iotdb.common.rpc.thrift.TConfigNodeLocation;
2323
import org.apache.iotdb.commons.conf.CommonConfig;
2424
import org.apache.iotdb.commons.conf.CommonDescriptor;
25+
import org.apache.iotdb.commons.conf.ConfigurationFileUtils;
2526
import org.apache.iotdb.commons.conf.IoTDBConstant;
2627
import org.apache.iotdb.commons.exception.BadNodeUrlException;
2728
import org.apache.iotdb.commons.file.SystemPropertiesHandler;
@@ -87,6 +88,7 @@ public static boolean isRestarted() {
8788
*/
8889
public static void checkSystemProperties() throws IOException {
8990
Properties systemProperties = systemPropertiesHandler.read();
91+
ConfigurationFileUtils.updateAppliedProperties(systemProperties, false);
9092
final String format =
9193
"[SystemProperties] The parameter \"{}\" can't be modified after first startup."
9294
+ " Your configuration: {} will be forced update to: {}";

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBStartCheck.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,4 +415,8 @@ public void checkEncryptMagicString() throws IOException, ConfigurationException
415415
}
416416
}
417417
}
418+
419+
public Properties getProperties() {
420+
return properties;
421+
}
418422
}

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/service/DataNode.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.apache.iotdb.commons.client.exception.ClientManagerException;
3636
import org.apache.iotdb.commons.concurrent.IoTDBDefaultThreadExceptionHandler;
3737
import org.apache.iotdb.commons.conf.CommonDescriptor;
38+
import org.apache.iotdb.commons.conf.ConfigurationFileUtils;
3839
import org.apache.iotdb.commons.conf.IoTDBConstant;
3940
import org.apache.iotdb.commons.consensus.ConsensusGroupId;
4041
import org.apache.iotdb.commons.consensus.DataRegionId;
@@ -270,6 +271,8 @@ protected void start() {
270271

271272
// Serialize mutable system properties
272273
IoTDBStartCheck.getInstance().serializeMutableSystemPropertiesIfNecessary();
274+
ConfigurationFileUtils.updateAppliedProperties(
275+
IoTDBStartCheck.getInstance().getProperties(), false);
273276

274277
logger.info("IoTDB configuration: {}", config.getConfigMessage());
275278
logger.info("Congratulations, IoTDB DataNode is set up successfully. Now, enjoy yourself!");
@@ -439,6 +442,7 @@ private void pullAndCheckSystemConfigurations() throws StartupException {
439442
throw new StartupException(e.getMessage());
440443
}
441444

445+
ConfigurationFileUtils.updateAppliedPropertiesFromCN(configurationResp);
442446
// init
443447
initTimestampPrecision();
444448
long endTime = System.currentTimeMillis();

iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/conf/ConfigurationFileUtils.java

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.apache.iotdb.commons.conf;
2121

2222
import org.apache.iotdb.commons.auth.entity.PrivilegeType;
23+
import org.apache.iotdb.confignode.rpc.thrift.TSystemConfigurationResp;
2324

2425
import org.slf4j.Logger;
2526
import org.slf4j.LoggerFactory;
@@ -91,7 +92,7 @@ public class ConfigurationFileUtils {
9192
hidedParameters.add("trust_store_pwd");
9293
}
9394

94-
public static void updateAppliedProperties(TrimProperties properties, boolean isHotReloading) {
95+
public static void updateAppliedProperties(Properties properties, boolean isHotReloading) {
9596
try {
9697
loadConfigurationDefaultValueFromTemplate();
9798
} catch (IOException e) {
@@ -114,6 +115,65 @@ public static void updateAppliedProperties(TrimProperties properties, boolean is
114115
}
115116
}
116117

118+
public static void updateAppliedPropertiesFromCN(TSystemConfigurationResp resp) {
119+
if (resp.getGlobalConfig().isSetTimestampPrecision()) {
120+
lastAppliedProperties.put(
121+
"timestamp_precision", resp.getGlobalConfig().getTimestampPrecision());
122+
}
123+
if (resp.getGlobalConfig().isSetTimePartitionInterval()) {
124+
lastAppliedProperties.put(
125+
"time_partition_interval",
126+
String.valueOf(resp.getGlobalConfig().getTimePartitionInterval()));
127+
}
128+
if (resp.getGlobalConfig().isSetTimePartitionOrigin()) {
129+
lastAppliedProperties.put(
130+
"time_partition_origin", String.valueOf(resp.getGlobalConfig().getTimePartitionOrigin()));
131+
}
132+
if (resp.getGlobalConfig().isSetSchemaEngineMode()) {
133+
lastAppliedProperties.put("schema_engine_mode", resp.getGlobalConfig().getSchemaEngineMode());
134+
}
135+
if (resp.getGlobalConfig().isSetTagAttributeTotalSize()) {
136+
lastAppliedProperties.put(
137+
"tag_attribute_total_size",
138+
String.valueOf(resp.getGlobalConfig().getTagAttributeTotalSize()));
139+
}
140+
if (resp.getGlobalConfig().isSetSeriesPartitionExecutorClass()) {
141+
lastAppliedProperties.put(
142+
"series_partition_executor_class",
143+
resp.getGlobalConfig().getSeriesPartitionExecutorClass());
144+
}
145+
if (resp.getGlobalConfig().isSetSeriesPartitionSlotNum()) {
146+
lastAppliedProperties.put(
147+
"series_slot_num", String.valueOf(resp.getGlobalConfig().getSeriesPartitionSlotNum()));
148+
}
149+
if (resp.getGlobalConfig().isSetDataRegionConsensusProtocolClass()) {
150+
lastAppliedProperties.put(
151+
"data_region_consensus_protocol_class",
152+
resp.getGlobalConfig().getDataRegionConsensusProtocolClass());
153+
}
154+
if (resp.getGlobalConfig().isSetSchemaRegionConsensusProtocolClass()) {
155+
lastAppliedProperties.put(
156+
"schema_region_consensus_protocol_class",
157+
resp.getGlobalConfig().getSchemaRegionConsensusProtocolClass());
158+
}
159+
if (resp.getGlobalConfig().isSetReadConsistencyLevel()) {
160+
lastAppliedProperties.put(
161+
"read_consistency_level", resp.getGlobalConfig().getReadConsistencyLevel());
162+
}
163+
if (resp.getGlobalConfig().isSetDiskSpaceWarningThreshold()) {
164+
lastAppliedProperties.put(
165+
"disk_space_warning_threshold",
166+
String.valueOf(resp.getGlobalConfig().getDiskSpaceWarningThreshold()));
167+
}
168+
}
169+
170+
// This method may not be used in the current version directly, but should not be removed to
171+
// reduce conflicts
172+
@SuppressWarnings("unused")
173+
public static void updateAppliedProperties(String key, String value) {
174+
lastAppliedProperties.put(key, value);
175+
}
176+
117177
public static Map<String, String> getAppliedProperties() {
118178
return lastAppliedProperties;
119179
}

iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/file/SystemPropertiesHandler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
package org.apache.iotdb.commons.file;
2121

22+
import org.apache.iotdb.commons.conf.ConfigurationFileUtils;
2223
import org.apache.iotdb.commons.conf.IoTDBConstant;
2324

2425
import org.apache.ratis.util.AutoCloseableLock;
@@ -80,6 +81,7 @@ public void put(Object... keyOrValue) throws IOException {
8081
}
8182

8283
public void overwrite(Properties properties) throws IOException {
84+
ConfigurationFileUtils.updateAppliedProperties(properties, false);
8385
try (AutoCloseableLock ignore = AutoCloseableLock.acquire(lock.writeLock())) {
8486
if (!formalFile.exists()) {
8587
writeWithoutLock(properties, formalFile);

0 commit comments

Comments
 (0)