Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
Rocketmq
提交
d0b0fa93
R
Rocketmq
项目概览
s920243400
/
Rocketmq
与 Fork 源项目一致
Fork自
Apache RocketMQ / Rocketmq
通知
1
Star
1
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看板
提交
d0b0fa93
编写于
1月 08, 2019
作者:
C
chenhoudao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify test case,cover FlushRealTimeService
上级
45a78aee
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
39 addition
and
10 deletion
+39
-10
store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java
...va/org/apache/rocketmq/store/DefaultMessageStoreTest.java
+39
-10
未找到文件。
store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java
浏览文件 @
d0b0fa93
...
...
@@ -30,6 +30,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import
org.apache.rocketmq.common.BrokerConfig
;
import
org.apache.rocketmq.common.UtilAll
;
import
org.apache.rocketmq.common.message.MessageDecoder
;
import
org.apache.rocketmq.store.config.FlushDiskType
;
import
org.apache.rocketmq.store.config.MessageStoreConfig
;
import
org.apache.rocketmq.store.config.StorePathConfigHelper
;
...
...
@@ -55,7 +56,7 @@ public class DefaultMessageStoreTest {
StoreHost
=
new
InetSocketAddress
(
InetAddress
.
getLocalHost
(),
8123
);
BornHost
=
new
InetSocketAddress
(
InetAddress
.
getByName
(
"127.0.0.1"
),
0
);
messageStore
=
buildMessageStore
();
messageStore
=
buildMessageStore
(
FlushDiskType
.
SYNC_FLUSH
);
boolean
load
=
messageStore
.
load
();
assertTrue
(
load
);
messageStore
.
start
();
...
...
@@ -95,19 +96,19 @@ public class DefaultMessageStoreTest {
UtilAll
.
deleteFile
(
file
);
}
private
MessageStore
buildMessageStore
()
throws
Exception
{
private
MessageStore
buildMessageStore
(
FlushDiskType
flushType
)
throws
Exception
{
MessageStoreConfig
messageStoreConfig
=
new
MessageStoreConfig
();
messageStoreConfig
.
setMapedFileSizeCommitLog
(
1024
*
1024
*
10
);
messageStoreConfig
.
setMapedFileSizeConsumeQueue
(
1024
*
1024
*
10
);
messageStoreConfig
.
setMaxHashSlotNum
(
10000
);
messageStoreConfig
.
setMaxIndexNum
(
100
*
100
);
messageStoreConfig
.
setFlushDiskType
(
FlushDiskType
.
SYNC_FLUSH
);
messageStoreConfig
.
setFlushDiskType
(
flushType
);
messageStoreConfig
.
setFlushIntervalConsumeQueue
(
1
);
return
new
DefaultMessageStore
(
messageStoreConfig
,
new
BrokerStatsManager
(
"simpleTest"
),
new
MyMessageArrivingListener
(),
new
BrokerConfig
());
}
@Test
public
void
testWriteAndRead
()
{
public
void
testWriteAndRead
()
throws
Exception
{
long
totalMsgs
=
10
;
QUEUE_TOTAL
=
1
;
MessageBody
=
StoreMessage
.
getBytes
();
...
...
@@ -115,12 +116,38 @@ public class DefaultMessageStoreTest {
messageStore
.
putMessage
(
buildMessage
());
}
Thread
.
sleep
(
100
);
//wait for build consumer queue
//reboot,messageStore start,flushType is ASYNC_FLUSH
messageStore
.
shutdown
();
messageStore
=
buildMessageStore
(
FlushDiskType
.
ASYNC_FLUSH
);
boolean
load
=
messageStore
.
load
();
assertTrue
(
load
);
messageStore
.
start
();
MessageBody
=
StoreMessage
.
getBytes
();
for
(
long
i
=
0
;
i
<
totalMsgs
;
i
++)
{
messageStore
.
putMessage
(
buildMessage
());
}
Thread
.
sleep
(
200
);
//wait for build consumer queue
//reboot,messageStore start,flushType is SYNC_FLUSH
messageStore
.
shutdown
();
messageStore
=
buildMessageStore
(
FlushDiskType
.
SYNC_FLUSH
);
load
=
messageStore
.
load
();
assertTrue
(
load
);
messageStore
.
start
();
totalMsgs
=
2
*
totalMsgs
;
for
(
long
i
=
0
;
i
<
totalMsgs
;
i
++)
{
GetMessageResult
result
=
messageStore
.
getMessage
(
"GROUP_A"
,
"
TOPIC_A
"
,
0
,
i
,
1024
*
1024
,
null
);
GetMessageResult
result
=
messageStore
.
getMessage
(
"GROUP_A"
,
"
FooBar
"
,
0
,
i
,
1024
*
1024
,
null
);
assertThat
(
result
).
isNotNull
();
result
.
release
();
}
verifyThatMasterIsFunctional
(
totalMsgs
,
messageStore
);
verifyThatMasterIsFunctional
(
totalMsgs
,
messageStore
);
}
private
MessageExtBrokerInner
buildMessage
()
{
...
...
@@ -135,6 +162,8 @@ public class DefaultMessageStoreTest {
msg
.
setBornTimestamp
(
System
.
currentTimeMillis
());
msg
.
setStoreHost
(
StoreHost
);
msg
.
setBornHost
(
BornHost
);
//setKeys
msg
.
setPropertiesString
(
MessageDecoder
.
messageProperties2String
(
msg
.
getProperties
()));
return
msg
;
}
...
...
@@ -144,7 +173,7 @@ public class DefaultMessageStoreTest {
}
for
(
long
i
=
0
;
i
<
totalMsgs
;
i
++)
{
GetMessageResult
result
=
master
.
getMessage
(
"GROUP_A"
,
"
TOPIC_A
"
,
0
,
i
,
1024
*
1024
,
null
);
GetMessageResult
result
=
master
.
getMessage
(
"GROUP_A"
,
"
FooBar
"
,
0
,
i
,
1024
*
1024
,
null
);
assertThat
(
result
).
isNotNull
();
result
.
release
();
...
...
@@ -192,7 +221,7 @@ public class DefaultMessageStoreTest {
//1.just reboot
messageStore
.
shutdown
();
messageStore
=
buildMessageStore
();
messageStore
=
buildMessageStore
(
FlushDiskType
.
SYNC_FLUSH
);
boolean
load
=
messageStore
.
load
();
assertTrue
(
load
);
messageStore
.
start
();
...
...
@@ -221,7 +250,7 @@ public class DefaultMessageStoreTest {
damageCommitlog
(
secondLastPhyOffset
);
//reboot
messageStore
=
buildMessageStore
();
messageStore
=
buildMessageStore
(
FlushDiskType
.
SYNC_FLUSH
);
load
=
messageStore
.
load
();
assertTrue
(
load
);
messageStore
.
start
();
...
...
@@ -253,7 +282,7 @@ public class DefaultMessageStoreTest {
MappedFile
.
ensureDirOK
(
file
.
getParent
());
file
.
createNewFile
();
messageStore
=
buildMessageStore
();
messageStore
=
buildMessageStore
(
FlushDiskType
.
SYNC_FLUSH
);
load
=
messageStore
.
load
();
assertTrue
(
load
);
messageStore
.
start
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录