Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
ede33c1d
R
Rocketmq
项目概览
Apache RocketMQ
/
Rocketmq
上一次同步 大约 3 年
通知
267
Star
16139
Fork
68
代码
文件
提交
分支
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看板
提交
ede33c1d
编写于
3月 06, 2019
作者:
H
hdchen
提交者:
dinglei
3月 06, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[RIP-10] optimization test case of DefaultMessageStore (#995)
上级
690a406e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
39 addition
and
12 deletion
+39
-12
store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java
...va/org/apache/rocketmq/store/DefaultMessageStoreTest.java
+39
-12
未找到文件。
store/src/test/java/org/apache/rocketmq/store/DefaultMessageStoreTest.java
浏览文件 @
ede33c1d
...
...
@@ -40,6 +40,7 @@ import org.apache.rocketmq.store.config.StorePathConfigHelper;
import
org.apache.rocketmq.store.stats.BrokerStatsManager
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.junit.MockitoJUnitRunner
;
...
...
@@ -123,6 +124,8 @@ public class DefaultMessageStoreTest {
messageStore
.
putMessage
(
buildMessage
());
}
StoreTestUtil
.
waitCommitLogReput
((
DefaultMessageStore
)
messageStore
);
for
(
long
i
=
0
;
i
<
totalMsgs
;
i
++)
{
GetMessageResult
result
=
messageStore
.
getMessage
(
"GROUP_A"
,
"TOPIC_A"
,
0
,
i
,
1024
*
1024
,
null
);
assertThat
(
result
).
isNotNull
();
...
...
@@ -180,7 +183,8 @@ public class DefaultMessageStoreTest {
int
queueId
=
0
;
String
topic
=
"FooBar"
;
AppendMessageResult
[]
appendMessageResults
=
putMessages
(
totalCount
,
topic
,
queueId
,
true
);
Thread
.
sleep
(
10
);
//Thread.sleep(10);
StoreTestUtil
.
waitCommitLogReput
((
DefaultMessageStore
)
messageStore
);
ConsumeQueue
consumeQueue
=
getDefaultMessageStore
().
findConsumeQueue
(
topic
,
queueId
);
for
(
AppendMessageResult
appendMessageResult
:
appendMessageResults
)
{
...
...
@@ -198,7 +202,8 @@ public class DefaultMessageStoreTest {
int
queueId
=
0
;
String
topic
=
"FooBar"
;
AppendMessageResult
[]
appendMessageResults
=
putMessages
(
totalCount
,
topic
,
queueId
,
true
);
Thread
.
sleep
(
10
);
//Thread.sleep(10);
StoreTestUtil
.
waitCommitLogReput
((
DefaultMessageStore
)
messageStore
);
int
skewing
=
2
;
ConsumeQueue
consumeQueue
=
getDefaultMessageStore
().
findConsumeQueue
(
topic
,
queueId
);
...
...
@@ -222,7 +227,8 @@ public class DefaultMessageStoreTest {
int
queueId
=
0
;
String
topic
=
"FooBar"
;
AppendMessageResult
[]
appendMessageResults
=
putMessages
(
totalCount
,
topic
,
queueId
,
true
);
Thread
.
sleep
(
10
);
//Thread.sleep(10);
StoreTestUtil
.
waitCommitLogReput
((
DefaultMessageStore
)
messageStore
);
int
skewing
=
20000
;
ConsumeQueue
consumeQueue
=
getDefaultMessageStore
().
findConsumeQueue
(
topic
,
queueId
);
...
...
@@ -235,6 +241,9 @@ public class DefaultMessageStoreTest {
assertThat
(
indexBuffer
.
getByteBuffer
().
getInt
()).
isEqualTo
(
appendMessageResults
[
totalCount
-
1
].
getWroteBytes
());
assertThat
(
indexBuffer2
.
getByteBuffer
().
getLong
()).
isEqualTo
(
appendMessageResults
[
0
].
getWroteOffset
());
assertThat
(
indexBuffer2
.
getByteBuffer
().
getInt
()).
isEqualTo
(
appendMessageResults
[
0
].
getWroteBytes
());
indexBuffer
.
release
();
indexBuffer2
.
release
();
}
}
...
...
@@ -245,7 +254,9 @@ public class DefaultMessageStoreTest {
int
wrongQueueId
=
1
;
String
topic
=
"FooBar"
;
AppendMessageResult
[]
appendMessageResults
=
putMessages
(
totalCount
,
topic
,
queueId
,
false
);
Thread
.
sleep
(
10
);
//Thread.sleep(10);
StoreTestUtil
.
waitCommitLogReput
((
DefaultMessageStore
)
messageStore
);
long
offset
=
messageStore
.
getOffsetInQueueByTime
(
topic
,
wrongQueueId
,
appendMessageResults
[
0
].
getStoreTimestamp
());
...
...
@@ -259,7 +270,8 @@ public class DefaultMessageStoreTest {
int
wrongQueueId
=
1
;
String
topic
=
"FooBar"
;
putMessages
(
totalCount
,
topic
,
queueId
,
false
);
Thread
.
sleep
(
10
);
//Thread.sleep(10);
StoreTestUtil
.
waitCommitLogReput
((
DefaultMessageStore
)
messageStore
);
long
messageStoreTimeStamp
=
messageStore
.
getMessageStoreTimeStamp
(
topic
,
wrongQueueId
,
0
);
...
...
@@ -273,7 +285,9 @@ public class DefaultMessageStoreTest {
int
wrongQueueId
=
1
;
String
topic
=
"FooBar"
;
putMessages
(
totalCount
,
topic
,
queueId
,
true
);
Thread
.
sleep
(
10
);
//Thread.sleep(10);
StoreTestUtil
.
waitCommitLogReput
((
DefaultMessageStore
)
messageStore
);
long
messageStoreTimeStamp
=
messageStore
.
getMessageStoreTimeStamp
(
topic
,
wrongQueueId
,
-
1
);
...
...
@@ -287,7 +301,8 @@ public class DefaultMessageStoreTest {
int
queueId
=
0
;
String
topic
=
"FooBar"
;
AppendMessageResult
[]
appendMessageResults
=
putMessages
(
totalCount
,
topic
,
queueId
,
false
);
Thread
.
sleep
(
10
);
//Thread.sleep(10);
StoreTestUtil
.
waitCommitLogReput
((
DefaultMessageStore
)
messageStore
);
ConsumeQueue
consumeQueue
=
getDefaultMessageStore
().
findConsumeQueue
(
topic
,
queueId
);
int
minOffsetInQueue
=
(
int
)
consumeQueue
.
getMinOffsetInQueue
();
...
...
@@ -310,7 +325,8 @@ public class DefaultMessageStoreTest {
int
queueId
=
0
;
String
topic
=
"FooBar"
;
AppendMessageResult
[]
appendMessageResults
=
putMessages
(
totalCount
,
topic
,
queueId
,
false
);
Thread
.
sleep
(
10
);
//Thread.sleep(10);
StoreTestUtil
.
waitCommitLogReput
((
DefaultMessageStore
)
messageStore
);
ConsumeQueue
consumeQueue
=
messageStore
.
getConsumeQueue
(
topic
,
queueId
);
for
(
int
i
=
0
;
i
<
totalCount
;
i
++)
{
...
...
@@ -412,6 +428,8 @@ public class DefaultMessageStoreTest {
master
.
putMessage
(
buildMessage
());
}
StoreTestUtil
.
waitCommitLogReput
((
DefaultMessageStore
)
messageStore
);
for
(
long
i
=
0
;
i
<
totalMsgs
;
i
++)
{
GetMessageResult
result
=
master
.
getMessage
(
"GROUP_A"
,
"TOPIC_A"
,
0
,
i
,
1024
*
1024
,
null
);
assertThat
(
result
).
isNotNull
();
...
...
@@ -432,16 +450,21 @@ public class DefaultMessageStoreTest {
}
// wait for consume queue build
// the sleep time should be great than consume queue flush interval
Thread
.
sleep
(
100
);
//Thread.sleep(100);
StoreTestUtil
.
waitCommitLogReput
((
DefaultMessageStore
)
messageStore
);
String
group
=
"simple"
;
GetMessageResult
getMessageResult32
=
messageStore
.
getMessage
(
group
,
topic
,
0
,
0
,
32
,
null
);
assertThat
(
getMessageResult32
.
getMessageBufferList
().
size
()).
isEqualTo
(
32
);
getMessageResult32
.
release
();
GetMessageResult
getMessageResult20
=
messageStore
.
getMessage
(
group
,
topic
,
0
,
0
,
20
,
null
);
assertThat
(
getMessageResult20
.
getMessageBufferList
().
size
()).
isEqualTo
(
20
);
getMessageResult20
.
release
();
GetMessageResult
getMessageResult45
=
messageStore
.
getMessage
(
group
,
topic
,
0
,
0
,
10
,
null
);
assertThat
(
getMessageResult45
.
getMessageBufferList
().
size
()).
isEqualTo
(
10
);
getMessageResult45
.
release
();
}
@Test
...
...
@@ -455,7 +478,9 @@ public class DefaultMessageStoreTest {
messageStore
.
putMessage
(
messageExtBrokerInner
);
}
Thread
.
sleep
(
100
);
//wait for build consumer queue
// Thread.sleep(100);//wait for build consumer queue
StoreTestUtil
.
waitCommitLogReput
((
DefaultMessageStore
)
messageStore
);
long
maxPhyOffset
=
messageStore
.
getMaxPhyOffset
();
long
maxCqOffset
=
messageStore
.
getMaxOffsetInQueue
(
topic
,
0
);
...
...
@@ -475,7 +500,8 @@ public class DefaultMessageStoreTest {
messageExtBrokerInner
.
setQueueId
(
0
);
messageStore
.
putMessage
(
messageExtBrokerInner
);
}
Thread
.
sleep
(
100
);
//Thread.sleep(100);
StoreTestUtil
.
waitCommitLogReput
((
DefaultMessageStore
)
messageStore
);
long
secondLastPhyOffset
=
messageStore
.
getMaxPhyOffset
();
long
secondLastCqOffset
=
messageStore
.
getMaxOffsetInQueue
(
topic
,
0
);
...
...
@@ -504,7 +530,8 @@ public class DefaultMessageStoreTest {
messageExtBrokerInner
.
setQueueId
(
0
);
messageStore
.
putMessage
(
messageExtBrokerInner
);
}
Thread
.
sleep
(
100
);
//Thread.sleep(100);
StoreTestUtil
.
waitCommitLogReput
((
DefaultMessageStore
)
messageStore
);
secondLastPhyOffset
=
messageStore
.
getMaxPhyOffset
();
secondLastCqOffset
=
messageStore
.
getMaxOffsetInQueue
(
topic
,
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录