Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小五666\n哈哈
Rocketmq
提交
ba48f6a2
R
Rocketmq
项目概览
小五666\n哈哈
/
Rocketmq
与 Fork 源项目一致
Fork自
Apache RocketMQ / Rocketmq
通知
1
Star
0
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看板
未验证
提交
ba48f6a2
编写于
1月 31, 2019
作者:
H
Heng Du
提交者:
GitHub
1月 31, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #739 from ShannonDing/snode
[ISSUE #737]Polish Push Consumer
上级
9fc0ce45
60e12f08
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
41 addition
and
33 deletion
+41
-33
client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
...cketmq/client/consumer/store/RemoteBrokerOffsetStore.java
+25
-22
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
...ketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
+5
-2
client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
...ache/rocketmq/client/impl/consumer/RebalancePushImpl.java
+2
-1
client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
...apache/rocketmq/client/impl/factory/MQClientInstance.java
+9
-8
未找到文件。
client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
浏览文件 @
ba48f6a2
...
...
@@ -124,14 +124,14 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
if
(
offset
!=
null
)
{
if
(
mqs
.
contains
(
mq
))
{
try
{
this
.
updateConsumeOffsetTo
Broker
(
mq
,
offset
.
get
());
log
.
info
(
"[persistAll] Group: {} ClientId: {} updateConsumeOffsetTo
Broker
{} {}"
,
this
.
updateConsumeOffsetTo
Snode
(
mq
,
offset
.
get
());
log
.
info
(
"[persistAll] Group: {} ClientId: {} updateConsumeOffsetTo
Snode
{} {}"
,
this
.
groupName
,
this
.
mQClientFactory
.
getClientId
(),
mq
,
offset
.
get
());
}
catch
(
Exception
e
)
{
log
.
error
(
"updateConsumeOffsetTo
Broker
exception, "
+
mq
.
toString
(),
e
);
log
.
error
(
"updateConsumeOffsetTo
Snode
exception, "
+
mq
.
toString
(),
e
);
}
}
else
{
unusedMQ
.
add
(
mq
);
...
...
@@ -153,14 +153,14 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
AtomicLong
offset
=
this
.
offsetTable
.
get
(
mq
);
if
(
offset
!=
null
)
{
try
{
this
.
updateConsumeOffsetTo
Broker
(
mq
,
offset
.
get
());
log
.
info
(
"[persist] Group: {} ClientId: {} updateConsumeOffsetTo
Broker
{} {}"
,
this
.
updateConsumeOffsetTo
Snode
(
mq
,
offset
.
get
());
log
.
info
(
"[persist] Group: {} ClientId: {} updateConsumeOffsetTo
Snode
{} {}"
,
this
.
groupName
,
this
.
mQClientFactory
.
getClientId
(),
mq
,
offset
.
get
());
}
catch
(
Exception
e
)
{
log
.
error
(
"updateConsumeOffsetTo
Broker
exception, "
+
mq
.
toString
(),
e
);
log
.
error
(
"updateConsumeOffsetTo
Snode
exception, "
+
mq
.
toString
(),
e
);
}
}
}
...
...
@@ -193,6 +193,10 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
MQBrokerException
,
InterruptedException
,
MQClientException
{
updateConsumeOffsetToBroker
(
mq
,
offset
,
true
);
}
private
void
updateConsumeOffsetToSnode
(
MessageQueue
mq
,
long
offset
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
updateConsumeOffsetToBroker
(
mq
,
offset
,
true
);
}
/**
* Update the Consumer Offset synchronously, once the Master is off, updated to Slave, here need to be optimized.
...
...
@@ -200,14 +204,14 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
@Override
public
void
updateConsumeOffsetToBroker
(
MessageQueue
mq
,
long
offset
,
boolean
isOneway
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
FindBrokerResult
findBrokerResult
=
this
.
mQClientFactory
.
findBrokerAddressInAdmin
(
mq
.
getBrokerName
());
if
(
null
==
findBrokerResult
)
{
this
.
mQClientFactory
.
updateTopicRouteInfoFromNameServer
(
mq
.
getTopic
());
findBrokerResult
=
this
.
mQClientFactory
.
findBrokerAddressInAdmin
(
mq
.
getBrokerName
());
String
snodeAddr
=
this
.
mQClientFactory
.
findSnodeAddressInPublish
();
if
(
null
==
snodeAddr
){
this
.
mQClientFactory
.
updateSnodeInfoFromNameServer
();
snodeAddr
=
this
.
mQClientFactory
.
findSnodeAddressInPublish
();
}
if
(
findBrokerResult
!=
null
)
{
if
(
snodeAddr
!=
null
)
{
UpdateConsumerOffsetRequestHeader
requestHeader
=
new
UpdateConsumerOffsetRequestHeader
();
requestHeader
.
setTopic
(
mq
.
getTopic
());
requestHeader
.
setConsumerGroup
(
this
.
groupName
);
...
...
@@ -216,35 +220,34 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
requestHeader
.
setEnodeName
(
mq
.
getBrokerName
());
if
(
isOneway
)
{
this
.
mQClientFactory
.
getMQClientAPIImpl
().
updateConsumerOffsetOneway
(
findBrokerResult
.
getBrokerAddr
()
,
requestHeader
,
1000
*
5
);
snodeAddr
,
requestHeader
,
1000
*
5
);
}
else
{
this
.
mQClientFactory
.
getMQClientAPIImpl
().
updateConsumerOffset
(
findBrokerResult
.
getBrokerAddr
()
,
requestHeader
,
1000
*
5
);
snodeAddr
,
requestHeader
,
1000
*
5
);
}
}
else
{
throw
new
MQClientException
(
"
The broker["
+
mq
.
getBrokerName
()
+
"] not exist
"
,
null
);
throw
new
MQClientException
(
"
Update offset to Broker["
+
mq
.
getBrokerName
()
+
"] failed, Snode is null.
"
,
null
);
}
}
private
long
fetchConsumeOffsetFromBroker
(
MessageQueue
mq
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
FindBrokerResult
findBrokerResult
=
this
.
mQClientFactory
.
findBrokerAddressInAdmin
(
mq
.
getBrokerName
());
if
(
null
==
findBrokerResult
)
{
this
.
mQClientFactory
.
updateTopicRouteInfoFromNameServer
(
mq
.
getTopic
());
findBrokerResult
=
this
.
mQClientFactory
.
findBrokerAddressInAdmin
(
mq
.
getBrokerName
());
String
snodeAddr
=
this
.
mQClientFactory
.
findSnodeAddressInPublish
();
if
(
null
==
snodeAddr
){
this
.
mQClientFactory
.
updateSnodeInfoFromNameServer
();
snodeAddr
=
this
.
mQClientFactory
.
findSnodeAddressInPublish
();
}
if
(
findBrokerResult
!=
null
)
{
if
(
snodeAddr
!=
null
)
{
QueryConsumerOffsetRequestHeader
requestHeader
=
new
QueryConsumerOffsetRequestHeader
();
requestHeader
.
setTopic
(
mq
.
getTopic
());
requestHeader
.
setConsumerGroup
(
this
.
groupName
);
requestHeader
.
setQueueId
(
mq
.
getQueueId
());
requestHeader
.
setEnodeName
(
mq
.
getBrokerName
());
return
this
.
mQClientFactory
.
getMQClientAPIImpl
().
queryConsumerOffset
(
findBrokerResult
.
getBrokerAddr
()
,
requestHeader
,
1000
*
5
);
snodeAddr
,
requestHeader
,
1000
*
5
);
}
else
{
throw
new
MQClientException
(
"
The broker["
+
mq
.
getBrokerName
()
+
"]
not exist"
,
null
);
throw
new
MQClientException
(
"
Get Offset from broker["
+
mq
.
getBrokerName
()
+
"] failed, Snode is
not exist"
,
null
);
}
}
}
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
浏览文件 @
ba48f6a2
...
...
@@ -627,10 +627,10 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
default
:
break
;
}
this
.
tryToFindSnodePublishInfo
();
this
.
updateTopicSubscribeInfoWhenSubscriptionChanged
();
this
.
mQClientFactory
.
checkClientInBroker
();
this
.
mQClientFactory
.
sendHeartbeatToAll
Broker
WithLock
();
this
.
mQClientFactory
.
sendHeartbeatToAll
Snode
WithLock
();
this
.
mQClientFactory
.
rebalanceImmediately
();
}
...
...
@@ -1138,4 +1138,7 @@ public class DefaultMQPushConsumerImpl implements MQConsumerInner {
this
.
consumeMessageService
=
consumeMessageService
;
}
private
void
tryToFindSnodePublishInfo
()
{
this
.
mQClientFactory
.
updateSnodeInfoFromNameServer
();
}
}
client/src/main/java/org/apache/rocketmq/client/impl/consumer/RebalancePushImpl.java
浏览文件 @
ba48f6a2
...
...
@@ -84,7 +84,8 @@ public class RebalancePushImpl extends RebalanceImpl {
}
// notify broker
this
.
getmQClientFactory
().
sendHeartbeatToAllBrokerWithLock
();
//this.getmQClientFactory().sendHeartbeatToAllBrokerWithLock();
this
.
getmQClientFactory
().
sendHeartbeatToAllSnodeWithLock
();
}
@Override
...
...
client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
浏览文件 @
ba48f6a2
...
...
@@ -501,7 +501,8 @@ public class MQClientInstance {
}
// may need to check one broker every cluster...
// assume that the configs of every broker in cluster are the the same.
String
addr
=
findBrokerAddrByTopic
(
subscriptionData
.
getTopic
());
//String addr = findBrokerAddrByTopic(subscriptionData.getTopic());
String
addr
=
findSnodeAddressInPublish
();
if
(
addr
!=
null
)
{
try
{
...
...
@@ -1191,17 +1192,17 @@ public class MQClientInstance {
}
public
List
<
String
>
findConsumerIdList
(
final
String
topic
,
final
String
group
)
{
String
brokerAddr
=
this
.
findBrokerAddrByTopic
(
topic
);
if
(
null
==
broker
Addr
)
{
this
.
update
TopicRouteInfoFromNameServer
(
topic
);
brokerAddr
=
this
.
findBrokerAddrByTopic
(
topic
);
String
snodeAddr
=
this
.
findSnodeAddressInPublish
(
);
if
(
null
==
snode
Addr
)
{
this
.
update
SnodeInfoFromNameServer
(
);
snodeAddr
=
this
.
findSnodeAddressInPublish
(
);
}
if
(
null
!=
broker
Addr
)
{
if
(
null
!=
snode
Addr
)
{
try
{
return
this
.
mQClientAPIImpl
.
getConsumerIdListByGroup
(
broker
Addr
,
group
,
3000
);
return
this
.
mQClientAPIImpl
.
getConsumerIdListByGroup
(
snode
Addr
,
group
,
3000
);
}
catch
(
Exception
e
)
{
log
.
warn
(
"getConsumerIdListByGroup exception, "
+
broker
Addr
+
" "
+
group
,
e
);
log
.
warn
(
"getConsumerIdListByGroup exception, "
+
snode
Addr
+
" "
+
group
,
e
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录