Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Apache RocketMQ
Rocketmq
提交
6c640286
R
Rocketmq
项目概览
Apache RocketMQ
/
Rocketmq
上一次同步 大约 3 年
通知
268
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看板
提交
6c640286
编写于
11月 24, 2021
作者:
D
dongeforever
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polish the json problem
上级
fa398156
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
105 addition
and
128 deletion
+105
-128
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
...pache/rocketmq/broker/processor/AdminBrokerProcessor.java
+5
-2
client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
...ain/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
+0
-17
client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
...java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
+4
-4
common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicQueueMappingBody.java
.../rocketmq/common/protocol/body/TopicQueueMappingBody.java
+0
-51
common/src/main/java/org/apache/rocketmq/common/statictopic/LogicQueueMappingItem.java
...he/rocketmq/common/statictopic/LogicQueueMappingItem.java
+12
-0
common/src/main/java/org/apache/rocketmq/common/statictopic/TopicQueueMappingDetail.java
.../rocketmq/common/statictopic/TopicQueueMappingDetail.java
+11
-0
common/src/main/java/org/apache/rocketmq/common/statictopic/TopicQueueMappingInfo.java
...he/rocketmq/common/statictopic/TopicQueueMappingInfo.java
+4
-0
common/src/test/java/org/apache/rocketmq/common/statictopic/TopicQueueMappingTest.java
...he/rocketmq/common/statictopic/TopicQueueMappingTest.java
+33
-22
test/src/test/java/org/apache/rocketmq/test/smoke/StaticTopicIT.java
...st/java/org/apache/rocketmq/test/smoke/StaticTopicIT.java
+1
-0
tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java
...va/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java
+3
-3
tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
...rg/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
+27
-25
tools/src/main/java/org/apache/rocketmq/tools/admin/MQAdminExt.java
...main/java/org/apache/rocketmq/tools/admin/MQAdminExt.java
+5
-4
未找到文件。
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
浏览文件 @
6c640286
...
...
@@ -313,7 +313,7 @@ public class AdminBrokerProcessor extends AsyncNettyRequestProcessor implements
(
CreateTopicRequestHeader
)
request
.
decodeCommandCustomHeader
(
CreateTopicRequestHeader
.
class
);
log
.
info
(
"updateAndCreateTopic called by {}"
,
RemotingHelper
.
parseChannelRemoteAddr
(
ctx
.
channel
()));
final
TopicQueueMapping
Body
topicQueueMappingBody
=
RemotingSerializable
.
decode
(
request
.
getBody
(),
TopicQueueMappingBody
.
class
);
final
TopicQueueMapping
Detail
topicQueueMappingDetail
=
RemotingSerializable
.
decode
(
request
.
getBody
(),
TopicQueueMappingDetail
.
class
);
String
topic
=
requestHeader
.
getTopic
();
...
...
@@ -338,7 +338,10 @@ public class AdminBrokerProcessor extends AsyncNettyRequestProcessor implements
try
{
this
.
brokerController
.
getTopicConfigManager
().
updateTopicConfig
(
topicConfig
);
this
.
brokerController
.
getTopicQueueMappingManager
().
updateTopicQueueMapping
(
topicQueueMappingBody
.
getMappingDetail
(),
force
);
System
.
out
.
println
(
"Broker body:"
+
new
String
(
request
.
getBody
()));
System
.
out
.
println
(
"Broker bodetaildy:"
+
topicQueueMappingDetail
.
toJson
());
this
.
brokerController
.
getTopicQueueMappingManager
().
updateTopicQueueMapping
(
topicQueueMappingDetail
,
force
);
this
.
brokerController
.
registerIncrementBrokerData
(
topicConfig
,
this
.
brokerController
.
getTopicConfigManager
().
getDataVersion
());
response
.
setCode
(
ResponseCode
.
SUCCESS
);
...
...
client/src/main/java/org/apache/rocketmq/client/impl/MQAdminImpl.java
浏览文件 @
6c640286
...
...
@@ -80,23 +80,6 @@ public class MQAdminImpl {
this
.
timeoutMillis
=
timeoutMillis
;
}
public
void
createStaticTopic
(
final
String
addr
,
final
String
defaultTopic
,
final
TopicConfig
topicConfig
,
final
TopicQueueMappingDetail
mappingDetail
,
boolean
force
)
throws
MQClientException
{
MQClientException
exception
=
null
;
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
try
{
this
.
mQClientFactory
.
getMQClientAPIImpl
().
createStaticTopic
(
addr
,
defaultTopic
,
topicConfig
,
mappingDetail
,
force
,
timeoutMillis
);
break
;
}
catch
(
Exception
e
)
{
if
(
2
==
i
)
{
exception
=
new
MQClientException
(
"create topic to broker exception"
,
e
);
}
}
}
if
(
exception
!=
null
)
{
throw
exception
;
}
}
public
void
createTopic
(
String
key
,
String
newTopic
,
int
queueNum
)
throws
MQClientException
{
createTopic
(
key
,
newTopic
,
queueNum
,
0
);
...
...
client/src/main/java/org/apache/rocketmq/client/impl/MQClientAPIImpl.java
浏览文件 @
6c640286
...
...
@@ -2708,7 +2708,7 @@ public class MQClientAPIImpl {
public
TopicConfigAndQueueMapping
getTopicConfig
(
final
String
brokerAddr
,
String
topic
,
long
timeoutMillis
)
throws
InterruptedException
,
RemotingTimeoutException
,
RemotingSendRequestException
,
RemotingConnectException
,
MQ
Client
Exception
{
RemotingTimeoutException
,
RemotingSendRequestException
,
RemotingConnectException
,
MQ
Broker
Exception
{
GetTopicConfigRequestHeader
header
=
new
GetTopicConfigRequestHeader
();
header
.
setTopic
(
topic
);
header
.
setWithMapping
(
true
);
...
...
@@ -2728,11 +2728,11 @@ public class MQClientAPIImpl {
default
:
break
;
}
throw
new
MQ
Client
Exception
(
response
.
getCode
(),
response
.
getRemark
());
throw
new
MQ
Broker
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
,
InterruptedException
,
MQ
Client
Exception
{
final
long
timeoutMillis
)
throws
RemotingException
,
InterruptedException
,
MQ
Broker
Exception
{
CreateTopicRequestHeader
requestHeader
=
new
CreateTopicRequestHeader
();
requestHeader
.
setTopic
(
topicConfig
.
getTopicName
());
requestHeader
.
setDefaultTopic
(
defaultTopic
);
...
...
@@ -2757,6 +2757,6 @@ public class MQClientAPIImpl {
break
;
}
throw
new
MQ
Client
Exception
(
response
.
getCode
(),
response
.
getRemark
());
throw
new
MQ
Broker
Exception
(
response
.
getCode
(),
response
.
getRemark
());
}
}
common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicQueueMappingBody.java
已删除
100644 → 0
浏览文件 @
fa398156
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.common.protocol.body
;
import
org.apache.rocketmq.common.statictopic.TopicQueueMappingDetail
;
import
org.apache.rocketmq.remoting.protocol.RemotingSerializable
;
public
class
TopicQueueMappingBody
extends
RemotingSerializable
{
private
boolean
force
;
private
int
prevGen
;
private
TopicQueueMappingDetail
mappingDetail
;
public
int
getPrevGen
()
{
return
prevGen
;
}
public
void
setPrevGen
(
int
prevGen
)
{
this
.
prevGen
=
prevGen
;
}
public
TopicQueueMappingDetail
getMappingDetail
()
{
return
mappingDetail
;
}
public
void
setMappingDetail
(
TopicQueueMappingDetail
mappingDetail
)
{
this
.
mappingDetail
=
mappingDetail
;
}
public
boolean
isForce
()
{
return
force
;
}
public
void
setForce
(
boolean
force
)
{
this
.
force
=
force
;
}
}
common/src/main/java/org/apache/rocketmq/common/statictopic/LogicQueueMappingItem.java
浏览文件 @
6c640286
...
...
@@ -100,6 +100,18 @@ public class LogicQueueMappingItem {
this
.
logicOffset
=
logicOffset
;
}
public
void
setEndOffset
(
long
endOffset
)
{
this
.
endOffset
=
endOffset
;
}
public
void
setTimeOfStart
(
long
timeOfStart
)
{
this
.
timeOfStart
=
timeOfStart
;
}
public
void
setTimeOfEnd
(
long
timeOfEnd
)
{
this
.
timeOfEnd
=
timeOfEnd
;
}
@Override
public
String
toString
()
{
return
"LogicQueueMappingItem{"
+
...
...
common/src/main/java/org/apache/rocketmq/common/statictopic/TopicQueueMappingDetail.java
浏览文件 @
6c640286
...
...
@@ -29,6 +29,13 @@ public class TopicQueueMappingDetail extends TopicQueueMappingInfo {
// make sure this value is not null
private
ConcurrentMap
<
Integer
/*global id*/
,
ImmutableList
<
LogicQueueMappingItem
>>
hostedQueues
=
new
ConcurrentHashMap
<
Integer
,
ImmutableList
<
LogicQueueMappingItem
>>();
public
TopicQueueMappingDetail
()
{
}
public
TopicQueueMappingDetail
(
String
topic
,
int
totalQueues
,
String
bname
,
long
epoch
)
{
super
(
topic
,
totalQueues
,
bname
,
epoch
);
buildIdMap
();
...
...
@@ -120,6 +127,10 @@ public class TopicQueueMappingDetail extends TopicQueueMappingInfo {
return
hostedQueues
;
}
public
void
setHostedQueues
(
ConcurrentMap
<
Integer
,
ImmutableList
<
LogicQueueMappingItem
>>
hostedQueues
)
{
this
.
hostedQueues
=
hostedQueues
;
}
public
boolean
checkIfAsPhysical
(
Integer
globalId
)
{
List
<
LogicQueueMappingItem
>
mappingItems
=
getMappingInfo
(
globalId
);
return
mappingItems
==
null
...
...
common/src/main/java/org/apache/rocketmq/common/statictopic/TopicQueueMappingInfo.java
浏览文件 @
6c640286
...
...
@@ -32,6 +32,10 @@ public class TopicQueueMappingInfo extends RemotingSerializable {
//register to broker to construct the route
transient
ConcurrentMap
<
Integer
/*logicId*/
,
Integer
/*physicalId*/
>
currIdMap
=
new
ConcurrentHashMap
<
Integer
,
Integer
>();
public
TopicQueueMappingInfo
()
{
}
public
TopicQueueMappingInfo
(
String
topic
,
int
totalQueues
,
String
bname
,
long
epoch
)
{
this
.
topic
=
topic
;
this
.
totalQueues
=
totalQueues
;
...
...
common/src/test/java/org/apache/rocketmq/common/statictopic/TopicQueueMappingTest.java
浏览文件 @
6c640286
...
...
@@ -4,8 +4,7 @@ import com.alibaba.fastjson.JSON;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.ImmutableList
;
import
org.apache.rocketmq.common.statictopic.LogicQueueMappingItem
;
import
org.apache.rocketmq.common.statictopic.TopicQueueMappingDetail
;
import
org.apache.rocketmq.remoting.protocol.RemotingSerializable
;
import
org.junit.Assert
;
import
org.junit.Test
;
...
...
@@ -20,33 +19,45 @@ public class TopicQueueMappingTest {
System
.
out
.
println
(
File
.
separator
);
}
@Test
public
void
testJsonSerialize
()
{
LogicQueueMappingItem
mappingItem
=
new
LogicQueueMappingItem
(
1
,
2
,
"broker01"
,
33333333333333333L
,
44444444444444444L
,
555555555555555555L
,
6666666666666666L
,
77777777777777777L
);
String
mappingItemJson
=
JSON
.
toJSONString
(
mappingItem
)
;
System
.
out
.
println
(
mappingItemJson
);
Map
<
String
,
Object
>
mappingItemMap
=
JSON
.
parseObject
(
mappingItemJson
,
Map
.
class
);
Assert
.
assertEquals
(
8
,
mappingItemMap
.
size
());
Assert
.
assertEquals
(
mappingItemMap
.
get
(
"bname"
),
mappingItem
.
getBname
());
Assert
.
assertEquals
(
mappingItemMap
.
get
(
"gen"
),
mappingItem
.
getGen
());
Assert
.
assertEquals
(
mappingItemMap
.
get
(
"logicOffset"
),
mappingItem
.
getLogicOffset
());
Assert
.
assertEquals
(
mappingItemMap
.
get
(
"queueId"
),
mappingItem
.
getQueueId
());
Assert
.
assertEquals
(
mappingItemMap
.
get
(
"startOffset"
),
mappingItem
.
getStartOffset
());
Assert
.
assertEquals
(
mappingItemMap
.
get
(
"endOffset"
),
mappingItem
.
getEndOffset
());
Assert
.
assertEquals
(
mappingItemMap
.
get
(
"timeOfStart"
),
mappingItem
.
getTimeOfStart
());
Assert
.
assertEquals
(
mappingItemMap
.
get
(
"timeOfEnd"
),
mappingItem
.
getTimeOfEnd
());
{
Map
<
String
,
Object
>
mappingItemMap
=
JSON
.
parseObject
(
mappingItemJson
,
Map
.
class
);
Assert
.
assertEquals
(
8
,
mappingItemMap
.
size
());
Assert
.
assertEquals
(
mappingItemMap
.
get
(
"bname"
),
mappingItem
.
getBname
());
Assert
.
assertEquals
(
mappingItemMap
.
get
(
"gen"
),
mappingItem
.
getGen
());
Assert
.
assertEquals
(
mappingItemMap
.
get
(
"logicOffset"
),
mappingItem
.
getLogicOffset
());
Assert
.
assertEquals
(
mappingItemMap
.
get
(
"queueId"
),
mappingItem
.
getQueueId
());
Assert
.
assertEquals
(
mappingItemMap
.
get
(
"startOffset"
),
mappingItem
.
getStartOffset
());
Assert
.
assertEquals
(
mappingItemMap
.
get
(
"endOffset"
),
mappingItem
.
getEndOffset
());
Assert
.
assertEquals
(
mappingItemMap
.
get
(
"timeOfStart"
),
mappingItem
.
getTimeOfStart
());
Assert
.
assertEquals
(
mappingItemMap
.
get
(
"timeOfEnd"
),
mappingItem
.
getTimeOfEnd
());
}
{
String
mappingItemJson2
=
RemotingSerializable
.
toJson
(
RemotingSerializable
.
decode
(
mappingItemJson
.
getBytes
(),
LogicQueueMappingItem
.
class
),
false
);
Assert
.
assertEquals
(
mappingItemJson
,
mappingItemJson2
);
}
TopicQueueMappingDetail
mappingDetail
=
new
TopicQueueMappingDetail
(
"test"
,
1
,
"broker01"
,
System
.
currentTimeMillis
());
mappingDetail
.
putMappingInfo
(
0
,
ImmutableList
.
of
(
mappingItem
));
String
mappingDetailJson
=
JSON
.
toJSONString
(
mappingDetail
);
Map
mappingDetailMap
=
JSON
.
parseObject
(
mappingDetailJson
);
Assert
.
assertFalse
(
mappingDetailMap
.
containsKey
(
"prevIdMap"
));
Assert
.
assertFalse
(
mappingDetailMap
.
containsKey
(
"currIdMap"
));
Assert
.
assertEquals
(
4
,
mappingDetailMap
.
size
());
Assert
.
assertEquals
(
1
,
((
JSONObject
)
mappingDetailMap
.
get
(
"hostedQueues"
)).
size
());
Assert
.
assertEquals
(
1
,
((
JSONArray
)((
JSONObject
)
mappingDetailMap
.
get
(
"hostedQueues"
)).
get
(
"0"
)).
size
());
{
Map
mappingDetailMap
=
JSON
.
parseObject
(
mappingDetailJson
);
Assert
.
assertFalse
(
mappingDetailMap
.
containsKey
(
"prevIdMap"
));
Assert
.
assertFalse
(
mappingDetailMap
.
containsKey
(
"currIdMap"
));
Assert
.
assertEquals
(
6
,
mappingDetailMap
.
size
());
Assert
.
assertEquals
(
1
,
((
JSONObject
)
mappingDetailMap
.
get
(
"hostedQueues"
)).
size
());
Assert
.
assertEquals
(
1
,
((
JSONArray
)((
JSONObject
)
mappingDetailMap
.
get
(
"hostedQueues"
)).
get
(
"0"
)).
size
());
}
{
System
.
out
.
println
(
mappingDetailJson
);
TopicQueueMappingDetail
detailFromJson
=
RemotingSerializable
.
decode
(
mappingDetailJson
.
getBytes
(),
TopicQueueMappingDetail
.
class
);
System
.
out
.
println
(
JSON
.
toJSONString
(
detailFromJson
));
//Assert.assertEquals(1, detailFromJson.getHostedQueues().size());
//Assert.assertEquals(1, detailFromJson.getHostedQueues().get("0").size());
}
}
}
test/src/test/java/org/apache/rocketmq/test/smoke/StaticTopicIT.java
浏览文件 @
6c640286
...
...
@@ -57,6 +57,7 @@ public class StaticTopicIT extends BaseConf {
String
broker
=
entry
.
getKey
();
String
addr
=
clientMetadata
.
findMasterBrokerAddr
(
broker
);
TopicConfigAndQueueMapping
configMapping
=
entry
.
getValue
();
System
.
out
.
println
(
configMapping
.
getMappingDetail
().
toJson
());
defaultMQAdminExt
.
createStaticTopic
(
addr
,
defaultMQAdminExt
.
getCreateTopicKey
(),
configMapping
,
configMapping
.
getMappingDetail
(),
false
);
}
}
...
...
tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExt.java
浏览文件 @
6c640286
...
...
@@ -218,12 +218,12 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
@Override
public
TopicConfig
examineTopicConfig
(
String
addr
,
String
topic
)
throws
RemotingSendRequestException
,
RemotingConnectException
,
RemotingTimeoutException
,
MQBrokerException
,
Interrupted
Exception
{
String
topic
)
throws
RemotingSendRequestException
,
RemotingConnectException
,
RemotingTimeoutException
,
InterruptedException
,
MQBroker
Exception
{
return
defaultMQAdminExtImpl
.
examineTopicConfig
(
addr
,
topic
);
}
@Override
public
Map
<
String
,
TopicConfigAndQueueMapping
>
examineTopicConfigAll
(
ClientMetadata
clientMetadata
,
String
topic
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClient
Exception
{
public
Map
<
String
,
TopicConfigAndQueueMapping
>
examineTopicConfigAll
(
ClientMetadata
clientMetadata
,
String
topic
)
throws
RemotingException
,
InterruptedException
,
MQBroker
Exception
{
return
this
.
defaultMQAdminExtImpl
.
examineTopicConfigAll
(
clientMetadata
,
topic
);
}
...
...
@@ -668,7 +668,7 @@ public class DefaultMQAdminExt extends ClientConfig implements MQAdminExt {
}
@Override
public
void
createStaticTopic
(
String
addr
,
String
defaultTopic
,
TopicConfig
topicConfig
,
TopicQueueMappingDetail
mappingDetail
,
boolean
force
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClient
Exception
{
public
void
createStaticTopic
(
String
addr
,
String
defaultTopic
,
TopicConfig
topicConfig
,
TopicQueueMappingDetail
mappingDetail
,
boolean
force
)
throws
RemotingException
,
InterruptedException
,
MQBroker
Exception
{
this
.
defaultMQAdminExtImpl
.
createStaticTopic
(
addr
,
defaultTopic
,
topicConfig
,
mappingDetail
,
force
);
}
...
...
tools/src/main/java/org/apache/rocketmq/tools/admin/DefaultMQAdminExtImpl.java
浏览文件 @
6c640286
...
...
@@ -211,7 +211,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public
void
createAndUpdateTopicConfig
(
String
addr
,
TopicConfig
config
)
throws
RemotingException
,
InterruptedException
,
MQClientException
{
public
void
createAndUpdateTopicConfig
(
String
addr
,
TopicConfig
config
)
throws
RemotingException
,
MQBrokerException
,
InterruptedException
,
MQClientException
{
this
.
mqClientInstance
.
getMQClientAPIImpl
().
createTopic
(
addr
,
this
.
defaultMQAdminExt
.
getCreateTopicKey
(),
config
,
timeoutMillis
);
}
...
...
@@ -257,7 +258,7 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public
TopicConfig
examineTopicConfig
(
String
addr
,
String
topic
)
throws
InterruptedException
,
MQ
Client
Exception
,
RemotingTimeoutException
,
RemotingSendRequestException
,
RemotingConnectException
{
public
TopicConfig
examineTopicConfig
(
String
addr
,
String
topic
)
throws
InterruptedException
,
MQ
Broker
Exception
,
RemotingTimeoutException
,
RemotingSendRequestException
,
RemotingConnectException
{
return
this
.
mqClientInstance
.
getMQClientAPIImpl
().
getTopicConfig
(
addr
,
topic
,
timeoutMillis
);
}
...
...
@@ -1105,8 +1106,8 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public
void
createStaticTopic
(
final
String
addr
,
final
String
defaultTopic
,
final
TopicConfig
topicConfig
,
final
TopicQueueMappingDetail
mappingDetail
,
final
boolean
force
)
throws
MQClient
Exception
{
this
.
mqClientInstance
.
getMQ
AdminImpl
().
createStaticTopic
(
addr
,
defaultTopic
,
topicConfig
,
mappingDetail
,
force
);
public
void
createStaticTopic
(
final
String
addr
,
final
String
defaultTopic
,
final
TopicConfig
topicConfig
,
final
TopicQueueMappingDetail
mappingDetail
,
final
boolean
force
)
throws
RemotingException
,
InterruptedException
,
MQBroker
Exception
{
this
.
mqClientInstance
.
getMQ
ClientAPIImpl
().
createStaticTopic
(
addr
,
defaultTopic
,
topicConfig
,
mappingDetail
,
force
,
timeoutMillis
);
}
...
...
@@ -1170,13 +1171,23 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
}
@Override
public
Map
<
String
,
TopicConfigAndQueueMapping
>
examineTopicConfigAll
(
ClientMetadata
clientMetadata
,
String
topic
)
throws
RemotingException
,
InterruptedException
,
MQClient
Exception
{
public
Map
<
String
,
TopicConfigAndQueueMapping
>
examineTopicConfigAll
(
ClientMetadata
clientMetadata
,
String
topic
)
throws
RemotingException
,
InterruptedException
,
MQBroker
Exception
{
Map
<
String
,
TopicConfigAndQueueMapping
>
brokerConfigMap
=
new
HashMap
<>();
boolean
getFromBrokers
=
false
;
TopicRouteData
routeData
=
null
;
try
{
TopicRouteData
routeData
=
examineTopicRouteInfo
(
topic
);
clientMetadata
.
freshTopicRoute
(
topic
,
routeData
);
routeData
=
examineTopicRouteInfo
(
topic
);
}
catch
(
MQClientException
exception
)
{
if
(
exception
.
getResponseCode
()
!=
ResponseCode
.
TOPIC_NOT_EXIST
)
{
throw
new
MQBrokerException
(
exception
.
getResponseCode
(),
exception
.
getErrorMessage
());
}
else
{
getFromBrokers
=
true
;
}
}
if
(!
getFromBrokers
)
{
if
(
routeData
!=
null
&&
!
routeData
.
getQueueDatas
().
isEmpty
())
{
clientMetadata
.
freshTopicRoute
(
topic
,
routeData
);
for
(
QueueData
queueData:
routeData
.
getQueueDatas
())
{
String
bname
=
queueData
.
getBrokerName
();
String
addr
=
clientMetadata
.
findMasterBrokerAddr
(
bname
);
...
...
@@ -1186,29 +1197,21 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
if
(
mapping
!=
null
)
{
brokerConfigMap
.
put
(
bname
,
mapping
);
}
}
catch
(
MQ
Client
Exception
exception
)
{
}
catch
(
MQ
Broker
Exception
exception
)
{
if
(
exception
.
getResponseCode
()
!=
ResponseCode
.
TOPIC_NOT_EXIST
)
{
throw
exception
;
}
}
}
}
}
catch
(
MQClientException
exception
)
{
if
(
exception
.
getResponseCode
()
!=
ResponseCode
.
TOPIC_NOT_EXIST
)
{
throw
exception
;
}
}
else
{
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
());
ClusterInfo
clusterInfo
=
examineBrokerClusterInfo
();
if
(
clusterInfo
!=
null
&&
clusterInfo
.
getBrokerAddrTable
()
!=
null
)
{
clientMetadata
.
refreshClusterInfo
(
clusterInfo
);
}
for
(
Entry
<
String
,
HashMap
<
Long
,
String
>>
entry
:
clientMetadata
.
getBrokerAddrTable
().
entrySet
())
{
String
bname
=
entry
.
getKey
();
...
...
@@ -1221,12 +1224,11 @@ public class DefaultMQAdminExtImpl implements MQAdminExt, MQAdminExtInner {
if
(
mapping
!=
null
)
{
brokerConfigMap
.
put
(
bname
,
mapping
);
}
}
catch
(
MQ
ClientException
clientException
)
{
if
(
clientException
.
getResponseCode
()
!=
ResponseCode
.
TOPIC_NOT_EXIST
)
{
throw
clientException
;
}
catch
(
MQ
BrokerException
exception1
)
{
if
(
exception1
.
getResponseCode
()
!=
ResponseCode
.
TOPIC_NOT_EXIST
)
{
throw
exception1
;
}
}
}
}
}
...
...
tools/src/main/java/org/apache/rocketmq/tools/admin/MQAdminExt.java
浏览文件 @
6c640286
...
...
@@ -108,8 +108,6 @@ 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
,
MQClientException
,
RemotingTimeoutException
,
RemotingSendRequestException
,
RemotingConnectException
;
TopicStatsTable
examineTopicStats
(
final
String
topic
)
throws
RemotingException
,
MQClientException
,
InterruptedException
,
...
...
@@ -344,9 +342,12 @@ 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
,
InterruptedException
,
MQClientException
;
TopicConfig
examineTopicConfig
(
final
String
addr
,
final
String
topic
)
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
,
InterruptedException
,
MQBrokerException
;
Map
<
String
,
TopicConfigAndQueueMapping
>
examineTopicConfigAll
(
ClientMetadata
clientMetadata
,
String
topic
)
throws
RemotingException
,
InterruptedException
,
MQ
Client
Exception
;
Map
<
String
,
TopicConfigAndQueueMapping
>
examineTopicConfigAll
(
ClientMetadata
clientMetadata
,
String
topic
)
throws
RemotingException
,
InterruptedException
,
MQ
Broker
Exception
;
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录