@@ -150,11 +150,7 @@ filter_pid_per_type(QPids) ->
150150
151151- spec stop (rabbit_types :vhost ()) -> 'ok' .
152152stop (VHost ) ->
153- % % Classic queues
154- ok = rabbit_amqqueue_sup_sup :stop_for_vhost (VHost ),
155- {ok , BQ } = application :get_env (rabbit , backing_queue_module ),
156- ok = BQ :stop (VHost ),
157- rabbit_quorum_queue :stop (VHost ).
153+ rabbit_queue_type :stop (VHost ).
158154
159155- spec start ([amqqueue :amqqueue ()]) -> 'ok' .
160156
@@ -424,6 +420,8 @@ rebalance(Type, VhostSpec, QueueSpec) ->
424420 % % We have not yet acquired the rebalance_queues global lock.
425421 maybe_rebalance (get_rebalance_lock (self ()), Type , VhostSpec , QueueSpec ).
426422
423+ % % TODO: classic queues do not support rebalancing, it looks like they are simply
424+ % % filtered out with is_replicated(Q). Maybe error instead?
427425maybe_rebalance ({true , Id }, Type , VhostSpec , QueueSpec ) ->
428426 rabbit_log :info (" Starting queue rebalance operation: '~ts ' for vhosts matching '~ts ' and queues matching '~ts '" ,
429427 [Type , VhostSpec , QueueSpec ]),
@@ -459,10 +457,15 @@ filter_per_type(stream, Q) ->
459457filter_per_type (classic , Q ) ->
460458 ? amqqueue_is_classic (Q ).
461459
462- rebalance_module (Q ) when ? amqqueue_is_quorum (Q ) ->
463- rabbit_quorum_queue ;
464- rebalance_module (Q ) when ? amqqueue_is_stream (Q ) ->
465- rabbit_stream_queue .
460+ % % TODO: note that it can return {error, not_supported}.
461+ % % this will result in a badmatch. However that's fine
462+ % % for now because the original function will fail with
463+ % % bad clause if called with classical queue.
464+ % % The assumption is all non-replicated queues
465+ % % are filtered before calling this with is_replicated/0
466+ rebalance_module (Q ) ->
467+ TypeModule = ? amqqueue_type (Q ),
468+ TypeModule :rebalance_module ().
466469
467470get_resource_name (# resource {name = Name }) ->
468471 Name .
@@ -487,13 +490,19 @@ iterative_rebalance(ByNode, MaxQueuesDesired) ->
487490maybe_migrate (ByNode , MaxQueuesDesired ) ->
488491 maybe_migrate (ByNode , MaxQueuesDesired , maps :keys (ByNode )).
489492
493+ % % TODO: unfortunate part - UI bits mixed deep inside logic.
494+ % % I will not be moving this inside queue type. Instead
495+ % % an attempt to generate something more readable than
496+ % % Other made.
490497column_name (rabbit_classic_queue ) -> <<" Number of replicated classic queues" >>;
491498column_name (rabbit_quorum_queue ) -> <<" Number of quorum queues" >>;
492499column_name (rabbit_stream_queue ) -> <<" Number of streams" >>;
493- column_name (Other ) -> Other .
500+ column_name (TypeModule ) ->
501+ Alias = rabbit_queue_type :short_alias_of (TypeModule ),
502+ <<" Number of \" " , Alias /binary , " \" queues" >>.
494503
495504maybe_migrate (ByNode , _ , []) ->
496- ByNodeAndType = maps :map (fun (_Node , Queues ) -> maps :groups_from_list (fun ({_ , Q , _ }) -> column_name (? amqqueue_v2_field_type (Q )) end , Queues ) end , ByNode ),
505+ ByNodeAndType = maps :map (fun (_Node , Queues ) -> maps :groups_from_list (fun ({_ , Q , _ }) -> column_name (? amqqueue_type (Q )) end , Queues ) end , ByNode ),
497506 CountByNodeAndType = maps :map (fun (_Node , Type ) -> maps :map (fun (_ , Qs )-> length (Qs ) end , Type ) end , ByNodeAndType ),
498507 {ok , maps :values (maps :map (fun (Node ,Counts ) -> [{<<" Node name" >>, Node } | maps :to_list (Counts )] end , CountByNodeAndType ))};
499508maybe_migrate (ByNode , MaxQueuesDesired , [N | Nodes ]) ->
@@ -1252,14 +1261,12 @@ list_durable() ->
12521261
12531262- spec list_by_type (atom ()) -> [amqqueue :amqqueue ()].
12541263
1255- list_by_type (classic ) -> list_by_type (rabbit_classic_queue );
1256- list_by_type (quorum ) -> list_by_type (rabbit_quorum_queue );
1257- list_by_type (stream ) -> list_by_type (rabbit_stream_queue );
1258- list_by_type (Type ) ->
1259- rabbit_db_queue :get_all_durable_by_type (Type ).
1264+ list_by_type (TypeDescriptor ) ->
1265+ TypeModule = rabbit_queue_type :discover (TypeDescriptor ),
1266+ rabbit_db_queue :get_all_durable_by_type (TypeModule ).
12601267
1268+ % % TODO: looks unused
12611269- spec list_local_quorum_queue_names () -> [name ()].
1262-
12631270list_local_quorum_queue_names () ->
12641271 [ amqqueue :get_name (Q ) || Q <- list_by_type (quorum ),
12651272 amqqueue :get_state (Q ) =/= crashed ,
@@ -1296,6 +1303,7 @@ list_local_followers() ->
12961303 rabbit_quorum_queue :is_recoverable (Q )
12971304 ].
12981305
1306+ % % TODO: looks unused
12991307- spec list_local_quorum_queues_with_name_matching (binary ()) -> [amqqueue :amqqueue ()].
13001308list_local_quorum_queues_with_name_matching (Pattern ) ->
13011309 [ Q || Q <- list_by_type (quorum ),
@@ -1882,11 +1890,9 @@ run_backing_queue(QPid, Mod, Fun) ->
18821890
18831891- spec is_replicated (amqqueue :amqqueue ()) -> boolean ().
18841892
1885- is_replicated (Q ) when ? amqqueue_is_classic (Q ) ->
1886- false ;
1887- is_replicated (_Q ) ->
1888- % % streams and quorum queues are all replicated
1889- true .
1893+ is_replicated (Q ) ->
1894+ TypeModule = ? amqqueue_type (Q ),
1895+ TypeModule :is_replicated ().
18901896
18911897is_exclusive (Q ) when ? amqqueue_exclusive_owner_is (Q , none ) ->
18921898 false ;
0 commit comments