summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bakken <lbakken@pivotal.io>2017-09-20 15:41:16 -0700
committerLuke Bakken <lbakken@pivotal.io>2017-09-22 11:23:32 -0700
commit225063f5607ddcf4a8e2ddc0805fc8991b675ca7 (patch)
tree18e32c4a152ffce7676a8008d5e9c8fe715c13c9
parent879d1837e74d987b23c337d98978f4311bc34222 (diff)
downloadrabbitmq-server-git-225063f5607ddcf4a8e2ddc0805fc8991b675ca7.tar.gz
Take ha-mode into account in choosing queue master
Fixes #1371
-rw-r--r--src/rabbit_queue_location_min_masters.erl4
-rw-r--r--src/rabbit_queue_location_random.erl4
-rw-r--r--src/rabbit_queue_master_location_misc.erl6
3 files changed, 8 insertions, 6 deletions
diff --git a/src/rabbit_queue_location_min_masters.erl b/src/rabbit_queue_location_min_masters.erl
index a1e73ee5d5..8fc8d47aae 100644
--- a/src/rabbit_queue_location_min_masters.erl
+++ b/src/rabbit_queue_location_min_masters.erl
@@ -37,8 +37,8 @@ description() ->
[{description,
<<"Locate queue master node from cluster node with least bound queues">>}].
-queue_master_location(#amqqueue{}) ->
- Cluster = rabbit_queue_master_location_misc:all_nodes(),
+queue_master_location(#amqqueue{}=Q) ->
+ Cluster = rabbit_queue_master_location_misc:all_nodes(Q),
VHosts = rabbit_vhost:list(),
BoundQueueMasters = get_bound_queue_masters_per_vhost(VHosts, []),
{_Count, MinMaster}= get_min_master(Cluster, BoundQueueMasters),
diff --git a/src/rabbit_queue_location_random.erl b/src/rabbit_queue_location_random.erl
index 3a3a2360b7..9f318b9359 100644
--- a/src/rabbit_queue_location_random.erl
+++ b/src/rabbit_queue_location_random.erl
@@ -37,8 +37,8 @@ description() ->
[{description,
<<"Locate queue master node from cluster in a random manner">>}].
-queue_master_location(#amqqueue{}) ->
- Cluster = rabbit_queue_master_location_misc:all_nodes(),
+queue_master_location(#amqqueue{}=Q) ->
+ Cluster = rabbit_queue_master_location_misc:all_nodes(Q),
RandomPos = erlang:phash2(time_compat:monotonic_time(), length(Cluster)),
MasterNode = lists:nth(RandomPos + 1, Cluster),
{ok, MasterNode}.
diff --git a/src/rabbit_queue_master_location_misc.erl b/src/rabbit_queue_master_location_misc.erl
index 0b9efdd6fc..0e3dec9b83 100644
--- a/src/rabbit_queue_master_location_misc.erl
+++ b/src/rabbit_queue_master_location_misc.erl
@@ -24,7 +24,7 @@
get_location_mod_by_config/1,
get_location_mod_by_args/1,
get_location_mod_by_policy/1,
- all_nodes/0]).
+ all_nodes/1]).
lookup_master(QueueNameBin, VHostPath) when is_binary(QueueNameBin),
is_binary(VHostPath) ->
@@ -92,4 +92,6 @@ get_location_mod_by_config(#amqqueue{}) ->
_ -> {error, "queue_master_locator undefined"}
end.
-all_nodes() -> rabbit_mnesia:cluster_nodes(running).
+all_nodes(Queue=#amqqueue{}) ->
+ {MNode, SNodes} = rabbit_mirror_queue_misc:suggested_queue_nodes(Queue),
+ [MNode|SNodes].