chore(emqx_cm): rm periodic count refresh after review

This will be done in another PR, if needed.
This commit is contained in:
Thales Macedo Garitezi 2021-11-05 13:51:47 -03:00
parent eb5e1a5cb9
commit 1fa7e70081
No known key found for this signature in database
GPG Key ID: DD279F8152A9B6DD
1 changed files with 2 additions and 24 deletions

View File

@ -450,11 +450,8 @@ init([]) ->
CRef = counters:new(1, [write_concurrency]),
ok = persistent_term:put({?MODULE, ?CONN_CLIENT_CTR}, CRef),
ok = emqx_stats:update_interval(chan_stats, fun ?MODULE:stats_fun/0),
RefreshPeriod = application:get_env(emqx, connected_client_count_refresh_period, 60000),
State = #{ chan_pmon => emqx_pmon:new()
, connected_client_refresh_period => RefreshPeriod
},
{ok, ensure_refresh_timer(State)}.
State = #{chan_pmon => emqx_pmon:new()},
{ok, State}.
handle_call(Req, _From, State) ->
?LOG(error, "Unexpected call: ~p", [Req]),
@ -483,17 +480,6 @@ handle_info({'DOWN', _MRef, process, Pid, _Reason}, State = #{chan_pmon := PMon}
Items),
ok = emqx_pool:async_submit(fun lists:foreach/2, [fun ?MODULE:clean_down/1, Items]),
{noreply, State#{chan_pmon := PMon1}};
handle_info({timeout, TRef, refresh_connected_client_count},
State0 = #{connected_client_refresh_timer := TRef}) ->
CCCount = refresh_connected_client_count(),
?tp(emqx_cm_refresh_connected_client_count,
#{ new_count => CCCount
, old_count => get_connected_client_count()
}),
CRef = persistent_term:get({?MODULE, ?CONN_CLIENT_CTR}),
ok = counters:put(CRef, ?CONN_CLIENT_CTR_IDX, CCCount),
State = ensure_refresh_timer(State0),
{noreply, State};
handle_info(Info, State) ->
?LOG(error, "Unexpected info: ~p", [Info]),
{noreply, State}.
@ -549,11 +535,3 @@ decrement_connected_client_count() ->
get_connected_client_count() ->
CRef = persistent_term:get({?MODULE, ?CONN_CLIENT_CTR}),
max(0, counters:get(CRef, ?CONN_CLIENT_CTR_IDX)).
ensure_refresh_timer(State = #{connected_client_refresh_period := RefreshPeriod}) ->
TRef = emqx_misc:start_timer(RefreshPeriod, refresh_connected_client_count),
State#{connected_client_refresh_timer => TRef}.
refresh_connected_client_count() ->
Spec = [{{'_', #{conn_state => connected}, '_'}, [], [true]}],
ets:select_count(?CHAN_INFO_TAB, Spec).