class Fluent::Plugin::TailInput::GroupWatcher
Constants
- FileCounter
Attributes
current_paths[RW]
limit[RW]
number_lines_read[RW]
rate_period[RW]
start_reading_time[RW]
Public Class Methods
new(rate_period = 60, limit = -1)
click to toggle source
# File lib/fluent/plugin/in_tail/group_watch.rb, line 140 def initialize(rate_period = 60, limit = -1) @current_paths = {} @rate_period = rate_period @limit = limit end
Public Instance Methods
add(path)
click to toggle source
# File lib/fluent/plugin/in_tail/group_watch.rb, line 146 def add(path) @current_paths[path] = FileCounter.new(0, nil) end
delete(path)
click to toggle source
# File lib/fluent/plugin/in_tail/group_watch.rb, line 158 def delete(path) @current_paths.delete(path) end
include?(path)
click to toggle source
# File lib/fluent/plugin/in_tail/group_watch.rb, line 150 def include?(path) @current_paths.key?(path) end
limit_lines_reached?(path)
click to toggle source
# File lib/fluent/plugin/in_tail/group_watch.rb, line 183 def limit_lines_reached?(path) return true unless include?(path) return true if @limit == 0 return false if @limit < 0 return false if @current_paths[path].number_lines_read < @limit / size # update_reading_time(path) if limit_time_period_reached?(path) # Exceeds limit true else # Does not exceed limit reset_counter(path) false end end
limit_time_period_reached?(path)
click to toggle source
# File lib/fluent/plugin/in_tail/group_watch.rb, line 179 def limit_time_period_reached?(path) time_spent_reading(path) < @rate_period end
reset_counter(path)
click to toggle source
# File lib/fluent/plugin/in_tail/group_watch.rb, line 170 def reset_counter(path) @current_paths[path].start_reading_time = nil @current_paths[path].number_lines_read = 0 end
size()
click to toggle source
# File lib/fluent/plugin/in_tail/group_watch.rb, line 154 def size @current_paths.size end
time_spent_reading(path)
click to toggle source
# File lib/fluent/plugin/in_tail/group_watch.rb, line 175 def time_spent_reading(path) Fluent::Clock.now - @current_paths[path].start_reading_time end
to_s()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_tail/group_watch.rb, line 199 def to_s super + " current_paths: #{@current_paths} rate_period: #{@rate_period} limit: #{@limit}" end
update_lines_read(path, value)
click to toggle source
# File lib/fluent/plugin/in_tail/group_watch.rb, line 166 def update_lines_read(path, value) @current_paths[path].number_lines_read += value end
update_reading_time(path)
click to toggle source
# File lib/fluent/plugin/in_tail/group_watch.rb, line 162 def update_reading_time(path) @current_paths[path].start_reading_time ||= Fluent::Clock.now end