diff options
| author | Michael Klishin <michael@clojurewerkz.org> | 2020-07-01 01:19:30 +0300 |
|---|---|---|
| committer | Michael Klishin <michael@clojurewerkz.org> | 2020-07-01 01:19:30 +0300 |
| commit | 8e0362f8b2a21f6f570ddb3b1e0d444cc8b36877 (patch) | |
| tree | 4e4fdf8c62125c023fcee93759a108ad1b8cf822 | |
| parent | 24fa7e1cc8aeb6ad4a5b356c01c4c090b766ca2b (diff) | |
| download | rabbitmq-server-git-8e0362f8b2a21f6f570ddb3b1e0d444cc8b36877.tar.gz | |
Introduce a function that checks if a node is the only one in its cluster
Part of rabbitmq/rabbitmq-cli#432
| -rw-r--r-- | src/rabbit_amqqueue.erl | 6 | ||||
| -rw-r--r-- | src/rabbit_nodes.erl | 14 |
2 files changed, 12 insertions, 8 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index 25e5a56d42..37fede8207 100644 --- a/src/rabbit_amqqueue.erl +++ b/src/rabbit_amqqueue.erl @@ -1106,9 +1106,9 @@ list_local_mirrored_classic_without_synchronised_mirrors_for_cli() -> #resource{name = Name} = amqqueue:get_name(Q), #{ <<"readable_name">> => rabbit_misc:rs(amqqueue:get_name(Q)), - <<"name">> => Name, - <<"virtual_host">> => amqqueue:get_vhost(Q), - <<"type">> => <<"quorum">> + <<"name">> => Name, + <<"virtual_host">> => amqqueue:get_vhost(Q), + <<"type">> => <<"classic">> } end || Q <- ClassicQs]. diff --git a/src/rabbit_nodes.erl b/src/rabbit_nodes.erl index 1f066c6b91..7757519aab 100644 --- a/src/rabbit_nodes.erl +++ b/src/rabbit_nodes.erl @@ -20,8 +20,8 @@ -export([names/1, diagnostics/1, make/1, make/2, parts/1, cookie_hash/0, is_running/2, is_process_running/2, cluster_name/0, set_cluster_name/1, set_cluster_name/2, ensure_epmd/0, - all_running/0, name_type/0, running_count/0, - await_running_count/2, + all_running/0, name_type/0, running_count/0, total_count/0, + await_running_count/2, is_single_node_cluster/0, boot/0]). -export([persistent_cluster_id/0, seed_internal_cluster_id/0, seed_user_provided_cluster_name/0]). @@ -138,15 +138,19 @@ ensure_epmd() -> rabbit_nodes_common:ensure_epmd(). -spec all_running() -> [node()]. - all_running() -> rabbit_mnesia:cluster_nodes(running). -spec running_count() -> integer(). - running_count() -> length(all_running()). --spec await_running_count(integer(), integer()) -> 'ok' | {'error', atom()}. +-spec total_count() -> integer(). +total_count() -> length(rabbit_mnesia:cluster_nodes(all)). +-spec is_single_node_cluster() -> boolean(). +is_single_node_cluster() -> + total_count() =:= 1 andalso running_count() =:= 1. + +-spec await_running_count(integer(), integer()) -> 'ok' | {'error', atom()}. await_running_count(TargetCount, Timeout) -> Retries = round(Timeout/?SAMPLING_INTERVAL), await_running_count_with_retries(TargetCount, Retries). |
