logstash-core 2.2.2-java → 2.2.3-java
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of logstash-core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/logstash-core/version.rb +1 -1
- data/lib/logstash/agent.rb +4 -11
- data/lib/logstash/output_delegator.rb +78 -56
- data/lib/logstash/version.rb +1 -1
- data/locales/en.yml +1 -2
- data/logstash-core.gemspec +3 -3
- data/spec/logstash/output_delegator_spec.rb +30 -12
- metadata +7 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39c92820b7e391a83095308508aea54dc84e1ea5
|
4
|
+
data.tar.gz: 324d6bd33d6caa20684de9c51430bae2db728c6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7db2d7f379a4d8b842a46cc3be888cab6867dbe2fa444f843d3e55480d2b1c59cbf35572d349cd4795b3e357f5eec5f18d83d33e38591befb7b395a6a168896a
|
7
|
+
data.tar.gz: 7ae5726ef2510ca14b70984c101cbc679f4a8b91753c9a90b0297d182100f9188191266223045286a5a19c19dcffb65548cbae5bb8c087ee98688ce3141e6a2c
|
data/lib/logstash/agent.rb
CHANGED
@@ -107,12 +107,6 @@ class LogStash::Agent < Clamp::Command
|
|
107
107
|
raise LogStash::ConfigurationError, message
|
108
108
|
end # def fail
|
109
109
|
|
110
|
-
def report(message)
|
111
|
-
# Print to stdout just in case we're logging to a file
|
112
|
-
puts message
|
113
|
-
@logger.log(message) if log_file
|
114
|
-
end
|
115
|
-
|
116
110
|
# Run the agent. This method is invoked after clamp parses the
|
117
111
|
# flags given to this program.
|
118
112
|
def execute
|
@@ -201,7 +195,7 @@ class LogStash::Agent < Clamp::Command
|
|
201
195
|
|
202
196
|
# Stop now if we are only asking for a config test.
|
203
197
|
if config_test?
|
204
|
-
|
198
|
+
@logger.terminal "Configuration OK"
|
205
199
|
return
|
206
200
|
end
|
207
201
|
|
@@ -212,15 +206,14 @@ class LogStash::Agent < Clamp::Command
|
|
212
206
|
return 0
|
213
207
|
rescue LogStash::ConfigurationError => e
|
214
208
|
@logger.unsubscribe(stdout_logs) if show_startup_errors
|
215
|
-
|
209
|
+
@logger.error I18n.t("logstash.agent.error", :error => e)
|
216
210
|
if !config_test?
|
217
|
-
|
211
|
+
@logger.info I18n.t("logstash.agent.configtest-flag-information")
|
218
212
|
end
|
219
213
|
return 1
|
220
214
|
rescue => e
|
221
215
|
@logger.unsubscribe(stdout_logs) if show_startup_errors
|
222
|
-
|
223
|
-
report e.backtrace if @logger.debug? || $DEBUGLIST.include?("stacktrace")
|
216
|
+
@logger.warn(I18n.t("oops"), :error => e, :class => e.class.name, :backtrace => e.backtrace)
|
224
217
|
return 1
|
225
218
|
ensure
|
226
219
|
@log_fd.close if @log_fd
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "concurrent/atomic/atomic_fixnum"
|
3
|
+
java_import "java.util.concurrent.CopyOnWriteArrayList"
|
3
4
|
|
4
5
|
# This class goes hand in hand with the pipeline to provide a pool of
|
5
6
|
# free workers to be used by pipeline worker threads. The pool is
|
@@ -8,63 +9,19 @@ require "concurrent/atomic/atomic_fixnum"
|
|
8
9
|
#
|
9
10
|
# This plugin also records some basic statistics
|
10
11
|
module LogStash class OutputDelegator
|
11
|
-
attr_reader :workers, :config, :
|
12
|
+
attr_reader :workers, :config, :threadsafe
|
12
13
|
|
13
14
|
# The *args this takes are the same format that a Outputs::Base takes. A list of hashes with parameters in them
|
14
15
|
# Internally these just get merged together into a single hash
|
15
|
-
def initialize(logger, klass, default_worker_count, *
|
16
|
+
def initialize(logger, klass, default_worker_count, *plugin_args)
|
16
17
|
@logger = logger
|
17
18
|
@threadsafe = klass.threadsafe?
|
18
|
-
@config =
|
19
|
+
@config = plugin_args.reduce({}, :merge)
|
19
20
|
@klass = klass
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
# a single instance
|
24
|
-
#
|
25
|
-
# Older plugins invoke the instance method Outputs::Base#workers_not_supported
|
26
|
-
# To detect these we need an instance to be created first :()
|
27
|
-
# TODO: In the next major version after 2.x remove support for this
|
28
|
-
@workers = [@klass.new(*args)]
|
29
|
-
@workers.first.register # Needed in case register calls `workers_not_supported`
|
30
|
-
|
31
|
-
# DO NOT move this statement before the instantiation of the first single instance
|
32
|
-
# Read the note above to understand why
|
33
|
-
@worker_count = calculate_worker_count(default_worker_count)
|
34
|
-
@logger.debug("Will start workers for output", :worker_count => @worker_count, :class => klass)
|
35
|
-
|
36
|
-
warn_on_worker_override!
|
37
|
-
# This queue is used to manage sharing across threads
|
38
|
-
@worker_queue = SizedQueue.new(@worker_count)
|
39
|
-
|
40
|
-
@workers += (@worker_count - 1).times.map do
|
41
|
-
inst = @klass.new(*args)
|
42
|
-
inst.register
|
43
|
-
inst
|
44
|
-
end
|
45
|
-
|
46
|
-
@workers.each { |w| @worker_queue << w }
|
47
|
-
|
21
|
+
@workers = java.util.concurrent.CopyOnWriteArrayList.new
|
22
|
+
@default_worker_count = default_worker_count
|
23
|
+
@registered = false
|
48
24
|
@events_received = Concurrent::AtomicFixnum.new(0)
|
49
|
-
|
50
|
-
|
51
|
-
# One might wonder why we don't use something like
|
52
|
-
# define_singleton_method(:multi_receive, method(:threadsafe_multi_receive)
|
53
|
-
# and the answer is this is buggy on Jruby 1.7.x . It works 98% of the time!
|
54
|
-
# The other 2% you get weird errors about rebinding to the same object
|
55
|
-
# Until we switch to Jruby 9.x keep the define_singleton_method parts
|
56
|
-
# the way they are, with a block
|
57
|
-
# See https://github.com/jruby/jruby/issues/3582
|
58
|
-
if threadsafe?
|
59
|
-
@threadsafe_worker = @workers.first
|
60
|
-
define_singleton_method(:multi_receive) do |events|
|
61
|
-
threadsafe_multi_receive(events)
|
62
|
-
end
|
63
|
-
else
|
64
|
-
define_singleton_method(:multi_receive) do |events|
|
65
|
-
worker_multi_receive(events)
|
66
|
-
end
|
67
|
-
end
|
68
25
|
end
|
69
26
|
|
70
27
|
def threadsafe?
|
@@ -89,11 +46,14 @@ module LogStash class OutputDelegator
|
|
89
46
|
@config["workers"] && @config["workers"] > 1 && @klass.workers_not_supported?
|
90
47
|
end
|
91
48
|
|
92
|
-
def
|
49
|
+
def target_worker_count
|
50
|
+
# Remove in 5.0 after all plugins upgraded to use class level declarations
|
51
|
+
raise ArgumentError, "Attempted to detect target worker count before instantiating a worker to test for legacy workers_not_supported!" if @workers.size == 0
|
52
|
+
|
93
53
|
if @threadsafe || @klass.workers_not_supported?
|
94
54
|
1
|
95
55
|
else
|
96
|
-
@config["workers"] || default_worker_count
|
56
|
+
@config["workers"] || @default_worker_count
|
97
57
|
end
|
98
58
|
end
|
99
59
|
|
@@ -102,7 +62,58 @@ module LogStash class OutputDelegator
|
|
102
62
|
end
|
103
63
|
|
104
64
|
def register
|
105
|
-
|
65
|
+
raise ArgumentError, "Attempted to register #{self} twice!" if @registered
|
66
|
+
@registered = true
|
67
|
+
# We define this as an array regardless of threadsafety
|
68
|
+
# to make reporting simpler, even though a threadsafe plugin will just have
|
69
|
+
# a single instance
|
70
|
+
#
|
71
|
+
# Older plugins invoke the instance method Outputs::Base#workers_not_supported
|
72
|
+
# To detect these we need an instance to be created first :()
|
73
|
+
# TODO: In the next major version after 2.x remove support for this
|
74
|
+
@workers << @klass.new(@config)
|
75
|
+
@workers.first.register # Needed in case register calls `workers_not_supported`
|
76
|
+
|
77
|
+
@logger.debug("Will start workers for output", :worker_count => target_worker_count, :class => @klass)
|
78
|
+
|
79
|
+
# Threadsafe versions don't need additional workers
|
80
|
+
setup_additional_workers!(target_worker_count) unless @threadsafe
|
81
|
+
# We skip the first worker because that's pre-registered to deal with legacy workers_not_supported
|
82
|
+
@workers.subList(1,@workers.size).each(&:register)
|
83
|
+
setup_multi_receive!
|
84
|
+
end
|
85
|
+
|
86
|
+
def setup_additional_workers!(target_worker_count)
|
87
|
+
warn_on_worker_override!
|
88
|
+
|
89
|
+
(target_worker_count - 1).times do
|
90
|
+
inst = @klass.new(@config)
|
91
|
+
@workers << inst
|
92
|
+
end
|
93
|
+
|
94
|
+
# This queue is used to manage sharing across threads
|
95
|
+
@worker_queue = SizedQueue.new(target_worker_count)
|
96
|
+
@workers.each {|w| @worker_queue << w }
|
97
|
+
end
|
98
|
+
|
99
|
+
def setup_multi_receive!
|
100
|
+
# One might wonder why we don't use something like
|
101
|
+
# define_singleton_method(:multi_receive, method(:threadsafe_multi_receive)
|
102
|
+
# and the answer is this is buggy on Jruby 1.7.x . It works 98% of the time!
|
103
|
+
# The other 2% you get weird errors about rebinding to the same object
|
104
|
+
# Until we switch to Jruby 9.x keep the define_singleton_method parts
|
105
|
+
# the way they are, with a block
|
106
|
+
# See https://github.com/jruby/jruby/issues/3582
|
107
|
+
if threadsafe?
|
108
|
+
@threadsafe_worker = @workers.first
|
109
|
+
define_singleton_method(:multi_receive) do |events|
|
110
|
+
threadsafe_multi_receive(events)
|
111
|
+
end
|
112
|
+
else
|
113
|
+
define_singleton_method(:multi_receive) do |events|
|
114
|
+
worker_multi_receive(events)
|
115
|
+
end
|
116
|
+
end
|
106
117
|
end
|
107
118
|
|
108
119
|
def threadsafe_multi_receive(events)
|
@@ -125,9 +136,13 @@ module LogStash class OutputDelegator
|
|
125
136
|
def do_close
|
126
137
|
@logger.debug("closing output delegator", :klass => self)
|
127
138
|
|
128
|
-
@
|
129
|
-
|
130
|
-
|
139
|
+
if @threadsafe
|
140
|
+
@workers.each(&:do_close)
|
141
|
+
else
|
142
|
+
worker_count.times do
|
143
|
+
worker = @worker_queue.pop
|
144
|
+
worker.do_close
|
145
|
+
end
|
131
146
|
end
|
132
147
|
end
|
133
148
|
|
@@ -140,10 +155,17 @@ module LogStash class OutputDelegator
|
|
140
155
|
if @threadsafe
|
141
156
|
0
|
142
157
|
else
|
158
|
+
# The pipeline reporter can run before the outputs are registered trying to pull a value here
|
159
|
+
# In that case @worker_queue is empty, we just return 0
|
160
|
+
return 0 unless @worker_queue
|
143
161
|
@workers.size - @worker_queue.size
|
144
162
|
end
|
145
163
|
end
|
146
164
|
|
165
|
+
def worker_count
|
166
|
+
@workers.size
|
167
|
+
end
|
168
|
+
|
147
169
|
private
|
148
170
|
# Needed for testing, so private
|
149
171
|
attr_reader :threadsafe_worker, :worker_queue
|
data/lib/logstash/version.rb
CHANGED
data/locales/en.yml
CHANGED
data/logstash-core.gemspec
CHANGED
@@ -4,8 +4,8 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'logstash-core/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
|
-
gem.authors = ["
|
8
|
-
gem.email = ["
|
7
|
+
gem.authors = ["Elastic"]
|
8
|
+
gem.email = ["info@elastic.co"]
|
9
9
|
gem.description = %q{The core components of logstash, the scalable log and event management tool}
|
10
10
|
gem.summary = %q{logstash-core - The core components of logstash}
|
11
11
|
gem.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.require_paths = ["lib"]
|
18
18
|
gem.version = LOGSTASH_CORE_VERSION
|
19
19
|
|
20
|
-
gem.add_runtime_dependency "logstash-core-event", "~> 2.2.
|
20
|
+
gem.add_runtime_dependency "logstash-core-event", "~> 2.2.3"
|
21
21
|
|
22
22
|
gem.add_runtime_dependency "cabin", "~> 0.7.0" #(Apache 2.0 license)
|
23
23
|
gem.add_runtime_dependency "pry", "~> 0.10.1" #(Ruby license)
|
@@ -27,6 +27,7 @@ describe LogStash::OutputDelegator do
|
|
27
27
|
|
28
28
|
context "after having received a batch of events" do
|
29
29
|
before do
|
30
|
+
subject.register
|
30
31
|
subject.multi_receive(events)
|
31
32
|
end
|
32
33
|
|
@@ -39,23 +40,35 @@ describe LogStash::OutputDelegator do
|
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
42
|
-
it "should register all workers on register" do
|
43
|
-
expect(out_inst).to receive(:register)
|
44
|
-
subject.register
|
45
|
-
end
|
46
43
|
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
describe "closing" do
|
45
|
+
before do
|
46
|
+
subject.register
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should register all workers on register" do
|
50
|
+
expect(out_inst).to have_received(:register)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should close all workers when closing" do
|
54
|
+
expect(out_inst).to receive(:do_close)
|
55
|
+
subject.do_close
|
56
|
+
end
|
50
57
|
end
|
51
58
|
|
52
59
|
describe "concurrency and worker support" do
|
60
|
+
before do
|
61
|
+
allow(out_inst).to receive(:id).and_return("a-simple-plugin")
|
62
|
+
allow(out_inst).to receive(:metric=).with(any_args)
|
63
|
+
allow(out_klass).to receive(:workers_not_supported?).and_return(false)
|
64
|
+
end
|
65
|
+
|
53
66
|
describe "non-threadsafe outputs that allow workers" do
|
54
67
|
let(:default_worker_count) { 3 }
|
55
68
|
|
56
69
|
before do
|
57
70
|
allow(out_klass).to receive(:threadsafe?).and_return(false)
|
58
|
-
|
71
|
+
subject.register
|
59
72
|
end
|
60
73
|
|
61
74
|
it "should instantiate multiple workers" do
|
@@ -71,7 +84,7 @@ describe LogStash::OutputDelegator do
|
|
71
84
|
describe "threadsafe outputs" do
|
72
85
|
before do
|
73
86
|
allow(out_klass).to receive(:threadsafe?).and_return(true)
|
74
|
-
|
87
|
+
subject.register
|
75
88
|
end
|
76
89
|
|
77
90
|
it "should return true when threadsafe? is invoked" do
|
@@ -88,14 +101,18 @@ describe LogStash::OutputDelegator do
|
|
88
101
|
end
|
89
102
|
|
90
103
|
it "should not utilize the worker queue" do
|
91
|
-
expect(subject.send(:worker_queue)).
|
92
|
-
subject.multi_receive(events)
|
104
|
+
expect(subject.send(:worker_queue)).to be_nil
|
93
105
|
end
|
94
106
|
|
95
107
|
it "should send received events to the worker" do
|
96
108
|
expect(out_inst).to receive(:multi_receive).with(events)
|
97
109
|
subject.multi_receive(events)
|
98
110
|
end
|
111
|
+
|
112
|
+
it "should close all workers when closing" do
|
113
|
+
expect(out_inst).to receive(:do_close)
|
114
|
+
subject.do_close
|
115
|
+
end
|
99
116
|
end
|
100
117
|
end
|
101
118
|
end
|
@@ -115,11 +132,12 @@ describe LogStash::OutputDelegator do
|
|
115
132
|
let(:default_worker_count) { 2 }
|
116
133
|
let(:out_klass) { LogStash::Outputs::NOOPDelLegacyNoWorkers }
|
117
134
|
|
118
|
-
before do
|
135
|
+
before(:each) do
|
119
136
|
allow(logger).to receive(:debug).with(any_args)
|
120
137
|
end
|
121
138
|
|
122
139
|
it "should only setup one worker" do
|
140
|
+
subject.register
|
123
141
|
expect(subject.worker_count).to eql(1)
|
124
142
|
end
|
125
143
|
end
|
metadata
CHANGED
@@ -1,23 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
- Pete Fritchman
|
9
|
-
- Elasticsearch
|
7
|
+
- Elastic
|
10
8
|
autorequire:
|
11
9
|
bindir: bin
|
12
10
|
cert_chain: []
|
13
|
-
date: 2016-
|
11
|
+
date: 2016-03-29 00:00:00.000000000 Z
|
14
12
|
dependencies:
|
15
13
|
- !ruby/object:Gem::Dependency
|
16
14
|
requirement: !ruby/object:Gem::Requirement
|
17
15
|
requirements:
|
18
16
|
- - ~>
|
19
17
|
- !ruby/object:Gem::Version
|
20
|
-
version: 2.2.
|
18
|
+
version: 2.2.3
|
21
19
|
name: logstash-core-event
|
22
20
|
prerelease: false
|
23
21
|
type: :runtime
|
@@ -25,7 +23,7 @@ dependencies:
|
|
25
23
|
requirements:
|
26
24
|
- - ~>
|
27
25
|
- !ruby/object:Gem::Version
|
28
|
-
version: 2.2.
|
26
|
+
version: 2.2.3
|
29
27
|
- !ruby/object:Gem::Dependency
|
30
28
|
requirement: !ruby/object:Gem::Requirement
|
31
29
|
requirements:
|
@@ -224,9 +222,7 @@ dependencies:
|
|
224
222
|
version: 0.3.7
|
225
223
|
description: The core components of logstash, the scalable log and event management tool
|
226
224
|
email:
|
227
|
-
-
|
228
|
-
- petef@databits.net
|
229
|
-
- info@elasticsearch.com
|
225
|
+
- info@elastic.co
|
230
226
|
executables: []
|
231
227
|
extensions: []
|
232
228
|
extra_rdoc_files: []
|
@@ -332,7 +328,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
332
328
|
version: '0'
|
333
329
|
requirements: []
|
334
330
|
rubyforge_project:
|
335
|
-
rubygems_version: 2.4.
|
331
|
+
rubygems_version: 2.4.8
|
336
332
|
signing_key:
|
337
333
|
specification_version: 4
|
338
334
|
summary: logstash-core - The core components of logstash
|