You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2020/04/01 09:40:34 UTC

[incubator-iotdb] 01/01: upgrade system.properties

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

jackietien pushed a commit to branch ty-upgrade
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit 46332366057ab91c5a9b03aafc2404a98f4a482d
Author: JackieTien97 <Ja...@foxmail.com>
AuthorDate: Wed Apr 1 17:40:10 2020 +0800

    upgrade system.properties
---
 pom.xml                                            |  5 --
 .../org/apache/iotdb/db/conf/IoTDBConfigCheck.java | 59 ++++++++++++++--------
 2 files changed, 39 insertions(+), 25 deletions(-)

diff --git a/pom.xml b/pom.xml
index 57e0d39..bbf972d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,8 +44,6 @@
         <url>ssh://git@github.com:apache/incubator-iotdb.git</url>
         <tag>rel/0.10</tag>
     </scm>
-
-
     <!-- Only configure the site distribution as the rest is handled by the apache parent -->
     <distributionManagement>
         <site>
@@ -53,12 +51,10 @@
             <url>scm:git:https://gitbox.apache.org/repos/asf/incubator-iotdb-website.git</url>
         </site>
     </distributionManagement>
-
     <issueManagement>
         <system>Jira</system>
         <url>https://issues.apache.org/jira/browse/iotdb</url>
     </issueManagement>
-
     <mailingLists>
         <mailingList>
             <name>Apache IoTDB Developer List</name>
@@ -82,7 +78,6 @@
             <archive>http://mail-archives.apache.org/mod_mbox/iotdb-notifications/</archive>
         </mailingList>
     </mailingLists>
-
     <modules>
         <module>tsfile</module>
         <module>service-rpc</module>
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java
index ec14db3..1b7e20b 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java
@@ -28,8 +28,8 @@ import java.util.Properties;
 
 public class IoTDBConfigCheck {
 
-  // this file is located in data/system/schema/system_properties.
-  // If user delete folder "data", system_properties can reset.
+  // this file is located in data/system/schema/system.properties
+  // If user delete folder "data", system.properties can reset.
   public static final String PROPERTIES_FILE_NAME = "system.properties";
   public static final String SCHEMA_DIR =
           IoTDBDescriptor.getInstance().getConfig().getSchemaDir();
@@ -81,7 +81,7 @@ public class IoTDBConfigCheck {
   }
 
   private void checkFile(String filepath) {
-    // create file : read timestamp precision from engine.properties, create system_properties.txt
+    // create file : read timestamp precision from engine.properties, create system.properties
     // use output stream to write timestamp precision to file.
     File file = SystemFileFactory.INSTANCE
             .getFile(filepath + File.separator + PROPERTIES_FILE_NAME);
@@ -104,26 +104,45 @@ public class IoTDBConfigCheck {
             .getFile(filepath + File.separator + PROPERTIES_FILE_NAME);
     try (FileInputStream inputStream = new FileInputStream(inputFile.toString())) {
       properties.load(new InputStreamReader(inputStream, TSFileConfig.STRING_CHARSET));
-      if (!properties.getProperty("timestamp_precision").equals(timestampPrecision)) {
-        logger.error("Wrong timestamp precision, please set as: " + properties
-                .getProperty("timestamp_precision") + " !");
-        System.exit(-1);
-      }
-      if (!(Long.parseLong(properties.getProperty("storage_group_time_range"))
-              == partitionInterval)) {
-        logger.error("Wrong storage group time range, please set as: " + properties
-                .getProperty("storage_group_time_range") + " !");
-        System.exit(-1);
-      }
-      if (!(properties.getProperty("tsfile_storage_fs").equals(tsfileFileSystem))) {
-        logger.error("Wrong tsfile file system, please set as: " + properties
-            .getProperty("tsfile_storage_fs") + " !");
-        System.exit(-1);
+      // need to upgrade
+      if (!properties.containsKey("storage_group_time_range")) {
+        properties.setProperty("storage_group_time_range", String.valueOf(partitionInterval));
+      } else {
+        checkProperties();
+        return;
       }
     } catch (IOException e) {
       logger.error("Load system.properties from {} failed.", file.getAbsolutePath(), e);
     }
-  }
-}
 
+    // it's an old version system.properties
+    // try to add the storage_group_time_range property in system.properties
+    try (FileOutputStream outputStream = new FileOutputStream(file.toString())) {
+      properties.store(outputStream, "System properties:");
+      logger.info("The system.properties has been upgraded successfully.");
+      checkProperties();
+    }  catch (IOException e) {
+      logger.error("Something went wrong while upgrading the system.properties. The file is {}.", file.getAbsolutePath(), e);
+    }
 
+  }
+
+  private void checkProperties() {
+    if (!properties.getProperty("timestamp_precision").equals(timestampPrecision)) {
+      logger.error("Wrong timestamp precision, please set as: " + properties
+              .getProperty("timestamp_precision") + " !");
+      System.exit(-1);
+    }
+    if (!(Long.parseLong(properties.getProperty("storage_group_time_range"))
+            == partitionInterval)) {
+      logger.error("Wrong storage group time range, please set as: " + properties
+              .getProperty("storage_group_time_range") + " !");
+      System.exit(-1);
+    }
+    if (!(properties.getProperty("tsfile_storage_fs").equals(tsfileFileSystem))) {
+      logger.error("Wrong tsfile file system, please set as: " + properties
+              .getProperty("tsfile_storage_fs") + " !");
+      System.exit(-1);
+    }
+  }
+}
\ No newline at end of file