From ecb49efc1144093376445566bb0828e4afffee36 Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Thu, 6 Apr 2017 16:07:09 -0400 Subject: [PATCH] Metric::Purging normalization - converted put_or_update to put on general queue - introduce purge_by_date concept (which is just naming) NOTE: this is still not a typical purger --- app/models/metric/purging.rb | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/app/models/metric/purging.rb b/app/models/metric/purging.rb index d33f09d7386..c7c5d4d6e74 100644 --- a/app/models/metric/purging.rb +++ b/app/models/metric/purging.rb @@ -36,14 +36,11 @@ def self.purge_realtime_timer(ts = nil) end def self.purge_timer(ts, interval) - MiqQueue.put_unless_exists( + MiqQueue.put( :class_name => name, :method_name => "purge_#{interval}", - :role => "ems_metrics_processor", - :queue_name => "ems_metrics_processor" - ) do |_msg, find_options| - find_options.merge(:args => [ts]) - end + :args => [ts], + ) end def self.purge_window_size @@ -75,18 +72,22 @@ def self.purge_associated_records(metric_type, ids) end def self.purge_daily(older_than, window = nil, total_limit = nil, &block) - purge(older_than, "daily", window, total_limit, &block) + purge_by_date(older_than, "daily", window, total_limit, &block) end def self.purge_hourly(older_than, window = nil, total_limit = nil, &block) - purge(older_than, "hourly", window, total_limit, &block) + purge_by_date(older_than, "hourly", window, total_limit, &block) end def self.purge_realtime(older_than, window = nil, total_limit = nil, &block) - purge(older_than, "realtime", window, total_limit, &block) + purge_by_date(older_than, "realtime", window, total_limit, &block) end def self.purge(older_than, interval, window = nil, total_limit = nil, &block) + purge_by_date(older_than, interval, window, total_limit, &block) + end + + def self.purge_by_date(older_than, interval, window = nil, total_limit = nil, &block) scope = purge_scope(older_than, interval) window ||= purge_window_size _log.info("Purging #{total_limit || "all"} #{interval} metrics older than [#{older_than}]...")