Skip to content
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

[ISSUE #2163]⚡️Nameserver supports batch broker unregistration #2164

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions rocketmq-namesrv/src/processor/default_request_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,19 @@
"decode UnRegisterBrokerRequestHeader fail".to_string(),
)
})?;
self.name_server_runtime_inner
.route_info_manager_mut()
.un_register_broker(vec![request_header]);
/*self.name_server_runtime_inner
.route_info_manager_mut()
.un_register_broker(vec![request_header]);*/
Comment on lines +334 to +336
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove commented out code.

The commented out code should be removed rather than left in the codebase. Version control history can be used to reference the old implementation if needed.

-        /*self.name_server_runtime_inner
-        .route_info_manager_mut()
-        .un_register_broker(vec![request_header]);*/

if !self
.name_server_runtime_inner
.route_info_manager()
.submit_unregister_broker_request(request_header)

Check warning on line 340 in rocketmq-namesrv/src/processor/default_request_processor.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-namesrv/src/processor/default_request_processor.rs#L337-L340

Added lines #L337 - L340 were not covered by tests
{
warn!("Couldn't submit the unregister broker request to handler");
return Ok(RemotingCommand::create_response_command_with_code(
ResponseCode::SystemError,
));
}

Check warning on line 346 in rocketmq-namesrv/src/processor/default_request_processor.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-namesrv/src/processor/default_request_processor.rs#L342-L346

Added lines #L342 - L346 were not covered by tests
Ok(RemotingCommand::create_response_command())
}
}
Expand Down
10 changes: 10 additions & 0 deletions rocketmq-namesrv/src/route/route_info_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
use tracing::warn;

use crate::bootstrap::NameServerRuntimeInner;
use crate::route::batch_unregistration_service::BatchUnregistrationService;
use crate::route_info::broker_addr_info::BrokerAddrInfo;
use crate::route_info::broker_addr_info::BrokerLiveInfo;
use crate::route_info::broker_addr_info::BrokerStatusChangeInfo;
Expand Down Expand Up @@ -121,12 +122,16 @@
pub(crate) filter_server_table: FilterServerTable,
pub(crate) topic_queue_mapping_info_table: TopicQueueMappingInfoTable,
pub(crate) name_server_runtime_inner: ArcMut<NameServerRuntimeInner>,
pub(crate) un_register_service: ArcMut<BatchUnregistrationService>,
lock: Arc<parking_lot::RwLock<()>>,
}

#[allow(private_interfaces)]
impl RouteInfoManager {
pub fn new(name_server_runtime_inner: ArcMut<NameServerRuntimeInner>) -> Self {
let un_register_service = ArcMut::new(BatchUnregistrationService::new(
name_server_runtime_inner.clone(),
));

Check warning on line 134 in rocketmq-namesrv/src/route/route_info_manager.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-namesrv/src/route/route_info_manager.rs#L132-L134

Added lines #L132 - L134 were not covered by tests
RouteInfoManager {
topic_queue_table: ArcMut::new(HashMap::new()),
broker_addr_table: ArcMut::new(HashMap::new()),
Expand All @@ -136,12 +141,17 @@
topic_queue_mapping_info_table: ArcMut::new(HashMap::new()),
lock: Arc::new(Default::default()),
name_server_runtime_inner,
un_register_service,

Check warning on line 144 in rocketmq-namesrv/src/route/route_info_manager.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-namesrv/src/route/route_info_manager.rs#L144

Added line #L144 was not covered by tests
}
}
}

//impl register broker
impl RouteInfoManager {
pub fn submit_unregister_broker_request(&self, request: UnRegisterBrokerRequestHeader) -> bool {
self.un_register_service.submit(request)
}

Check warning on line 153 in rocketmq-namesrv/src/route/route_info_manager.rs

View check run for this annotation

Codecov / codecov/patch

rocketmq-namesrv/src/route/route_info_manager.rs#L151-L153

Added lines #L151 - L153 were not covered by tests

pub fn register_broker(
&self,
cluster_name: CheetahString,
Expand Down
Loading