logstash-core 2.4.0.snapshot1-java → 2.4.0.snapshot2-java
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.
Potentially problematic release.
This version of logstash-core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/logstash/codecs/base.rb +29 -1
- data/lib/logstash/outputs/base.rb +32 -1
- data/lib/logstash/version.rb +1 -1
- data/lib/logstash-core/version.rb +1 -1
- data/logstash-core.gemspec +1 -1
- data/spec/logstash/codecs/base_spec.rb +74 -0
- data/spec/logstash/outputs/base_spec.rb +107 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d434dcd578f2d8de2e1e04b8a93b9747431d239d
|
4
|
+
data.tar.gz: a385001b8eb874819f9ba4a5c9c04c88a4e2ea15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb9478658883a032ad4f2e779d835d16feab56b4e88880ee9e6b8de4e5ca1a355e315965b5db7a8fe0a6d96cd838849fbcc6ec46ae0e602c745c8bcf0ab38197
|
7
|
+
data.tar.gz: bb1e11a7cb48bcf052298e9031eee04db3ce27c11551c0f2e6a94e35b1b94daf9e5beac65fe58c0f528d1d13fe31ab6a88dd287dc6619c93aa88495867bb6bfe
|
data/lib/logstash/codecs/base.rb
CHANGED
@@ -13,6 +13,7 @@ module LogStash::Codecs; class Base < LogStash::Plugin
|
|
13
13
|
super
|
14
14
|
config_init(@params)
|
15
15
|
register if respond_to?(:register)
|
16
|
+
setup_multi_encode!
|
16
17
|
end
|
17
18
|
|
18
19
|
public
|
@@ -23,10 +24,37 @@ module LogStash::Codecs; class Base < LogStash::Plugin
|
|
23
24
|
alias_method :<<, :decode
|
24
25
|
|
25
26
|
public
|
27
|
+
# DEPRECATED: Prefer defining encode_sync or multi_encode
|
26
28
|
def encode(event)
|
27
|
-
|
29
|
+
encoded = multi_encode([event])
|
30
|
+
encoded.each {|event,data| @on_event.call(event,data) }
|
28
31
|
end # def encode
|
29
32
|
|
33
|
+
public
|
34
|
+
# Relies on the codec being synchronous (which they all are!)
|
35
|
+
# We need a better long term design here, but this is an improvement
|
36
|
+
# over the current API for shared plugins
|
37
|
+
# It is best if the codec implements this directly
|
38
|
+
def multi_encode(events)
|
39
|
+
if @has_encode_sync
|
40
|
+
events.map {|event| [event, self.encode_sync(event)]}
|
41
|
+
else
|
42
|
+
batch = Thread.current[:logstash_output_codec_batch] ||= []
|
43
|
+
batch.clear
|
44
|
+
|
45
|
+
events.each {|event| self.encode(event) }
|
46
|
+
batch
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def setup_multi_encode!
|
51
|
+
@has_encode_sync = self.methods.include?(:encode_sync)
|
52
|
+
|
53
|
+
on_event do |event, data|
|
54
|
+
Thread.current[:logstash_output_codec_batch] << [event, data]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
30
58
|
public
|
31
59
|
def close; end;
|
32
60
|
|
@@ -27,6 +27,22 @@ class LogStash::Outputs::Base < LogStash::Plugin
|
|
27
27
|
|
28
28
|
attr_reader :worker_plugins, :available_workers, :workers, :worker_plugins, :workers_not_supported
|
29
29
|
|
30
|
+
# Set or return concurrency type
|
31
|
+
def self.concurrency(type=nil)
|
32
|
+
if type
|
33
|
+
@concurrency = type
|
34
|
+
|
35
|
+
if type == :shared
|
36
|
+
declare_threadsafe!
|
37
|
+
elsif type == :single
|
38
|
+
declare_workers_not_supported!("This plugin only supports one worker!")
|
39
|
+
end
|
40
|
+
|
41
|
+
else
|
42
|
+
@concurrency || :legacy # default is :legacyo
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
30
46
|
def self.declare_threadsafe!
|
31
47
|
declare_workers_not_supported!
|
32
48
|
@threadsafe = true
|
@@ -65,6 +81,8 @@ class LogStash::Outputs::Base < LogStash::Plugin
|
|
65
81
|
# If we're running with a single thread we must enforce single-threaded concurrency by default
|
66
82
|
# Maybe in a future version we'll assume output plugins are threadsafe
|
67
83
|
@single_worker_mutex = Mutex.new
|
84
|
+
|
85
|
+
@receives_encoded = self.methods.include?(:multi_receive_encoded)
|
68
86
|
end
|
69
87
|
|
70
88
|
public
|
@@ -77,10 +95,23 @@ class LogStash::Outputs::Base < LogStash::Plugin
|
|
77
95
|
raise "#{self.class}#receive must be overidden"
|
78
96
|
end # def receive
|
79
97
|
|
98
|
+
public
|
99
|
+
def concurrency
|
100
|
+
self.class.concurrency
|
101
|
+
end
|
102
|
+
|
80
103
|
public
|
81
104
|
# To be overriden in implementations
|
82
105
|
def multi_receive(events)
|
83
|
-
|
106
|
+
if @receives_encoded
|
107
|
+
self.multi_receive_encoded(codec.multi_encode(events))
|
108
|
+
else
|
109
|
+
events.each {|event| receive(event) }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def codec
|
114
|
+
params["codec"]
|
84
115
|
end
|
85
116
|
|
86
117
|
private
|
data/lib/logstash/version.rb
CHANGED
data/logstash-core.gemspec
CHANGED
@@ -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.4.0.
|
20
|
+
gem.add_runtime_dependency "logstash-core-event", "2.4.0.snapshot2"
|
21
21
|
# gem.add_runtime_dependency "logstash-core-event-java", "2.4.0.dev"
|
22
22
|
|
23
23
|
gem.add_runtime_dependency "cabin", "~> 0.8.0" #(Apache 2.0 license)
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
DATA_DOUBLE = "data".freeze
|
5
|
+
|
6
|
+
# use a dummy NOOP output to test Outputs::Base
|
7
|
+
class LogStash::Codecs::NOOPAsync < LogStash::Codecs::Base
|
8
|
+
attr_reader :last_result
|
9
|
+
config_name "noop_async"
|
10
|
+
|
11
|
+
def encode(event)
|
12
|
+
@last_result = @on_event.call(event, DATA_DOUBLE)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class LogStash::Codecs::NOOPSync < LogStash::Codecs::Base
|
17
|
+
attr_reader :last_result
|
18
|
+
config_name "noop_sync"
|
19
|
+
|
20
|
+
def encode_sync(event)
|
21
|
+
DATA_DOUBLE
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class LogStash::Codecs::NOOPMulti < LogStash::Codecs::Base
|
26
|
+
attr_reader :last_result
|
27
|
+
config_name "noop_multi"
|
28
|
+
|
29
|
+
def encode_sync(event)
|
30
|
+
DATA_DOUBLE
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe LogStash::Codecs::Base do
|
35
|
+
let(:params) { {} }
|
36
|
+
subject(:instance) { klass.new(params.dup) }
|
37
|
+
let(:event) { double("event") }
|
38
|
+
let(:encoded_data) { DATA_DOUBLE }
|
39
|
+
let(:encoded_tuple) { [event, encoded_data] }
|
40
|
+
|
41
|
+
describe "encoding" do
|
42
|
+
shared_examples "encoder types" do |codec_class|
|
43
|
+
let(:klass) { codec_class }
|
44
|
+
|
45
|
+
describe "#{codec_class}" do
|
46
|
+
describe "multi_encode" do
|
47
|
+
it "should return an array of [event,data] tuples" do
|
48
|
+
expect(instance.multi_encode([event,event])).to eq([encoded_tuple, encoded_tuple])
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#encode" do
|
53
|
+
before do
|
54
|
+
@result = nil
|
55
|
+
instance.on_event do |event, data|
|
56
|
+
@result = [event, data]
|
57
|
+
end
|
58
|
+
instance.encode(event)
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should yield the correct result" do
|
62
|
+
expect(@result).to eq(encoded_tuple)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
include_examples("encoder types", LogStash::Codecs::NOOPAsync)
|
69
|
+
include_examples("encoder types", LogStash::Codecs::NOOPSync)
|
70
|
+
include_examples("encoder types", LogStash::Codecs::NOOPMulti)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
@@ -15,6 +15,31 @@ class LogStash::Outputs::NOOP < LogStash::Outputs::Base
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
|
19
|
+
# use a dummy NOOP output to test Outputs::Base
|
20
|
+
class LogStash::Outputs::NOOPSingle < LogStash::Outputs::Base
|
21
|
+
config_name "noop single"
|
22
|
+
concurrency :single
|
23
|
+
|
24
|
+
config :dummy_option, :validate => :string
|
25
|
+
|
26
|
+
def register; end
|
27
|
+
|
28
|
+
def receive(event)
|
29
|
+
return output?(event)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class LogStash::Outputs::NOOPShared < ::LogStash::Outputs::Base
|
34
|
+
concurrency :shared
|
35
|
+
|
36
|
+
def register; end
|
37
|
+
end
|
38
|
+
|
39
|
+
class LogStash::Outputs::NOOPLegacy < ::LogStash::Outputs::Base
|
40
|
+
def register; end
|
41
|
+
end
|
42
|
+
|
18
43
|
class LogStash::Outputs::NOOPLegacyNoWorkers < ::LogStash::Outputs::Base
|
19
44
|
LEGACY_WORKERS_NOT_SUPPORTED_REASON = "legacy reason"
|
20
45
|
|
@@ -23,7 +48,52 @@ class LogStash::Outputs::NOOPLegacyNoWorkers < ::LogStash::Outputs::Base
|
|
23
48
|
end
|
24
49
|
end
|
25
50
|
|
51
|
+
class LogStash::Outputs::NOOPMultiReceiveEncoded < ::LogStash::Outputs::Base
|
52
|
+
concurrency :single
|
53
|
+
|
54
|
+
def register; end
|
55
|
+
|
56
|
+
def multi_receive_encoded(events_and_encoded)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
26
60
|
describe "LogStash::Outputs::Base#new" do
|
61
|
+
describe "concurrency" do
|
62
|
+
subject { klass.new({}) }
|
63
|
+
|
64
|
+
context "single" do
|
65
|
+
let(:klass) { LogStash::Outputs::NOOPSingle }
|
66
|
+
|
67
|
+
it "should set concurrency correctly" do
|
68
|
+
expect(subject.concurrency).to eq(:single)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "shared" do
|
73
|
+
let(:klass) { LogStash::Outputs::NOOPShared }
|
74
|
+
|
75
|
+
it "should set concurrency correctly" do
|
76
|
+
expect(subject.concurrency).to eq(:shared)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context "legacy" do
|
81
|
+
let(:klass) { LogStash::Outputs::NOOPLegacy }
|
82
|
+
|
83
|
+
it "should set concurrency correctly" do
|
84
|
+
expect(subject.concurrency).to eq(:legacy)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should default the # of workers to 1" do
|
88
|
+
expect(subject.workers).to eq(1)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should default concurrency to :legacy" do
|
92
|
+
expect(subject.concurrency).to eq(:legacy)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
27
97
|
it "should instantiate cleanly" do
|
28
98
|
params = { "dummy_option" => "potatoes", "codec" => "json", "workers" => 2 }
|
29
99
|
worker_params = params.dup; worker_params["workers"] = 1
|
@@ -37,4 +107,41 @@ describe "LogStash::Outputs::Base#new" do
|
|
37
107
|
LogStash::Outputs::NOOPLegacyNoWorkers.new.register
|
38
108
|
expect(LogStash::Outputs::NOOPLegacyNoWorkers.workers_not_supported?).to eql(true)
|
39
109
|
end
|
110
|
+
|
111
|
+
describe "dispatching multi_receive" do
|
112
|
+
let(:event) { double("event") }
|
113
|
+
let(:events) { [event] }
|
114
|
+
subject { klass.new({}) }
|
115
|
+
|
116
|
+
context "with multi_receive_encoded" do
|
117
|
+
let(:klass) { LogStash::Outputs::NOOPMultiReceiveEncoded }
|
118
|
+
let(:codec) { double("codec") }
|
119
|
+
let(:encoded) { double("encoded") }
|
120
|
+
|
121
|
+
before do
|
122
|
+
allow(codec).to receive(:multi_encode).with(events).and_return(encoded)
|
123
|
+
allow(subject).to receive(:codec).and_return(codec)
|
124
|
+
allow(subject).to receive(:multi_receive_encoded)
|
125
|
+
subject.multi_receive(events)
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should invoke multi_receive_encoded if it exists" do
|
129
|
+
expect(subject).to have_received(:multi_receive_encoded).with(encoded)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context "with plain #receive" do
|
134
|
+
let(:klass) { LogStash::Outputs::NOOPSingle }
|
135
|
+
|
136
|
+
before do
|
137
|
+
allow(subject).to receive(:multi_receive).and_call_original
|
138
|
+
allow(subject).to receive(:receive).with(event)
|
139
|
+
subject.multi_receive(events)
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should receive the event by itself" do
|
143
|
+
expect(subject).to have_received(:receive).with(event)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
40
147
|
end
|
metadata
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.0.
|
4
|
+
version: 2.4.0.snapshot2
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
16
|
- - '='
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 2.4.0.
|
18
|
+
version: 2.4.0.snapshot2
|
19
19
|
name: logstash-core-event
|
20
20
|
prerelease: false
|
21
21
|
type: :runtime
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.4.0.
|
26
|
+
version: 2.4.0.snapshot2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
@@ -287,6 +287,7 @@ files:
|
|
287
287
|
- logstash-core.gemspec
|
288
288
|
- spec/conditionals_spec.rb
|
289
289
|
- spec/logstash/agent_spec.rb
|
290
|
+
- spec/logstash/codecs/base_spec.rb
|
290
291
|
- spec/logstash/config/config_ast_spec.rb
|
291
292
|
- spec/logstash/config/cpu_core_strategy_spec.rb
|
292
293
|
- spec/logstash/config/defaults_spec.rb
|
@@ -343,6 +344,7 @@ summary: logstash-core - The core components of logstash
|
|
343
344
|
test_files:
|
344
345
|
- spec/conditionals_spec.rb
|
345
346
|
- spec/logstash/agent_spec.rb
|
347
|
+
- spec/logstash/codecs/base_spec.rb
|
346
348
|
- spec/logstash/config/config_ast_spec.rb
|
347
349
|
- spec/logstash/config/cpu_core_strategy_spec.rb
|
348
350
|
- spec/logstash/config/defaults_spec.rb
|