Class: Fluent::CatSweepInput
- Inherits:
-
Input
- Object
- Input
- Fluent::CatSweepInput
show all
- Defined in:
- lib/fluent/plugin/in_cat_sweep.rb
Defined Under Namespace
Classes: FormatError, OneLineMaxBytesOverError
Instance Method Summary
collapse
Instance Method Details
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/fluent/plugin/in_cat_sweep.rb', line 35
def configure(conf)
super
@parser = Plugin.new_parser(@format)
@parser.configure(conf)
if @processing_file_suffix.empty?
raise Fluent::ConfigError, "in_cat_sweep: `processing_file_suffix` must has some letters."
end
if @error_file_suffix.empty?
raise Fluent::ConfigError, "in_cat_sweep: `error_file_suffix` must has some letters."
end
if @line_terminated_by.empty?
raise Fluent::ConfigError, "in_cat_sweep: `line_terminated_by` must has some letters."
end
if !remove_file?
first_filename = Dir.glob(@file_path_with_glob).first
dirname = first_filename ? move_dirname(first_filename) : @move_to
if Dir.exist?(dirname)
if !File.writable?(dirname)
raise Fluent::ConfigError, "in_cat_sweep: `move_to` directory (#{dirname}) must be writable."
end
else
begin
FileUtils.mkdir_p(dirname)
rescue => e
raise Fluent::ConfigError, "in_cat_sweep: `move_to` directory (#{dirname}) must be writable."
end
end
end
@read_bytes_once = 262144
end
|
#run_periodic ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/fluent/plugin/in_cat_sweep.rb', line 83
def run_periodic
while @processing
sleep @run_interval
Dir.glob(@file_path_with_glob).map do |filename|
next unless will_process?(filename)
processing_filename = get_processing_filename(filename)
begin
lock_with_renaming(filename, processing_filename) do
process(filename, processing_filename)
after_processing(processing_filename)
end
rescue => e
log.error "in_cat_sweep: processing: #{processing_filename}", :error => e, :error_class => e.class
log.error_backtrace
safe_fail(e, processing_filename)
end
end
end
end
|
#shutdown ⇒ Object
78
79
80
81
|
# File 'lib/fluent/plugin/in_cat_sweep.rb', line 78
def shutdown
@processing = false
@thread.join
end
|
#start ⇒ Object
73
74
75
76
|
# File 'lib/fluent/plugin/in_cat_sweep.rb', line 73
def start
@processing = true
@thread = Thread.new(&method(:run_periodic))
end
|