Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
a493ca44
R
Rocketmq
项目概览
Apache RocketMQ
/
Rocketmq
上一次同步 大约 3 年
通知
268
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看板
提交
a493ca44
编写于
11月 24, 2021
作者:
D
dongeforever
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add the allocator test
上级
8962581e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
66 addition
and
9 deletion
+66
-9
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
...pache/rocketmq/broker/processor/AdminBrokerProcessor.java
+0
-3
common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicConfigSerializeWrapper.java
...tmq/common/protocol/body/TopicConfigSerializeWrapper.java
+2
-3
common/src/main/java/org/apache/rocketmq/common/statictopic/TopicQueueMappingUtils.java
...e/rocketmq/common/statictopic/TopicQueueMappingUtils.java
+3
-2
common/src/test/java/org/apache/rocketmq/common/statictopic/TopicMappingUtilsTest.java
...he/rocketmq/common/statictopic/TopicMappingUtilsTest.java
+61
-0
test/src/test/java/org/apache/rocketmq/test/smoke/StaticTopicIT.java
...st/java/org/apache/rocketmq/test/smoke/StaticTopicIT.java
+0
-1
未找到文件。
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
浏览文件 @
a493ca44
...
...
@@ -338,9 +338,6 @@ public class AdminBrokerProcessor extends AsyncNettyRequestProcessor implements
try
{
this
.
brokerController
.
getTopicConfigManager
().
updateTopicConfig
(
topicConfig
);
System
.
out
.
println
(
"Broker body:"
+
new
String
(
request
.
getBody
()));
System
.
out
.
println
(
"Broker bodetaildy:"
+
topicQueueMappingDetail
.
toJson
());
this
.
brokerController
.
getTopicQueueMappingManager
().
updateTopicQueueMapping
(
topicQueueMappingDetail
,
force
);
this
.
brokerController
.
registerIncrementBrokerData
(
topicConfig
,
this
.
brokerController
.
getTopicConfigManager
().
getDataVersion
());
...
...
common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicConfigSerializeWrapper.java
浏览文件 @
a493ca44
...
...
@@ -17,13 +17,12 @@
package
org.apache.rocketmq.common.protocol.body
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
import
org.apache.rocketmq.common.DataVersion
;
import
org.apache.rocketmq.common.TopicConfig
;
import
org.apache.rocketmq.remoting.protocol.RemotingSerializable
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentMap
;
public
class
TopicConfigSerializeWrapper
extends
RemotingSerializable
{
private
ConcurrentMap
<
String
,
TopicConfig
>
topicConfigTable
=
new
ConcurrentHashMap
<
String
,
TopicConfig
>();
...
...
common/src/main/java/org/apache/rocketmq/common/statictopic/TopicQueueMappingUtils.java
浏览文件 @
a493ca44
...
...
@@ -49,11 +49,12 @@ public class TopicQueueMappingUtils {
}
private
void
freshState
()
{
int
minNum
=
-
1
;
int
minNum
=
Integer
.
MAX_VALUE
;
for
(
Map
.
Entry
<
String
,
Integer
>
entry
:
brokerNumMap
.
entrySet
())
{
if
(
entry
.
getValue
()
>
minNum
)
{
if
(
entry
.
getValue
()
<
minNum
)
{
leastBrokers
.
clear
();
leastBrokers
.
add
(
entry
.
getKey
());
minNum
=
entry
.
getValue
();
}
else
if
(
entry
.
getValue
()
==
minNum
)
{
leastBrokers
.
add
(
entry
.
getKey
());
}
...
...
common/src/test/java/org/apache/rocketmq/common/statictopic/TopicMappingUtilsTest.java
0 → 100644
浏览文件 @
a493ca44
package
org.apache.rocketmq.common.statictopic
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
TopicMappingUtilsTest
{
private
Map
<
String
,
Integer
>
buildBrokerNumMap
(
int
num
)
{
Map
<
String
,
Integer
>
map
=
new
HashMap
<
String
,
Integer
>();
for
(
int
i
=
0
;
i
<
num
;
i
++)
{
map
.
put
(
"broker"
+
i
,
0
);
}
return
map
;
}
private
void
testIdToBroker
(
Map
<
Integer
,
String
>
idToBroker
,
Map
<
String
,
Integer
>
brokerNumMap
)
{
Map
<
String
,
Integer
>
brokerNumOther
=
new
HashMap
<
String
,
Integer
>();
for
(
int
i
=
0
;
i
<
idToBroker
.
size
();
i
++)
{
Assert
.
assertTrue
(
idToBroker
.
containsKey
(
i
));
String
broker
=
idToBroker
.
get
(
i
);
if
(
brokerNumOther
.
containsKey
(
broker
))
{
brokerNumOther
.
put
(
broker
,
brokerNumOther
.
get
(
broker
)
+
1
);
}
else
{
brokerNumOther
.
put
(
broker
,
1
);
}
}
Assert
.
assertEquals
(
brokerNumMap
.
size
(),
brokerNumOther
.
size
());
for
(
Map
.
Entry
<
String
,
Integer
>
entry:
brokerNumOther
.
entrySet
())
{
Assert
.
assertEquals
(
entry
.
getValue
(),
brokerNumMap
.
get
(
entry
.
getKey
()));
}
}
@Test
public
void
testAllocator
()
{
//stability
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
int
num
=
3
;
Map
<
String
,
Integer
>
brokerNumMap
=
buildBrokerNumMap
(
num
);
TopicQueueMappingUtils
.
MappingAllocator
allocator
=
TopicQueueMappingUtils
.
buildMappingAllocator
(
new
HashMap
<
Integer
,
String
>(),
brokerNumMap
);
allocator
.
upToNum
(
num
*
2
);
for
(
Map
.
Entry
<
String
,
Integer
>
entry:
allocator
.
getBrokerNumMap
().
entrySet
())
{
Assert
.
assertEquals
(
2L
,
entry
.
getValue
().
longValue
());
}
Assert
.
assertEquals
(
num
*
2
,
allocator
.
getIdToBroker
().
size
());
testIdToBroker
(
allocator
.
idToBroker
,
allocator
.
getBrokerNumMap
());
allocator
.
upToNum
(
num
*
3
-
1
);
for
(
Map
.
Entry
<
String
,
Integer
>
entry:
allocator
.
getBrokerNumMap
().
entrySet
())
{
Assert
.
assertTrue
(
entry
.
getValue
()
>=
2
);
Assert
.
assertTrue
(
entry
.
getValue
()
<=
3
);
}
Assert
.
assertEquals
(
num
*
3
-
1
,
allocator
.
getIdToBroker
().
size
());
testIdToBroker
(
allocator
.
idToBroker
,
allocator
.
getBrokerNumMap
());
}
}
}
test/src/test/java/org/apache/rocketmq/test/smoke/StaticTopicIT.java
浏览文件 @
a493ca44
...
...
@@ -57,7 +57,6 @@ public class StaticTopicIT extends BaseConf {
String
broker
=
entry
.
getKey
();
String
addr
=
clientMetadata
.
findMasterBrokerAddr
(
broker
);
TopicConfigAndQueueMapping
configMapping
=
entry
.
getValue
();
System
.
out
.
println
(
configMapping
.
getMappingDetail
().
toJson
());
defaultMQAdminExt
.
createStaticTopic
(
addr
,
defaultMQAdminExt
.
getCreateTopicKey
(),
configMapping
,
configMapping
.
getMappingDetail
(),
false
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录