Class: Fluent::Plugin::CatSweepInput
- Inherits:
-
Input
- Object
- Input
- Fluent::Plugin::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
30
31
32
33
34
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
|
# File 'lib/fluent/plugin/in_cat_sweep.rb', line 30
def configure(conf)
compat_parameters_convert(conf, :parser, :buffer, default_chunk_key: "time")
super
configure_parser(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
raise Fluent::ConfigError, "in_cat_sweep: `move_to` directory (#{dirname}) must be writable."
end
end
end
@read_bytes_once = 262144
end
|
#run_periodic ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/fluent/plugin/in_cat_sweep.rb', line 82
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
75
76
77
78
79
80
|
# File 'lib/fluent/plugin/in_cat_sweep.rb', line 75
def shutdown
@processing = false
@thread.join
super
end
|
#start ⇒ Object
68
69
70
71
72
73
|
# File 'lib/fluent/plugin/in_cat_sweep.rb', line 68
def start
super
@processing = true
@thread = Thread.new(&method(:run_periodic))
end
|