Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小五666\n哈哈
Rocketmq
提交
466bb98e
R
Rocketmq
项目概览
小五666\n哈哈
/
Rocketmq
与 Fork 源项目一致
Fork自
Apache RocketMQ / Rocketmq
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rocketmq
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
466bb98e
编写于
9月 17, 2021
作者:
J
Jiang Haiting
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix error in org.apache.rocketmq.store.DefaultMessageStore.CleanCommitLogService#isSpaceFull
上级
9b0e31e4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
64 addition
and
1 deletion
+64
-1
store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
...n/java/org/apache/rocketmq/store/DefaultMessageStore.java
+22
-1
store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreCleanFilesTest.java
...che/rocketmq/store/DefaultMessageStoreCleanFilesTest.java
+42
-0
未找到文件。
store/src/main/java/org/apache/rocketmq/store/DefaultMessageStore.java
浏览文件 @
466bb98e
...
...
@@ -1744,8 +1744,29 @@ public class DefaultMessageStore implements MessageStore {
public
void
setManualDeleteFileSeveralTimes
(
int
manualDeleteFileSeveralTimes
)
{
this
.
manualDeleteFileSeveralTimes
=
manualDeleteFileSeveralTimes
;
}
public
double
calcStorePathPhysicRatio
()
{
String
storePath
=
getStorePathPhysic
();
if
(
storePath
.
contains
(
MessageStoreConfig
.
MULTI_PATH_SPLITTER
))
{
Set
<
String
>
fullStorePath
=
new
HashSet
<>();
String
[]
paths
=
storePath
.
trim
().
split
(
MessageStoreConfig
.
MULTI_PATH_SPLITTER
);
double
minPhysicRatio
=
100
;
for
(
String
path
:
paths
)
{
double
physicRatio
=
UtilAll
.
getDiskPartitionSpaceUsedPercent
(
path
);
minPhysicRatio
=
Math
.
min
(
minPhysicRatio
,
physicRatio
);
if
(
physicRatio
>
diskSpaceCleanForciblyRatio
)
{
fullStorePath
.
add
(
path
);
}
}
DefaultMessageStore
.
this
.
commitLog
.
setFullStorePaths
(
fullStorePath
);
return
minPhysicRatio
;
}
else
{
return
UtilAll
.
getDiskPartitionSpaceUsedPercent
(
storePath
);
}
}
public
boolean
isSpaceFull
()
{
double
physicRatio
=
UtilAll
.
getDiskPartitionSpaceUsedPercent
(
getStorePathPhysic
()
);
double
physicRatio
=
calcStorePathPhysicRatio
(
);
double
ratio
=
DefaultMessageStore
.
this
.
getMessageStoreConfig
().
getDiskMaxUsedSpaceRatio
()
/
100.0
;
if
(
physicRatio
>
ratio
)
{
DefaultMessageStore
.
log
.
info
(
"physic disk of commitLog used: "
+
physicRatio
);
...
...
store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreCleanFilesTest.java
浏览文件 @
466bb98e
...
...
@@ -94,6 +94,41 @@ public class DefaultMessageStoreCleanFilesTest {
}
@Test
public
void
testIsSpaceFullMultiCommitLogStorePath
()
throws
Exception
{
String
deleteWhen
=
"04"
;
// the min value of diskMaxUsedSpaceRatio.
int
diskMaxUsedSpaceRatio
=
1
;
// used to set disk-full flag
double
diskSpaceCleanForciblyRatio
=
0.01
D
;
MessageStoreConfig
config
=
genMessageStoreConfig
(
deleteWhen
,
diskMaxUsedSpaceRatio
);
String
storePath
=
config
.
getStorePathCommitLog
();
StringBuilder
storePathBuilder
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
storePathBuilder
.
append
(
storePath
).
append
(
i
).
append
(
":"
);
}
config
.
setStorePathCommitLog
(
storePathBuilder
.
toString
());
String
[]
paths
=
config
.
getStorePathCommitLog
().
trim
().
split
(
MessageStoreConfig
.
MULTI_PATH_SPLITTER
);
assertEquals
(
3
,
paths
.
length
);
initMessageStore
(
config
,
diskSpaceCleanForciblyRatio
);
// build and put 55 messages, exactly one message per CommitLog file.
buildAndPutMessagesToMessageStore
(
msgCount
);
MappedFileQueue
commitLogQueue
=
getMappedFileQueueCommitLog
();
assertEquals
(
fileCountCommitLog
,
commitLogQueue
.
getMappedFiles
().
size
());
int
fileCountConsumeQueue
=
getFileCountConsumeQueue
();
MappedFileQueue
consumeQueue
=
getMappedFileQueueConsumeQueue
();
assertEquals
(
fileCountConsumeQueue
,
consumeQueue
.
getMappedFiles
().
size
());
cleanCommitLogService
.
isSpaceFull
();
assertEquals
(
1
<<
4
,
messageStore
.
getRunningFlags
().
getFlagBits
()
&
(
1
<<
4
));
messageStore
.
shutdown
();
messageStore
.
destroy
();
}
@Test
public
void
testIsSpaceFullFunctionFull2Empty
()
throws
Exception
{
String
deleteWhen
=
"04"
;
...
...
@@ -421,6 +456,10 @@ public class DefaultMessageStoreCleanFilesTest {
}
private
void
initMessageStore
(
String
deleteWhen
,
int
diskMaxUsedSpaceRatio
,
double
diskSpaceCleanForciblyRatio
)
throws
Exception
{
initMessageStore
(
genMessageStoreConfig
(
deleteWhen
,
diskMaxUsedSpaceRatio
),
diskSpaceCleanForciblyRatio
);
}
private
MessageStoreConfig
genMessageStoreConfig
(
String
deleteWhen
,
int
diskMaxUsedSpaceRatio
)
{
MessageStoreConfig
messageStoreConfig
=
new
MessageStoreConfigForTest
();
messageStoreConfig
.
setMappedFileSizeCommitLog
(
mappedFileSize
);
messageStoreConfig
.
setMappedFileSizeConsumeQueue
(
mappedFileSize
);
...
...
@@ -442,7 +481,10 @@ public class DefaultMessageStoreCleanFilesTest {
String
storePathCommitLog
=
storePathRootDir
+
File
.
separator
+
"commitlog"
;
messageStoreConfig
.
setStorePathRootDir
(
storePathRootDir
);
messageStoreConfig
.
setStorePathCommitLog
(
storePathCommitLog
);
return
messageStoreConfig
;
}
private
void
initMessageStore
(
MessageStoreConfig
messageStoreConfig
,
double
diskSpaceCleanForciblyRatio
)
throws
Exception
{
messageStore
=
new
DefaultMessageStore
(
messageStoreConfig
,
new
BrokerStatsManager
(
"test"
),
new
MyMessageArrivingListener
(),
new
BrokerConfig
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录