From 46332366057ab91c5a9b03aafc2404a98f4a482d Mon Sep 17 00:00:00 2001 From: JackieTien97 Date: Wed, 1 Apr 2020 17:40:10 +0800 Subject: [PATCH] upgrade system.properties --- pom.xml | 5 -- .../iotdb/db/conf/IoTDBConfigCheck.java | 59 ++++++++++++------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/pom.xml b/pom.xml index 57e0d39b0324..bbf972d364fb 100644 --- a/pom.xml +++ b/pom.xml @@ -44,8 +44,6 @@ ssh://git@github.com:apache/incubator-iotdb.git rel/0.10 - - @@ -53,12 +51,10 @@ scm:git:https://gitbox.apache.org/repos/asf/incubator-iotdb-website.git - Jira https://issues.apache.org/jira/browse/iotdb - Apache IoTDB Developer List @@ -82,7 +78,6 @@ http://mail-archives.apache.org/mod_mbox/iotdb-notifications/ - tsfile service-rpc 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 ec14db31634f..1b7e20bc3287 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 @@ 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 @@ private void createDir(String filepath) { } 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 @@ private void checkFile(String filepath) { .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