feat(olp): rename olp mgmt API
on -> enable off -> disable
This commit is contained in:
parent
58033c083d
commit
23fc8afc50
|
@ -27,8 +27,8 @@
|
|||
|
||||
%% exports for O&M
|
||||
-export([ status/0
|
||||
, on/0
|
||||
, off/0
|
||||
, enable/0
|
||||
, disable/0
|
||||
]).
|
||||
|
||||
-type cfg_key() ::
|
||||
|
@ -97,13 +97,13 @@ status() ->
|
|||
is_overloaded().
|
||||
|
||||
%% @doc turn off backgroud runq check.
|
||||
-spec off() -> ok | {error, timeout}.
|
||||
off() ->
|
||||
-spec disable() -> ok | {error, timeout}.
|
||||
disable() ->
|
||||
load_ctl:stop_runq_flagman(5000).
|
||||
|
||||
%% @doc turn on backgroud runq check.
|
||||
-spec on() -> {ok, pid()} | {error, running | restarting | disabled}.
|
||||
on() ->
|
||||
-spec enable() -> {ok, pid()} | {error, running | restarting | disabled}.
|
||||
enable() ->
|
||||
case load_ctl:restart_runq_flagman() of
|
||||
{error, disabled} ->
|
||||
OldCfg = load_ctl:get_config(),
|
||||
|
|
|
@ -34,7 +34,7 @@ end_per_suite(_Config) ->
|
|||
emqx_ct_helpers:stop_apps([]).
|
||||
|
||||
init_per_testcase(_, Config) ->
|
||||
emqx_olp:on(),
|
||||
emqx_olp:enable(),
|
||||
case wait_for(fun() -> lc_sup:whereis_runq_flagman() end, 10) of
|
||||
true -> ok;
|
||||
false ->
|
||||
|
@ -51,11 +51,11 @@ init_per_testcase(_, Config) ->
|
|||
Config.
|
||||
|
||||
%% Test that olp could be enabled/disabled globally
|
||||
t_off_on(_Config) ->
|
||||
t_disable_enable(_Config) ->
|
||||
Old = load_ctl:whereis_runq_flagman(),
|
||||
ok = emqx_olp:off(),
|
||||
ok = emqx_olp:disable(),
|
||||
?assert(not is_process_alive(Old)),
|
||||
{ok, Pid} = emqx_olp:on(),
|
||||
{ok, Pid} = emqx_olp:enable(),
|
||||
timer:sleep(1000),
|
||||
?assert(is_process_alive(Pid)).
|
||||
|
||||
|
|
|
@ -505,16 +505,16 @@ olp(["status"]) ->
|
|||
false -> "not overloaded"
|
||||
end,
|
||||
emqx_ctl:print("~p is ~s ~n", [node(), S]);
|
||||
olp(["off"]) ->
|
||||
Res = emqx_olp:off(),
|
||||
emqx_ctl:print("Turn off overload protetion ~p : ~p ~n", [node(), Res]);
|
||||
olp(["on"]) ->
|
||||
Res = emqx_olp:on(),
|
||||
emqx_ctl:print("Turn on overload protection ~p : ~p ~n", [node(), Res]);
|
||||
olp(["disable"]) ->
|
||||
Res = emqx_olp:disable(),
|
||||
emqx_ctl:print("Disable overload protetion ~p : ~p ~n", [node(), Res]);
|
||||
olp(["enable"]) ->
|
||||
Res = emqx_olp:enable(),
|
||||
emqx_ctl:print("Enable overload protection ~p : ~p ~n", [node(), Res]);
|
||||
olp(_) ->
|
||||
emqx_ctl:usage([{"olp status", "Return OLP status if system is overloaded"},
|
||||
{"olp on", "Turn on overload protection"},
|
||||
{"olp off", "Turn off overload protection"}
|
||||
{"olp enable", "Enable overload protection"},
|
||||
{"olp disable", "Disable overload protection"}
|
||||
]).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue