Class: Humboldt::HadoopStatusFilter
- Inherits:
-
Object
- Object
- Humboldt::HadoopStatusFilter
- Defined in:
- lib/humboldt/hadoop_status_filter.rb
Instance Method Summary collapse
-
#initialize(hadoop_stderr, shell, silent) ⇒ HadoopStatusFilter
constructor
A new instance of HadoopStatusFilter.
- #run ⇒ Object
Constructor Details
#initialize(hadoop_stderr, shell, silent) ⇒ HadoopStatusFilter
Returns a new instance of HadoopStatusFilter.
5 6 7 8 9 10 |
# File 'lib/humboldt/hadoop_status_filter.rb', line 5 def initialize(hadoop_stderr, shell, silent) @hadoop_stderr = hadoop_stderr @shell = shell @silent = silent @counters = {} end |
Instance Method Details
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/humboldt/hadoop_status_filter.rb', line 12 def run counter_group = nil while line = @hadoop_stderr.gets if @counters_printing && (hadoop_log?(line) || line =~ /^\t+/) case line.chomp when /(?:JobClient: |\t+)([^\t]+)=(\d+)$/ if counter_group @counters[counter_group] ||= {} @counters[counter_group][$1.strip] = $2.to_i end when /(?:JobClient: |\t+)([^\t]+)$/ counter_group = $1.strip end elsif @error_printing && !hadoop_log?(line) && !ignore?(line) report_error(line) elsif ignore?(line) # do nothing else @counters_printing = false @error_printing = false case line when /map (\d+)% reduce (\d+)%/ report_progress($1, $2) when /Counters: \d+/ @counters_printing = true else unless hadoop_log?(line) @error_printing = true if line =~ /warning(!|:)/i @error_type = :warning else @error_type = :error end report_error(line) end end end @shell.say(line.chomp, :red) unless @silent end print_counters_table end |