Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
Rocketmq
提交
1aa6d197
R
Rocketmq
项目概览
Kwan的解忧杂货铺@新空间代码工作室
/
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看板
提交
1aa6d197
编写于
2月 01, 2019
作者:
H
huzongtang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[ISSUE #743]fix codestyle issue and adjust some issues in client module.
上级
81b4293a
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
80 addition
and
17 deletion
+80
-17
client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
.../rocketmq/client/consumer/store/LocalFileOffsetStore.java
+6
-0
client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
...rg/apache/rocketmq/client/consumer/store/OffsetStore.java
+8
-0
client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
...cketmq/client/consumer/store/RemoteBrokerOffsetStore.java
+63
-8
client/src/main/java/org/apache/rocketmq/client/exception/MQSnodeException.java
...rg/apache/rocketmq/client/exception/MQSnodeException.java
+0
-3
client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
...java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
+1
-1
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
...ketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
+2
-2
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
...ketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
+0
-1
client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
...apache/rocketmq/client/impl/factory/MQClientInstance.java
+0
-2
未找到文件。
client/src/main/java/org/apache/rocketmq/client/consumer/store/LocalFileOffsetStore.java
浏览文件 @
1aa6d197
...
...
@@ -160,6 +160,12 @@ public class LocalFileOffsetStore implements OffsetStore {
}
@Override
public
void
updateConsumeOffsetToSnode
(
final
MessageQueue
mq
,
final
long
offset
,
final
boolean
isOneway
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
}
@Override
public
void
updateConsumeOffsetToBroker
(
final
MessageQueue
mq
,
final
long
offset
,
final
boolean
isOneway
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
...
...
client/src/main/java/org/apache/rocketmq/client/consumer/store/OffsetStore.java
浏览文件 @
1aa6d197
...
...
@@ -71,4 +71,12 @@ public interface OffsetStore {
*/
void
updateConsumeOffsetToBroker
(
MessageQueue
mq
,
long
offset
,
boolean
isOneway
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
;
/**
* @param mq
* @param offset
* @param isOneway
*/
void
updateConsumeOffsetToSnode
(
MessageQueue
mq
,
long
offset
,
boolean
isOneway
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
;
}
client/src/main/java/org/apache/rocketmq/client/consumer/store/RemoteBrokerOffsetStore.java
浏览文件 @
1aa6d197
...
...
@@ -88,7 +88,7 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
}
case
READ_FROM_STORE:
{
try
{
long
brokerOffset
=
this
.
fetchConsumeOffsetFrom
Broker
(
mq
);
long
brokerOffset
=
this
.
fetchConsumeOffsetFrom
Snode
(
mq
);
AtomicLong
offset
=
new
AtomicLong
(
brokerOffset
);
this
.
updateOffset
(
mq
,
offset
.
get
(),
false
);
return
brokerOffset
;
...
...
@@ -195,20 +195,20 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
}
private
void
updateConsumeOffsetToSnode
(
MessageQueue
mq
,
long
offset
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
updateConsumeOffsetTo
Broker
(
mq
,
offset
,
true
);
updateConsumeOffsetTo
Snode
(
mq
,
offset
,
true
);
}
/**
* Update the Consumer Offset synchronously, once the Master is off, updated to Slave, here need to be optimized.
*/
@Override
public
void
updateConsumeOffsetTo
Broker
(
MessageQueue
mq
,
long
offset
,
boolean
isOneway
)
throws
RemotingException
,
public
void
updateConsumeOffsetTo
Snode
(
MessageQueue
mq
,
long
offset
,
boolean
isOneway
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
String
snodeAddr
=
this
.
mQClientFactory
.
findSnodeAddressInPublish
();
if
(
null
==
snodeAddr
){
if
(
null
==
snodeAddr
)
{
this
.
mQClientFactory
.
updateSnodeInfoFromNameServer
();
snodeAddr
=
this
.
mQClientFactory
.
findSnodeAddressInPublish
();
snodeAddr
=
this
.
mQClientFactory
.
findSnodeAddressInPublish
();
}
if
(
snodeAddr
!=
null
)
{
...
...
@@ -226,16 +226,71 @@ public class RemoteBrokerOffsetStore implements OffsetStore {
snodeAddr
,
requestHeader
,
1000
*
5
);
}
}
else
{
throw
new
MQClientException
(
"Update offset to Broker["
+
mq
.
getBrokerName
()
+
"] failed, Snode is null."
,
null
);
throw
new
MQClientException
(
"Update offset to Snode["
+
mq
.
getBrokerName
()
+
"] failed, Snode is null."
,
null
);
}
}
/**
* Preserved firstly,Compatible with RocketMQ 4.X Version
*/
@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
());
}
if
(
findBrokerResult
!=
null
)
{
UpdateConsumerOffsetRequestHeader
requestHeader
=
new
UpdateConsumerOffsetRequestHeader
();
requestHeader
.
setTopic
(
mq
.
getTopic
());
requestHeader
.
setConsumerGroup
(
this
.
groupName
);
requestHeader
.
setQueueId
(
mq
.
getQueueId
());
requestHeader
.
setCommitOffset
(
offset
);
requestHeader
.
setEnodeName
(
mq
.
getBrokerName
());
if
(
isOneway
)
{
this
.
mQClientFactory
.
getMQClientAPIImpl
().
updateConsumerOffsetOneway
(
findBrokerResult
.
getBrokerAddr
(),
requestHeader
,
1000
*
5
);
}
else
{
this
.
mQClientFactory
.
getMQClientAPIImpl
().
updateConsumerOffset
(
findBrokerResult
.
getBrokerAddr
(),
requestHeader
,
1000
*
5
);
}
}
else
{
throw
new
MQClientException
(
"The broker["
+
mq
.
getBrokerName
()
+
"] not exist"
,
null
);
}
}
private
long
fetchConsumeOffsetFromSnode
(
MessageQueue
mq
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
String
snodeAddr
=
this
.
mQClientFactory
.
findSnodeAddressInPublish
();
if
(
null
==
snodeAddr
)
{
this
.
mQClientFactory
.
updateSnodeInfoFromNameServer
();
snodeAddr
=
this
.
mQClientFactory
.
findSnodeAddressInPublish
();
}
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
(
snodeAddr
,
requestHeader
,
1000
*
5
);
}
else
{
throw
new
MQClientException
(
"Get Offset from Snode["
+
mq
.
getBrokerName
()
+
"] failed, Snode is not exist"
,
null
);
}
}
/**
* Preserved firstly,Compatible with RocketMQ 4.X Version
*/
private
long
fetchConsumeOffsetFromBroker
(
MessageQueue
mq
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
String
snodeAddr
=
this
.
mQClientFactory
.
findSnodeAddressInPublish
();
if
(
null
==
snodeAddr
){
if
(
null
==
snodeAddr
)
{
this
.
mQClientFactory
.
updateSnodeInfoFromNameServer
();
snodeAddr
=
this
.
mQClientFactory
.
findSnodeAddressInPublish
();
snodeAddr
=
this
.
mQClientFactory
.
findSnodeAddressInPublish
();
}
if
(
snodeAddr
!=
null
)
{
...
...
client/src/main/java/org/apache/rocketmq/client/exception/MQSnodeException.java
浏览文件 @
1aa6d197
...
...
@@ -16,9 +16,6 @@
*/
package
org.apache.rocketmq.client.exception
;
import
org.apache.rocketmq.common.UtilAll
;
import
org.apache.rocketmq.common.help.FAQUrl
;
public
class
MQSnodeException
extends
MQBrokerException
{
public
MQSnodeException
(
int
responseCode
,
String
errorMessage
)
{
...
...
client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
浏览文件 @
1aa6d197
...
...
@@ -1194,7 +1194,7 @@ public class MQClientAPIImpl {
public
SnodeClusterInfo
getSnodeClusterInfo
(
//Todo Redifine snode exception
final
long
timeoutMillis
)
throws
InterruptedException
,
RemotingTimeoutException
,
RemotingSendRequestException
,
RemotingConnectException
,
MQBrokerException
{
RemotingSendRequestException
,
RemotingConnectException
,
MQBrokerException
{
RemotingCommand
request
=
RemotingCommand
.
createRequestCommand
(
RequestCode
.
GET_SNODE_CLUSTER_INFO
,
null
);
RemotingCommand
response
=
this
.
remotingClient
.
invokeSync
(
null
,
request
,
timeoutMillis
);
...
...
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPullConsumerImpl.java
浏览文件 @
1aa6d197
...
...
@@ -480,9 +480,9 @@ public class DefaultMQPullConsumerImpl implements MQConsumerInner {
sendMessageBack
(
msg
,
delayLevel
,
brokerName
,
this
.
defaultMQPullConsumer
.
getConsumerGroup
());
}
public
void
updateConsumeOffsetTo
Broker
(
MessageQueue
mq
,
long
offset
,
boolean
isOneway
)
throws
RemotingException
,
public
void
updateConsumeOffsetTo
Snode
(
MessageQueue
mq
,
long
offset
,
boolean
isOneway
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
this
.
offsetStore
.
updateConsumeOffsetTo
Broker
(
mq
,
offset
,
isOneway
);
this
.
offsetStore
.
updateConsumeOffsetTo
Snode
(
mq
,
offset
,
isOneway
);
}
public
void
sendMessageBack
(
MessageExt
msg
,
int
delayLevel
,
final
String
brokerName
,
String
consumerGroup
)
...
...
client/src/main/java/org/apache/rocketmq/client/impl/consumer/DefaultMQPushConsumerImpl.java
浏览文件 @
1aa6d197
...
...
@@ -73,7 +73,6 @@ import org.apache.rocketmq.common.protocol.route.BrokerData;
import
org.apache.rocketmq.common.protocol.route.TopicRouteData
;
import
org.apache.rocketmq.common.sysflag.PullSysFlag
;
import
org.apache.rocketmq.remoting.RPCHook
;
import
org.apache.rocketmq.remoting.common.RemotingHelper
;
import
org.apache.rocketmq.remoting.exception.RemotingException
;
public
class
DefaultMQPushConsumerImpl
implements
MQConsumerInner
{
...
...
client/src/main/java/org/apache/rocketmq/client/impl/factory/MQClientInstance.java
浏览文件 @
1aa6d197
...
...
@@ -38,7 +38,6 @@ import java.util.concurrent.locks.Lock;
import
java.util.concurrent.locks.ReentrantLock
;
import
org.apache.rocketmq.client.admin.MQAdminExtInner
;
import
org.apache.rocketmq.client.common.ThreadLocalIndex
;
import
org.apache.rocketmq.client.exception.MQBrokerException
;
import
org.apache.rocketmq.client.exception.MQClientException
;
import
org.apache.rocketmq.client.impl.ClientRemotingProcessor
;
import
org.apache.rocketmq.client.impl.FindBrokerResult
;
...
...
@@ -80,7 +79,6 @@ import org.apache.rocketmq.common.protocol.route.TopicRouteData;
import
org.apache.rocketmq.logging.InternalLogger
;
import
org.apache.rocketmq.remoting.ClientConfig
;
import
org.apache.rocketmq.remoting.common.RemotingHelper
;
import
org.apache.rocketmq.remoting.exception.RemotingException
;
import
org.apache.rocketmq.remoting.interceptor.InterceptorGroup
;
import
org.apache.rocketmq.remoting.protocol.RemotingCommand
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录