提交 f32406d6 编写于 作者: J Jiang Haiting

change default value of...

change default value of org.apache.rocketmq.store.config.MessageStoreConfig#MULTI_PATH_SPLITTER to ',' and can be changed by System.getProperty("rocketmq.broker.multiPathSplitter")
上级 255a2028
......@@ -1754,7 +1754,8 @@ public class DefaultMessageStore implements MessageStore {
String[] paths = storePath.trim().split(MessageStoreConfig.MULTI_PATH_SPLITTER);
double minPhysicRatio = 100;
for (String path : paths) {
double physicRatio = UtilAll.getDiskPartitionSpaceUsedPercent(path);
double physicRatio = UtilAll.isPathExists(path) ?
UtilAll.getDiskPartitionSpaceUsedPercent(path) : -1;
minPhysicRatio = Math.min(minPhysicRatio, physicRatio);
if (physicRatio > diskSpaceCleanForciblyRatio) {
fullStorePath.add(path);
......@@ -1763,7 +1764,8 @@ public class DefaultMessageStore implements MessageStore {
DefaultMessageStore.this.commitLog.setFullStorePaths(fullStorePath);
return minPhysicRatio;
} else {
return UtilAll.getDiskPartitionSpaceUsedPercent(storePath);
return UtilAll.isPathExists(storePath) ?
UtilAll.getDiskPartitionSpaceUsedPercent(storePath) : -1;
}
}
......
......@@ -23,7 +23,7 @@ import org.apache.rocketmq.store.ConsumeQueue;
public class MessageStoreConfig {
public static final String MULTI_PATH_SPLITTER = ":";
public static final String MULTI_PATH_SPLITTER = System.getProperty("rocketmq.broker.multiPathSplitter", ",");
//The root directory in which the log data is kept
@ImportantField
......
......@@ -105,7 +105,7 @@ public class DefaultMessageStoreCleanFilesTest {
String storePath = config.getStorePathCommitLog();
StringBuilder storePathBuilder = new StringBuilder();
for (int i = 0; i < 3; i++) {
storePathBuilder.append(storePath).append(i).append(":");
storePathBuilder.append(storePath).append(i).append(MessageStoreConfig.MULTI_PATH_SPLITTER);
}
config.setStorePathCommitLog(storePathBuilder.toString());
String[] paths = config.getStorePathCommitLog().trim().split(MessageStoreConfig.MULTI_PATH_SPLITTER);
......
......@@ -31,7 +31,9 @@ public class MultiPathMappedFileQueueTest {
final byte[] fixedMsg = new byte[1024];
MessageStoreConfig config = new MessageStoreConfig();
config.setStorePathCommitLog("target/unit_test_store/a/:target/unit_test_store/b/:target/unit_test_store/c/");
config.setStorePathCommitLog("target/unit_test_store/a/" + MessageStoreConfig.MULTI_PATH_SPLITTER
+ "target/unit_test_store/b/" + MessageStoreConfig.MULTI_PATH_SPLITTER
+ "target/unit_test_store/c/");
MappedFileQueue mappedFileQueue = new MultiPathMappedFileQueue(config, 1024, null, null);
String[] storePaths = config.getStorePathCommitLog().trim().split(MessageStoreConfig.MULTI_PATH_SPLITTER);
for (int i = 0; i < 1024; i++) {
......@@ -51,8 +53,9 @@ public class MultiPathMappedFileQueueTest {
//create old mapped files
final byte[] fixedMsg = new byte[1024];
MessageStoreConfig config = new MessageStoreConfig();
config.setStorePathCommitLog(
"target/unit_test_store/a/:target/unit_test_store/b/:target/unit_test_store/c/");
config.setStorePathCommitLog("target/unit_test_store/a/" + MessageStoreConfig.MULTI_PATH_SPLITTER
+ "target/unit_test_store/b/" + MessageStoreConfig.MULTI_PATH_SPLITTER
+ "target/unit_test_store/c/");
MappedFileQueue mappedFileQueue = new MultiPathMappedFileQueue(config, 1024, null, null);
String[] storePaths = config.getStorePathCommitLog().trim().split(MessageStoreConfig.MULTI_PATH_SPLITTER);
for (int i = 0; i < 1024; i++) {
......@@ -68,7 +71,8 @@ public class MultiPathMappedFileQueueTest {
// test load and readonly
MessageStoreConfig config = new MessageStoreConfig();
config.setStorePathCommitLog("target/unit_test_store/b/");
config.setReadOnlyCommitLogStorePaths("target/unit_test_store/a:target/unit_test_store/c");
config.setReadOnlyCommitLogStorePaths("target/unit_test_store/a" + MessageStoreConfig.MULTI_PATH_SPLITTER
+ "target/unit_test_store/c");
MultiPathMappedFileQueue mappedFileQueue = new MultiPathMappedFileQueue(config, 1024, null, null);
mappedFileQueue.load();
......@@ -83,7 +87,9 @@ public class MultiPathMappedFileQueueTest {
final byte[] fixedMsg = new byte[1024];
MessageStoreConfig config = new MessageStoreConfig();
config.setStorePathCommitLog("target/unit_test_store/a/:target/unit_test_store/b/:target/unit_test_store/c/");
config.setStorePathCommitLog("target/unit_test_store/a/" + MessageStoreConfig.MULTI_PATH_SPLITTER
+ "target/unit_test_store/b/" + MessageStoreConfig.MULTI_PATH_SPLITTER
+ "target/unit_test_store/c/");
MappedFileQueue mappedFileQueue = new MultiPathMappedFileQueue(config, 1024, null, null);
String[] storePaths = config.getStorePathCommitLog().trim().split(MessageStoreConfig.MULTI_PATH_SPLITTER);
for (int i = 0; i < 1024; i++) {
......@@ -94,7 +100,8 @@ public class MultiPathMappedFileQueueTest {
assertThat(mappedFile.getFileName().startsWith(storePaths[idx])).isTrue();
if (i == 500) {
config.setStorePathCommitLog("target/unit_test_store/a/:target/unit_test_store/b/");
config.setStorePathCommitLog("target/unit_test_store/a/" + MessageStoreConfig.MULTI_PATH_SPLITTER
+ "target/unit_test_store/b/");
storePaths = config.getStorePathCommitLog().trim().split(MessageStoreConfig.MULTI_PATH_SPLITTER);
}
}
......@@ -108,7 +115,9 @@ public class MultiPathMappedFileQueueTest {
Set<String> fullStorePath = new HashSet<>();
MessageStoreConfig config = new MessageStoreConfig();
config.setStorePathCommitLog("target/unit_test_store/a/:target/unit_test_store/b/:target/unit_test_store/c/");
config.setStorePathCommitLog("target/unit_test_store/a/" + MessageStoreConfig.MULTI_PATH_SPLITTER
+ "target/unit_test_store/b/" + MessageStoreConfig.MULTI_PATH_SPLITTER
+ "target/unit_test_store/c/");
MappedFileQueue mappedFileQueue = new MultiPathMappedFileQueue(config, 1024, null, () -> fullStorePath);
String[] storePaths = config.getStorePathCommitLog().trim().split(MessageStoreConfig.MULTI_PATH_SPLITTER);
assertThat(storePaths.length).isEqualTo(3);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册