diff options
| author | Michael Klishin <mklishin@pivotal.io> | 2020-07-01 01:53:21 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-01 01:53:21 +0300 |
| commit | 167c376be968da27a5b1e90e562930474680a7a8 (patch) | |
| tree | 6fac781f6437cde24d329ad3c363882ca85ce384 | |
| parent | 24fa7e1cc8aeb6ad4a5b356c01c4c090b766ca2b (diff) | |
| parent | 8fa9c3c64adffb3be7ec59c17495447ba7cb9a9b (diff) | |
| download | rabbitmq-server-git-167c376be968da27a5b1e90e562930474680a7a8.tar.gz | |
Merge pull request #2397 from rabbitmq/rabbitmq-cli-432
Introduce a way to check if a node is the only cluster member
| -rw-r--r-- | src/rabbit_amqqueue.erl | 8 | ||||
| -rw-r--r-- | src/rabbit_nodes.erl | 14 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl index 25e5a56d42..21c027451d 100644 --- a/src/rabbit_amqqueue.erl +++ b/src/rabbit_amqqueue.erl @@ -1105,10 +1105,10 @@ list_local_mirrored_classic_without_synchronised_mirrors_for_cli() -> [begin #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">> + <<"readable_name">> => rabbit_data_coercion:to_binary(rabbit_misc:rs(amqqueue:get_name(Q))), + <<"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..d209798575 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. + +-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). |
