|
14 | 14 | * See the License for the specific language governing permissions and
|
15 | 15 | * limitations under the License.
|
16 | 16 | */
|
17 |
| -use std::{net::SocketAddr, sync::Arc}; |
| 17 | +use std::{collections::HashMap, net::SocketAddr, sync::Arc}; |
18 | 18 |
|
19 |
| -use rocketmq_common::{common::config_manager::ConfigManager, TokioExecutorService}; |
| 19 | +use rocketmq_common::{ |
| 20 | + common::{config::TopicConfig, config_manager::ConfigManager, constant::PermName}, |
| 21 | + TokioExecutorService, |
| 22 | +}; |
20 | 23 | use rocketmq_remoting::{
|
21 | 24 | code::request_code::RequestCode,
|
| 25 | + protocol::{ |
| 26 | + body::topic_info_wrapper::topic_config_wrapper::TopicConfigAndMappingSerializeWrapper, |
| 27 | + static_topic::topic_queue_mapping_detail::TopicQueueMappingDetail, |
| 28 | + }, |
22 | 29 | remoting::RemotingService,
|
23 | 30 | server::{rocketmq_server::RocketmqDefaultServer, RemotingServer},
|
24 | 31 | };
|
@@ -160,6 +167,7 @@ impl BrokerController {
|
160 | 167 | }
|
161 | 168 | }
|
162 | 169 |
|
| 170 | +#[allow(unused_variables)] |
163 | 171 | impl BrokerController {
|
164 | 172 | pub async fn start(&mut self) {
|
165 | 173 | if self.message_store.as_mut().is_some() {
|
@@ -278,6 +286,104 @@ impl BrokerController {
|
278 | 286 | fn initial_acl(&mut self) {}
|
279 | 287 |
|
280 | 288 | fn initial_rpc_hooks(&mut self) {}
|
| 289 | + |
| 290 | + fn register_broker_all( |
| 291 | + &mut self, |
| 292 | + check_order_config: bool, |
| 293 | + oneway: bool, |
| 294 | + force_register: bool, |
| 295 | + ) { |
| 296 | + let mut topic_config_table = HashMap::new(); |
| 297 | + for topic_config in self.topic_config_manager_inner.topic_config_table.values() { |
| 298 | + let new_topic_config = if !PermName::is_writeable(self.broker_config.broker_permission) |
| 299 | + || !PermName::is_readable(self.broker_config.broker_permission) |
| 300 | + { |
| 301 | + TopicConfig { |
| 302 | + topic_name: topic_config.topic_name.clone(), |
| 303 | + read_queue_nums: topic_config.read_queue_nums, |
| 304 | + write_queue_nums: topic_config.write_queue_nums, |
| 305 | + perm: topic_config.perm & self.broker_config.broker_permission as u32, |
| 306 | + ..TopicConfig::default() |
| 307 | + } |
| 308 | + } else { |
| 309 | + topic_config.clone() |
| 310 | + }; |
| 311 | + topic_config_table.insert(new_topic_config.topic_name.clone(), new_topic_config); |
| 312 | + } |
| 313 | + |
| 314 | + // Handle split registration logic |
| 315 | + if self.broker_config.enable_split_registration |
| 316 | + && topic_config_table.len() as i32 >= self.broker_config.split_registration_size |
| 317 | + { |
| 318 | + let topic_config_wrapper = self |
| 319 | + .topic_config_manager_inner |
| 320 | + .build_serialize_wrapper(topic_config_table.clone()); |
| 321 | + self.do_register_broker_all(check_order_config, oneway, topic_config_wrapper); |
| 322 | + } |
| 323 | + |
| 324 | + // Collect topicQueueMappingInfoMap |
| 325 | + let topic_queue_mapping_info_map = self |
| 326 | + .topic_queue_mapping_manager |
| 327 | + .topic_queue_mapping_table |
| 328 | + .iter() |
| 329 | + .map(|(key, value)| { |
| 330 | + ( |
| 331 | + key.clone(), |
| 332 | + TopicQueueMappingDetail::clone_as_mapping_info(value), |
| 333 | + ) |
| 334 | + }) |
| 335 | + .collect(); |
| 336 | + |
| 337 | + let topic_config_wrapper = self |
| 338 | + .topic_config_manager_inner |
| 339 | + .build_serialize_wrapper_with_topic_queue_map( |
| 340 | + topic_config_table, |
| 341 | + topic_queue_mapping_info_map, |
| 342 | + ); |
| 343 | + |
| 344 | + if self.broker_config.enable_split_registration |
| 345 | + || force_register |
| 346 | + || self.need_register( |
| 347 | + self.broker_config |
| 348 | + .broker_identity |
| 349 | + .broker_cluster_name |
| 350 | + .clone() |
| 351 | + .as_str(), |
| 352 | + self.broker_config.broker_ip1.clone().as_str(), |
| 353 | + self.broker_config |
| 354 | + .broker_identity |
| 355 | + .broker_name |
| 356 | + .clone() |
| 357 | + .as_str(), |
| 358 | + self.broker_config.broker_identity.broker_id, |
| 359 | + self.broker_config.register_broker_timeout_mills, |
| 360 | + self.broker_config.is_in_broker_container, |
| 361 | + ) |
| 362 | + { |
| 363 | + self.do_register_broker_all(check_order_config, oneway, topic_config_wrapper); |
| 364 | + } |
| 365 | + } |
| 366 | + |
| 367 | + fn need_register( |
| 368 | + &mut self, |
| 369 | + cluster_name: &str, |
| 370 | + broker_addr: &str, |
| 371 | + broker_name: &str, |
| 372 | + broker_id: u64, |
| 373 | + register_timeout_mills: i32, |
| 374 | + in_broker_container: bool, |
| 375 | + ) -> bool { |
| 376 | + unimplemented!() |
| 377 | + } |
| 378 | + |
| 379 | + fn do_register_broker_all( |
| 380 | + &mut self, |
| 381 | + check_order_config: bool, |
| 382 | + oneway: bool, |
| 383 | + topic_config_wrapper: TopicConfigAndMappingSerializeWrapper, |
| 384 | + ) { |
| 385 | + unimplemented!() |
| 386 | + } |
281 | 387 | }
|
282 | 388 |
|
283 | 389 | impl Drop for BrokerController {
|
|
0 commit comments