Monitor cluster partition event (#2814)
This commit is contained in:
parent
c69a2b1b48
commit
8710df31b2
|
@ -3,7 +3,7 @@
|
||||||
{cowboy, "2.6.1"}, % hex
|
{cowboy, "2.6.1"}, % hex
|
||||||
{gproc, "0.8.0"}, % hex
|
{gproc, "0.8.0"}, % hex
|
||||||
{esockd, "5.5.0"}, %hex
|
{esockd, "5.5.0"}, %hex
|
||||||
{ekka, "0.6.0"}, %hex
|
{ekka, "0.6.1"}, %hex
|
||||||
{gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.4.1"}}},
|
{gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.4.1"}}},
|
||||||
{cuttlefish, {git, "https://github.com/emqx/cuttlefish", {tag, "v3.0.0"}}}
|
{cuttlefish, {git, "https://github.com/emqx/cuttlefish", {tag, "v3.0.0"}}}
|
||||||
]}.
|
]}.
|
||||||
|
|
|
@ -57,6 +57,10 @@ start_link(Opts) ->
|
||||||
init([Opts]) ->
|
init([Opts]) ->
|
||||||
erlang:system_monitor(self(), parse_opt(Opts)),
|
erlang:system_monitor(self(), parse_opt(Opts)),
|
||||||
emqx_logger:set_proc_metadata(#{sysmon => true}),
|
emqx_logger:set_proc_metadata(#{sysmon => true}),
|
||||||
|
|
||||||
|
%% Monitor cluster partition event
|
||||||
|
ekka:monitor(partition, fun handle_partition_event/1),
|
||||||
|
|
||||||
{ok, start_timer(#{timer => undefined, events => []})}.
|
{ok, start_timer(#{timer => undefined, events => []})}.
|
||||||
|
|
||||||
start_timer(State) ->
|
start_timer(State) ->
|
||||||
|
@ -156,6 +160,15 @@ terminate(_Reason, #{timer := TRef}) ->
|
||||||
code_change(_OldVsn, State, _Extra) ->
|
code_change(_OldVsn, State, _Extra) ->
|
||||||
{ok, State}.
|
{ok, State}.
|
||||||
|
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
%% Internal Functions
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
|
handle_partition_event({partition, {occurred, Node}}) ->
|
||||||
|
alarm_handler:set_alarm({partitioned, Node});
|
||||||
|
handle_partition_event({partition, {healed, Node}}) ->
|
||||||
|
alarm_handler:clear_alarm(partitioned).
|
||||||
|
|
||||||
suppress(Key, SuccFun, State = #{events := Events}) ->
|
suppress(Key, SuccFun, State = #{events := Events}) ->
|
||||||
case lists:member(Key, Events) of
|
case lists:member(Key, Events) of
|
||||||
true -> {noreply, State};
|
true -> {noreply, State};
|
||||||
|
|
Loading…
Reference in New Issue