This is an automated email from the ASF dual-hosted git repository. xingtanzjr pushed a commit to branch multi_dir_to_rel12 in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit c5b6d515556971db86062d22edc820c351f00550 Author: Zhang.Jinrui <[email protected]> AuthorDate: Fri Jun 16 10:52:37 2023 +0800 Only SequenceStrategy and MaxDiskUsableSpaceFirstStrategy are allowed in cluster mode (#10164) --- docs/UserGuide/Reference/DataNode-Config-Manual.md | 2 +- docs/zh/UserGuide/Reference/DataNode-Config-Manual.md | 12 ++++++------ .../assembly/resources/conf/iotdb-datanode.properties | 4 +--- .../java/org/apache/iotdb/db/conf/IoTDBConfig.java | 18 ++++++++++++------ 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/docs/UserGuide/Reference/DataNode-Config-Manual.md b/docs/UserGuide/Reference/DataNode-Config-Manual.md index d1f41596acb..dfb1f8e69ae 100644 --- a/docs/UserGuide/Reference/DataNode-Config-Manual.md +++ b/docs/UserGuide/Reference/DataNode-Config-Manual.md @@ -297,7 +297,7 @@ The permission definitions are in ${IOTDB\_CONF}/conf/jmx.access. | Name | dn\_multi\_dir\_strategy [...] |:-----------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...] -| Description | IoTDB's strategy for selecting directories for TsFile in tsfile_dir. You can use a simple class name or a full name of the class. The system provides the following three strategies: <br>1. SequenceStrategy: IoTDB selects the directory from tsfile\_dir in order, traverses all the directories in tsfile\_dir in turn, and keeps counting;<br>2. MaxDiskUsableSpaceFirstStrategy: IoTDB first selects the directory with the largest free disk space in tsfile\_dir;<br>3. MinFolderOcc [...] +| Description | IoTDB's strategy for selecting directories for TsFile in tsfile_dir. You can use a simple class name or a full name of the class. The system provides the following three strategies: <br>1. SequenceStrategy: IoTDB selects the directory from tsfile\_dir in order, traverses all the directories in tsfile\_dir in turn, and keeps counting;<br>2. MaxDiskUsableSpaceFirstStrategy: IoTDB first selects the directory with the largest free disk space in tsfile\_dir;<br>You can complet [...] | Type | String [...] | Default | SequenceStrategy [...] | Effective | hot-load [...] diff --git a/docs/zh/UserGuide/Reference/DataNode-Config-Manual.md b/docs/zh/UserGuide/Reference/DataNode-Config-Manual.md index e0706d1412c..b3c9d194501 100644 --- a/docs/zh/UserGuide/Reference/DataNode-Config-Manual.md +++ b/docs/zh/UserGuide/Reference/DataNode-Config-Manual.md @@ -287,12 +287,12 @@ IoTDB DataNode 与 Standalone 模式共用一套配置文件,均位于 IoTDB * dn\_multi\_dir\_strategy -| 名字 | dn\_multi\_dir\_strategy [...] -|:------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...] -| 描述 | IoTDB 在 data\_dirs 中为 TsFile 选择目录时采用的策略。可使用简单类名或类名全称。系统提供以下三种策略:<br>1. SequenceStrategy:IoTDB 按顺序选择目录,依次遍历 data\_dirs 中的所有目录,并不断轮循;<br>2. MaxDiskUsableSpaceFirstStrategy:IoTDB 优先选择 data\_dirs 中对应磁盘空余空间最大的目录;<br>3. MinFolderOccupiedSpaceFirstStrategy:IoTDB 优先选择 data\_dirs 中已使用空间最小的目录;<br>4. UserDefineStrategyPackage(用户自定义策略)<br>您可以通过以下方法完成用户自定义策略:<br>1. 继承 org.apache.iotdb.db.conf.directories.strategy 类并实现自身的 Strategy 方法;<br>2. 将实现的类的完整类名(包名加类名,UserDefineStrategyPackage)填写到该配置项 [...] -| 类型 | String [...] -| 默认值 | SequenceStrategy [...] -| 改后生效方式 | 热加载 [...] +| 名字 | dn\_multi\_dir\_strategy [...] +|:------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [...] +| 描述 | IoTDB 在 data\_dirs 中为 TsFile 选择目录时采用的策略。可使用简单类名或类名全称。系统提供以下三种策略:<br>1. SequenceStrategy:IoTDB 按顺序选择目录,依次遍历 data\_dirs 中的所有目录,并不断轮循;<br>2. MaxDiskUsableSpaceFirstStrategy:IoTDB 优先选择 data\_dirs 中对应磁盘空余空间最大的目录;<br>您可以通过以下方法完成用户自定义策略:<br>1. 继承 org.apache.iotdb.db.conf.directories.strategy 类并实现自身的 Strategy 方法;<br>2. 将实现的类的完整类名(包名加类名,UserDefineStrategyPackage)填写到该配置项;<br>3. 将该类 jar 包添加到工程中。 [...] +| 类型 | String [...] +| 默认值 | SequenceStrategy [...] +| 改后生效方式 | 热加载 [...] * dn\_consensus\_dir diff --git a/server/src/assembly/resources/conf/iotdb-datanode.properties b/server/src/assembly/resources/conf/iotdb-datanode.properties index 0cbe58a606d..12e806103d0 100644 --- a/server/src/assembly/resources/conf/iotdb-datanode.properties +++ b/server/src/assembly/resources/conf/iotdb-datanode.properties @@ -160,9 +160,7 @@ dn_target_config_node_list=127.0.0.1:10710 # The info of the four strategies are as follows: # 1. SequenceStrategy: the system will choose the directory in sequence. # 2. MaxDiskUsableSpaceFirstStrategy: the system will choose the directory whose disk has the maximum space. -# 3. MinFolderOccupiedSpaceFirstStrategy: the system will choose the directory whose folder has the minimum occupied space. -# 4. RandomOnDiskUsableSpaceStrategy: the system will randomly choose the directory based on usable space of disks. The more usable space, the greater the chance of being chosen; -# Set SequenceStrategy,MaxDiskUsableSpaceFirstStrategy and MinFolderOccupiedSpaceFirstStrategy to apply the corresponding strategy. +# Set SequenceStrategy or MaxDiskUsableSpaceFirstStrategy to apply the corresponding strategy. # If this property is unset, system will use SequenceStrategy as default strategy. # For this property, fully-qualified class name (include package name) and simple class name are both acceptable. # dn_multi_dir_strategy=SequenceStrategy 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 46e8f212bbe..f0c4fa30d50 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 @@ -74,6 +74,8 @@ public class IoTDBConfig { private static final Logger logger = LoggerFactory.getLogger(IoTDBConfig.class); private static final String MULTI_DIR_STRATEGY_PREFIX = "org.apache.iotdb.db.conf.directories.strategy."; + private static final String[] CLUSTER_ALLOWED_MULTI_DIR_STRATEGIES = + new String[] {"SequenceStrategy", "MaxDiskUsableSpaceFirstStrategy"}; private static final String DEFAULT_MULTI_DIR_STRATEGY = "SequenceStrategy"; private static final String STORAGE_GROUP_MATCHER = "([a-zA-Z0-9`_.\\-\\u2E80-\\u9FFF]+)"; @@ -1578,14 +1580,18 @@ public class IoTDBConfig { } public void checkMultiDirStrategyClassName() { - if (isClusterMode - && !(multiDirStrategyClassName.equals(DEFAULT_MULTI_DIR_STRATEGY) - || multiDirStrategyClassName.equals( - MULTI_DIR_STRATEGY_PREFIX + DEFAULT_MULTI_DIR_STRATEGY))) { + if (isClusterMode) { + for (String multiDirStrategy : CLUSTER_ALLOWED_MULTI_DIR_STRATEGIES) { + // If the multiDirStrategyClassName is one of cluster allowed strategy, the check is passed. + if (multiDirStrategyClassName.equals(multiDirStrategy) + || multiDirStrategyClassName.equals(MULTI_DIR_STRATEGY_PREFIX + multiDirStrategy)) { + return; + } + } String msg = String.format( - "Cannot set multi_dir_strategy to %s, because cluster mode only allows MaxDiskUsableSpaceFirstStrategy.", - multiDirStrategyClassName); + "Cannot set multi_dir_strategy to %s, because cluster mode only allows %s.", + multiDirStrategyClassName, Arrays.toString(CLUSTER_ALLOWED_MULTI_DIR_STRATEGIES)); logger.error(msg); throw new RuntimeException(msg); }
