From: William Morgan Date: Mon, 4 May 2009 12:32:06 +0000 (-0700) Subject: improve sup-sync output X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=59132d4251c8ef694579723b7b19f731aeaab25d;p=sup improve sup-sync output Report every 15 seconds, and show the sender for added messages. --- diff --git a/bin/sup-sync b/bin/sup-sync index 4d7a3d3..01dbaa7 100644 --- a/bin/sup-sync +++ b/bin/sup-sync @@ -5,6 +5,8 @@ require 'rubygems' require 'trollop' require "sup" +PROGRESS_UPDATE_INTERVAL = 15 # seconds + class Float def to_s; sprintf '%.2f', self; end def to_time_s @@ -139,6 +141,15 @@ begin num_scanned += 1 seen[m.id] = true + if Time.now - last_info_time > PROGRESS_UPDATE_INTERVAL + last_info_time = Time.now + elapsed = last_info_time - start_time + start = opts[:start_at] || source.start_offset + pctdone = 100.0 * (source.cur_offset - start).to_f / (source.end_offset - start).to_f + remaining = (100.0 - pctdone) * (elapsed.to_f / pctdone) + $stderr.printf "## read %dm (about %.0f%%) @ %.1fm/s. %s elapsed, about %s remaining\n", num_scanned, pctdone, num_scanned / elapsed, elapsed.to_time_s, remaining.to_time_s + end + ## skip if we're operating only on changed messages, the message ## is in the index, and it's unchanged from what the source is ## reporting. @@ -173,16 +184,8 @@ begin ## nothin! use default source labels end - if Time.now - last_info_time > 60 - last_info_time = Time.now - elapsed = last_info_time - start_time - pctdone = source.respond_to?(:pct_done) ? source.pct_done : 100.0 * (source.cur_offset.to_f - source.start_offset).to_f / (source.end_offset - source.start_offset).to_f - remaining = (100.0 - pctdone) * (elapsed.to_f / pctdone) - $stderr.puts "## #{num_scanned} (#{pctdone}%) read; #{elapsed.to_time_s} elapsed; #{remaining.to_time_s} remaining" - end - if index_state.nil? - puts "Adding message #{source}##{offset} with state {#{m.labels * ', '}}" if opts[:verbose] + puts "Adding message #{source}##{offset} from #{m.from} with state {#{m.labels * ', '}}" if opts[:verbose] num_added += 1 else puts "Updating message #{source}##{offset}, source #{entry[:source_id]} => #{source.id}, offset #{entry[:source_info]} => #{offset}, state {#{index_state * ', '}} => {#{m.labels * ', '}}" if opts[:verbose]