You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by dongeforever <gi...@git.apache.org> on 2017/09/22 02:45:15 UTC
[GitHub] incubator-rocketmq pull request #133: [ROCKETMQ-249] Do not attempt to clear...
Github user dongeforever commented on a diff in the pull request:
https://github.com/apache/incubator-rocketmq/pull/133#discussion_r140402195
--- Diff: store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java ---
@@ -1509,65 +1514,62 @@ private boolean isTimeToDelete() {
return false;
}
- private boolean isSpaceToDelete() {
- double ratio = DefaultMessageStore.this.getMessageStoreConfig().getDiskMaxUsedSpaceRatio() / 100.0;
+ double getDiskUsageRatio() {
+ return UtilAll.getDiskPartitionSpaceUsedPercent(
+ DefaultMessageStore.this.getMessageStoreConfig().getStorePathCommitLog());
+ }
- cleanImmediately = false;
+ double getQueueSpace() {
+ return UtilAll.getDiskPartitionSpaceUsedPercent(StorePathConfigHelper
+ .getStorePathConsumeQueue(DefaultMessageStore.this.getMessageStoreConfig().getStorePathRootDir()));
+ }
- {
- String storePathPhysic = DefaultMessageStore.this.getMessageStoreConfig().getStorePathCommitLog();
- double physicRatio = UtilAll.getDiskPartitionSpaceUsedPercent(storePathPhysic);
- if (physicRatio > diskSpaceWarningLevelRatio) {
- boolean diskok = DefaultMessageStore.this.runningFlags.getAndMakeDiskFull();
- if (diskok) {
- DefaultMessageStore.log.error("physic disk maybe full soon " + physicRatio + ", so mark disk full");
- }
+ /**
+ * Checks if cleaning on the disk is needed.
+ *
+ * @param usageRatio Usage ratio.
+ * @param allowedRatio Allowed ratio.
+ * @return <code>True</code> if cleaning is needed, otherwise <code>false</code>.
+ */
+ private boolean needCleaning(double usageRatio, double allowedRatio) {
+ if (usageRatio == -1)
--- End diff --
It is not safe to use == for float value. In this case, usageRatio < 0 is OK
---