Skip to content

Commit

Permalink
Merge pull request #19519 from kbrock/cu_capture_interval_priority
Browse files Browse the repository at this point in the history
introduce capture interval_priority
  • Loading branch information
agrare authored Nov 15, 2019
2 parents fe53386 + 5498df7 commit cc44b50
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions app/models/metric/capture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ module Metric::Capture
REALTIME_PRIORITY = HOURLY_PRIORITY = DAILY_PRIORITY = MiqQueue::NORMAL_PRIORITY
HISTORICAL_PRIORITY = MiqQueue::LOW_PRIORITY

# @param [String[ capture interval
# @return [Integer] MiqQueue priority level for this message
def self.interval_priority(interval)
interval == "historical" ? MiqQueue::LOW_PRIORITY : MiqQueue::NORMAL_PRIORITY
end

def self.capture_cols
@capture_cols ||= Metric.columns_hash.collect { |c, h| c.to_sym if h.type == :float && c[0, 7] != "derived" }.compact
end
Expand Down Expand Up @@ -193,6 +199,8 @@ def self.calc_target_options(zone, targets_by_rollup_parent)
end
private_class_method :calc_target_options

# @param targets [Array<Object>] list of the targets for capture (from `capture_ems_targets`)
# @param target_options [ Hash{Object => Hash{Symbol => Object}}] list of options indexed by target
def self.queue_captures(targets, target_options)
# Queue the captures for each target
use_historical = historical_days != 0
Expand Down
2 changes: 1 addition & 1 deletion app/models/metric/ci_mixin/capture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def split_capture_intervals(interval_name, start_time, end_time, threshold = 1.d
def perf_capture_queue(interval_name, options = {})
start_time = options[:start_time]&.utc
end_time = options[:end_time]&.utc
priority = options[:priority] || Metric::Capture.const_get("#{interval_name.upcase}_PRIORITY")
priority = options[:priority] || Metric::Capture.interval_priority(interval_name)
task_id = options[:task_id]
zone = options[:zone] || my_zone
zone = zone.name if zone.respond_to?(:name)
Expand Down
2 changes: 1 addition & 1 deletion app/models/metric/ci_mixin/rollup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def perf_rollup_queue(time, interval_name, time_profile = nil)
:role => 'ems_metrics_processor',
:queue_name => 'ems_metrics_processor',
:deliver_on => deliver_on,
:priority => Metric::Capture.const_get("#{interval_name.upcase}_PRIORITY")
:priority => Metric::Capture.interval_priority(interval_name)
) do |msg|
_log.debug("Skipping queueing [#{interval_name}] rollup of #{self.class.name} name: [#{name}], id: [#{id}] for time: [#{time}], since it is already queued") unless msg.nil?
end
Expand Down

0 comments on commit cc44b50

Please sign in to comment.