Revert "Delete metrics for all deleted queues in 4 ETS operations (master)"

This commit is contained in:
Michael Klishin 2018-03-28 21:31:39 +03:00 committed by GitHub
parent aae5a663e7
commit ffe132d823
2 changed files with 2 additions and 68 deletions

View File

@ -40,8 +40,7 @@
-export([queue_stats/2,
queue_stats/5,
queue_deleted/1,
queues_deleted/1]).
queue_deleted/1]).
-export([node_stats/2]).
@ -242,71 +241,6 @@ queue_deleted(Name) ->
ets:update_element(channel_queue_metrics, Key, {8, 1})
end, CQ).
queues_deleted(Queues) ->
[ delete_queue_metrics(Queue) || Queue <- Queues ],
[
begin
MatchSpecCondition = build_match_spec_conditions_to_delete_all_queues(QueuesPartition),
delete_channel_queue_exchange_metrics(MatchSpecCondition),
delete_channel_queue_metrics(MatchSpecCondition)
end || QueuesPartition <- partition_queues(Queues)
],
ok.
partition_queues(Queues) when length(Queues) >= 1000 ->
{Partition, Rest} = lists:split(1000, Queues),
[Partition | partition_queues(Rest)];
partition_queues(Queues) ->
[Queues].
delete_queue_metrics(Queue) ->
ets:delete(queue_coarse_metrics, Queue),
ets:update_element(queue_metrics, Queue, {3, 1}),
ok.
delete_channel_queue_exchange_metrics(MatchSpecCondition) ->
ets:select_replace(
channel_queue_exchange_metrics,
[
{
{{'$2', {'$1', '$3'}}, '$4', '_'},
[MatchSpecCondition],
[{{{{'$2', {{'$1', '$3'}}}}, '$4', 1}}]
}
]
).
delete_channel_queue_metrics(MatchSpecCondition) ->
ets:select_replace(
channel_queue_metrics,
[
{
{{'$2', '$1'}, '$3', '$4', '$5', '$6', '$7', '$8', '_'},
[MatchSpecCondition],
[{{{{'$2', '$1'}}, '$3', '$4', '$5', '$6', '$7', '$8', 1}}]
}
]
).
% [{'orelse',
% {'==', {Queue}, '$1'},
% {'orelse',
% {'==', {Queue}, '$1'},
% % ...
% {'orelse',
% {'==', {Queue}, '$1'},
% {'==', true, true}
% }
% }
% }],
build_match_spec_conditions_to_delete_all_queues([Queue|Queues]) ->
{'orelse',
{'==', {Queue}, '$1'},
build_match_spec_conditions_to_delete_all_queues(Queues)
};
build_match_spec_conditions_to_delete_all_queues([]) ->
true.
node_stats(persister_metrics, Infos) ->
ets:insert(node_persister_metrics, {node(), Infos}),
ok;

View File

@ -65,7 +65,7 @@
%%----------------------------------------------------------------------------
start_link() ->
gen_event:start_link({local, ?MODULE}, [{spawn_opt, [{fullsweep_after, 0}]}]).
gen_event:start_link({local, ?MODULE}).
%% The idea is, for each stat-emitting object:
%%