Skip to content

Support kernel.net_ticktime in Cuttlefish configuration (master) #1524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/rabbitmq.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@
# Kernel section
# ======================================

# kernel.net_ticktime = 60
# net_ticktime = 60

## ----------------------------------------------------------------------------
## RabbitMQ Management Plugin
Expand Down
14 changes: 14 additions & 0 deletions priv/schema/rabbit.schema
Original file line number Diff line number Diff line change
Expand Up @@ -1150,6 +1150,15 @@ end}.
{datatype, {enum, [debug, info, notice, warning, error, critical, alert, emergency, none]}}
]}.

% ==========================
% Kernel section
% ==========================

{mapping, "net_ticktime", "kernel.net_ticktime",[
{datatype, [integer]},
{validators, ["non_zero_positive_integer"]}
]}.

% ===============================
% Validators
% ===============================
Expand Down Expand Up @@ -1199,3 +1208,8 @@ end}.
fun(Int) when is_integer(Int) ->
Int >= 0
end}.

{validator, "non_zero_positive_integer", "number should be greater or equal to one",
fun(Int) when is_integer(Int) ->
Int >= 1
end}.
40 changes: 35 additions & 5 deletions src/rabbit_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,10 @@ update_app_config(ConfigFile) ->
%% For application config to be updated, applications should
%% be unloaded first.
%% If an application is already running, print an error.
lists:foreach(fun({App, _Config}) ->
lists:foreach(fun({App, AppConfig}) ->
case lists:member(App, RunningApps) of
true ->
io:format(standard_error,
"~nUnable to update config for app ~p from *.conf file."
" App is already running. Use advanced.config instead.~n",
[App]);
maybe_print_warning_for_running_app(App, AppConfig);
false ->
case lists:member(App, LoadedApps) of
true -> application:unload(App);
Expand All @@ -87,11 +84,44 @@ update_app_config(ConfigFile) ->
end
end,
Config),
maybe_set_net_ticktime(proplists:get_value(kernel, Config)),
ok = application_controller:change_application_data([], [ConfigFile]),
%% Make sure to load all the applications we're unloaded
lists:foreach(fun(App) -> application:load(App) end, LoadedApps),
ok.

maybe_print_warning_for_running_app(kernel, Config) ->
ConfigWithoutSupportedEntry = proplists:delete(net_ticktime, Config),
case length(ConfigWithoutSupportedEntry) > 0 of
true -> io:format(standard_error,
"~nUnable to update config for app ~p from *.conf file."
" App is already running. Use advanced.config instead.~n", [kernel]);
false -> ok
end;
maybe_print_warning_for_running_app(App, _Config) ->
io:format(standard_error,
"~nUnable to update config for app ~p from *.conf file."
" App is already running. Use advanced.config instead.~n",
[App]).

maybe_set_net_ticktime(undefined) ->
ok;
maybe_set_net_ticktime(KernelConfig) ->
case proplists:get_value(net_ticktime, KernelConfig) of
undefined ->
ok;
NetTickTime ->
case net_kernel:set_net_ticktime(NetTickTime) of
{ongoing_change_to, NewNetTicktime} ->
io:format(standard_error,
"~nCouldn't set net_ticktime to ~p "
"as net_kernel is busy changing net_ticktime to ~p seconds ~n",
[NetTickTime, NewNetTicktime]);
_ ->
ok
end
end.

generate_config_file(ConfFiles, ConfDir, ScriptDir) ->
generate_config_file(ConfFiles, ConfDir, ScriptDir,
schema_dir(), get_advanced_config()).
Expand Down
8 changes: 7 additions & 1 deletion test/config_schema_SUITE_data/rabbit.snippets
Original file line number Diff line number Diff line change
Expand Up @@ -528,5 +528,11 @@ credential_validator.regexp = ^abc\\d+",
[{rabbit, [
{delegate_count, 64}
]}],
[]}
[]},
{kernel_net_ticktime,
"net_ticktime = 20",
[{kernel, [
{net_ticktime, 20}
]}],
[]}
].