Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
小五666\n哈哈
Rocketmq
提交
3e2c9202
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看板
提交
3e2c9202
编写于
11月 06, 2021
作者:
D
dongeforever
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add update_static_topic code
上级
e862ac88
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
149 addition
and
37 deletion
+149
-37
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
...ain/java/org/apache/rocketmq/broker/BrokerController.java
+9
-0
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
...pache/rocketmq/broker/processor/AdminBrokerProcessor.java
+45
-30
broker/src/main/java/org/apache/rocketmq/broker/topic/TopicQueueMappingManager.java
...pache/rocketmq/broker/topic/TopicQueueMappingManager.java
+8
-1
common/src/main/java/org/apache/rocketmq/common/LogicQueueMappingItem.java
...ava/org/apache/rocketmq/common/LogicQueueMappingItem.java
+1
-1
common/src/main/java/org/apache/rocketmq/common/TopicConfigAndQueueMapping.java
...rg/apache/rocketmq/common/TopicConfigAndQueueMapping.java
+35
-0
common/src/main/java/org/apache/rocketmq/common/TopicQueueMappingInfo.java
...ava/org/apache/rocketmq/common/TopicQueueMappingInfo.java
+10
-4
common/src/main/java/org/apache/rocketmq/common/protocol/RequestCode.java
...java/org/apache/rocketmq/common/protocol/RequestCode.java
+4
-0
common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicQueueMappingBody.java
.../rocketmq/common/protocol/body/TopicQueueMappingBody.java
+26
-0
common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicQueueMappingSerializeWrapper.java
...mmon/protocol/body/TopicQueueMappingSerializeWrapper.java
+1
-1
common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicConfigRequestHeader.java
...q/common/protocol/header/GetTopicConfigRequestHeader.java
+10
-0
未找到文件。
broker/src/main/java/org/apache/rocketmq/broker/BrokerController.java
浏览文件 @
3e2c9202
...
...
@@ -80,6 +80,7 @@ import org.apache.rocketmq.broker.processor.SendMessageProcessor;
import
org.apache.rocketmq.broker.slave.SlaveSynchronize
;
import
org.apache.rocketmq.broker.subscription.SubscriptionGroupManager
;
import
org.apache.rocketmq.broker.topic.TopicConfigManager
;
import
org.apache.rocketmq.broker.topic.TopicQueueMappingManager
;
import
org.apache.rocketmq.broker.transaction.AbstractTransactionalMessageCheckListener
;
import
org.apache.rocketmq.broker.transaction.TransactionalMessageCheckService
;
import
org.apache.rocketmq.broker.transaction.TransactionalMessageService
;
...
...
@@ -179,6 +180,7 @@ public class BrokerController {
private
RemotingServer
remotingServer
;
private
RemotingServer
fastRemotingServer
;
private
TopicConfigManager
topicConfigManager
;
private
TopicQueueMappingManager
topicQueueMappingManager
;
private
ExecutorService
sendMessageExecutor
;
private
ExecutorService
pullMessageExecutor
;
private
ExecutorService
ackMessageExecutor
;
...
...
@@ -215,6 +217,7 @@ public class BrokerController {
this
.
messageStoreConfig
=
messageStoreConfig
;
this
.
consumerOffsetManager
=
new
ConsumerOffsetManager
(
this
);
this
.
topicConfigManager
=
new
TopicConfigManager
(
this
);
this
.
topicQueueMappingManager
=
new
TopicQueueMappingManager
(
this
);
this
.
pullMessageProcessor
=
new
PullMessageProcessor
(
this
);
this
.
pullRequestHoldService
=
new
PullRequestHoldService
(
this
);
this
.
popMessageProcessor
=
new
PopMessageProcessor
(
this
);
...
...
@@ -287,6 +290,8 @@ public class BrokerController {
public
boolean
initialize
()
throws
CloneNotSupportedException
{
boolean
result
=
this
.
topicConfigManager
.
load
();
result
=
result
&&
this
.
topicQueueMappingManager
.
load
();
result
=
result
&&
this
.
consumerOffsetManager
.
load
();
result
=
result
&&
this
.
subscriptionGroupManager
.
load
();
result
=
result
&&
this
.
consumerFilterManager
.
load
();
...
...
@@ -1184,6 +1189,10 @@ public class BrokerController {
this
.
topicConfigManager
=
topicConfigManager
;
}
public
TopicQueueMappingManager
getTopicQueueMappingManager
()
{
return
topicQueueMappingManager
;
}
public
String
getHAServerAddr
()
{
return
this
.
brokerConfig
.
getBrokerIP2
()
+
":"
+
this
.
messageStoreConfig
.
getHaListenPort
();
}
...
...
broker/src/main/java/org/apache/rocketmq/broker/processor/AdminBrokerProcessor.java
浏览文件 @
3e2c9202
...
...
@@ -54,13 +54,7 @@ import org.apache.rocketmq.broker.filter.ConsumerFilterData;
import
org.apache.rocketmq.broker.filter.ExpressionMessageFilter
;
import
org.apache.rocketmq.broker.topic.TopicConfigManager
;
import
org.apache.rocketmq.broker.transaction.queue.TransactionalMessageUtil
;
import
org.apache.rocketmq.common.AclConfig
;
import
org.apache.rocketmq.common.MQVersion
;
import
org.apache.rocketmq.common.MixAll
;
import
org.apache.rocketmq.common.PlainAccessConfig
;
import
org.apache.rocketmq.common.TopicConfig
;
import
org.apache.rocketmq.common.TopicQueueId
;
import
org.apache.rocketmq.common.UtilAll
;
import
org.apache.rocketmq.common.*
;
import
org.apache.rocketmq.common.admin.ConsumeStats
;
import
org.apache.rocketmq.common.admin.OffsetWrapper
;
import
org.apache.rocketmq.common.admin.TopicOffset
;
...
...
@@ -74,28 +68,7 @@ import org.apache.rocketmq.common.message.MessageId;
import
org.apache.rocketmq.common.message.MessageQueue
;
import
org.apache.rocketmq.common.protocol.RequestCode
;
import
org.apache.rocketmq.common.protocol.ResponseCode
;
import
org.apache.rocketmq.common.protocol.body.BrokerStatsData
;
import
org.apache.rocketmq.common.protocol.body.BrokerStatsItem
;
import
org.apache.rocketmq.common.protocol.body.Connection
;
import
org.apache.rocketmq.common.protocol.body.ConsumeQueueData
;
import
org.apache.rocketmq.common.protocol.body.ConsumeStatsList
;
import
org.apache.rocketmq.common.protocol.body.ConsumerConnection
;
import
org.apache.rocketmq.common.protocol.body.CreateMessageQueueForLogicalQueueRequestBody
;
import
org.apache.rocketmq.common.protocol.body.GroupList
;
import
org.apache.rocketmq.common.protocol.body.KVTable
;
import
org.apache.rocketmq.common.protocol.body.LockBatchRequestBody
;
import
org.apache.rocketmq.common.protocol.body.LockBatchResponseBody
;
import
org.apache.rocketmq.common.protocol.body.MigrateLogicalQueueBody
;
import
org.apache.rocketmq.common.protocol.body.ProducerConnection
;
import
org.apache.rocketmq.common.protocol.body.QueryConsumeQueueResponseBody
;
import
org.apache.rocketmq.common.protocol.body.QueryConsumeTimeSpanBody
;
import
org.apache.rocketmq.common.protocol.body.QueryCorrectionOffsetBody
;
import
org.apache.rocketmq.common.protocol.body.QueueTimeSpan
;
import
org.apache.rocketmq.common.protocol.body.ReuseTopicLogicalQueueRequestBody
;
import
org.apache.rocketmq.common.protocol.body.SealTopicLogicalQueueRequestBody
;
import
org.apache.rocketmq.common.protocol.body.TopicList
;
import
org.apache.rocketmq.common.protocol.body.UnlockBatchRequestBody
;
import
org.apache.rocketmq.common.protocol.body.UpdateTopicLogicalQueueMappingRequestBody
;
import
org.apache.rocketmq.common.protocol.body.*
;
import
org.apache.rocketmq.common.protocol.header.CloneGroupOffsetRequestHeader
;
import
org.apache.rocketmq.common.protocol.header.ConsumeMessageDirectlyResultRequestHeader
;
import
org.apache.rocketmq.common.protocol.header.CreateAccessConfigRequestHeader
;
...
...
@@ -282,6 +255,8 @@ public class AdminBrokerProcessor extends AsyncNettyRequestProcessor implements
return
migrateTopicLogicalQueueCommit
(
ctx
,
request
);
case
RequestCode
.
MIGRATE_TOPIC_LOGICAL_QUEUE_NOTIFY
:
return
migrateTopicLogicalQueueNotify
(
ctx
,
request
);
case
RequestCode
.
UPDATE_AND_CREATE_STATIC_TOPIC
:
return
this
.
updateAndCreateStaticTopic
(
ctx
,
request
);
default
:
return
getUnknownCmdResponse
(
ctx
,
request
);
}
...
...
@@ -323,6 +298,42 @@ public class AdminBrokerProcessor extends AsyncNettyRequestProcessor implements
return
response
;
}
private
synchronized
RemotingCommand
updateAndCreateStaticTopic
(
ChannelHandlerContext
ctx
,
RemotingCommand
request
)
throws
RemotingCommandException
{
final
RemotingCommand
response
=
RemotingCommand
.
createResponseCommand
(
null
);
final
CreateTopicRequestHeader
requestHeader
=
(
CreateTopicRequestHeader
)
request
.
decodeCommandCustomHeader
(
CreateTopicRequestHeader
.
class
);
log
.
info
(
"updateAndCreateTopic called by {}"
,
RemotingHelper
.
parseChannelRemoteAddr
(
ctx
.
channel
()));
final
TopicQueueMappingBody
topicQueueMappingBody
=
RemotingSerializable
.
decode
(
request
.
getBody
(),
TopicQueueMappingBody
.
class
);
String
topic
=
requestHeader
.
getTopic
();
if
(!
TopicValidator
.
validateTopic
(
topic
,
response
))
{
return
response
;
}
if
(
TopicValidator
.
isSystemTopic
(
topic
,
response
))
{
return
response
;
}
TopicConfig
topicConfig
=
new
TopicConfig
(
topic
);
topicConfig
.
setReadQueueNums
(
requestHeader
.
getReadQueueNums
());
topicConfig
.
setWriteQueueNums
(
requestHeader
.
getWriteQueueNums
());
topicConfig
.
setTopicFilterType
(
requestHeader
.
getTopicFilterTypeEnum
());
topicConfig
.
setPerm
(
requestHeader
.
getPerm
());
topicConfig
.
setTopicSysFlag
(
requestHeader
.
getTopicSysFlag
()
==
null
?
0
:
requestHeader
.
getTopicSysFlag
());
this
.
brokerController
.
getTopicConfigManager
().
updateTopicConfig
(
topicConfig
);
this
.
brokerController
.
getTopicQueueMappingManager
().
updateTopicQueueMapping
(
topicQueueMappingBody
);
this
.
brokerController
.
registerIncrementBrokerData
(
topicConfig
,
this
.
brokerController
.
getTopicConfigManager
().
getDataVersion
());
response
.
setCode
(
ResponseCode
.
SUCCESS
);
return
response
;
}
private
synchronized
RemotingCommand
deleteTopic
(
ChannelHandlerContext
ctx
,
RemotingCommand
request
)
throws
RemotingCommandException
{
final
RemotingCommand
response
=
RemotingCommand
.
createResponseCommand
(
null
);
...
...
@@ -1715,7 +1726,11 @@ public class AdminBrokerProcessor extends AsyncNettyRequestProcessor implements
response
.
setRemark
(
"No topic in this broker. topic: "
+
requestHeader
.
getTopic
());
return
response
;
}
String
content
=
JSONObject
.
toJSONString
(
topicConfig
);
TopicQueueMappingInfo
topicQueueMappingInfo
=
null
;
if
(
Boolean
.
TRUE
.
equals
(
requestHeader
.
getWithMapping
()))
{
topicQueueMappingInfo
=
this
.
brokerController
.
getTopicQueueMappingManager
().
getTopicQueueMapping
(
requestHeader
.
getTopic
());
}
String
content
=
JSONObject
.
toJSONString
(
new
TopicConfigAndQueueMapping
(
topicConfig
,
topicQueueMappingInfo
));
try
{
response
.
setBody
(
content
.
getBytes
(
MixAll
.
DEFAULT_CHARSET
));
}
catch
(
UnsupportedEncodingException
e
)
{
...
...
broker/src/main/java/org/apache/rocketmq/broker/topic/TopicQueueMappingManager.java
浏览文件 @
3e2c9202
...
...
@@ -23,7 +23,7 @@ import org.apache.rocketmq.common.ConfigManager;
import
org.apache.rocketmq.common.DataVersion
;
import
org.apache.rocketmq.common.constant.LoggerName
;
import
org.apache.rocketmq.common.protocol.body.TopicQueueMappingSerializeWrapper
;
import
org.apache.rocketmq.common.
protocol.route.
TopicQueueMappingInfo
;
import
org.apache.rocketmq.common.TopicQueueMappingInfo
;
import
org.apache.rocketmq.logging.InternalLogger
;
import
org.apache.rocketmq.logging.InternalLoggerFactory
;
...
...
@@ -45,7 +45,14 @@ public class TopicQueueMappingManager extends ConfigManager {
public
TopicQueueMappingManager
(
BrokerController
brokerController
)
{
this
.
brokerController
=
brokerController
;
}
public
void
updateTopicQueueMapping
(
TopicQueueMappingInfo
topicQueueMappingInfo
)
{
topicQueueMappingTable
.
put
(
topicQueueMappingInfo
.
getTopic
(),
topicQueueMappingInfo
);
}
public
TopicQueueMappingInfo
getTopicQueueMapping
(
String
topic
)
{
return
topicQueueMappingTable
.
get
(
topic
);
}
@Override
...
...
common/src/main/java/org/apache/rocketmq/common/
protocol/route/
LogicQueueMappingItem.java
→
common/src/main/java/org/apache/rocketmq/common/LogicQueueMappingItem.java
浏览文件 @
3e2c9202
package
org.apache.rocketmq.common
.protocol.route
;
package
org.apache.rocketmq.common
;
public
class
LogicQueueMappingItem
{
...
...
common/src/main/java/org/apache/rocketmq/common/TopicConfigAndQueueMapping.java
0 → 100644
浏览文件 @
3e2c9202
/*
* 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
;
public
class
TopicConfigAndQueueMapping
extends
TopicConfig
{
private
TopicConfig
topicConfig
;
private
TopicQueueMappingInfo
topicQueueMappingInfo
;
public
TopicConfigAndQueueMapping
(
TopicConfig
topicConfig
,
TopicQueueMappingInfo
topicQueueMappingInfo
)
{
this
.
topicConfig
=
topicConfig
;
this
.
topicQueueMappingInfo
=
topicQueueMappingInfo
;
}
public
TopicQueueMappingInfo
getTopicQueueMappingInfo
()
{
return
topicQueueMappingInfo
;
}
public
TopicConfig
getTopicConfig
()
{
return
topicConfig
;
}
}
common/src/main/java/org/apache/rocketmq/common/
protocol/route/
TopicQueueMappingInfo.java
→
common/src/main/java/org/apache/rocketmq/common/TopicQueueMappingInfo.java
浏览文件 @
3e2c9202
...
...
@@ -14,21 +14,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.rocketmq.common.protocol.route
;
package
org.apache.rocketmq.common
;
import
org.apache.rocketmq.remoting.protocol.RemotingSerializable
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
TopicQueueMappingInfo
{
public
class
TopicQueueMappingInfo
extends
RemotingSerializable
{
private
String
topic
;
// redundant field
private
int
totalQueues
;
private
String
bname
;
//identify the host name
//the newest mapping is in current broker
private
Map
<
Integer
/*global id*/
,
List
<
LogicQueueMappingItem
>>
hostedQueues
=
new
HashMap
<
Integer
,
List
<
LogicQueueMappingItem
>>();
public
TopicQueueMappingInfo
(
int
totalQueues
,
String
bname
)
{
public
TopicQueueMappingInfo
(
String
topic
,
int
totalQueues
,
String
bname
)
{
this
.
topic
=
topic
;
this
.
totalQueues
=
totalQueues
;
this
.
bname
=
bname
;
}
...
...
@@ -57,5 +61,7 @@ public class TopicQueueMappingInfo {
return
bname
;
}
public
String
getTopic
()
{
return
topic
;
}
}
common/src/main/java/org/apache/rocketmq/common/protocol/RequestCode.java
浏览文件 @
3e2c9202
...
...
@@ -209,4 +209,8 @@ public class RequestCode {
public
static
final
int
MIGRATE_TOPIC_LOGICAL_QUEUE_PREPARE
=
417
;
public
static
final
int
MIGRATE_TOPIC_LOGICAL_QUEUE_COMMIT
=
418
;
public
static
final
int
MIGRATE_TOPIC_LOGICAL_QUEUE_NOTIFY
=
419
;
public
static
final
int
UPDATE_AND_CREATE_STATIC_TOPIC
=
513
;
}
common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicQueueMappingBody.java
0 → 100644
浏览文件 @
3e2c9202
/*
* 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.TopicQueueMappingInfo
;
public
class
TopicQueueMappingBody
extends
TopicQueueMappingInfo
{
public
TopicQueueMappingBody
(
String
topic
,
int
totalQueues
,
String
bname
)
{
super
(
topic
,
totalQueues
,
bname
);
}
}
common/src/main/java/org/apache/rocketmq/common/protocol/body/TopicQueueMappingSerializeWrapper.java
浏览文件 @
3e2c9202
...
...
@@ -18,7 +18,7 @@
package
org.apache.rocketmq.common.protocol.body
;
import
org.apache.rocketmq.common.DataVersion
;
import
org.apache.rocketmq.common.
protocol.route.
TopicQueueMappingInfo
;
import
org.apache.rocketmq.common.TopicQueueMappingInfo
;
import
org.apache.rocketmq.remoting.protocol.RemotingSerializable
;
import
java.util.Map
;
...
...
common/src/main/java/org/apache/rocketmq/common/protocol/header/GetTopicConfigRequestHeader.java
浏览文件 @
3e2c9202
...
...
@@ -29,6 +29,8 @@ public class GetTopicConfigRequestHeader implements CommandCustomHeader {
@CFNotNull
private
String
topic
;
private
Boolean
withMapping
;
/**
* @return the topic
*/
...
...
@@ -42,4 +44,12 @@ public class GetTopicConfigRequestHeader implements CommandCustomHeader {
public
void
setTopic
(
String
topic
)
{
this
.
topic
=
topic
;
}
public
Boolean
getWithMapping
()
{
return
withMapping
;
}
public
void
setWithMapping
(
Boolean
withMapping
)
{
this
.
withMapping
=
withMapping
;
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录