-
Notifications
You must be signed in to change notification settings - Fork 11.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RIP-7] Fix some issue and Optimization code for multiple_disk_dir #1144
[RIP-7] Fix some issue and Optimization code for multiple_disk_dir #1144
Conversation
@@ -114,7 +113,7 @@ | |||
boolean shutDownNormal = false; | |||
|
|||
public DefaultMessageStore(final MessageStoreConfig messageStoreConfig, final BrokerStatsManager brokerStatsManager, | |||
final MessageArrivingListener messageArrivingListener, final BrokerConfig brokerConfig) throws IOException { | |||
final MessageArrivingListener messageArrivingListener, final BrokerConfig brokerConfig) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here,you should make sure your code style has no issues.
final int maxMsgNums, | ||
final MessageFilter messageFilter) { | ||
final int maxMsgNums, | ||
final MessageFilter messageFilter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here,as above!
@@ -199,18 +199,20 @@ public static double getDiskPartitionSpaceUsedPercent(final String path) { | |||
if (null == path || path.isEmpty()) | |||
return -1; | |||
|
|||
String[] pathArr = path.trim().split(";"); | |||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the function,you should add some comments,such as if you path parameter is a mutiple-disk paths variable.
private final MessageStoreConfig config; | ||
|
||
public MultiPathMappedFileQueue(MessageStoreConfig messageStoreConfig, int mappedFileSize, | ||
AllocateMappedFileService allocateMappedFileService) { | ||
AllocateMappedFileService allocateMappedFileService) { | ||
super(messageStoreConfig.getStorePathCommitLog(), mappedFileSize, allocateMappedFileService); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here,you should make sure your code style has no issues as above!
long usedSpace = totalSpace - freeSpace; | ||
|
||
return usedSpace / (double) totalSpace; | ||
} | ||
} catch (Exception e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here,you can print the exception error info by using printStackTrace
@@ -36,9 +33,9 @@ | |||
|
|||
private boolean multiCommitLogPathEnable = false; | |||
|
|||
private List<String> commitLogStorePaths = null; | |||
private String commitLogStorePaths = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change List to Sting ? Repeatedly parse this parameter every u need use it.
@@ -199,18 +199,20 @@ public static double getDiskPartitionSpaceUsedPercent(final String path) { | |||
if (null == path || path.isEmpty()) | |||
return -1; | |||
|
|||
String[] pathArr = path.trim().split(";"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, It's better to put all these parse actions in one place.
public String[] getCommitLogStorePaths() { | ||
String[] storPaths = null; | ||
if (!UtilAll.isBlank(config.getCommitLogStorePaths())) { | ||
storPaths = config.getCommitLogStorePaths().trim().split(";") ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
';' is really not a shell friendly file path separator. IMHO, ',' or ':' is more commonly used.
@@ -83,18 +84,18 @@ public void testUpdatePathsOnline() { | |||
|
|||
MessageStoreConfig config = new MessageStoreConfig(); | |||
config.setMultiCommitLogPathEnable(true); | |||
config.setCommitLogStorePaths("target/unit_test_store/a/:target/unit_test_store/b/:target/unit_test_store/c/"); | |||
MappedFileQueue mappedFileQueue = new MultiPathMappedFileQueue(config, 1024, null); | |||
config.setCommitLogStorePaths("target/unit_test_store/a/;target/unit_test_store/b/;target/unit_test_store/c/"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"," is more commonly used as the path separator in config parameters. IMHO, I suggest using "," instead of ";" as the path separator.
} | ||
double physicRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePaths); | ||
if (physicRatio > diskSpaceWarningLevelRatio) { | ||
boolean diskok = DefaultMessageStore.this.runningFlags.getAndMakeDiskFull(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any update? what's the meaning of the diskok?
@vongosling @Jason918 @liuruiyiyang @duhenglucky @RongtongJin please help to review this pr together.Thanks |
// public static double getMaxDiskPartitionSpaceUsedPercent(final String paths) { | ||
// if (null == paths || paths.isEmpty()) { | ||
// return -1; | ||
// } | ||
// | ||
// String[] pathArr = paths.trim().split(";"); | ||
// try { | ||
// | ||
// double maxUsedPercent = 0; | ||
// for (int i = 0; i < pathArr.length; i++) { | ||
// File file = new File(pathArr[i]); | ||
// if (!file.exists()) { | ||
// continue; | ||
// } | ||
// long totalSpace = file.getTotalSpace(); | ||
// long freeSpace = file.getFreeSpace(); | ||
// double usedPercent = (totalSpace - freeSpace) / (double) totalSpace; | ||
// if (usedPercent > maxUsedPercent) { | ||
// maxUsedPercent = usedPercent; | ||
// } | ||
// } | ||
// return maxUsedPercent; | ||
// } catch (Exception e) { | ||
// return -1; | ||
// } | ||
// } | ||
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you add code annotation in this place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this method isn't necessary,you can remove it! @wangshaojie4039
I am closing this as RIP-7 was merge with another PR #3357 |
What is the purpose of the change
Add Multiple Directories Storage Support for commit log.
Detailed info is in RIP-7
Brief changelog
(1).Check whether the disk is full and available before creating the file
(2).When deleting files, change the calculation method of disk remaining space
(3).Support for online write-off paths
Verifying this change
Follow this checklist to help us incorporate your contribution quickly and easily. Notice,
it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR
.[ISSUE #123] Fix UnknownException when host config not exist
. Each commit in the pull request should have a meaningful subject line and body.mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle
to make sure basic checks pass. Runmvn clean install -DskipITs
to make sure unit-test pass. Runmvn clean test-compile failsafe:integration-test
to make sure integration-test pass.