class Ring::SQA::Analyzer
Constants
- INFLIGHT_WAIT
- INTERVAL
Public Class Methods
Source
# File lib/ring/sqa/analyzer.rb, line 38 def initialize database, nodes @db = database @nodes = nodes @alarm = Alarm.new @nodes @buffer = AnalyzeBuffer.new @nodes.all.size @db_id_seen = 0 @graphite = graphite if CFG.graphite? @influxdb = influxdb if CFG.influxdb? end
Public Instance Methods
Source
# File lib/ring/sqa/analyzer.rb, line 9 def run sleep INTERVAL loop do start = Time.now @db.purge first_id = @db_id_seen+1 @db_id_seen, records = @db.nodes_down(first_id) sleep INFLIGHT_WAIT records = records.all @graphite.add @db.id_range(first_id, @db_id_seen).all if @graphite @influxdb.add @db.id_range(first_id, @db_id_seen).all if @influxdb @buffer.push records.map { |record| record.peer } @buffer.exceed_median? ? @alarm.set(@buffer) : @alarm.clear(@buffer) delay = INTERVAL-(Time.now-start) # in case delay happens to be too big if delay > INTERVAL delay = INTERVAL Log.warn "delay became larger than #{INTERVAL}, capping it. (did ntp just sync?)" end if delay > 0 sleep delay else Log.error "Analyzer loop took longer than #{INTERVAL}, wanted to sleep for #{delay}s" end end end
Private Instance Methods
Source
# File lib/ring/sqa/analyzer.rb, line 48 def graphite require_relative 'graphite' Graphite.new @nodes end
Source
# File lib/ring/sqa/analyzer.rb, line 53 def influxdb require_relative 'influxdb' InfluxDBWriter.new @nodes end