lib/ring/sqa/analyzer.rb in ring-sqa-0.2.1 vs lib/ring/sqa/analyzer.rb in ring-sqa-0.2.2
- old
+ new
@@ -9,13 +9,15 @@
def run
sleep INTERVAL
loop do
start = Time.now
@db.purge
- @db_id_seen, records = @db.nodes_down(@db_id_seen+1)
+ 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
@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
@@ -36,10 +38,17 @@
@db = database
@nodes = nodes
@alarm = Alarm.new @nodes
@buffer = AnalyzeBuffer.new @nodes.all.size
@db_id_seen = 0
+ @graphite = graphite if CFG.graphite?
end
+
+ def graphite
+ require_relative 'graphite'
+ Graphite.new
+ end
+
end
class AnalyzeBuffer
attr_reader :array
def initialize nodes_count, max_size=CFG.analyzer.size, median_of=CFG.analyzer.median_of