1use std::collections::HashMap;
18use std::collections::HashSet;
19
20use cheetah_string::CheetahString;
21use rocketmq_common::common::base::plain_access_config::PlainAccessConfig;
22use rocketmq_common::common::config::TopicConfig;
23use rocketmq_common::common::message::message_enum::MessageRequestMode;
24use rocketmq_common::common::message::message_queue::MessageQueue;
25use rocketmq_remoting::protocol::admin::consume_stats::ConsumeStats;
26use rocketmq_remoting::protocol::admin::topic_stats_table::TopicStatsTable;
27use rocketmq_remoting::protocol::body::broker_body::cluster_info::ClusterInfo;
28use rocketmq_remoting::protocol::body::consume_message_directly_result::ConsumeMessageDirectlyResult;
29use rocketmq_remoting::protocol::body::consumer_connection::ConsumerConnection;
30use rocketmq_remoting::protocol::body::consumer_running_info::ConsumerRunningInfo;
31use rocketmq_remoting::protocol::body::group_list::GroupList;
32use rocketmq_remoting::protocol::body::kv_table::KVTable;
33use rocketmq_remoting::protocol::body::producer_connection::ProducerConnection;
34use rocketmq_remoting::protocol::body::topic::topic_list::TopicList;
35use rocketmq_remoting::protocol::body::topic_info_wrapper::TopicConfigSerializeWrapper;
36use rocketmq_remoting::protocol::heartbeat::subscription_data::SubscriptionData;
37use rocketmq_remoting::protocol::route::topic_route_data::TopicRouteData;
38use rocketmq_remoting::protocol::static_topic::topic_queue_mapping_detail::TopicQueueMappingDetail;
39use rocketmq_remoting::protocol::subscription::subscription_group_config::SubscriptionGroupConfig;
40
41use crate::common::admin_tool_result::AdminToolResult;
42
43#[allow(dead_code)]
44#[allow(async_fn_in_trait)]
45pub trait MQAdminExt: Send {
46 async fn start(&mut self) -> rocketmq_error::RocketMQResult<()>;
47 async fn shutdown(&mut self);
48 async fn add_broker_to_container(
49 &self,
50 broker_container_addr: CheetahString,
51 broker_config: CheetahString,
52 ) -> rocketmq_error::RocketMQResult<()>;
53
54 async fn remove_broker_from_container(
55 &self,
56 broker_container_addr: CheetahString,
57 cluster_name: CheetahString,
58 broker_name: CheetahString,
59 broker_id: u64,
60 ) -> rocketmq_error::RocketMQResult<()>;
61
62 async fn update_broker_config(
63 &self,
64 broker_addr: CheetahString,
65 properties: HashMap<CheetahString, CheetahString>,
66 ) -> rocketmq_error::RocketMQResult<()>;
67
68 async fn get_broker_config(
69 &self,
70 broker_addr: CheetahString,
71 ) -> rocketmq_error::RocketMQResult<HashMap<CheetahString, CheetahString>>;
72
73 async fn create_and_update_topic_config(
74 &self,
75 addr: CheetahString,
76 config: TopicConfig,
77 ) -> rocketmq_error::RocketMQResult<()>;
78
79 async fn create_and_update_topic_config_list(
80 &self,
81 addr: CheetahString,
82 topic_config_list: Vec<TopicConfig>,
83 ) -> rocketmq_error::RocketMQResult<()>;
84
85 async fn create_and_update_plain_access_config(
86 &self,
87 addr: CheetahString,
88 config: PlainAccessConfig,
89 ) -> rocketmq_error::RocketMQResult<()>;
90
91 async fn delete_plain_access_config(
92 &self,
93 addr: CheetahString,
94 access_key: CheetahString,
95 ) -> rocketmq_error::RocketMQResult<()>;
96
97 async fn update_global_white_addr_config(
98 &self,
99 addr: CheetahString,
100 global_white_addrs: CheetahString,
101 acl_file_full_path: Option<CheetahString>,
102 ) -> rocketmq_error::RocketMQResult<()>;
103
104 async fn examine_broker_cluster_acl_version_info(
105 &self,
106 addr: CheetahString,
107 ) -> rocketmq_error::RocketMQResult<CheetahString>;
108
109 async fn create_and_update_subscription_group_config(
110 &self,
111 addr: CheetahString,
112 config: SubscriptionGroupConfig,
113 ) -> rocketmq_error::RocketMQResult<()>;
114
115 async fn create_and_update_subscription_group_config_list(
116 &self,
117 broker_addr: CheetahString,
118 configs: Vec<SubscriptionGroupConfig>,
119 ) -> rocketmq_error::RocketMQResult<()>;
120
121 async fn examine_subscription_group_config(
122 &self,
123 addr: CheetahString,
124 group: CheetahString,
125 ) -> rocketmq_error::RocketMQResult<SubscriptionGroupConfig>;
126
127 async fn examine_topic_stats(
128 &self,
129 topic: CheetahString,
130 broker_addr: Option<CheetahString>,
131 ) -> rocketmq_error::RocketMQResult<TopicStatsTable>;
132
133 async fn examine_topic_stats_concurrent(
134 &self,
135 topic: CheetahString,
136 ) -> AdminToolResult<TopicStatsTable>;
137
138 async fn fetch_all_topic_list(&self) -> rocketmq_error::RocketMQResult<TopicList>;
139
140 async fn fetch_topics_by_cluster(
141 &self,
142 cluster_name: CheetahString,
143 ) -> rocketmq_error::RocketMQResult<TopicList>;
144
145 async fn fetch_broker_runtime_stats(
146 &self,
147 broker_addr: CheetahString,
148 ) -> rocketmq_error::RocketMQResult<KVTable>;
149
150 async fn examine_consume_stats(
151 &self,
152 consumer_group: CheetahString,
153 topic: Option<CheetahString>,
154 cluster_name: Option<CheetahString>,
155 broker_addr: Option<CheetahString>,
156 timeout_millis: Option<u64>,
157 ) -> rocketmq_error::RocketMQResult<ConsumeStats>;
158
159 async fn examine_broker_cluster_info(&self) -> rocketmq_error::RocketMQResult<ClusterInfo>;
166
167 async fn examine_topic_route_info(
168 &self,
169 topic: CheetahString,
170 ) -> rocketmq_error::RocketMQResult<Option<TopicRouteData>>;
171
172 async fn examine_consumer_connection_info(
173 &self,
174 consumer_group: CheetahString,
175 broker_addr: Option<CheetahString>,
176 ) -> rocketmq_error::RocketMQResult<ConsumerConnection>;
177
178 async fn examine_producer_connection_info(
179 &self,
180 producer_group: CheetahString,
181 topic: CheetahString,
182 ) -> rocketmq_error::RocketMQResult<ProducerConnection>;
183
184 async fn get_name_server_address_list(&self) -> Vec<CheetahString>;
190
191 async fn wipe_write_perm_of_broker(
192 &self,
193 namesrv_addr: CheetahString,
194 broker_name: CheetahString,
195 ) -> rocketmq_error::RocketMQResult<i32>;
196
197 async fn add_write_perm_of_broker(
198 &self,
199 namesrv_addr: CheetahString,
200 broker_name: CheetahString,
201 ) -> rocketmq_error::RocketMQResult<i32>;
202
203 async fn put_kv_config(
204 &self,
205 namespace: CheetahString,
206 key: CheetahString,
207 value: CheetahString,
208 );
209
210 async fn get_kv_config(
211 &self,
212 namespace: CheetahString,
213 key: CheetahString,
214 ) -> rocketmq_error::RocketMQResult<CheetahString>;
215
216 async fn get_kv_list_by_namespace(
217 &self,
218 namespace: CheetahString,
219 ) -> rocketmq_error::RocketMQResult<KVTable>;
220
221 async fn delete_topic(
222 &self,
223 topic_name: CheetahString,
224 cluster_name: CheetahString,
225 ) -> rocketmq_error::RocketMQResult<()>;
226
227 async fn delete_topic_in_broker(
228 &self,
229 addrs: HashSet<CheetahString>,
230 topic: CheetahString,
231 ) -> rocketmq_error::RocketMQResult<()>;
232
233 async fn delete_topic_in_name_server(
240 &self,
241 addrs: HashSet<CheetahString>,
242 cluster_name: Option<CheetahString>,
243 topic: CheetahString,
244 ) -> rocketmq_error::RocketMQResult<()>;
245
246 async fn delete_subscription_group(
247 &self,
248 addr: CheetahString,
249 group_name: CheetahString,
250 remove_offset: Option<bool>,
251 ) -> rocketmq_error::RocketMQResult<()>;
252
253 async fn create_and_update_kv_config(
254 &self,
255 namespace: CheetahString,
256 key: CheetahString,
257 value: CheetahString,
258 ) -> rocketmq_error::RocketMQResult<()>;
259
260 async fn delete_kv_config(
261 &self,
262 namespace: CheetahString,
263 key: CheetahString,
264 ) -> rocketmq_error::RocketMQResult<()>;
265
266 async fn reset_offset_by_timestamp(
275 &self,
276 cluster_name: Option<CheetahString>,
277 topic: CheetahString,
278 group: CheetahString,
279 timestamp: u64,
280 is_force: bool,
281 ) -> rocketmq_error::RocketMQResult<HashMap<MessageQueue, u64>>;
282
283 async fn reset_offset_new(
284 &self,
285 consumer_group: CheetahString,
286 topic: CheetahString,
287 timestamp: u64,
288 ) -> rocketmq_error::RocketMQResult<()>;
289
290 async fn get_consume_status(
298 &self,
299 topic: CheetahString,
300 group: CheetahString,
301 client_addr: CheetahString,
302 ) -> rocketmq_error::RocketMQResult<HashMap<CheetahString, HashMap<MessageQueue, u64>>>;
303
304 async fn create_or_update_order_conf(
305 &self,
306 key: CheetahString,
307 value: CheetahString,
308 is_cluster: bool,
309 ) -> rocketmq_error::RocketMQResult<()>;
310
311 async fn query_topic_consume_by_who(
312 &self,
313 topic: CheetahString,
314 ) -> rocketmq_error::RocketMQResult<GroupList>;
315
316 async fn query_topics_by_consumer(
317 &self,
318 group: CheetahString,
319 ) -> rocketmq_error::RocketMQResult<TopicList>;
320
321 async fn query_topics_by_consumer_concurrent(
322 &self,
323 group: CheetahString,
324 ) -> AdminToolResult<TopicList>;
325
326 async fn query_subscription(
327 &self,
328 group: CheetahString,
329 topic: CheetahString,
330 ) -> rocketmq_error::RocketMQResult<SubscriptionData>;
331
332 async fn clean_expired_consumer_queue(
345 &self,
346 cluster: Option<CheetahString>,
347 addr: Option<CheetahString>,
348 ) -> rocketmq_error::RocketMQResult<bool>;
349
350 async fn delete_expired_commit_log(
351 &self,
352 cluster: Option<CheetahString>,
353 addr: Option<CheetahString>,
354 ) -> rocketmq_error::RocketMQResult<bool>;
355
356 async fn clean_unused_topic(
357 &self,
358 cluster: Option<CheetahString>,
359 addr: Option<CheetahString>,
360 ) -> rocketmq_error::RocketMQResult<bool>;
361
362 async fn get_consumer_running_info(
363 &self,
364 consumer_group: CheetahString,
365 client_id: CheetahString,
366 jstack: bool,
367 metrics: Option<bool>,
368 ) -> rocketmq_error::RocketMQResult<ConsumerRunningInfo>;
369
370 async fn consume_message_directly(
371 &self,
372 consumer_group: CheetahString,
373 client_id: CheetahString,
374 topic: CheetahString,
375 msg_id: CheetahString,
376 ) -> rocketmq_error::RocketMQResult<ConsumeMessageDirectlyResult>;
377
378 async fn consume_message_directly_ext(
379 &self,
380 cluster_name: CheetahString,
381 consumer_group: CheetahString,
382 client_id: CheetahString,
383 topic: CheetahString,
384 msg_id: CheetahString,
385 ) -> rocketmq_error::RocketMQResult<ConsumeMessageDirectlyResult>;
386
387 async fn clone_group_offset(
398 &self,
399 src_group: CheetahString,
400 dest_group: CheetahString,
401 topic: CheetahString,
402 is_offline: bool,
403 ) -> rocketmq_error::RocketMQResult<()>;
404
405 async fn get_cluster_list(
413 &self,
414 topic: String,
415 ) -> rocketmq_error::RocketMQResult<HashSet<CheetahString>>;
416
417 async fn get_topic_cluster_list(
425 &self,
426 topic: String,
427 ) -> rocketmq_error::RocketMQResult<HashSet<CheetahString>>;
428
429 async fn get_all_topic_config(
442 &self,
443 broker_addr: CheetahString,
444 timeout_millis: u64,
445 ) -> rocketmq_error::RocketMQResult<TopicConfigSerializeWrapper>;
446
447 async fn get_user_topic_config(
448 &self,
449 broker_addr: CheetahString,
450 special_topic: bool,
451 timeout_millis: u64,
452 ) -> rocketmq_error::RocketMQResult<TopicConfigSerializeWrapper>;
453
454 async fn update_consume_offset(
455 &self,
456 broker_addr: CheetahString,
457 consume_group: CheetahString,
458 mq: MessageQueue,
459 offset: u64,
460 ) -> rocketmq_error::RocketMQResult<()>;
461
462 async fn update_name_server_config(
463 &self,
464 properties: HashMap<CheetahString, CheetahString>,
465 name_servers: Option<Vec<CheetahString>>,
466 ) -> rocketmq_error::RocketMQResult<()>;
467
468 async fn get_name_server_config(
469 &self,
470 name_servers: Vec<CheetahString>,
471 ) -> rocketmq_error::RocketMQResult<HashMap<CheetahString, HashMap<CheetahString, CheetahString>>>;
472
473 async fn resume_check_half_message(
484 &self,
485 topic: CheetahString,
486 msg_id: CheetahString,
487 ) -> rocketmq_error::RocketMQResult<bool>;
488
489 async fn set_message_request_mode(
490 &self,
491 broker_addr: CheetahString,
492 topic: CheetahString,
493 consumer_group: CheetahString,
494 mode: MessageRequestMode,
495 pop_work_group_size: i32,
496 timeout_millis: u64,
497 ) -> rocketmq_error::RocketMQResult<()>;
498
499 async fn reset_offset_by_queue_id(
500 &self,
501 broker_addr: CheetahString,
502 consumer_group: CheetahString,
503 topic_name: CheetahString,
504 queue_id: i32,
505 reset_offset: u64,
506 ) -> rocketmq_error::RocketMQResult<()>;
507
508 async fn examine_topic_config(
509 &self,
510 addr: CheetahString,
511 topic: CheetahString,
512 ) -> rocketmq_error::RocketMQResult<TopicConfig>;
513
514 async fn create_static_topic(
515 &self,
516 addr: CheetahString,
517 default_topic: CheetahString,
518 topic_config: TopicConfig,
519 mapping_detail: TopicQueueMappingDetail,
520 force: bool,
521 ) -> rocketmq_error::RocketMQResult<()>;
522
523 async fn reset_master_flush_offset(
557 &self,
558 broker_addr: CheetahString,
559 master_flush_offset: u64,
560 ) -> rocketmq_error::RocketMQResult<()>;
561
562 async fn get_controller_config(
563 &self,
564 controller_servers: Vec<CheetahString>,
565 ) -> rocketmq_error::RocketMQResult<HashMap<CheetahString, HashMap<CheetahString, CheetahString>>>;
566
567 async fn update_controller_config(
568 &self,
569 properties: HashMap<CheetahString, CheetahString>,
570 controllers: Vec<CheetahString>,
571 ) -> rocketmq_error::RocketMQResult<()>;
572
573 async fn clean_controller_broker_data(
582 &self,
583 controller_addr: CheetahString,
584 cluster_name: CheetahString,
585 broker_name: CheetahString,
586 broker_controller_ids_to_clean: Option<CheetahString>,
587 is_clean_living_broker: bool,
588 ) -> rocketmq_error::RocketMQResult<()>;
589
590 async fn update_cold_data_flow_ctr_group_config(
591 &self,
592 broker_addr: CheetahString,
593 properties: HashMap<CheetahString, CheetahString>,
594 ) -> rocketmq_error::RocketMQResult<()>;
595
596 async fn remove_cold_data_flow_ctr_group_config(
597 &self,
598 broker_addr: CheetahString,
599 consumer_group: CheetahString,
600 ) -> rocketmq_error::RocketMQResult<()>;
601
602 async fn get_cold_data_flow_ctr_info(
603 &self,
604 broker_addr: CheetahString,
605 ) -> rocketmq_error::RocketMQResult<CheetahString>;
606
607 async fn set_commit_log_read_ahead_mode(
608 &self,
609 broker_addr: CheetahString,
610 mode: CheetahString,
611 ) -> rocketmq_error::RocketMQResult<CheetahString>;
612
613 async fn create_user(
614 &self,
615 broker_addr: CheetahString,
616 username: CheetahString,
617 password: CheetahString,
618 user_type: CheetahString,
619 ) -> rocketmq_error::RocketMQResult<()>;
620
621 async fn update_user(
628 &self,
629 broker_addr: CheetahString,
630 username: CheetahString,
631 password: CheetahString,
632 user_type: CheetahString,
633 user_status: CheetahString,
634 ) -> rocketmq_error::RocketMQResult<()>;
635
636 async fn delete_user(
643 &self,
644 broker_addr: CheetahString,
645 username: CheetahString,
646 ) -> rocketmq_error::RocketMQResult<()>;
647
648 async fn create_acl(
661 &self,
662 broker_addr: CheetahString,
663 subject: CheetahString,
664 resources: Vec<CheetahString>,
665 actions: Vec<CheetahString>,
666 source_ips: Vec<CheetahString>,
667 decision: CheetahString,
668 ) -> rocketmq_error::RocketMQResult<()>;
669
670 async fn update_acl(
677 &self,
678 broker_addr: CheetahString,
679 subject: CheetahString,
680 resources: Vec<CheetahString>,
681 actions: Vec<CheetahString>,
682 source_ips: Vec<CheetahString>,
683 decision: CheetahString,
684 ) -> rocketmq_error::RocketMQResult<()>;
685
686 async fn delete_acl(
693 &self,
694 broker_addr: CheetahString,
695 subject: CheetahString,
696 resource: CheetahString,
697 ) -> rocketmq_error::RocketMQResult<()>;
698
699 }