Skip to content
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

Avoid double notifying on node termination. #37

Merged
merged 1 commit into from
Dec 20, 2023
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
18 changes: 7 additions & 11 deletions src/aten.erl
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,19 @@
start/0,
register/1,
unregister/1
]).

-export_type([
]).

]).

start() ->
application:ensure_all_started(aten).

-spec register(node()) -> ok.
-spec register(node()) -> ok | ignore.
register(Node) when Node == node() ->
ignore;
register(Node) ->
aten_detector:register(Node).

-spec unregister(node()) -> ok.
-spec unregister(node()) -> ok | ignore.
unregister(Node) when Node == node() ->
ignore;
unregister(Node) ->
aten_detector:unregister(Node).

-ifdef(TEST).
-include_lib("eunit/include/eunit.hrl").
-endif.
12 changes: 10 additions & 2 deletions src/aten_detector.erl
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,18 @@ analyse_one(_Curr, _Prev, _Thresh) ->
no_change.

analyse(Curr, Prev, Thresh) ->
Down0 = maps:fold(fun (N, _S, Acc) ->
Down0 = maps:fold(fun (N, Sample, Acc) ->
case maps:get(N, Curr, undefined) of
undefined ->
[N | Acc];
case Sample >= Thresh of
true ->
%% already down
%% this should already have been
%% been notified
Acc;
_ ->
[N | Acc]
end;
_ ->
Acc
end
Expand Down
2 changes: 0 additions & 2 deletions src/aten_sink.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

-behaviour(gen_server).

-include_lib("kernel/include/logger.hrl").

%% API functions
-export([start_link/0,
get_failure_probabilities/0,
Expand Down
Loading