This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 8bafdfc [IOTDB-697] add enablePartition in config (#1248)
8bafdfc is described below
commit 8bafdfc0d5656eefb0352ee79902fab0ff8fa290
Author: Jialin Qiao <[email protected]>
AuthorDate: Sun May 24 19:53:49 2020 +0800
[IOTDB-697] add enablePartition in config (#1248)
* add enablePartition in config
* refactor IoTDBConfigCheck
---
docs/UserGuide/3-Server/4-Config Manual.md | 11 +-
docs/zh/UserGuide/3-Server/4-Config Manual.md | 9 +
.../resources/conf/iotdb-engine.properties | 8 +-
.../java/org/apache/iotdb/db/conf/IoTDBConfig.java | 23 +-
.../org/apache/iotdb/db/conf/IoTDBConfigCheck.java | 302 ++++++++++++---------
.../org/apache/iotdb/db/conf/IoTDBDescriptor.java | 7 +-
.../org/apache/iotdb/db/engine/StorageEngine.java | 47 ++--
.../engine/storagegroup/StorageGroupProcessor.java | 4 +-
.../java/org/apache/iotdb/db/service/IoTDB.java | 7 +-
9 files changed, 270 insertions(+), 148 deletions(-)
diff --git a/docs/UserGuide/3-Server/4-Config Manual.md
b/docs/UserGuide/3-Server/4-Config Manual.md
index 2059bb4..86f8165 100644
--- a/docs/UserGuide/3-Server/4-Config Manual.md
+++ b/docs/UserGuide/3-Server/4-Config Manual.md
@@ -272,6 +272,15 @@ The permission definitions are in
${IOTDB\_CONF}/conf/jmx.access.
|Default| true |
|Effective|Trigger|
+* enable\_partition
+
+|Name| enable\_partition |
+|:---:|:---|
+|Description| Whether enable time partition for data, if disabled, all data
belongs to partition 0 |
+|Type|Bool|
+|Default| false |
+|Effective|After restart system|
+
* partition\_interval
|Name| partition\_interval |
@@ -288,7 +297,7 @@ The permission definitions are in
${IOTDB\_CONF}/conf/jmx.access.
|:---:|:---|
|Description| This config decides how many time partitions in a storage group
can be inserted concurrently </br> For example, your partitionInterval is 86400
and you want to insert data in 5 different days, |
|Type|Int32|
-|Default| 5 |
+|Default| 1 |
|Effective|After restart system|
* multi\_dir\_strategy
diff --git a/docs/zh/UserGuide/3-Server/4-Config Manual.md
b/docs/zh/UserGuide/3-Server/4-Config Manual.md
index 1361cf5..d75c978 100644
--- a/docs/zh/UserGuide/3-Server/4-Config Manual.md
+++ b/docs/zh/UserGuide/3-Server/4-Config Manual.md
@@ -253,6 +253,15 @@
|默认值| 0 |
|改后生效方式|重启服务器生效|
+* enable\_partition
+
+|Name| enable\_partition |
+|:---:|:---|
+|Description| 是否开启将数据按时间分区存储的功能,如果关闭,所有数据都属于分区 0|
+|Type|Bool|
+|Default| false |
+|Effective|重启服务器生效|
+
* partition\_interval
|名字| partition\_interval |
diff --git a/server/src/assembly/resources/conf/iotdb-engine.properties
b/server/src/assembly/resources/conf/iotdb-engine.properties
index 6135c24..4d10c01 100644
--- a/server/src/assembly/resources/conf/iotdb-engine.properties
+++ b/server/src/assembly/resources/conf/iotdb-engine.properties
@@ -175,6 +175,10 @@ timestamp_precision=ms
# data.
# default_ttl=36000000
+# whether enable data partition
+# if disabled, all data belongs to the partition 0
+enable_partition=false
+
# Time range for divide storage group
# Time series data will divide into groups by this time range
# Unit is second
@@ -211,8 +215,8 @@ chunk_buffer_pool_enable=false
# This config decides how many time partitions in a storage group can be
inserted concurrently
# For example, your partitionInterval is 86400 and you want to insert data in
5 different days,
# you should set this param >= 5
-# default number is 5
-concurrent_writing_time_partition=5
+# default number is 1
+concurrent_writing_time_partition=1
# The amount of data iterate each time in server (the number of data strips,
that is, the number of different timestamps.)
batch_size=100000
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
index 0d04592..8547960 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
@@ -516,7 +516,7 @@ public class IoTDBConfig {
/**
* the num of memtable in each storage group
*/
- private int concurrentWritingTimePartition = 10;
+ private int concurrentWritingTimePartition = 1;
/**
* the default fill interval in LinearFill and PreviousFill, -1 means
infinite past time
@@ -534,6 +534,13 @@ public class IoTDBConfig {
* The default value of primitive array size in array pool
*/
private int primitiveArraySize = 128;
+
+ /**
+ * whether enable data partition
+ * if disabled, all data belongs to partition 0
+ */
+ private boolean enablePartition = false;
+
/**
* Time range for partitioning data inside each storage group, the unit is
second
*/
@@ -568,6 +575,14 @@ public class IoTDBConfig {
this.defaultFillInterval = defaultFillInterval;
}
+ public boolean isEnablePartition() {
+ return enablePartition;
+ }
+
+ public void setEnablePartition(boolean enablePartition) {
+ this.enablePartition = enablePartition;
+ }
+
public long getPartitionInterval() {
return partitionInterval;
}
@@ -729,6 +744,12 @@ public class IoTDBConfig {
}
void setTimestampPrecision(String timestampPrecision) {
+ if (!(timestampPrecision.equals("ms") || timestampPrecision.equals("us")
+ || timestampPrecision.equals("ns"))) {
+ logger.error("Wrong timestamp precision, please set as: ms, us or ns !
Current is: "
+ + timestampPrecision);
+ System.exit(-1);
+ }
this.timestampPrecision = timestampPrecision;
}
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 eacca25..0c090ac 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
@@ -18,6 +18,9 @@
*/
package org.apache.iotdb.db.conf;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
import org.apache.commons.io.FileUtils;
import org.apache.iotdb.db.conf.directories.DirectoryManager;
import org.apache.iotdb.db.engine.fileSystem.SystemFileFactory;
@@ -37,38 +40,71 @@ import java.util.Properties;
public class IoTDBConfigCheck {
+ private static final Logger logger =
LoggerFactory.getLogger(IoTDBDescriptor.class);
+
// 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();
- public static final String WAL_DIR =
- IoTDBDescriptor.getInstance().getConfig().getWalFolder();
- private static final Logger logger =
LoggerFactory.getLogger(IoTDBDescriptor.class);
- // this is a initial parameter.
- private static String timestampPrecision = "ms";
- private static long partitionInterval = 86400;
- private static String tsfileFileSystem = "LOCAL";
- private static String iotdbVersion = "0.10.0";
+ private static final String PROPERTIES_FILE_NAME = "system.properties";
+ private static final String SCHEMA_DIR =
IoTDBDescriptor.getInstance().getConfig().getSchemaDir();
+ private static final String WAL_DIR =
IoTDBDescriptor.getInstance().getConfig().getWalFolder();
+
+ private File propertiesFile;
+ private File tmpPropertiesFile;
+
private Properties properties = new Properties();
+ private Map<String, String> systemProperties = new HashMap<>();
+
+ private static final String SYSTEM_PROPERTIES_STRING = "System properties:";
+
+ private static final String TIMESTAMP_PRECISION_STRING =
"timestamp_precision";
+ private static String timestampPrecision =
IoTDBDescriptor.getInstance().getConfig().getTimestampPrecision();
+
+ private static final String PARTITION_INTERVAL_STRING = "partition_interval";
+ private static long partitionInterval =
IoTDBDescriptor.getInstance().getConfig().getPartitionInterval();
+
+ private static final String TSFILE_FILE_SYSTEM_STRING = "tsfile_storage_fs";
+ private static String tsfileFileSystem =
IoTDBDescriptor.getInstance().getConfig().getTsFileStorageFs().toString();
+
+ private static final String ENABLE_PARTITION_STRING = "enable_partition";
+ private static boolean enablePartition =
IoTDBDescriptor.getInstance().getConfig().isEnablePartition();
+
+ private static final String IOTDB_VERSION_STRING = "iotdb_version";
+ private static String iotdbVersion = "0.10.0";
+
public static IoTDBConfigCheck getInstance() {
return IoTDBConfigCheckHolder.INSTANCE;
}
- public void checkConfig() {
- timestampPrecision =
IoTDBDescriptor.getInstance().getConfig().getTimestampPrecision();
+ private static class IoTDBConfigCheckHolder {
+ private static final IoTDBConfigCheck INSTANCE = new IoTDBConfigCheck();
+ }
+
+ private IoTDBConfigCheck() {
+ logger.info("Starting IoTDB " + iotdbVersion);
+
+ // check whether SCHEMA_DIR exists, create if not exists
+ File dir = SystemFileFactory.INSTANCE.getFile(SCHEMA_DIR);
+ if (!dir.exists()) {
+ if (!dir.mkdirs()) {
+ logger.error("can not create schema dir: {}", SCHEMA_DIR);
+ System.exit(-1);
+ } else {
+ logger.info(" {} dir has been created.", SCHEMA_DIR);
+ }
+ }
// check time stamp precision
if (!(timestampPrecision.equals("ms") || timestampPrecision.equals("us")
- || timestampPrecision.equals("ns"))) {
- logger.error("Wrong timestamp precision, please set as: ms, us or ns !
Current is: "
- + timestampPrecision);
+ || timestampPrecision.equals("ns"))) {
+ logger.error("Wrong " + TIMESTAMP_PRECISION_STRING + ", please set as:
ms, us or ns ! Current is: "
+ + timestampPrecision);
System.exit(-1);
}
- partitionInterval = IoTDBDescriptor.getInstance().getConfig()
- .getPartitionInterval();
+ if (!enablePartition) {
+ partitionInterval = Long.MAX_VALUE;
+ }
// check partition interval
if (partitionInterval <= 0) {
@@ -76,131 +112,157 @@ public class IoTDBConfigCheck {
System.exit(-1);
}
- tsfileFileSystem =
IoTDBDescriptor.getInstance().getConfig().getTsFileStorageFs().toString();
- createDir(SCHEMA_DIR);
- checkFile(SCHEMA_DIR);
- logger.info("System configuration is ok.");
-
+ systemProperties.put(TIMESTAMP_PRECISION_STRING, timestampPrecision);
+ systemProperties.put(PARTITION_INTERVAL_STRING,
String.valueOf(partitionInterval));
+ systemProperties.put(TSFILE_FILE_SYSTEM_STRING, tsfileFileSystem);
+ systemProperties.put(ENABLE_PARTITION_STRING,
String.valueOf(enablePartition));
+ systemProperties.put(IOTDB_VERSION_STRING, iotdbVersion);
}
- private void createDir(String filepath) {
- File dir = SystemFileFactory.INSTANCE.getFile(filepath);
- if (!dir.exists()) {
- dir.mkdirs();
- logger.info(" {} dir has been created.", SCHEMA_DIR);
- }
- }
- private void checkFile(String filepath) {
- // 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);
- File tmpPropertiesFile = new File(file.getAbsoluteFile() + ".tmp");
- try {
- if (!file.exists() && !tmpPropertiesFile.exists()) {
- file.createNewFile();
- logger.info(" {} has been created.", file.getAbsolutePath());
- 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:");
- }
- return;
+ /**
+ * check configuration in system.properties when starting IoTDB
+ *
+ * When init: create system.properties directly
+ *
+ * When upgrading the system.properties:
+ * (1) create system.properties.tmp
+ * (2) delete system.properties
+ * (2) rename system.properties.tmp to system.properties
+ */
+ public void checkConfig() throws IOException {
+ propertiesFile = SystemFileFactory.INSTANCE
+ .getFile(IoTDBConfigCheck.SCHEMA_DIR + File.separator +
PROPERTIES_FILE_NAME);
+ tmpPropertiesFile = new File(propertiesFile.getAbsoluteFile() + ".tmp");
+
+ // system init first time, no need to check, write system.properties and
return
+ if (!propertiesFile.exists() && !tmpPropertiesFile.exists()) {
+ // create system.properties
+ if (propertiesFile.createNewFile()) {
+ logger.info(" {} has been created.", propertiesFile.getAbsolutePath());
+ } else {
+ logger.error("can not create {}", propertiesFile.getAbsolutePath());
+ System.exit(-1);
}
- else if (!file.exists() && tmpPropertiesFile.exists()) {
- // rename upgraded system.properties.tmp to system.properties
- FileUtils.moveFile(tmpPropertiesFile, file);
- logger.info(" {} has been upgraded.", file.getAbsolutePath());
- checkProperties();
- return;
+
+ // write properties to system.properties
+ try (FileOutputStream outputStream = new
FileOutputStream(propertiesFile)) {
+ systemProperties.forEach((k, v) -> properties.setProperty(k, v));
+ properties.store(outputStream, SYSTEM_PROPERTIES_STRING);
}
- } 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())) {
+ return;
+ }
+
+ if (!propertiesFile.exists() && tmpPropertiesFile.exists()) {
+ // rename tmp file to system.properties, no need to check
+ FileUtils.moveFile(tmpPropertiesFile, propertiesFile);
+ logger.info("rename {} to {}", tmpPropertiesFile, propertiesFile);
+ return;
+ } else if (propertiesFile.exists() && tmpPropertiesFile.exists()) {
+ // both files exist, remove tmp file
+ FileUtils.forceDeleteOnExit(tmpPropertiesFile);
+ logger.info("remove {}", tmpPropertiesFile);
+ }
+
+ // no tmp file, read properties from system.properties
+ try (FileInputStream inputStream = new FileInputStream(propertiesFile)) {
properties.load(new InputStreamReader(inputStream,
TSFileConfig.STRING_CHARSET));
- // need to upgrade
- if (!properties.containsKey("iotdb_version")) {
+ // need to upgrade from 0.9 to 0.10
+ if (!properties.containsKey(IOTDB_VERSION_STRING)) {
checkUnClosedTsFileV1();
- upgradeMlog();
- } else {
- checkProperties();
- return;
+ MLogWriter.upgradeMLog(SCHEMA_DIR, MetadataConstant.METADATA_LOG);
+ upgradePropertiesFile();
}
- } catch (IOException e) {
- logger.error("Load system.properties from {} failed.",
file.getAbsolutePath(), e);
+ checkProperties();
+ }
+ }
+
+ /**
+ * upgrade 0.9 properties to 0.10 properties
+ */
+ private void upgradePropertiesFile()
+ 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);
}
- // if tmpPropertiesFile exists, remove it
- if (tmpPropertiesFile.exists()) {
- try {
- Files.delete(tmpPropertiesFile.toPath());
- } catch (IOException e) {
- logger.error("Fail to remove broken file {}", tmpPropertiesFile);
+ try (FileOutputStream tmpFOS = new
FileOutputStream(tmpPropertiesFile.toString())) {
+ properties.setProperty(PARTITION_INTERVAL_STRING,
String.valueOf(partitionInterval));
+ properties.setProperty(TSFILE_FILE_SYSTEM_STRING, tsfileFileSystem);
+ properties.setProperty(IOTDB_VERSION_STRING, iotdbVersion);
+ properties.setProperty(ENABLE_PARTITION_STRING,
String.valueOf(enablePartition));
+ properties.store(tmpFOS, SYSTEM_PROPERTIES_STRING);
+
+ // upgrade finished, delete old system.properties file
+ if (propertiesFile.exists()) {
+ Files.delete(propertiesFile.toPath());
}
+ // rename system.properties.tmp to system.properties
+ FileUtils.moveFile(tmpPropertiesFile, propertiesFile);
}
+ }
+
+
+ /**
+ * repair 0.10 properties
+ */
+ private void upgradePropertiesFileFromBrokenFile()
+ throws IOException {
// create an empty tmpPropertiesFile
- try {
- if (tmpPropertiesFile.createNewFile()) {
- logger.info("Create system.properties.tmp {}.", tmpPropertiesFile);
- }
- } catch (IOException e) {
- logger.error("Create system.properties.tmp {} failed.",
tmpPropertiesFile, e);
- }
- // 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())) {
- 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:");
- checkProperties();
+ if (tmpPropertiesFile.createNewFile()) {
+ logger.info("Create system.properties.tmp {}.", tmpPropertiesFile);
+ } else {
+ logger.error("Create system.properties.tmp {} failed.",
tmpPropertiesFile);
+ System.exit(-1);
+ }
+
+ try (FileOutputStream tmpFOS = new
FileOutputStream(tmpPropertiesFile.toString())) {
+ systemProperties.forEach((k, v) -> properties.setProperty(k, v));
+
+ properties.store(tmpFOS, SYSTEM_PROPERTIES_STRING);
// upgrade finished, delete old system.properties file
- if (file.exists()) {
- Files.delete(file.toPath());
+ if (propertiesFile.exists()) {
+ Files.delete(propertiesFile.toPath());
}
// rename system.properties.tmp to system.properties
- FileUtils.moveFile(tmpPropertiesFile, file);
- } catch (IOException e) {
- logger.error("Something went wrong while upgrading teh
system.properties. The file is {}.", file.getAbsolutePath(), e);
+ FileUtils.moveFile(tmpPropertiesFile, propertiesFile);
}
-
}
- 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);
+ private void checkProperties() throws IOException {
+ for (Entry<String, String> entry : systemProperties.entrySet()) {
+ if (!properties.contains(entry.getKey())) {
+ upgradePropertiesFileFromBrokenFile();
+ logger.info("repair system.properties, lack {}", entry.getKey());
+ }
}
- 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") + " !");
+
+ if
(!properties.getProperty(TIMESTAMP_PRECISION_STRING).equals(timestampPrecision))
{
+ logger.error("Wrong {}, please set as: {} !",
TIMESTAMP_PRECISION_STRING, properties
+ .getProperty(TIMESTAMP_PRECISION_STRING));
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") + " !");
+
+ if (Long.parseLong(properties.getProperty(PARTITION_INTERVAL_STRING)) !=
partitionInterval) {
+ logger.error("Wrong {}, please set as: {} !", PARTITION_INTERVAL_STRING,
properties
+ .getProperty(PARTITION_INTERVAL_STRING));
System.exit(-1);
}
- }
- private void upgradeMlog() {
- try {
- MLogWriter.upgradeMLog(SCHEMA_DIR, MetadataConstant.METADATA_LOG);
- } catch (IOException e) {
- logger.error("Upgrade mlog.txt from {} failed.", SCHEMA_DIR, e);
+ if
(!(properties.getProperty(TSFILE_FILE_SYSTEM_STRING).equals(tsfileFileSystem)))
{
+ logger.error("Wrong {}, please set as: {} !", TSFILE_FILE_SYSTEM_STRING,
properties
+ .getProperty(TSFILE_FILE_SYSTEM_STRING));
+ System.exit(-1);
}
}
+ /**
+ * ensure all tsfiles are closed in 0.9 when starting 0.10
+ */
private void checkUnClosedTsFileV1() {
if (SystemFileFactory.INSTANCE.getFile(WAL_DIR).isDirectory()
&& SystemFileFactory.INSTANCE.getFile(WAL_DIR).list().length != 0) {
@@ -208,11 +270,11 @@ public class IoTDBConfigCheck {
+ " before upgrading to V0.10");
System.exit(-1);
}
-
checkUnClosedTsFileV1Helper(DirectoryManager.getInstance().getAllSequenceFileFolders());
-
checkUnClosedTsFileV1Helper(DirectoryManager.getInstance().getAllUnSequenceFileFolders());
+
checkUnClosedTsFileV1InFolders(DirectoryManager.getInstance().getAllSequenceFileFolders());
+
checkUnClosedTsFileV1InFolders(DirectoryManager.getInstance().getAllUnSequenceFileFolders());
}
- private void checkUnClosedTsFileV1Helper(List<String> folders) {
+ private void checkUnClosedTsFileV1InFolders(List<String> folders) {
for (String baseDir : folders) {
File fileFolder = FSFactoryProducer.getFSFactory().getFile(baseDir);
if (!fileFolder.isDirectory()) {
@@ -235,10 +297,6 @@ public class IoTDBConfigCheck {
}
}
- private static class IoTDBConfigCheckHolder {
-
- private static final IoTDBConfigCheck INSTANCE = new IoTDBConfigCheck();
- }
}
diff --git a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
index c6dc527..c2d3887 100644
--- a/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
+++ b/server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
@@ -365,9 +365,12 @@ public class IoTDBDescriptor {
conf.setDefaultTTL(Long.parseLong(properties.getProperty("default_ttl",
String.valueOf(conf.getDefaultTTL()))));
+
+ conf.setEnablePartition(Boolean.parseBoolean(
+ properties.getProperty("enable_partition",
String.valueOf(conf.isEnablePartition()))));
+
// Time range for dividing storage group
- conf.setPartitionInterval(
- Long.parseLong(properties
+ conf.setPartitionInterval(Long.parseLong(properties
.getProperty("partition_interval",
String.valueOf(conf.getPartitionInterval()))));
// the num of memtables in each storage group
diff --git a/server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java
b/server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java
index a1cc16c..9dff8b3 100644
--- a/server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java
+++ b/server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java
@@ -113,24 +113,37 @@ public class StorageEngine implements IService {
@ServerConfigConsistent
private static long timePartitionInterval;
+ /**
+ * whether enable data partition
+ * if disabled, all data belongs to partition 0
+ */
+ @ServerConfigConsistent
+ private static boolean enablePartition =
+ IoTDBDescriptor.getInstance().getConfig().isEnablePartition();
+
private StorageEngine() {
logger = LoggerFactory.getLogger(StorageEngine.class);
systemDir = FilePathUtils.regularizePath(config.getSystemDir()) +
"storage_groups";
- // build time Interval to divide time partition
- String timePrecision =
IoTDBDescriptor.getInstance().getConfig().getTimestampPrecision();
- switch (timePrecision) {
- case "ns":
- timePartitionInterval = IoTDBDescriptor.getInstance().
- getConfig().getPartitionInterval() * 1000_000_000L;
- break;
- case "us":
- timePartitionInterval = IoTDBDescriptor.getInstance().
- getConfig().getPartitionInterval() * 1000_000L;
- break;
- default:
- timePartitionInterval = IoTDBDescriptor.getInstance().
- getConfig().getPartitionInterval() * 1000;
- break;
+
+ if (!enablePartition) {
+ timePartitionInterval = Long.MAX_VALUE;
+ } else {
+ // build time Interval to divide time partition
+ String timePrecision =
IoTDBDescriptor.getInstance().getConfig().getTimestampPrecision();
+ switch (timePrecision) {
+ case "ns":
+ timePartitionInterval = IoTDBDescriptor.getInstance().
+ getConfig().getPartitionInterval() * 1000_000_000L;
+ break;
+ case "us":
+ timePartitionInterval = IoTDBDescriptor.getInstance().
+ getConfig().getPartitionInterval() * 1000_000L;
+ break;
+ default:
+ timePartitionInterval = IoTDBDescriptor.getInstance().
+ getConfig().getPartitionInterval() * 1000;
+ break;
+ }
}
// create systemDir
try {
@@ -140,10 +153,10 @@ public class StorageEngine implements IService {
}
// recover upgrade process
UpgradeUtils.recoverUpgrade();
+
/*
* recover all storage group processors.
*/
-
List<StorageGroupMNode> sgNodes =
MManager.getInstance().getAllStorageGroupNodes();
List<Future> futures = new ArrayList<>();
for (StorageGroupMNode storageGroup : sgNodes) {
@@ -520,6 +533,6 @@ public class StorageEngine implements IService {
}
public static long getTimePartition(long time) {
- return time / timePartitionInterval;
+ return enablePartition ? time / timePartitionInterval : 0;
}
}
diff --git
a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
index 58a7810..700f44c 100755
---
a/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
+++
b/server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupProcessor.java
@@ -874,8 +874,8 @@ public class StorageGroupProcessor {
>=
IoTDBDescriptor.getInstance().getConfig().getConcurrentWritingTimePartition()) {
Map.Entry<Long, TsFileProcessor> processorEntry =
tsFileProcessorTreeMap.firstEntry();
logger.info(
- "will close a TsFile because too many memtables ({} > {}) in the
storage group {},",
- tsFileProcessorTreeMap.size(),
+ "will close a {} TsFile because too many active partitions ({} >
{}) in the storage group {},",
+ sequence, tsFileProcessorTreeMap.size(),
IoTDBDescriptor.getInstance().getConfig().getConcurrentWritingTimePartition(),
storageGroupName);
asyncCloseOneTsFileProcessor(sequence, processorEntry.getValue());
diff --git a/server/src/main/java/org/apache/iotdb/db/service/IoTDB.java
b/server/src/main/java/org/apache/iotdb/db/service/IoTDB.java
index 435888c..0988c17 100644
--- a/server/src/main/java/org/apache/iotdb/db/service/IoTDB.java
+++ b/server/src/main/java/org/apache/iotdb/db/service/IoTDB.java
@@ -18,6 +18,7 @@
*/
package org.apache.iotdb.db.service;
+import java.io.IOException;
import org.apache.iotdb.db.concurrent.IoTDBDefaultThreadExceptionHandler;
import org.apache.iotdb.db.conf.IoTDBConfigCheck;
import org.apache.iotdb.db.conf.IoTDBConstant;
@@ -53,7 +54,11 @@ public class IoTDB implements IoTDBMBean {
if (args.length > 0) {
IoTDBDescriptor.getInstance().replaceProps(args);
}
- IoTDBConfigCheck.getInstance().checkConfig();
+ try {
+ IoTDBConfigCheck.getInstance().checkConfig();
+ } catch (IOException e) {
+ logger.error("meet error when doing start checking", e);
+ }
IoTDB daemon = IoTDB.getInstance();
daemon.active();
}