Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小五666\n哈哈
Rocketmq
提交
fa398156
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看板
提交
fa398156
编写于
11月 23, 2021
作者:
D
dongeforever
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Catch the exception
上级
e93536a9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
77 addition
and
28 deletion
+77
-28
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
...pache/rocketmq/broker/processor/AdminBrokerProcessor.java
+2
-1
client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
...java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
+10
-6
common/src/main/java/org/apache/rocketmq/common/rpc/ClientMetadata.java
...n/java/org/apache/rocketmq/common/rpc/ClientMetadata.java
+4
-0
test/src/test/java/org/apache/rocketmq/test/smoke/StaticTopicIT.java
...st/java/org/apache/rocketmq/test/smoke/StaticTopicIT.java
+1
-1
tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
...rg/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
+57
-15
tools/src/main/java/org/apache/rocketmq/tools/admin/MQAdminExt.java
...main/java/org/apache/rocketmq/tools/admin/MQAdminExt.java
+3
-5
未找到文件。
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
浏览文件 @
fa398156
...
...
@@ -1880,7 +1880,8 @@ public class AdminBrokerProcessor extends AsyncNettyRequestProcessor implements
TopicConfig
topicConfig
=
this
.
brokerController
.
getTopicConfigManager
().
getTopicConfigTable
().
get
(
requestHeader
.
getTopic
());
if
(
topicConfig
==
null
)
{
log
.
error
(
"No topic in this broker, client: {} topic: {}"
,
ctx
.
channel
().
remoteAddress
(),
requestHeader
.
getTopic
());
response
.
setCode
(
ResponseCode
.
SYSTEM_ERROR
);
//be care of the response code, should set "not-exist" explictly
response
.
setCode
(
ResponseCode
.
TOPIC_NOT_EXIST
);
response
.
setRemark
(
"No topic in this broker. topic: "
+
requestHeader
.
getTopic
());
return
response
;
}
...
...
client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
浏览文件 @
fa398156
...
...
@@ -332,7 +332,7 @@ public class MQClientAPIImpl {
public
void
createTopic
(
final
String
addr
,
final
String
defaultTopic
,
final
TopicConfig
topicConfig
,
final
long
timeoutMillis
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
throws
RemotingException
,
InterruptedException
,
MQClientException
{
CreateTopicRequestHeader
requestHeader
=
new
CreateTopicRequestHeader
();
requestHeader
.
setTopic
(
topicConfig
.
getTopicName
());
requestHeader
.
setDefaultTopic
(
defaultTopic
);
...
...
@@ -2708,7 +2708,7 @@ public class MQClientAPIImpl {
public
TopicConfigAndQueueMapping
getTopicConfig
(
final
String
brokerAddr
,
String
topic
,
long
timeoutMillis
)
throws
InterruptedException
,
RemotingTimeoutException
,
RemotingSendRequestException
,
RemotingConnectException
,
MQ
Broker
Exception
{
RemotingTimeoutException
,
RemotingSendRequestException
,
RemotingConnectException
,
MQ
Client
Exception
{
GetTopicConfigRequestHeader
header
=
new
GetTopicConfigRequestHeader
();
header
.
setTopic
(
topic
);
header
.
setWithMapping
(
true
);
...
...
@@ -2720,15 +2720,19 @@ public class MQClientAPIImpl {
case
ResponseCode
.
SUCCESS
:
{
return
RemotingSerializable
.
decode
(
response
.
getBody
(),
TopicConfigAndQueueMapping
.
class
);
}
//should check the exist
case
ResponseCode
.
TOPIC_NOT_EXIST
:
{
//should return null?
break
;
}
default
:
break
;
}
throw
new
MQ
Broker
Exception
(
response
.
getCode
(),
response
.
getRemark
());
throw
new
MQ
Client
Exception
(
response
.
getCode
(),
response
.
getRemark
());
}
public
void
createStaticTopic
(
final
String
addr
,
final
String
defaultTopic
,
final
TopicConfig
topicConfig
,
final
TopicQueueMappingDetail
topicQueueMappingDetail
,
boolean
force
,
final
long
timeoutMillis
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
final
long
timeoutMillis
)
throws
RemotingException
,
InterruptedException
,
MQClientException
{
CreateTopicRequestHeader
requestHeader
=
new
CreateTopicRequestHeader
();
requestHeader
.
setTopic
(
topicConfig
.
getTopicName
());
requestHeader
.
setDefaultTopic
(
defaultTopic
);
...
...
@@ -2753,6 +2757,6 @@ public class MQClientAPIImpl {
break
;
}
throw
new
MQ
Broker
Exception
(
response
.
getCode
(),
response
.
getRemark
());
throw
new
MQ
Client
Exception
(
response
.
getCode
(),
response
.
getRemark
());
}
}
common/src/main/java/org/apache/rocketmq/common/rpc/ClientMetadata.java
浏览文件 @
fa398156
...
...
@@ -91,6 +91,10 @@ public class ClientMetadata {
return
brokerAddrTable
.
get
(
brokerName
).
get
(
MixAll
.
MASTER_ID
);
}
public
ConcurrentMap
<
String
,
HashMap
<
Long
,
String
>>
getBrokerAddrTable
()
{
return
brokerAddrTable
;
}
public
static
ConcurrentMap
<
MessageQueue
,
String
>
topicRouteData2EndpointsForStaticTopic
(
final
String
topic
,
final
TopicRouteData
route
)
{
if
(
route
.
getTopicQueueMappingByBroker
()
==
null
||
route
.
getTopicQueueMappingByBroker
().
isEmpty
())
{
...
...
test/src/test/java/org/apache/rocketmq/test/smoke/StaticTopicIT.java
浏览文件 @
fa398156
...
...
@@ -33,13 +33,13 @@ public class StaticTopicIT extends BaseConf {
defaultMQAdminExt
=
getAdmin
(
nsAddr
);
waitBrokerRegistered
(
nsAddr
,
clusterName
);
clientMetadata
=
new
ClientMetadata
();
defaultMQAdminExt
.
start
();
ClusterInfo
clusterInfo
=
defaultMQAdminExt
.
examineBrokerClusterInfo
();
if
(
clusterInfo
==
null
||
clusterInfo
.
getClusterAddrTable
().
isEmpty
())
{
throw
new
RuntimeException
(
"The Cluster info is empty"
);
}
clientMetadata
.
refreshClusterInfo
(
clusterInfo
);
}
@Test
...
...
tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
浏览文件 @
fa398156
...
...
@@ -211,8 +211,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public
void
createAndUpdateTopicConfig
(
String
addr
,
TopicConfig
config
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
public
void
createAndUpdateTopicConfig
(
String
addr
,
TopicConfig
config
)
throws
RemotingException
,
InterruptedException
,
MQClientException
{
this
.
mqClientInstance
.
getMQClientAPIImpl
().
createTopic
(
addr
,
this
.
defaultMQAdminExt
.
getCreateTopicKey
(),
config
,
timeoutMillis
);
}
...
...
@@ -258,7 +257,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public
TopicConfig
examineTopicConfig
(
String
addr
,
String
topic
)
throws
InterruptedException
,
MQ
Broker
Exception
,
RemotingTimeoutException
,
RemotingSendRequestException
,
RemotingConnectException
{
public
TopicConfig
examineTopicConfig
(
String
addr
,
String
topic
)
throws
InterruptedException
,
MQ
Client
Exception
,
RemotingTimeoutException
,
RemotingSendRequestException
,
RemotingConnectException
{
return
this
.
mqClientInstance
.
getMQClientAPIImpl
().
getTopicConfig
(
addr
,
topic
,
timeoutMillis
);
}
...
...
@@ -1171,20 +1170,63 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public
Map
<
String
,
TopicConfigAndQueueMapping
>
examineTopicConfigAll
(
ClientMetadata
clientMetadata
,
String
topic
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
TopicRouteData
routeData
=
examineTopicRouteInfo
(
topic
);
clientMetadata
.
freshTopicRoute
(
topic
,
routeData
);
public
Map
<
String
,
TopicConfigAndQueueMapping
>
examineTopicConfigAll
(
ClientMetadata
clientMetadata
,
String
topic
)
throws
RemotingException
,
InterruptedException
,
MQClientException
{
Map
<
String
,
TopicConfigAndQueueMapping
>
brokerConfigMap
=
new
HashMap
<>();
try
{
TopicRouteData
routeData
=
examineTopicRouteInfo
(
topic
);
clientMetadata
.
freshTopicRoute
(
topic
,
routeData
);
if
(
routeData
!=
null
&&
!
routeData
.
getQueueDatas
().
isEmpty
())
{
for
(
QueueData
queueData:
routeData
.
getQueueDatas
())
{
String
bname
=
queueData
.
getBrokerName
();
String
addr
=
clientMetadata
.
findMasterBrokerAddr
(
bname
);
try
{
TopicConfigAndQueueMapping
mapping
=
(
TopicConfigAndQueueMapping
)
examineTopicConfig
(
addr
,
topic
);
//allow the config is null
if
(
mapping
!=
null
)
{
brokerConfigMap
.
put
(
bname
,
mapping
);
}
}
catch
(
MQClientException
exception
)
{
if
(
exception
.
getResponseCode
()
!=
ResponseCode
.
TOPIC_NOT_EXIST
)
{
throw
exception
;
}
}
}
}
}
catch
(
MQClientException
exception
)
{
if
(
exception
.
getResponseCode
()
!=
ResponseCode
.
TOPIC_NOT_EXIST
)
{
throw
exception
;
}
log
.
info
(
"The topic {} dose not exist in nameserver, so check it from all brokers"
,
topic
);
//if cannot get from nameserver, then check all the brokers
try
{
ClusterInfo
clusterInfo
=
examineBrokerClusterInfo
();
if
(
clusterInfo
!=
null
&&
clusterInfo
.
getBrokerAddrTable
()
!=
null
)
{
clientMetadata
.
refreshClusterInfo
(
clusterInfo
);
}
}
catch
(
MQBrokerException
e
)
{
throw
new
MQClientException
(
e
.
getResponseCode
(),
e
.
getMessage
());
}
for
(
Entry
<
String
,
HashMap
<
Long
,
String
>>
entry
:
clientMetadata
.
getBrokerAddrTable
().
entrySet
())
{
String
bname
=
entry
.
getKey
();
HashMap
<
Long
,
String
>
map
=
entry
.
getValue
();
String
addr
=
map
.
get
(
MixAll
.
MASTER_ID
);
if
(
addr
!=
null
)
{
try
{
TopicConfigAndQueueMapping
mapping
=
(
TopicConfigAndQueueMapping
)
examineTopicConfig
(
addr
,
topic
);
//allow the config is null
if
(
mapping
!=
null
)
{
brokerConfigMap
.
put
(
bname
,
mapping
);
}
}
catch
(
MQClientException
clientException
)
{
if
(
clientException
.
getResponseCode
()
!=
ResponseCode
.
TOPIC_NOT_EXIST
)
{
throw
clientException
;
}
}
if
(
routeData
!=
null
&&
!
routeData
.
getQueueDatas
().
isEmpty
())
{
for
(
QueueData
queueData:
routeData
.
getQueueDatas
())
{
String
bname
=
queueData
.
getBrokerName
();
String
addr
=
clientMetadata
.
findMasterBrokerAddr
(
bname
);
TopicConfigAndQueueMapping
mapping
=
(
TopicConfigAndQueueMapping
)
examineTopicConfig
(
addr
,
topic
);
//allow the config is null
if
(
mapping
!=
null
)
{
brokerConfigMap
.
put
(
bname
,
mapping
);
}
}
}
...
...
tools/src/main/java/org/apache/rocketmq/tools/admin/MQAdminExt.java
浏览文件 @
fa398156
...
...
@@ -109,7 +109,7 @@ public interface MQAdminExt extends MQAdmin {
SubscriptionGroupConfig
examineSubscriptionGroupConfig
(
final
String
addr
,
final
String
group
)
throws
InterruptedException
,
RemotingException
,
MQClientException
,
MQBrokerException
;
TopicConfig
examineTopicConfig
(
final
String
addr
,
final
String
topic
)
throws
InterruptedException
,
MQ
Broker
Exception
,
RemotingTimeoutException
,
RemotingSendRequestException
,
RemotingConnectException
;
final
String
topic
)
throws
InterruptedException
,
MQ
Client
Exception
,
RemotingTimeoutException
,
RemotingSendRequestException
,
RemotingConnectException
;
TopicStatsTable
examineTopicStats
(
final
String
topic
)
throws
RemotingException
,
MQClientException
,
InterruptedException
,
...
...
@@ -344,11 +344,9 @@ public interface MQAdminExt extends MQAdmin {
LogicalQueueRouteData
toQueueRouteData
)
throws
InterruptedException
,
MQBrokerException
,
RemotingTimeoutException
,
RemotingSendRequestException
,
RemotingConnectException
;
void
createStaticTopic
(
final
String
addr
,
final
String
defaultTopic
,
final
TopicConfig
topicConfig
,
final
TopicQueueMappingDetail
mappingDetail
,
final
boolean
force
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
;
void
createStaticTopic
(
final
String
addr
,
final
String
defaultTopic
,
final
TopicConfig
topicConfig
,
final
TopicQueueMappingDetail
mappingDetail
,
final
boolean
force
)
throws
RemotingException
,
InterruptedException
,
MQClientException
;
Map
<
String
,
TopicConfigAndQueueMapping
>
examineTopicConfigAll
(
ClientMetadata
clientMetadata
,
String
topic
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
;
Map
<
String
,
TopicConfigAndQueueMapping
>
examineTopicConfigAll
(
ClientMetadata
clientMetadata
,
String
topic
)
throws
RemotingException
,
InterruptedException
,
MQClientException
;
void
remappingStaticTopic
(
ClientMetadata
clientMetadata
,
String
topic
,
Set
<
String
>
brokersToMapIn
,
Set
<
String
>
brokersToMapOut
,
Map
<
String
,
TopicConfigAndQueueMapping
>
brokerConfigMap
,
int
blockSeqSize
,
boolean
force
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录