diff options
| author | Michael Klishin <michael@novemberain.com> | 2018-02-23 02:18:14 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-23 02:18:14 +0300 |
| commit | 179f229094dc631b95ae595447bf2c3ee5dad3ef (patch) | |
| tree | 44a44a277a5d936e6075fe315f9dda6b8d504d30 | |
| parent | da988060c5557d453dd3de99a2e2f48f7f31fdfc (diff) | |
| parent | 7bb8c758a3eb4631b14caa8d637d7a1af8770281 (diff) | |
| download | rabbitmq-server-git-179f229094dc631b95ae595447bf2c3ee5dad3ef.tar.gz | |
Merge pull request #1523 from rabbitmq/rabbitmq-server-1522-net-ticktime-in-new-config-formatv3.7.4-rc.2
Support kernel.net_ticktime in Cuttlefish configuration
| -rw-r--r-- | docs/rabbitmq.conf.example | 2 | ||||
| -rw-r--r-- | priv/schema/rabbit.schema | 14 | ||||
| -rw-r--r-- | src/rabbit_config.erl | 44 | ||||
| -rw-r--r-- | test/config_schema_SUITE_data/rabbit.snippets | 8 |
4 files changed, 61 insertions, 7 deletions
diff --git a/docs/rabbitmq.conf.example b/docs/rabbitmq.conf.example index c362e9a8d2..c0ef61fac1 100644 --- a/docs/rabbitmq.conf.example +++ b/docs/rabbitmq.conf.example @@ -459,7 +459,7 @@ # Kernel section # ====================================== -# kernel.net_ticktime = 60 +# net_ticktime = 60 ## ---------------------------------------------------------------------------- ## RabbitMQ Management Plugin diff --git a/priv/schema/rabbit.schema b/priv/schema/rabbit.schema index a39e47f7af..a8a36ad87d 100644 --- a/priv/schema/rabbit.schema +++ b/priv/schema/rabbit.schema @@ -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 % =============================== @@ -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}. diff --git a/src/rabbit_config.erl b/src/rabbit_config.erl index a3f7d19136..de22d298be 100644 --- a/src/rabbit_config.erl +++ b/src/rabbit_config.erl @@ -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); @@ -87,11 +84,48 @@ 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 a .conf file." + " The 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 a .conf file: " + " The app is already running.~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, 0) of + unchanged -> + ok; + change_initiated -> + ok; + {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()). diff --git a/test/config_schema_SUITE_data/rabbit.snippets b/test/config_schema_SUITE_data/rabbit.snippets index d8b43c7fb8..12c2774501 100644 --- a/test/config_schema_SUITE_data/rabbit.snippets +++ b/test/config_schema_SUITE_data/rabbit.snippets @@ -528,5 +528,11 @@ credential_validator.regexp = ^abc\\d+", [{rabbit, [ {delegate_count, 64} ]}], - []} + []}, + {kernel_net_ticktime, + "net_ticktime = 20", + [{kernel, [ + {net_ticktime, 20} + ]}], + []} ]. |
