Skip to content

Commit

Permalink
[ISSUE #88]📝Namesrv support get has unit sub topic list (request code…
Browse files Browse the repository at this point in the history
… 312)
  • Loading branch information
mxsm committed Jan 23, 2024
1 parent 5f85bd0 commit 651ce9a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ Feature list:
| Register topic in name server | 217 | :sparkling_heart: :white_check_mark: | |
| Get topics by cluster | 224 | :sparkling_heart: :white_check_mark: | |
| Get system topic list from name server | 304 | :sparkling_heart: :white_check_mark: | |
| Get unit topic list | 311 | :broken_heart: :x: | |
| Get has unit sub topic list | 312 | :broken_heart: :x: | |
| Get unit topic list | 311 | :sparkling_heart: :white_check_mark: | |
| Get has unit sub topic list | 312 | :sparkling_heart: :white_check_mark: | |
| Get has unit sub ununit topic list | 313 | :broken_heart: :x: | |
| Update name server config | 318 | :broken_heart: :x: | |
| Get name server config | 318 | :broken_heart: :x: | |
Expand Down
4 changes: 2 additions & 2 deletions rocketmq-namesrv/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ Feature list:
| Register topic in name server | 217 | :sparkling_heart: :white_check_mark: | |
| Get topics by cluster | 224 | :sparkling_heart: :white_check_mark: | |
| Get system topic list from name server | 304 | :sparkling_heart: :white_check_mark: | |
| Get unit topic list | 311 | :broken_heart: :x: | |
| Get has unit sub topic list | 312 | :broken_heart: :x: | |
| Get unit topic list | 311 | :sparkling_heart: :white_check_mark: | |
| Get has unit sub topic list | 312 | :sparkling_heart: :white_check_mark: | |
| Get has unit sub ununit topic list | 313 | :broken_heart: :x: | |
| Update name server config | 318 | :broken_heart: :x: | |
| Get name server config | 318 | :broken_heart: :x: | |
Expand Down
15 changes: 15 additions & 0 deletions rocketmq-namesrv/src/processor/default_request_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ impl RequestProcessor for DefaultRequestProcessor {
self.get_system_topic_list_from_ns(request)
}
Some(RequestCode::GetUnitTopicList) => self.get_unit_topic_list(request),
Some(RequestCode::GetHasUnitSubTopicList) => self.get_has_unit_sub_topic_list(request),
_ => RemotingCommand::create_response_command_with_code(
RemotingSysResponseCode::SystemError,
),
Expand Down Expand Up @@ -465,6 +466,20 @@ impl DefaultRequestProcessor {
RemotingCommand::create_response_command_with_code(RemotingSysResponseCode::SystemError)
.set_remark(Some(String::from("disable")))
}

fn get_has_unit_sub_topic_list(&mut self, _request: RemotingCommand) -> RemotingCommand {
if self
.route_info_manager
.read()
.namesrv_config
.enable_topic_list
{
let topic_list = self.route_info_manager.read().get_has_unit_sub_topic_list();
return RemotingCommand::create_response_command().set_body(Some(topic_list.encode()));
}
RemotingCommand::create_response_command_with_code(RemotingSysResponseCode::SystemError)
.set_remark(Some(String::from("disable")))
}
}

fn extract_register_topic_config_from_request(
Expand Down
15 changes: 15 additions & 0 deletions rocketmq-namesrv/src/route/route_info_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,4 +813,19 @@ impl RouteInfoManager {
broker_addr: None,
}
}

pub(crate) fn get_has_unit_sub_topic_list(&self) -> TopicList {
let mut topic_list = Vec::new();
for (topic, entry) in self.topic_queue_table.iter() {
if !entry.is_empty()
&& TopicSysFlag::has_unit_sub_flag(entry.values().next().unwrap().topic_sys_flag())
{
topic_list.push(topic.clone());
}
}
TopicList {
topic_list,
broker_addr: None,
}
}
}

0 comments on commit 651ce9a

Please sign in to comment.