From 839c886755d361caf8b909f958eedd74a42083ee Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Wed, 24 Oct 2012 13:25:03 +0100 Subject: If the current master is currently not in the nodes specified, act like it is for the purposes of suggested_queue_nodes - otherwise we will not return it in the results. --- src/rabbit_mirror_queue_misc.erl | 6 +++++- src/rabbit_tests.erl | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/rabbit_mirror_queue_misc.erl b/src/rabbit_mirror_queue_misc.erl index 4a00846e..8a363f76 100644 --- a/src/rabbit_mirror_queue_misc.erl +++ b/src/rabbit_mirror_queue_misc.erl @@ -268,7 +268,11 @@ policy(Policy, Q) -> suggested_queue_nodes(<<"all">>, _Params, {MNode, _SNodes}, Possible) -> {MNode, Possible -- [MNode]}; suggested_queue_nodes(<<"nodes">>, Nodes0, {MNode, _SNodes}, Possible) -> - Nodes = [list_to_atom(binary_to_list(Node)) || Node <- Nodes0], + Nodes1 = [list_to_atom(binary_to_list(Node)) || Node <- Nodes0], + %% If the current master is currently not in the nodes specified, + %% act like it is for the purposes below - otherwise we will not + %% return it in the results... + Nodes = lists:usort([MNode | Nodes1]), Unavailable = Nodes -- Possible, Available = Nodes -- Unavailable, case Available of diff --git a/src/rabbit_tests.erl b/src/rabbit_tests.erl index 962bb648..afc10b9f 100644 --- a/src/rabbit_tests.erl +++ b/src/rabbit_tests.erl @@ -914,12 +914,12 @@ test_dynamic_mirroring() -> Test({b,[a,c],0},<<"nodes">>,[<<"a">>,<<"b">>,<<"c">>],{b,[a]},[a,b,c,d]), %% Add two nodes and drop one Test({a,[b,c],0},<<"nodes">>,[<<"a">>,<<"b">>,<<"c">>],{a,[d]},[a,b,c,d]), - %% Promote slave to master by policy - Test({a,[b,c],0},<<"nodes">>,[<<"a">>,<<"b">>,<<"c">>],{d,[a]},[a,b,c,d]), %% Don't try to include nodes that are not running Test({a,[b], 0},<<"nodes">>,[<<"a">>,<<"b">>,<<"f">>],{a,[b]},[a,b,c,d]), %% If we can't find any of the nodes listed then just keep the master Test({a,[], 0},<<"nodes">>,[<<"f">>,<<"g">>,<<"h">>],{a,[b]},[a,b,c,d]), + %% And once that's happened, still keep the master even when not listed + Test({a,[b,c],0},<<"nodes">>,[<<"b">>,<<"c">>], {a,[]}, [a,b,c,d]), Test({a,[], 1},<<"exactly">>,2,{a,[]}, [a,b,c,d]), Test({a,[], 2},<<"exactly">>,3,{a,[]}, [a,b,c,d]), -- cgit v1.2.1