You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2020/04/23 14:41:45 UTC
[GitHub] [incubator-iotdb] HTHou commented on a change in pull request #983: Upgrade tool
HTHou commented on a change in pull request #983:
URL: https://github.com/apache/incubator-iotdb/pull/983#discussion_r413855542
##########
File path: server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java
##########
@@ -100,46 +102,83 @@ private void checkFile(String filepath) {
properties.store(outputStream, "System properties:");
}
}
+ else if (!file.exists() && tmpPropertiesFile.exists()) {
+ // rename upgraded system.properties.tmp to system.properties
+ FSFactoryProducer.getFSFactory().moveFile(tmpPropertiesFile, file);
+ logger.info(" {} has been upgraded.", file.getAbsolutePath());
+ }
} catch (IOException e) {
logger.error("Can not create {}.", file.getAbsolutePath(), e);
}
+
// get existed properties from system_properties.txt
File inputFile = SystemFileFactory.INSTANCE
.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);
- }
- if (properties.getProperty("iotdb_version") == null) {
- logger.info("Lower iotdb version detected, upgrading old mlog file... ");
- MLogWriter.upgradeMLog(IoTDBDescriptor.getInstance().getConfig().getSchemaDir(),
- MetadataConstant.METADATA_LOG);
- logger.info("Old mlog file is upgraded.");
- try (FileOutputStream outputStream = new FileOutputStream(file.toString())) {
- properties.setProperty("timestamp_precision", timestampPrecision);
- properties.setProperty("storage_group_time_range", String.valueOf(partitionInterval));
- properties.setProperty("tsfile_storage_fs", tsfileFileSystem);
- properties.setProperty("iotdb_version", iotdbVersion);
- properties.store(outputStream, "System properties:");
+ // need to upgrade
+ if (!properties.containsKey("iotdb_version")) {
+ properties.setProperty("storage_group_time_range", String.valueOf(partitionInterval));
+ properties.setProperty("tsfile_storage_fs", tsfileFileSystem);
+ properties.setProperty("iotdb_version", iotdbVersion);
+ // upgrade mlog
+ try {
+ MLogWriter.upgradeMLog(IoTDBDescriptor.getInstance().getConfig().getSchemaDir(),
+ MetadataConstant.METADATA_LOG);
+ } catch (IOException e) {
+ logger.error("Upgrade mlog.txt from {} failed.", file.getAbsolutePath(), e);
}
+ } 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, tsfile_storage_fs
+ // and iotdb_version property in system.properties.tmp
+ try (FileOutputStream outputStream = new FileOutputStream(tmpPropertiesFile.toString())) {
Review comment:
I have fixed this bug. This is caused by the wrong name of system.properties.tmp.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org