Skip to content

Commit

Permalink
Metric::Purging normalization
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
kbrock committed Apr 7, 2017
1 parent a84c909 commit ecb49ef
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions app/models/metric/purging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}]...")
Expand Down

0 comments on commit ecb49ef

Please sign in to comment.