Skip to content

Commit

Permalink
upgrade system.properties
Browse files Browse the repository at this point in the history
  • Loading branch information
JackieTien97 committed Apr 1, 2020
1 parent c6c23a3 commit 4633236
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 25 deletions.
5 changes: 0 additions & 5 deletions pom.xml
Expand Up @@ -44,21 +44,17 @@
<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>
<id>apache.website</id>
<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>
Expand All @@ -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>
Expand Down
59 changes: 39 additions & 20 deletions server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
}
}

0 comments on commit 4633236

Please sign in to comment.