Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
Rocketmq
提交
bf343a31
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看板
未验证
提交
bf343a31
编写于
9月 13, 2021
作者:
R
racoon
提交者:
GitHub
9月 13, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[ISSUE #3225]change Random to ThreadLocalRandom in broker
上级
83b04d03
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
15 addition
and
12 deletion
+15
-12
broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
...cketmq/broker/processor/AbstractSendMessageProcessor.java
+3
-3
broker/src/main/java/org/apache/rocketmq/broker/processor/ReplyMessageProcessor.java
...ache/rocketmq/broker/processor/ReplyMessageProcessor.java
+3
-1
broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
...pache/rocketmq/broker/processor/SendMessageProcessor.java
+6
-5
broker/src/main/java/org/apache/rocketmq/broker/transaction/AbstractTransactionalMessageCheckListener.java
...ransaction/AbstractTransactionalMessageCheckListener.java
+0
-2
broker/src/main/java/org/apache/rocketmq/broker/transaction/queue/DefaultTransactionalMessageCheckListener.java
...ction/queue/DefaultTransactionalMessageCheckListener.java
+3
-1
未找到文件。
broker/src/main/java/org/apache/rocketmq/broker/processor/AbstractSendMessageProcessor.java
浏览文件 @
bf343a31
...
...
@@ -22,7 +22,8 @@ import java.net.SocketAddress;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
import
java.util.concurrent.ThreadLocalRandom
;
import
org.apache.rocketmq.broker.BrokerController
;
import
org.apache.rocketmq.broker.mqtrace.SendMessageContext
;
import
org.apache.rocketmq.broker.mqtrace.SendMessageHook
;
...
...
@@ -60,7 +61,6 @@ public abstract class AbstractSendMessageProcessor extends AsyncNettyRequestProc
protected
final
static
int
DLQ_NUMS_PER_GROUP
=
1
;
protected
final
BrokerController
brokerController
;
protected
final
Random
random
=
new
Random
(
System
.
currentTimeMillis
());
protected
final
SocketAddress
storeHost
;
private
List
<
SendMessageHook
>
sendMessageHookList
;
...
...
@@ -109,7 +109,7 @@ public abstract class AbstractSendMessageProcessor extends AsyncNettyRequestProc
final
SendMessageRequestHeader
requestHeader
,
final
byte
[]
body
,
TopicConfig
topicConfig
)
{
int
queueIdInt
=
requestHeader
.
getQueueId
();
if
(
queueIdInt
<
0
)
{
queueIdInt
=
Math
.
abs
(
this
.
random
.
nextInt
()
%
99999999
)
%
topicConfig
.
getWriteQueueNums
();
queueIdInt
=
ThreadLocalRandom
.
current
().
nextInt
(
99999999
)
%
topicConfig
.
getWriteQueueNums
();
}
int
sysFlag
=
requestHeader
.
getSysFlag
();
...
...
broker/src/main/java/org/apache/rocketmq/broker/processor/ReplyMessageProcessor.java
浏览文件 @
bf343a31
...
...
@@ -45,6 +45,8 @@ import org.apache.rocketmq.store.MessageExtBrokerInner;
import
org.apache.rocketmq.store.PutMessageResult
;
import
org.apache.rocketmq.store.stats.BrokerStatsManager
;
import
java.util.concurrent.ThreadLocalRandom
;
public
class
ReplyMessageProcessor
extends
AbstractSendMessageProcessor
implements
NettyRequestProcessor
{
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
BROKER_LOGGER_NAME
);
...
...
@@ -125,7 +127,7 @@ public class ReplyMessageProcessor extends AbstractSendMessageProcessor implemen
TopicConfig
topicConfig
=
this
.
brokerController
.
getTopicConfigManager
().
selectTopicConfig
(
requestHeader
.
getTopic
());
if
(
queueIdInt
<
0
)
{
queueIdInt
=
Math
.
abs
(
this
.
random
.
nextInt
()
%
99999999
)
%
topicConfig
.
getWriteQueueNums
();
queueIdInt
=
ThreadLocalRandom
.
current
().
nextInt
(
99999999
)
%
topicConfig
.
getWriteQueueNums
();
}
MessageExtBrokerInner
msgInner
=
new
MessageExtBrokerInner
();
...
...
broker/src/main/java/org/apache/rocketmq/broker/processor/SendMessageProcessor.java
浏览文件 @
bf343a31
...
...
@@ -21,6 +21,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.ThreadLocalRandom
;
import
io.netty.channel.ChannelHandlerContext
;
import
org.apache.rocketmq.broker.BrokerController
;
...
...
@@ -141,7 +142,7 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
}
String
newTopic
=
MixAll
.
getRetryTopic
(
requestHeader
.
getGroup
());
int
queueIdInt
=
Math
.
abs
(
this
.
random
.
nextInt
()
%
99999999
)
%
subscriptionGroupConfig
.
getRetryQueueNums
();
int
queueIdInt
=
ThreadLocalRandom
.
current
().
nextInt
(
99999999
)
%
subscriptionGroupConfig
.
getRetryQueueNums
();
int
topicSysFlag
=
0
;
if
(
requestHeader
.
isUnitMode
())
{
topicSysFlag
=
TopicSysFlag
.
buildSysFlag
(
false
,
true
);
...
...
@@ -188,7 +189,7 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
if
(
msgExt
.
getReconsumeTimes
()
>=
maxReconsumeTimes
||
delayLevel
<
0
)
{
newTopic
=
MixAll
.
getDLQTopic
(
requestHeader
.
getGroup
());
queueIdInt
=
Math
.
abs
(
this
.
random
.
nextInt
()
%
99999999
)
%
DLQ_NUMS_PER_GROUP
;
queueIdInt
=
ThreadLocalRandom
.
current
().
nextInt
(
99999999
)
%
DLQ_NUMS_PER_GROUP
;
topicConfig
=
this
.
brokerController
.
getTopicConfigManager
().
createTopicInSendMessageBackMethod
(
newTopic
,
DLQ_NUMS_PER_GROUP
,
...
...
@@ -353,7 +354,7 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
int
reconsumeTimes
=
requestHeader
.
getReconsumeTimes
()
==
null
?
0
:
requestHeader
.
getReconsumeTimes
();
if
(
reconsumeTimes
>=
maxReconsumeTimes
)
{
newTopic
=
MixAll
.
getDLQTopic
(
groupName
);
int
queueIdInt
=
Math
.
abs
(
this
.
random
.
nextInt
()
%
99999999
)
%
DLQ_NUMS_PER_GROUP
;
int
queueIdInt
=
ThreadLocalRandom
.
current
().
nextInt
(
99999999
)
%
DLQ_NUMS_PER_GROUP
;
topicConfig
=
this
.
brokerController
.
getTopicConfigManager
().
createTopicInSendMessageBackMethod
(
newTopic
,
DLQ_NUMS_PER_GROUP
,
PermName
.
PERM_WRITE
,
0
...
...
@@ -410,7 +411,7 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
TopicConfig
topicConfig
=
this
.
brokerController
.
getTopicConfigManager
().
selectTopicConfig
(
requestHeader
.
getTopic
());
if
(
queueIdInt
<
0
)
{
queueIdInt
=
Math
.
abs
(
this
.
random
.
nextInt
()
%
99999999
)
%
topicConfig
.
getWriteQueueNums
();
queueIdInt
=
ThreadLocalRandom
.
current
().
nextInt
(
99999999
)
%
topicConfig
.
getWriteQueueNums
();
}
MessageExtBrokerInner
msgInner
=
new
MessageExtBrokerInner
();
...
...
@@ -666,7 +667,7 @@ public class SendMessageProcessor extends AbstractSendMessageProcessor implement
}
private
int
randomQueueId
(
int
writeQueueNums
)
{
return
(
this
.
random
.
nextInt
()
%
99999999
)
%
writeQueueNums
;
return
ThreadLocalRandom
.
current
().
nextInt
(
99999999
)
%
writeQueueNums
;
}
private
RemotingCommand
preSend
(
ChannelHandlerContext
ctx
,
RemotingCommand
request
,
...
...
broker/src/main/java/org/apache/rocketmq/broker/transaction/AbstractTransactionalMessageCheckListener.java
浏览文件 @
bf343a31
...
...
@@ -17,7 +17,6 @@
package
org.apache.rocketmq.broker.transaction
;
import
io.netty.channel.Channel
;
import
java.util.Random
;
import
org.apache.rocketmq.broker.BrokerController
;
import
org.apache.rocketmq.common.constant.LoggerName
;
import
org.apache.rocketmq.common.message.MessageConst
;
...
...
@@ -40,7 +39,6 @@ public abstract class AbstractTransactionalMessageCheckListener {
//queue nums of topic TRANS_CHECK_MAX_TIME_TOPIC
protected
final
static
int
TCMT_QUEUE_NUMS
=
1
;
protected
final
Random
random
=
new
Random
(
System
.
currentTimeMillis
());
private
static
ExecutorService
executorService
=
new
ThreadPoolExecutor
(
2
,
5
,
100
,
TimeUnit
.
SECONDS
,
new
ArrayBlockingQueue
<
Runnable
>(
2000
),
new
ThreadFactory
()
{
@Override
...
...
broker/src/main/java/org/apache/rocketmq/broker/transaction/queue/DefaultTransactionalMessageCheckListener.java
浏览文件 @
bf343a31
...
...
@@ -30,6 +30,8 @@ import org.apache.rocketmq.store.MessageExtBrokerInner;
import
org.apache.rocketmq.store.PutMessageResult
;
import
org.apache.rocketmq.store.PutMessageStatus
;
import
java.util.concurrent.ThreadLocalRandom
;
public
class
DefaultTransactionalMessageCheckListener
extends
AbstractTransactionalMessageCheckListener
{
private
static
final
InternalLogger
log
=
InternalLoggerFactory
.
getLogger
(
LoggerName
.
TRANSACTION_LOGGER_NAME
);
...
...
@@ -58,7 +60,7 @@ public class DefaultTransactionalMessageCheckListener extends AbstractTransactio
private
MessageExtBrokerInner
toMessageExtBrokerInner
(
MessageExt
msgExt
)
{
TopicConfig
topicConfig
=
this
.
getBrokerController
().
getTopicConfigManager
().
createTopicOfTranCheckMaxTime
(
TCMT_QUEUE_NUMS
,
PermName
.
PERM_READ
|
PermName
.
PERM_WRITE
);
int
queueId
=
Math
.
abs
(
random
.
nextInt
()
%
99999999
)
%
TCMT_QUEUE_NUMS
;
int
queueId
=
ThreadLocalRandom
.
current
().
nextInt
(
99999999
)
%
TCMT_QUEUE_NUMS
;
MessageExtBrokerInner
inner
=
new
MessageExtBrokerInner
();
inner
.
setTopic
(
topicConfig
.
getTopicName
());
inner
.
setBody
(
msgExt
.
getBody
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录