You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by do...@apache.org on 2021/12/03 07:34:58 UTC
[rocketmq] 03/03: Add code reading guide to doc
This is an automated email from the ASF dual-hosted git repository.
dongeforever pushed a commit to branch 5.0.0-alpha-static-topic
in repository https://gitbox.apache.org/repos/asf/rocketmq.git
commit 3a621e6b79fe26987b3e30590d05779a0f77493b
Author: dongeforever <do...@apache.org>
AuthorDate: Fri Dec 3 15:33:57 2021 +0800
Add code reading guide to doc
---
..._Topic_Logic_Queue_\350\256\276\350\256\241.md" | 29 +++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git "a/docs/cn/statictopic/RocketMQ_Static_Topic_Logic_Queue_\350\256\276\350\256\241.md" "b/docs/cn/statictopic/RocketMQ_Static_Topic_Logic_Queue_\350\256\276\350\256\241.md"
index d2e8e10..f091a51 100644
--- "a/docs/cn/statictopic/RocketMQ_Static_Topic_Logic_Queue_\350\256\276\350\256\241.md"
+++ "b/docs/cn/statictopic/RocketMQ_Static_Topic_Logic_Queue_\350\256\276\350\256\241.md"
@@ -377,7 +377,12 @@ logicOffset的决策,依赖于上一个 PhysicalQueue 的最大位点。
#### logicOffset 为 -1 时的处理
此时,可以写,但返回给 客户端的 offset 也是-1。
此时,不可以读最新 PhysicalQueue。
-需要确保,相关查找 MappingItem 的操作,忽略 logicOffset 为-1的Item,否则可能触发位点被重置!
+需要非常小心触发位点被重置:
+- 忽略logicOffset为 -1 的item
+- 计算staticOffset时,如果发现logicOffset为-1,则报错
+
+目前只允许,SendMessage和GetMin时,返回-1。其余场景,要严格校验并报错。
+
#### 队列重复映射
如果允许1个 PhysicalQueue 被重复利用,也即多段映射给多个 LogicQueue,或者从非0开始映射。
@@ -426,6 +431,28 @@ Command操作时,提前预判Master是否存在,如果不存在,则提前
二阶消息需要支持远程读写操作。
一期的LogicQueue不支持『二阶消息』。
+### 代码走读要点
+#### Admin 入口
+主要看两个类:
+UpdateStaticTopicSubCommand
+RemappingStaticTopicSubCommand
+#### Metadata 入口
+主要看:
+TopicQueueMappingManager
+#### Client 入口
+重点关注:
+MQClientInstance.updateTopicRouteInfoFromNameServer
+#### Server 入口
+以 SendMessageProcessor 为例,插桩代码普遍是以下风格:
+```
+TopicQueueMappingContext mappingContext = this.brokerController.getTopicQueueMappingManager().buildTopicQueueMappingContext(requestHeader, true);
+RemotingCommand rewriteResult = rewriteRequestForStaticTopic(requestHeader, mappingContext);
+if (rewriteResult != null) {
+ return CompletableFuture.completedFuture(rewriteResult);
+}
+```
+其它Processor类似
+