logstash-input-file 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/logstash/inputs/identity_map_codec_component.rb +56 -0
- data/logstash-input-file.gemspec +1 -1
- data/spec/inputs/file_spec.rb +1 -1
- data/spec/spec_helper.rb +64 -57
- metadata +34 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a518dc6300f2a903753525dcf94fc0f584c7e649
|
4
|
+
data.tar.gz: da489dd9356805859dca510bb43b22a8d87a619d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8f9f23d212d58b1a8fa491ee66d988352877dc9726cd728dc3ac520849985001b3f916c636142fa8a9dd7e5301bb34c95d27a61201e8df0858626995abb5f2a
|
7
|
+
data.tar.gz: 094901654c14d47f5216b9d4382b1006f1f94150c67e3a83ddacfd1f6e086b0d84692c186937c6c57515c455a597cb1f11c3e47cfc4200b25953dc63793773ff
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/inputs/component"
|
3
|
+
require "logstash/codecs/identity_map_codec"
|
4
|
+
|
5
|
+
module LogStash module Inputs class IdentityMapCodecComponent
|
6
|
+
include Component
|
7
|
+
|
8
|
+
attr_reader :codec
|
9
|
+
|
10
|
+
def add_codec(codec)
|
11
|
+
@codec = LogStash::Codecs::IdentityMapCodec.new(codec)
|
12
|
+
self
|
13
|
+
end
|
14
|
+
|
15
|
+
def stop
|
16
|
+
@codec.close
|
17
|
+
end
|
18
|
+
|
19
|
+
def do_work(context, data)
|
20
|
+
do_line(context, data) || do_eviction(context, data)
|
21
|
+
end
|
22
|
+
|
23
|
+
def process(context, data)
|
24
|
+
# data should be an event
|
25
|
+
deliver(context, data)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def do_line(context, data)
|
31
|
+
return false unless line?(context)
|
32
|
+
@codec.decode_accept(context, data, self)
|
33
|
+
# above should call back on #process
|
34
|
+
true
|
35
|
+
end
|
36
|
+
|
37
|
+
def do_eviction(context, data)
|
38
|
+
return false unless evicting?(context)
|
39
|
+
path = context[:path]
|
40
|
+
@codec.evict(path) if path
|
41
|
+
true
|
42
|
+
end
|
43
|
+
|
44
|
+
def line?(ctx)
|
45
|
+
action(ctx) == "line"
|
46
|
+
end
|
47
|
+
|
48
|
+
def evicting?(ctx)
|
49
|
+
_action = action(ctx)
|
50
|
+
_action == "timed_out" || _action == "deleted"
|
51
|
+
end
|
52
|
+
|
53
|
+
def action(ctx)
|
54
|
+
ctx[:action]
|
55
|
+
end
|
56
|
+
end end end
|
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 = '2.1.
|
4
|
+
s.version = '2.1.2'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Stream 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/plugin install gemname. This gem is not a stand-alone program"
|
data/spec/inputs/file_spec.rb
CHANGED
@@ -147,7 +147,7 @@ describe LogStash::Inputs::File do
|
|
147
147
|
let(:mlconf) { Hash.new }
|
148
148
|
let(:events) { Array.new }
|
149
149
|
let(:mlcodec) { LogStash::Codecs::Multiline.new(mlconf) }
|
150
|
-
let(:codec) { CodecTracer.new }
|
150
|
+
let(:codec) { FileInput::CodecTracer.new }
|
151
151
|
let(:tmpfile_path) { Stud::Temporary.pathname }
|
152
152
|
let(:sincedb_path) { Stud::Temporary.pathname }
|
153
153
|
let(:tmpdir_path) { Stud::Temporary.directory }
|
data/spec/spec_helper.rb
CHANGED
@@ -2,78 +2,85 @@
|
|
2
2
|
|
3
3
|
require "logstash/devutils/rspec/spec_helper"
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
module FileInput
|
6
|
+
class TracerBase
|
7
|
+
def initialize() @tracer = []; end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
def trace_for(symbol)
|
10
|
+
params = @tracer.map {|k,v| k == symbol ? v : nil}.compact
|
11
|
+
params.empty? ? false : params
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
def clear()
|
15
|
+
@tracer.clear()
|
16
|
+
end
|
15
17
|
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class FileLogTracer < TracerBase
|
19
|
-
def warn(*args) @tracer.push [:warn, args]; end
|
20
|
-
def error(*args) @tracer.push [:error, args]; end
|
21
|
-
def debug(*args) @tracer.push [:debug, args]; end
|
22
|
-
def info(*args) @tracer.push [:info, args]; end
|
23
18
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
class ComponentTracer < TracerBase
|
31
|
-
def accept(*args) @tracer.push [:accept, args]; end
|
32
|
-
def deliver(*args) @tracer.push [:deliver, args]; end
|
33
|
-
end
|
19
|
+
class FileLogTracer < TracerBase
|
20
|
+
def warn(*args) @tracer.push [:warn, args]; end
|
21
|
+
def error(*args) @tracer.push [:error, args]; end
|
22
|
+
def debug(*args) @tracer.push [:debug, args]; end
|
23
|
+
def info(*args) @tracer.push [:info, args]; end
|
34
24
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
def accept(listener)
|
41
|
-
@tracer.push [:accept, true]
|
42
|
-
end
|
43
|
-
def auto_flush()
|
44
|
-
@tracer.push [:auto_flush, true]
|
25
|
+
def info?() true; end
|
26
|
+
def debug?() true; end
|
27
|
+
def warn?() true; end
|
28
|
+
def error?() true; end
|
45
29
|
end
|
46
|
-
|
47
|
-
|
30
|
+
|
31
|
+
class ComponentTracer < TracerBase
|
32
|
+
def accept(*args) @tracer.push [:accept, args]; end
|
33
|
+
def deliver(*args) @tracer.push [:deliver, args]; end
|
48
34
|
end
|
49
|
-
|
50
|
-
|
35
|
+
|
36
|
+
class CodecTracer < TracerBase
|
37
|
+
def decode_accept(ctx, data, listener)
|
38
|
+
@tracer.push [:decode_accept, [ctx, data]]
|
39
|
+
listener.process(ctx, {"message" => data})
|
40
|
+
end
|
41
|
+
def accept(listener)
|
42
|
+
@tracer.push [:accept, true]
|
43
|
+
end
|
44
|
+
def auto_flush()
|
45
|
+
@tracer.push [:auto_flush, true]
|
46
|
+
end
|
47
|
+
def close
|
48
|
+
@tracer.push [:close, true]
|
49
|
+
end
|
50
|
+
def clone
|
51
|
+
self.class.new
|
52
|
+
end
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
56
|
+
unless Kernel.method_defined?(:pause_until)
|
57
|
+
module Kernel
|
58
|
+
def pause_until(nap = 5, &block)
|
59
|
+
sq = SizedQueue.new(1)
|
60
|
+
th1 = Thread.new(sq) {|q| sleep nap; q.push(false) }
|
61
|
+
th2 = Thread.new(sq) do |q|
|
62
|
+
success = false
|
63
|
+
iters = nap * 5 + 1
|
64
|
+
iters.times do
|
65
|
+
break if !!(success = block.call)
|
66
|
+
sleep(0.2)
|
67
|
+
end
|
68
|
+
q.push(success)
|
64
69
|
end
|
65
|
-
|
70
|
+
sq.pop
|
66
71
|
end
|
67
|
-
sq.pop
|
68
72
|
end
|
69
73
|
end
|
70
74
|
|
71
|
-
RSpec::Matchers.
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
+
unless RSpec::Matchers.method_defined?(:receive_call_and_args)
|
76
|
+
RSpec::Matchers.define(:receive_call_and_args) do |m, args|
|
77
|
+
match do |actual|
|
78
|
+
actual.trace_for(m) == args
|
79
|
+
end
|
75
80
|
|
76
|
-
|
77
|
-
|
81
|
+
failure_message do
|
82
|
+
"Expecting method #{m} to receive: #{args} but got: #{actual.trace_for(m)}"
|
83
|
+
end
|
78
84
|
end
|
79
85
|
end
|
86
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-file
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
@@ -11,8 +11,7 @@ cert_chain: []
|
|
11
11
|
date: 2015-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
|
15
|
-
version_requirements: !ruby/object:Gem::Requirement
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
16
|
- - '>='
|
18
17
|
- !ruby/object:Gem::Version
|
@@ -20,7 +19,10 @@ dependencies:
|
|
20
19
|
- - <
|
21
20
|
- !ruby/object:Gem::Version
|
22
21
|
version: 3.0.0
|
23
|
-
|
22
|
+
name: logstash-core
|
23
|
+
prerelease: false
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
26
|
requirements:
|
25
27
|
- - '>='
|
26
28
|
- !ruby/object:Gem::Version
|
@@ -28,46 +30,35 @@ dependencies:
|
|
28
30
|
- - <
|
29
31
|
- !ruby/object:Gem::Version
|
30
32
|
version: 3.0.0
|
31
|
-
prerelease: false
|
32
|
-
type: :runtime
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name: logstash-codec-plain
|
35
|
-
version_requirements: !ruby/object:Gem::Requirement
|
36
|
-
requirements:
|
37
|
-
- - '>='
|
38
|
-
- !ruby/object:Gem::Version
|
39
|
-
version: '0'
|
40
34
|
requirement: !ruby/object:Gem::Requirement
|
41
35
|
requirements:
|
42
36
|
- - '>='
|
43
37
|
- !ruby/object:Gem::Version
|
44
38
|
version: '0'
|
39
|
+
name: logstash-codec-plain
|
45
40
|
prerelease: false
|
46
41
|
type: :runtime
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: addressable
|
49
42
|
version_requirements: !ruby/object:Gem::Requirement
|
50
43
|
requirements:
|
51
44
|
- - '>='
|
52
45
|
- !ruby/object:Gem::Version
|
53
46
|
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
54
48
|
requirement: !ruby/object:Gem::Requirement
|
55
49
|
requirements:
|
56
50
|
- - '>='
|
57
51
|
- !ruby/object:Gem::Version
|
58
52
|
version: '0'
|
53
|
+
name: addressable
|
59
54
|
prerelease: false
|
60
55
|
type: :runtime
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: filewatch
|
63
56
|
version_requirements: !ruby/object:Gem::Requirement
|
64
57
|
requirements:
|
65
58
|
- - '>='
|
66
59
|
- !ruby/object:Gem::Version
|
67
|
-
version: 0
|
68
|
-
|
69
|
-
- !ruby/object:Gem::Version
|
70
|
-
version: '0.7'
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
71
62
|
requirement: !ruby/object:Gem::Requirement
|
72
63
|
requirements:
|
73
64
|
- - '>='
|
@@ -76,64 +67,73 @@ dependencies:
|
|
76
67
|
- - ~>
|
77
68
|
- !ruby/object:Gem::Version
|
78
69
|
version: '0.7'
|
70
|
+
name: filewatch
|
79
71
|
prerelease: false
|
80
72
|
type: :runtime
|
81
|
-
- !ruby/object:Gem::Dependency
|
82
|
-
name: logstash-codec-multiline
|
83
73
|
version_requirements: !ruby/object:Gem::Requirement
|
84
74
|
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.7.0
|
85
78
|
- - ~>
|
86
79
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
80
|
+
version: '0.7'
|
81
|
+
- !ruby/object:Gem::Dependency
|
88
82
|
requirement: !ruby/object:Gem::Requirement
|
89
83
|
requirements:
|
90
84
|
- - ~>
|
91
85
|
- !ruby/object:Gem::Version
|
92
86
|
version: 2.0.5
|
87
|
+
name: logstash-codec-multiline
|
93
88
|
prerelease: false
|
94
89
|
type: :runtime
|
95
|
-
- !ruby/object:Gem::Dependency
|
96
|
-
name: stud
|
97
90
|
version_requirements: !ruby/object:Gem::Requirement
|
98
91
|
requirements:
|
99
92
|
- - ~>
|
100
93
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
94
|
+
version: 2.0.5
|
95
|
+
- !ruby/object:Gem::Dependency
|
102
96
|
requirement: !ruby/object:Gem::Requirement
|
103
97
|
requirements:
|
104
98
|
- - ~>
|
105
99
|
- !ruby/object:Gem::Version
|
106
100
|
version: 0.0.19
|
101
|
+
name: stud
|
107
102
|
prerelease: false
|
108
103
|
type: :development
|
109
|
-
- !ruby/object:Gem::Dependency
|
110
|
-
name: logstash-devutils
|
111
104
|
version_requirements: !ruby/object:Gem::Requirement
|
112
105
|
requirements:
|
113
|
-
- -
|
106
|
+
- - ~>
|
114
107
|
- !ruby/object:Gem::Version
|
115
|
-
version:
|
108
|
+
version: 0.0.19
|
109
|
+
- !ruby/object:Gem::Dependency
|
116
110
|
requirement: !ruby/object:Gem::Requirement
|
117
111
|
requirements:
|
118
112
|
- - '>='
|
119
113
|
- !ruby/object:Gem::Version
|
120
114
|
version: '0'
|
115
|
+
name: logstash-devutils
|
121
116
|
prerelease: false
|
122
117
|
type: :development
|
123
|
-
- !ruby/object:Gem::Dependency
|
124
|
-
name: logstash-codec-json
|
125
118
|
version_requirements: !ruby/object:Gem::Requirement
|
126
119
|
requirements:
|
127
120
|
- - '>='
|
128
121
|
- !ruby/object:Gem::Version
|
129
122
|
version: '0'
|
123
|
+
- !ruby/object:Gem::Dependency
|
130
124
|
requirement: !ruby/object:Gem::Requirement
|
131
125
|
requirements:
|
132
126
|
- - '>='
|
133
127
|
- !ruby/object:Gem::Version
|
134
128
|
version: '0'
|
129
|
+
name: logstash-codec-json
|
135
130
|
prerelease: false
|
136
131
|
type: :development
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - '>='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
137
|
description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
|
138
138
|
email: info@elastic.co
|
139
139
|
executables: []
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- NOTICE.TXT
|
148
148
|
- README.md
|
149
149
|
- lib/logstash/inputs/file.rb
|
150
|
+
- lib/logstash/inputs/identity_map_codec_component.rb
|
150
151
|
- logstash-input-file.gemspec
|
151
152
|
- spec/inputs/file_spec.rb
|
152
153
|
- spec/spec_helper.rb
|
@@ -172,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
173
|
version: '0'
|
173
174
|
requirements: []
|
174
175
|
rubyforge_project:
|
175
|
-
rubygems_version: 2.4.
|
176
|
+
rubygems_version: 2.4.5
|
176
177
|
signing_key:
|
177
178
|
specification_version: 4
|
178
179
|
summary: Stream events from files.
|