logstash-input-file 4.4.2 → 4.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/docs/index.asciidoc +0 -10
- data/lib/filewatch/read_mode/handlers/read_file.rb +10 -0
- data/lib/filewatch/read_mode/handlers/read_zip_file.rb +1 -1
- data/lib/jars/filewatch-1.0.1.jar +0 -0
- data/logstash-input-file.gemspec +1 -1
- data/spec/filewatch/read_mode_handlers_read_file_spec.rb +40 -0
- data/spec/filewatch/spec_helper.rb +2 -0
- data/spec/helpers/spec_helper.rb +7 -1
- data/spec/inputs/file_tail_spec.rb +2 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 318b69d75d8239cbc9287eac35038a576c48c8bd106e0841161d95320d262d81
|
|
4
|
+
data.tar.gz: 6e15365687edf5a185071708df3c56bdc341e67c76f6c0e4faabb516cf142bd2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 547e151e76062bc384d7e40fdfbc4cc79310d642c60aa0fbc2ff27971b820bb94979f78f3ef2515b2a1cff979bc9052c9202e7250257a1328ca4de97721b5da1
|
|
7
|
+
data.tar.gz: 4e6b547db17a8bc96d8741089d5c0d6b93e3169cc6b847a7133d3cbaf3de2b766c21c6683b71f7f8f6fe6150f2568ef160580391a8eee64a5825b6534df61162
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## 4.4.4
|
|
2
|
+
- Fixes gzip file handling in read mode when run on JDK12+, including JDK17 that is bundled with Logstash 8.4+ [#312](https://github.com/logstash-plugins/logstash-input-file/pull/312)
|
|
3
|
+
|
|
4
|
+
## 4.4.3
|
|
5
|
+
- Fixes read mode to restart the read from reference stored in sincedb in case the file wasn't completely consumed. [#307](https://github.com/logstash-plugins/logstash-input-file/pull/307)
|
|
6
|
+
|
|
1
7
|
## 4.4.2
|
|
2
8
|
- Doc: Fix attribute by removing extra character [#310](https://github.com/logstash-plugins/logstash-input-file/pull/310)
|
|
3
9
|
|
data/docs/index.asciidoc
CHANGED
|
@@ -9,11 +9,6 @@ START - GENERATED VARIABLES, DO NOT EDIT!
|
|
|
9
9
|
:release_date: %RELEASE_DATE%
|
|
10
10
|
:changelog_url: %CHANGELOG_URL%
|
|
11
11
|
:include_path: ../../../../logstash/docs/include
|
|
12
|
-
|
|
13
|
-
ifeval::["{versioned_docs}"=="true"]
|
|
14
|
-
:branch: %BRANCH%
|
|
15
|
-
:ecs_version: %ECS_VERSION%
|
|
16
|
-
endif::[]
|
|
17
12
|
///////////////////////////////////////////
|
|
18
13
|
END - GENERATED VARIABLES, DO NOT EDIT!
|
|
19
14
|
///////////////////////////////////////////
|
|
@@ -538,9 +533,4 @@ Supported values: `us` `usec` `usecs`, e.g. "600 us", "800 usec", "900 usecs"
|
|
|
538
533
|
[NOTE]
|
|
539
534
|
`micro` `micros` and `microseconds` are not supported
|
|
540
535
|
|
|
541
|
-
ifeval::["{versioned_docs}"=="true"]
|
|
542
|
-
:branch: current
|
|
543
|
-
:ecs_version: current
|
|
544
|
-
endif::[]
|
|
545
|
-
|
|
546
536
|
:default_codec!:
|
|
@@ -2,9 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
module FileWatch module ReadMode module Handlers
|
|
4
4
|
class ReadFile < Base
|
|
5
|
+
|
|
6
|
+
# seek file to which ever is furthest: either current bytes read or sincedb position
|
|
7
|
+
private
|
|
8
|
+
def seek_to_furthest_position(watched_file)
|
|
9
|
+
previous_pos = sincedb_collection.find(watched_file).position
|
|
10
|
+
watched_file.file_seek([watched_file.bytes_read, previous_pos].max)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
public
|
|
5
14
|
def handle_specifically(watched_file)
|
|
6
15
|
if open_file(watched_file)
|
|
7
16
|
add_or_update_sincedb_collection(watched_file) unless sincedb_collection.member?(watched_file.sincedb_key)
|
|
17
|
+
seek_to_furthest_position(watched_file)
|
|
8
18
|
loop do
|
|
9
19
|
break if quit?
|
|
10
20
|
loop_control = watched_file.loop_control_adjusted_for_stat_size
|
|
@@ -29,7 +29,7 @@ module FileWatch module ReadMode module Handlers
|
|
|
29
29
|
gzip_stream = GZIPInputStream.new(file_stream)
|
|
30
30
|
decoder = InputStreamReader.new(gzip_stream, "UTF-8")
|
|
31
31
|
buffered = BufferedReader.new(decoder)
|
|
32
|
-
while (line = buffered.readLine(
|
|
32
|
+
while (line = buffered.readLine())
|
|
33
33
|
watched_file.listener.accept(line)
|
|
34
34
|
# can't quit, if we did then we would incorrectly write a 'completed' sincedb entry
|
|
35
35
|
# what do we do about quit when we have just begun reading the zipped file (e.g. pipeline reloading)
|
|
Binary file
|
data/logstash-input-file.gemspec
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
|
|
3
3
|
s.name = 'logstash-input-file'
|
|
4
|
-
s.version = '4.4.
|
|
4
|
+
s.version = '4.4.4'
|
|
5
5
|
s.licenses = ['Apache-2.0']
|
|
6
6
|
s.summary = "Streams events from files"
|
|
7
7
|
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
|
@@ -36,5 +36,45 @@ module FileWatch
|
|
|
36
36
|
processor.read_file(watched_file)
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
|
+
|
|
40
|
+
context "when restart from existing sincedb" do
|
|
41
|
+
let(:settings) do
|
|
42
|
+
Settings.from_options(
|
|
43
|
+
:sincedb_write_interval => 0,
|
|
44
|
+
:sincedb_path => File::NULL,
|
|
45
|
+
:file_chunk_size => 10
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
let(:processor) { double("fake processor") }
|
|
50
|
+
let(:observer) { TestObserver.new }
|
|
51
|
+
let(:watch) { double("watch") }
|
|
52
|
+
|
|
53
|
+
before(:each) {
|
|
54
|
+
allow(watch).to receive(:quit?).and_return(false)#.and_return(false).and_return(true)
|
|
55
|
+
allow(processor).to receive(:watch).and_return(watch)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
it "read from where it left" do
|
|
59
|
+
listener = observer.listener_for(Pathname.new(pathname).to_path)
|
|
60
|
+
sut = ReadMode::Handlers::ReadFile.new(processor, sdb_collection, observer, settings)
|
|
61
|
+
|
|
62
|
+
# simulate a previous partial read of the file
|
|
63
|
+
sincedb_value = SincedbValue.new(0)
|
|
64
|
+
sincedb_value.set_watched_file(watched_file)
|
|
65
|
+
sdb_collection.set(watched_file.sincedb_key, sincedb_value)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# simulate a consumption of first line, (size + newline) bytes
|
|
69
|
+
sdb_collection.increment(watched_file.sincedb_key, File.readlines(pathname)[0].size + 2)
|
|
70
|
+
|
|
71
|
+
# exercise
|
|
72
|
+
sut.handle(watched_file)
|
|
73
|
+
|
|
74
|
+
# verify
|
|
75
|
+
expect(listener.lines.size).to eq(1)
|
|
76
|
+
expect(listener.lines[0]).to start_with("2010-03-12 23:51:21 SEA4 192.0.2.222 play 3914 OK")
|
|
77
|
+
end
|
|
78
|
+
end
|
|
39
79
|
end
|
|
40
80
|
end
|
data/spec/helpers/spec_helper.rb
CHANGED
|
@@ -31,7 +31,13 @@ module FileInput
|
|
|
31
31
|
|
|
32
32
|
def trace_for(symbol)
|
|
33
33
|
params = @tracer.map {|k,v| k == symbol ? v : nil}.compact
|
|
34
|
-
params.empty?
|
|
34
|
+
if params.empty?
|
|
35
|
+
false
|
|
36
|
+
else
|
|
37
|
+
# merge all params with same key
|
|
38
|
+
# there could be multiple instances of same call, e.g. [[:accept, true], [:auto_flush, true], [:close, true], [:auto_flush, true]]
|
|
39
|
+
params.reduce {|b1, b2| b1 and b2}
|
|
40
|
+
end
|
|
35
41
|
end
|
|
36
42
|
|
|
37
43
|
def clear
|
|
@@ -332,7 +332,7 @@ describe LogStash::Inputs::File do
|
|
|
332
332
|
.then("wait accept") do
|
|
333
333
|
wait(0.75).for {
|
|
334
334
|
subject.codec.identity_map[tmpfile_path].codec.trace_for(:accept)
|
|
335
|
-
}.to eq(
|
|
335
|
+
}.to eq(true), "accept didn't"
|
|
336
336
|
end
|
|
337
337
|
.then("request a stop") do
|
|
338
338
|
# without this the subject.run doesn't invokes the #exit_flush which is the only @codec.flush_mapped invocation
|
|
@@ -341,12 +341,11 @@ describe LogStash::Inputs::File do
|
|
|
341
341
|
.then("wait for auto_flush") do
|
|
342
342
|
wait(2).for {
|
|
343
343
|
subject.codec.identity_map[tmpfile_path].codec.trace_for(:auto_flush)
|
|
344
|
-
.reduce {|b1, b2| b1 and b2} # there could be multiple instances of same call, e.g. [[:accept, true], [:auto_flush, true], [:close, true], [:auto_flush, true]]
|
|
345
344
|
}.to eq(true), "autoflush didn't"
|
|
346
345
|
end
|
|
347
346
|
subject.run(events)
|
|
348
347
|
actions.assert_no_errors
|
|
349
|
-
expect(subject.codec.identity_map[tmpfile_path].codec.trace_for(:accept)).to eq(
|
|
348
|
+
expect(subject.codec.identity_map[tmpfile_path].codec.trace_for(:accept)).to eq(true)
|
|
350
349
|
end
|
|
351
350
|
end
|
|
352
351
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: logstash-input-file
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.4.
|
|
4
|
+
version: 4.4.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Elastic
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-
|
|
11
|
+
date: 2022-09-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|