This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch rel/1.2
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/rel/1.2 by this push:
     new 61d5da09659  [To rel/1.2] [IOTDB-5999] system.properties patch (#10228)
61d5da09659 is described below

commit 61d5da0965925750cd90e2c4f6ec76f72a75de5a
Author: YongzaoDan <[email protected]>
AuthorDate: Tue Jun 20 17:59:06 2023 +0800

     [To rel/1.2] [IOTDB-5999] system.properties patch (#10228)
---
 .../confignode/conf/SystemPropertiesUtils.java     |  1 +
 .../org/apache/iotdb/db/conf/IoTDBStartCheck.java  | 35 ++--------------------
 .../java/org/apache/iotdb/db/service/DataNode.java |  1 -
 3 files changed, 4 insertions(+), 33 deletions(-)

diff --git 
a/confignode/src/main/java/org/apache/iotdb/confignode/conf/SystemPropertiesUtils.java
 
b/confignode/src/main/java/org/apache/iotdb/confignode/conf/SystemPropertiesUtils.java
index b9ac61a07e4..4406c80d7b2 100644
--- 
a/confignode/src/main/java/org/apache/iotdb/confignode/conf/SystemPropertiesUtils.java
+++ 
b/confignode/src/main/java/org/apache/iotdb/confignode/conf/SystemPropertiesUtils.java
@@ -215,6 +215,7 @@ public class SystemPropertiesUtils {
     Properties systemProperties = getSystemProperties();
 
     systemProperties.setProperty("iotdb_version", IoTDBConstant.VERSION);
+    systemProperties.setProperty("commit_id", IoTDBConstant.BUILD_INFO);
 
     // Cluster configuration
     systemProperties.setProperty("cluster_name", conf.getClusterName());
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBStartCheck.java 
b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBStartCheck.java
index 49254e93b6b..4d9530b7d62 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBStartCheck.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBStartCheck.java
@@ -24,7 +24,6 @@ import org.apache.iotdb.commons.conf.CommonDescriptor;
 import org.apache.iotdb.commons.conf.IoTDBConstant;
 import org.apache.iotdb.commons.exception.ConfigurationException;
 import org.apache.iotdb.commons.file.SystemFileFactory;
-import org.apache.iotdb.confignode.rpc.thrift.TGlobalConfig;
 import org.apache.iotdb.consensus.ConsensusFactory;
 import org.apache.iotdb.db.conf.directories.DirectoryChecker;
 import org.apache.iotdb.db.wal.utils.WALMode;
@@ -100,6 +99,7 @@ public class IoTDBStartCheck {
   // endregion
   // region params don't need checking, determined by the system
   private static final String IOTDB_VERSION_STRING = "iotdb_version";
+  private static final String COMMIT_ID_STRING = "commit_id";
   private static final String DATA_NODE_ID = "data_node_id";
   private static final String SCHEMA_REGION_CONSENSUS_PROTOCOL = 
"schema_region_consensus_protocol";
   private static final String DATA_REGION_CONSENSUS_PROTOCOL = 
"data_region_consensus_protocol";
@@ -147,6 +147,7 @@ public class IoTDBStartCheck {
             IoTDBStartCheck.SCHEMA_DIR + File.separator + PROPERTIES_FILE_NAME 
+ ".tmp");
 
     systemProperties.put(IOTDB_VERSION_STRING, () -> IoTDBConstant.VERSION);
+    systemProperties.put(COMMIT_ID_STRING, () -> IoTDBConstant.BUILD_INFO);
     for (String param : variableParamValueTable.keySet()) {
       systemProperties.put(param, () -> getVal(param));
     }
@@ -344,6 +345,7 @@ public class IoTDBStartCheck {
             }
           });
       properties.setProperty(IOTDB_VERSION_STRING, IoTDBConstant.VERSION);
+      properties.setProperty(COMMIT_ID_STRING, IoTDBConstant.BUILD_INFO);
       properties.store(tmpFOS, SYSTEM_PROPERTIES_STRING);
       // upgrade finished, delete old system.properties file
       if (propertiesFile.exists()) {
@@ -425,37 +427,6 @@ public class IoTDBStartCheck {
     FileUtils.moveFile(tmpPropertiesFile, propertiesFile);
   }
 
-  public void serializeGlobalConfig(TGlobalConfig globalConfig) throws 
IOException {
-    // create an empty tmpPropertiesFile
-    if (tmpPropertiesFile.createNewFile()) {
-      logger.info("Create system.properties.tmp {}.", tmpPropertiesFile);
-    } else {
-      logger.error("Create system.properties.tmp {} failed.", 
tmpPropertiesFile);
-      System.exit(-1);
-    }
-
-    reloadProperties();
-
-    try (FileOutputStream tmpFOS = new 
FileOutputStream(tmpPropertiesFile.toString())) {
-
-      if (!checkConsensusProtocolExists(TConsensusGroupType.DataRegion)) {
-        properties.setProperty(
-            DATA_REGION_CONSENSUS_PROTOCOL, 
globalConfig.getDataRegionConsensusProtocolClass());
-      }
-      if (!checkConsensusProtocolExists(TConsensusGroupType.SchemaRegion)) {
-        properties.setProperty(
-            SCHEMA_REGION_CONSENSUS_PROTOCOL, 
globalConfig.getSchemaRegionConsensusProtocolClass());
-      }
-      properties.store(tmpFOS, SYSTEM_PROPERTIES_STRING);
-      // serialize finished, delete old system.properties file
-      if (propertiesFile.exists()) {
-        Files.delete(propertiesFile.toPath());
-      }
-    }
-    // rename system.properties.tmp to system.properties
-    FileUtils.moveFile(tmpPropertiesFile, propertiesFile);
-  }
-
   public boolean checkConsensusProtocolExists(TConsensusGroupType type) {
     if (type == TConsensusGroupType.DataRegion) {
       return properties.containsKey(DATA_REGION_CONSENSUS_PROTOCOL);
diff --git a/server/src/main/java/org/apache/iotdb/db/service/DataNode.java 
b/server/src/main/java/org/apache/iotdb/db/service/DataNode.java
index ebcc6cea623..5ae417d3a29 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/DataNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/DataNode.java
@@ -293,7 +293,6 @@ public class DataNode implements DataNodeMBean {
     try {
       IoTDBStartCheck.getInstance().checkSystemConfig();
       IoTDBStartCheck.getInstance().checkDirectory();
-      
IoTDBStartCheck.getInstance().serializeGlobalConfig(configurationResp.globalConfig);
       if 
(!config.getDataRegionConsensusProtocolClass().equals(ConsensusFactory.IOT_CONSENSUS))
 {
         // In current implementation, only IoTConsensus need separated memory 
from Consensus
         IoTDBDescriptor.getInstance().reclaimConsensusMemory();

Reply via email to