summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_definitions.erl13
-rw-r--r--src/rabbit_nodes.erl43
2 files changed, 48 insertions, 8 deletions
diff --git a/src/rabbit_definitions.erl b/src/rabbit_definitions.erl
index 8c70b5aa6c..1923e2947e 100644
--- a/src/rabbit_definitions.erl
+++ b/src/rabbit_definitions.erl
@@ -27,7 +27,8 @@
-export([
list_users/0, list_vhosts/0, list_permissions/0, list_topic_permissions/0,
list_runtime_parameters/0, list_global_runtime_parameters/0, list_policies/0,
- list_exchanges/0, list_queues/0, list_bindings/0
+ list_exchanges/0, list_queues/0, list_bindings/0,
+ is_internal_parameter/1
]).
-export([decode/1, decode/2, args/1]).
@@ -677,12 +678,20 @@ runtime_parameter_definition(Param) ->
}.
list_global_runtime_parameters() ->
- [global_runtime_parameter_definition(P) || P <- rabbit_runtime_parameters:list_global()].
+ [global_runtime_parameter_definition(P) || P <- rabbit_runtime_parameters:list_global(), not is_internal_parameter(P)].
global_runtime_parameter_definition(P0) ->
P = [{rabbit_data_coercion:to_binary(K), V} || {K, V} <- P0],
maps:from_list(P).
+-define(INTERNAL_GLOBAL_PARAM_PREFIX, "internal").
+
+is_internal_parameter(Param) ->
+ Name = rabbit_data_coercion:to_list(pget(name, Param)),
+ %% if global parameter name starts with an "internal", consider it to be internal
+ %% and exclude it from definition export
+ string:left(Name, length(?INTERNAL_GLOBAL_PARAM_PREFIX)) =:= ?INTERNAL_GLOBAL_PARAM_PREFIX.
+
list_policies() ->
[policy_definition(P) || P <- rabbit_policy:list()].
diff --git a/src/rabbit_nodes.erl b/src/rabbit_nodes.erl
index 3d499c8a0b..eb582c69f5 100644
--- a/src/rabbit_nodes.erl
+++ b/src/rabbit_nodes.erl
@@ -23,23 +23,22 @@
all_running/0, name_type/0, running_count/0,
await_running_count/2,
boot/0]).
+-export([persistent_cluster_id/0, seed_internal_cluster_id/0, seed_user_provided_cluster_name/0]).
-include_lib("kernel/include/inet.hrl").
-include_lib("rabbit_common/include/rabbit.hrl").
-define(SAMPLING_INTERVAL, 1000).
+-define(INTERNAL_CLUSTER_ID_PARAM_NAME, internal_cluster_id).
+
%%----------------------------------------------------------------------------
%% API
%%----------------------------------------------------------------------------
boot() ->
- case application:get_env(rabbit, cluster_name) of
- undefined -> ok;
- {ok, Name} ->
- rabbit_log:info("Setting cluster name to '~s' as configured", [Name]),
- set_cluster_name(rabbit_data_coercion:to_binary(Name))
- end.
+ seed_internal_cluster_id(),
+ seed_user_provided_cluster_name().
name_type() ->
case os:getenv("RABBITMQ_USE_LONGNAME") of
@@ -90,6 +89,38 @@ cluster_name_default() ->
FQDN = rabbit_net:hostname(),
list_to_binary(atom_to_list(make({ID, FQDN}))).
+-spec persistent_cluster_id() -> binary().
+persistent_cluster_id() ->
+ case rabbit_runtime_parameters:lookup_global(?INTERNAL_CLUSTER_ID_PARAM_NAME) of
+ not_found ->
+ seed_internal_cluster_id(),
+ persistent_cluster_id();
+ Param ->
+ #{value := Val, name := ?INTERNAL_CLUSTER_ID_PARAM_NAME} = maps:from_list(Param),
+ Val
+ end.
+
+-spec seed_internal_cluster_id() -> binary().
+seed_internal_cluster_id() ->
+ case rabbit_runtime_parameters:lookup_global(?INTERNAL_CLUSTER_ID_PARAM_NAME) of
+ not_found ->
+ Id = rabbit_guid:binary(rabbit_guid:gen(), "rabbitmq-cluster-id"),
+ rabbit_log:info("Initialising internal cluster ID to '~s'", [Id]),
+ rabbit_runtime_parameters:set_global(?INTERNAL_CLUSTER_ID_PARAM_NAME, Id, ?INTERNAL_USER),
+ Id;
+ Param ->
+ #{value := Val, name := ?INTERNAL_CLUSTER_ID_PARAM_NAME} = maps:from_list(Param),
+ Val
+ end.
+
+seed_user_provided_cluster_name() ->
+ case application:get_env(rabbit, cluster_name) of
+ undefined -> ok;
+ {ok, Name} ->
+ rabbit_log:info("Setting cluster name to '~s' as configured", [Name]),
+ set_cluster_name(rabbit_data_coercion:to_binary(Name))
+ end.
+
-spec set_cluster_name(binary()) -> 'ok'.
set_cluster_name(Name) ->