-
Notifications
You must be signed in to change notification settings - Fork 144
[ISSUE #1249]🍻Optimize RouteInfoManager logic #1250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,15 +180,14 @@ | |
); | ||
let mut rim_write = self.route_info_manager.write(); | ||
rim_write.update_broker_info_update_timestamp( | ||
request_header.cluster_name.as_str(), | ||
request_header.broker_addr.as_str(), | ||
request_header.cluster_name.clone(), | ||
request_header.broker_addr.clone(), | ||
); | ||
let mut command = RemotingCommand::create_response_command() | ||
.set_command_custom_header(QueryDataVersionResponseHeader::new(changed)); | ||
if let Some(value) = rim_write.query_broker_topic_config( | ||
request_header.cluster_name.as_str(), | ||
request_header.broker_addr.as_str(), | ||
) { | ||
if let Some(value) = rim_write | ||
.query_broker_topic_config(request_header.cluster_name, request_header.broker_addr) | ||
{ | ||
command = command.set_body(value.encode()); | ||
} | ||
drop(rim_write); | ||
|
@@ -311,8 +310,8 @@ | |
self.route_info_manager | ||
.write() | ||
.update_broker_info_update_timestamp( | ||
request_header.cluster_name.as_str(), | ||
request_header.broker_addr.as_str(), | ||
request_header.cluster_name, | ||
request_header.broker_addr, | ||
); | ||
RemotingCommand::create_response_command() | ||
} | ||
|
@@ -322,10 +321,10 @@ | |
.decode_command_custom_header::<GetBrokerMemberGroupRequestHeader>() | ||
.unwrap(); | ||
|
||
let broker_member_group = self.route_info_manager.write().get_broker_member_group( | ||
request_header.cluster_name.as_str(), | ||
request_header.broker_name.as_str(), | ||
); | ||
let broker_member_group = self | ||
.route_info_manager | ||
.write() | ||
.get_broker_member_group(&request_header.cluster_name, &request_header.broker_name); | ||
Comment on lines
+324
to
+327
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Add tests for broker member group functionality The optimization to use references instead of cloned values in
🔗 Analysis chainGood optimization using references, but needs test coverage. Using references instead of cloned values is a good optimization that can improve performance by reducing unnecessary memory allocations. Let's verify the broker member group functionality: 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Search for broker member group tests
rg -A 5 "test.*broker.*member.*group" --type rust
Length of output: 51 Script: #!/bin/bash
# Let's search for any tests related to the RouteInfoManager and broker functionality
rg -l "RouteInfoManager" --type rust
# Also search for any test modules in the namesrv directory
fd "test" -e rs --type f rocketmq-namesrv/
Length of output: 309 Script: #!/bin/bash
# Let's check the route_info_manager.rs file for existing tests
rg "mod test" -A 10 rocketmq-namesrv/src/route/route_info_manager.rs
# Also check for any test functions related to broker operations
ast-grep --pattern 'fn test_$_broker$_() { $$$ }' rocketmq-namesrv/src/route/route_info_manager.rs
Length of output: 171 🧰 Tools🪛 GitHub Check: codecov/patch[warning] 324-327: rocketmq-namesrv/src/processor/default_request_processor.rs#L324-L327 |
||
let response_body = GetBrokerMemberGroupResponseBody { | ||
broker_member_group, | ||
}; | ||
|
@@ -397,7 +396,7 @@ | |
if !topic_route_data.queue_datas.is_empty() { | ||
self.route_info_manager | ||
.write() | ||
.register_topic(request_header.topic.as_str(), topic_route_data.queue_datas) | ||
.register_topic(request_header.topic, topic_route_data.queue_datas) | ||
} | ||
} | ||
RemotingCommand::create_response_command() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Missing test coverage for broker heartbeat functionality
The verification reveals:
scan_not_active_broker
)process_broker_heartbeat
affect core broker registration functionalityAction items:
process_broker_heartbeat
to verify the string handling changes🔗 Analysis chain
Consistent string handling optimization, but needs test coverage.
The string handling changes are consistent with the optimization pattern seen elsewhere in the file. However, these changes are not covered by tests.
Let's verify the broker heartbeat functionality:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 47
Script:
Length of output: 669
Script:
Length of output: 2841
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 313-314: rocketmq-namesrv/src/processor/default_request_processor.rs#L313-L314
Added lines #L313 - L314 were not covered by tests