Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
40adaf76
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看板
未验证
提交
40adaf76
编写于
2月 20, 2021
作者:
张
张皮皮
提交者:
GitHub
2月 20, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[ISSUE #2652] change the method name to incrementAndGet
Co-authored-by:
N
张玻
<
zhangbo@mydataway.com
>
上级
97c77701
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
12 addition
and
12 deletion
+12
-12
client/src/main/java/org/apache/rocketmq/client/common/ThreadLocalIndex.java
...a/org/apache/rocketmq/client/common/ThreadLocalIndex.java
+1
-1
client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
...pache/rocketmq/client/impl/producer/TopicPublishInfo.java
+2
-2
client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
...he/rocketmq/client/latency/LatencyFaultToleranceImpl.java
+1
-1
client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java
...a/org/apache/rocketmq/client/latency/MQFaultStrategy.java
+2
-2
client/src/main/java/org/apache/rocketmq/client/trace/AsyncTraceDispatcher.java
...rg/apache/rocketmq/client/trace/AsyncTraceDispatcher.java
+1
-1
client/src/test/java/org/apache/rocketmq/client/common/ThreadLocalIndexTest.java
...g/apache/rocketmq/client/common/ThreadLocalIndexTest.java
+5
-5
未找到文件。
client/src/main/java/org/apache/rocketmq/client/common/ThreadLocalIndex.java
浏览文件 @
40adaf76
...
@@ -23,7 +23,7 @@ public class ThreadLocalIndex {
...
@@ -23,7 +23,7 @@ public class ThreadLocalIndex {
private
final
ThreadLocal
<
Integer
>
threadLocalIndex
=
new
ThreadLocal
<
Integer
>();
private
final
ThreadLocal
<
Integer
>
threadLocalIndex
=
new
ThreadLocal
<
Integer
>();
private
final
Random
random
=
new
Random
();
private
final
Random
random
=
new
Random
();
public
int
getAndIncremen
t
()
{
public
int
incrementAndGe
t
()
{
Integer
index
=
this
.
threadLocalIndex
.
get
();
Integer
index
=
this
.
threadLocalIndex
.
get
();
if
(
null
==
index
)
{
if
(
null
==
index
)
{
index
=
Math
.
abs
(
random
.
nextInt
());
index
=
Math
.
abs
(
random
.
nextInt
());
...
...
client/src/main/java/org/apache/rocketmq/client/impl/producer/TopicPublishInfo.java
浏览文件 @
40adaf76
...
@@ -71,7 +71,7 @@ public class TopicPublishInfo {
...
@@ -71,7 +71,7 @@ public class TopicPublishInfo {
return
selectOneMessageQueue
();
return
selectOneMessageQueue
();
}
else
{
}
else
{
for
(
int
i
=
0
;
i
<
this
.
messageQueueList
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
this
.
messageQueueList
.
size
();
i
++)
{
int
index
=
this
.
sendWhichQueue
.
getAndIncremen
t
();
int
index
=
this
.
sendWhichQueue
.
incrementAndGe
t
();
int
pos
=
Math
.
abs
(
index
)
%
this
.
messageQueueList
.
size
();
int
pos
=
Math
.
abs
(
index
)
%
this
.
messageQueueList
.
size
();
if
(
pos
<
0
)
if
(
pos
<
0
)
pos
=
0
;
pos
=
0
;
...
@@ -85,7 +85,7 @@ public class TopicPublishInfo {
...
@@ -85,7 +85,7 @@ public class TopicPublishInfo {
}
}
public
MessageQueue
selectOneMessageQueue
()
{
public
MessageQueue
selectOneMessageQueue
()
{
int
index
=
this
.
sendWhichQueue
.
getAndIncremen
t
();
int
index
=
this
.
sendWhichQueue
.
incrementAndGe
t
();
int
pos
=
Math
.
abs
(
index
)
%
this
.
messageQueueList
.
size
();
int
pos
=
Math
.
abs
(
index
)
%
this
.
messageQueueList
.
size
();
if
(
pos
<
0
)
if
(
pos
<
0
)
pos
=
0
;
pos
=
0
;
...
...
client/src/main/java/org/apache/rocketmq/client/latency/LatencyFaultToleranceImpl.java
浏览文件 @
40adaf76
...
@@ -80,7 +80,7 @@ public class LatencyFaultToleranceImpl implements LatencyFaultTolerance<String>
...
@@ -80,7 +80,7 @@ public class LatencyFaultToleranceImpl implements LatencyFaultTolerance<String>
if
(
half
<=
0
)
{
if
(
half
<=
0
)
{
return
tmpList
.
get
(
0
).
getName
();
return
tmpList
.
get
(
0
).
getName
();
}
else
{
}
else
{
final
int
i
=
this
.
whichItemWorst
.
getAndIncremen
t
()
%
half
;
final
int
i
=
this
.
whichItemWorst
.
incrementAndGe
t
()
%
half
;
return
tmpList
.
get
(
i
).
getName
();
return
tmpList
.
get
(
i
).
getName
();
}
}
}
}
...
...
client/src/main/java/org/apache/rocketmq/client/latency/MQFaultStrategy.java
浏览文件 @
40adaf76
...
@@ -58,7 +58,7 @@ public class MQFaultStrategy {
...
@@ -58,7 +58,7 @@ public class MQFaultStrategy {
public
MessageQueue
selectOneMessageQueue
(
final
TopicPublishInfo
tpInfo
,
final
String
lastBrokerName
)
{
public
MessageQueue
selectOneMessageQueue
(
final
TopicPublishInfo
tpInfo
,
final
String
lastBrokerName
)
{
if
(
this
.
sendLatencyFaultEnable
)
{
if
(
this
.
sendLatencyFaultEnable
)
{
try
{
try
{
int
index
=
tpInfo
.
getSendWhichQueue
().
getAndIncremen
t
();
int
index
=
tpInfo
.
getSendWhichQueue
().
incrementAndGe
t
();
for
(
int
i
=
0
;
i
<
tpInfo
.
getMessageQueueList
().
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
tpInfo
.
getMessageQueueList
().
size
();
i
++)
{
int
pos
=
Math
.
abs
(
index
++)
%
tpInfo
.
getMessageQueueList
().
size
();
int
pos
=
Math
.
abs
(
index
++)
%
tpInfo
.
getMessageQueueList
().
size
();
if
(
pos
<
0
)
if
(
pos
<
0
)
...
@@ -74,7 +74,7 @@ public class MQFaultStrategy {
...
@@ -74,7 +74,7 @@ public class MQFaultStrategy {
final
MessageQueue
mq
=
tpInfo
.
selectOneMessageQueue
();
final
MessageQueue
mq
=
tpInfo
.
selectOneMessageQueue
();
if
(
notBestBroker
!=
null
)
{
if
(
notBestBroker
!=
null
)
{
mq
.
setBrokerName
(
notBestBroker
);
mq
.
setBrokerName
(
notBestBroker
);
mq
.
setQueueId
(
tpInfo
.
getSendWhichQueue
().
getAndIncremen
t
()
%
writeQueueNums
);
mq
.
setQueueId
(
tpInfo
.
getSendWhichQueue
().
incrementAndGe
t
()
%
writeQueueNums
);
}
}
return
mq
;
return
mq
;
}
else
{
}
else
{
...
...
client/src/main/java/org/apache/rocketmq/client/trace/AsyncTraceDispatcher.java
浏览文件 @
40adaf76
...
@@ -387,7 +387,7 @@ public class AsyncTraceDispatcher implements TraceDispatcher {
...
@@ -387,7 +387,7 @@ public class AsyncTraceDispatcher implements TraceDispatcher {
filterMqs
.
add
(
queue
);
filterMqs
.
add
(
queue
);
}
}
}
}
int
index
=
sendWhichQueue
.
getAndIncremen
t
();
int
index
=
sendWhichQueue
.
incrementAndGe
t
();
int
pos
=
Math
.
abs
(
index
)
%
filterMqs
.
size
();
int
pos
=
Math
.
abs
(
index
)
%
filterMqs
.
size
();
if
(
pos
<
0
)
{
if
(
pos
<
0
)
{
pos
=
0
;
pos
=
0
;
...
...
client/src/test/java/org/apache/rocketmq/client/common/ThreadLocalIndexTest.java
浏览文件 @
40adaf76
...
@@ -22,17 +22,17 @@ import static org.assertj.core.api.Assertions.assertThat;
...
@@ -22,17 +22,17 @@ import static org.assertj.core.api.Assertions.assertThat;
public
class
ThreadLocalIndexTest
{
public
class
ThreadLocalIndexTest
{
@Test
@Test
public
void
test
GetAndIncremen
t
()
throws
Exception
{
public
void
test
IncrementAndGe
t
()
throws
Exception
{
ThreadLocalIndex
localIndex
=
new
ThreadLocalIndex
();
ThreadLocalIndex
localIndex
=
new
ThreadLocalIndex
();
int
initialVal
=
localIndex
.
getAndIncremen
t
();
int
initialVal
=
localIndex
.
incrementAndGe
t
();
assertThat
(
localIndex
.
getAndIncremen
t
()).
isEqualTo
(
initialVal
+
1
);
assertThat
(
localIndex
.
incrementAndGe
t
()).
isEqualTo
(
initialVal
+
1
);
}
}
@Test
@Test
public
void
test
GetAndIncremen
t2
()
throws
Exception
{
public
void
test
IncrementAndGe
t2
()
throws
Exception
{
ThreadLocalIndex
localIndex
=
new
ThreadLocalIndex
();
ThreadLocalIndex
localIndex
=
new
ThreadLocalIndex
();
int
initialVal
=
localIndex
.
getAndIncremen
t
();
int
initialVal
=
localIndex
.
incrementAndGe
t
();
assertThat
(
initialVal
>=
0
);
assertThat
(
initialVal
>=
0
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录