@@ -163,10 +163,7 @@ maybe_add_member(Q, Running, MemberNodes, TargetSize) ->
163
163
true ->
164
164
% % In the future, sort the list of new nodes based on load,
165
165
% % availability zones etc
166
- QueueCount = rabbit_amqqueue :count (),
167
- QueueCountStartRandom = application :get_env (rabbit , queue_count_start_random_selection ,
168
- ? QUEUE_COUNT_START_RANDOM_SELECTION ),
169
- Node = select_node (New , QueueCount , QueueCountStartRandom ),
166
+ Node = select_node (New ),
170
167
QName = amqqueue :get_name (Q ),
171
168
case rabbit_quorum_queue :add_member (Q , Node ) of
172
169
ok ->
@@ -241,28 +238,7 @@ update_result(Result, noop) ->
241
238
update_result (Result , Result ) ->
242
239
Result .
243
240
244
- select_node ([Node ], _QueueCount , _QueueCountStartRandom ) ->
241
+ select_node ([Node ]) ->
245
242
Node ;
246
- select_node (Nodes , QueueCount , QueueCountStartRandom )
247
- when QueueCount >= QueueCountStartRandom ->
248
- lists :nth (rand :uniform (length (Nodes )), Nodes );
249
- select_node (Nodes , _QueueCount , _QueueCountStartRandom ) ->
250
- Counters0 = maps :from_list ([{N , 0 } || N <- Nodes ]),
251
- Queues = rabbit_amqqueue :list_by_type (rabbit_quorum_queue ),
252
- Counters = lists :foldl (fun (Q , Acc ) ->
253
- #{nodes := MNodes } = amqqueue :get_type_state (Q ),
254
- lists :foldl (fun (N , A )
255
- when is_map_key (N , A ) ->
256
- maps :update_with (N , fun (C ) -> C + 1 end , A );
257
- (_ , A ) ->
258
- A
259
- end , Acc , MNodes )
260
- end , Counters0 , Queues ),
261
- L0 = maps :to_list (Counters ),
262
- % % Maybe cache this result for a few seconds, to
263
- % % not run this check for each queue?
264
- L1 = lists :sort (fun ({_N0 , C0 }, {_N1 , C1 }) ->
265
- C0 =< C1
266
- end , L0 ),
267
- {Node , _ } = hd (L1 ),
268
- Node .
243
+ select_node (Nodes ) ->
244
+ lists :nth (rand :uniform (length (Nodes )), Nodes ).
0 commit comments