Skip to content
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

Closed
wants to merge 3 commits into from
Closed

[RIP-7] Fix some issue and Optimization code for multiple_disk_dir #1144

wants to merge 3 commits into from

Conversation

wangshaojie4039
Copy link

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.

  • Make sure there is a Github issue filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Format the pull request title like [ISSUE #123] Fix UnknownException when host config not exist. Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add integration-test in test module.
  • Run mvn -B clean apache-rat:check findbugs:findbugs checkstyle:checkstyle to make sure basic checks pass. Run mvn clean install -DskipITs to make sure unit-test pass. Run mvn clean test-compile failsafe:integration-test to make sure integration-test pass.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

@zongtanghu zongtanghu changed the title [RIP-7] fix some issue and Optimization code   [RIP-7] fix some issue and Optimization code for multiple_disk_dir Apr 8, 2019
@zongtanghu zongtanghu self-requested a review April 8, 2019 10:03
@zongtanghu zongtanghu added this to the 4.6.0 milestone Apr 8, 2019
@@ -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 {
Copy link
Contributor

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) {
Copy link
Contributor

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 {
Copy link
Contributor

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);
Copy link
Contributor

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) {
Copy link
Contributor

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

@vongosling vongosling changed the title [RIP-7] fix some issue and Optimization code for multiple_disk_dir [RIP-7] Fix some issue and Optimization code for multiple_disk_dir Apr 12, 2019
@@ -36,9 +33,9 @@

private boolean multiCommitLogPathEnable = false;

private List<String> commitLogStorePaths = null;
private String commitLogStorePaths = null;
Copy link
Contributor

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(";");
Copy link
Contributor

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(";") ;
Copy link
Contributor

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/");
Copy link
Contributor

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();
Copy link
Member

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?

@duhenglucky duhenglucky modified the milestones: 4.6.0, 4.7.0 Nov 27, 2019
@zongtanghu
Copy link
Contributor

@vongosling @Jason918 @liuruiyiyang @duhenglucky @RongtongJin please help to review this pr together.Thanks

Comment on lines +225 to +254
// 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;
// }
// }




Copy link
Contributor

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.

Copy link
Contributor

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

@ShannonDing ShannonDing modified the milestones: 4.7.0, 4.7.1 Mar 30, 2020
@RongtongJin RongtongJin modified the milestones: 4.7.1, 4.8.0 May 25, 2020
@RongtongJin RongtongJin modified the milestones: 4.8.0, 4.8.1 Dec 8, 2020
@Jason918
Copy link
Contributor

Jason918 commented Nov 7, 2021

I am closing this as RIP-7 was merge with another PR #3357

@Jason918 Jason918 closed this Nov 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants