logstash-core 2.2.0.snapshot2-java → 2.2.0.snapshot3-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2e8a27f3e4542a393c4b4c04ed487993d5815ef
4
- data.tar.gz: b1ec9b12ec522cdce7067a03a4aa169ae0ced2a8
3
+ metadata.gz: c7857e5445f210282edca3adc2180baaa618e37b
4
+ data.tar.gz: fc225f76018d011dbd0ae2b03cc8245df78f1293
5
5
  SHA512:
6
- metadata.gz: 1df89a5890ee55a5038aa5edf11773e83a6fd727d5ce74b89f408d2f7faf0bcb0d915a75e56d7c406aa215e3a88dea015cda213f8e9dbfb26ee3c9870867fb19
7
- data.tar.gz: 4f6b5a0e4180eab5a7cf8744db6b7336f8833ec03b8c140a86398f9f86e4b1f77e8b22e5b026c344c741b9c76c77286b32a43bbf15e63268387e371290f3984f
6
+ metadata.gz: 86be18d25f189e0a406cfa846b57cdf4c14ff9375e115304fd11e0ce26ed4d9810db88ebc019e8c3850a1dd8be76a2df3f8c84750cb7929450a19f27e00c35f1
7
+ data.tar.gz: a83f30280dc94bd6580af794436fc0055c4d3e0677f54d25d5cb70d839d197f950f094e9e6cedba79cc3d6ef22f013d479cf80153af448ddab664d4faa142cf8
@@ -5,4 +5,4 @@
5
5
  # Note to authors: this should not include dashes because 'gem' barfs if
6
6
  # you include a dash in the version string.
7
7
 
8
- LOGSTASH_CORE_VERSION = "2.2.0.snapshot2"
8
+ LOGSTASH_CORE_VERSION = "2.2.0.snapshot3"
@@ -24,17 +24,18 @@ class LogStash::Agent < Clamp::Command
24
24
  option ["-w", "--pipeline-workers"], "COUNT",
25
25
  I18n.t("logstash.runner.flag.pipeline-workers"),
26
26
  :attribute_name => :pipeline_workers,
27
- :default => LogStash::Pipeline::DEFAULT_SETTINGS[:default_pipeline_workers], &:to_i
27
+ :default => LogStash::Pipeline::DEFAULT_SETTINGS[:default_pipeline_workers]
28
+
28
29
 
29
30
  option ["-b", "--pipeline-batch-size"], "SIZE",
30
31
  I18n.t("logstash.runner.flag.pipeline-batch-size"),
31
32
  :attribute_name => :pipeline_batch_size,
32
- :default => LogStash::Pipeline::DEFAULT_SETTINGS[:pipeline_batch_size], &:to_i
33
+ :default => LogStash::Pipeline::DEFAULT_SETTINGS[:pipeline_batch_size]
33
34
 
34
35
  option ["-u", "--pipeline-batch-delay"], "DELAY_IN_MS",
35
36
  I18n.t("logstash.runner.flag.pipeline-batch-delay"),
36
37
  :attribute_name => :pipeline_batch_delay,
37
- :default => LogStash::Pipeline::DEFAULT_SETTINGS[:pipeline_batch_delay], &:to_i
38
+ :default => LogStash::Pipeline::DEFAULT_SETTINGS[:pipeline_batch_delay]
38
39
 
39
40
  option ["-l", "--log"], "FILE",
40
41
  I18n.t("logstash.agent.flag.log"),
@@ -66,6 +67,32 @@ class LogStash::Agent < Clamp::Command
66
67
  :attribute_name => :unsafe_shutdown,
67
68
  :default => false
68
69
 
70
+ def initialize(*args)
71
+ super(*args)
72
+ @pipeline_settings ||= { :pipeline_id => "base" }
73
+ end
74
+
75
+ def pipeline_workers=(pipeline_workers_value)
76
+ @pipeline_settings[:pipeline_workers] = validate_positive_integer(pipeline_workers_value)
77
+ end
78
+
79
+ def pipeline_batch_size=(pipeline_batch_size_value)
80
+ @pipeline_settings[:pipeline_batch_size] = validate_positive_integer(pipeline_batch_size_value)
81
+ end
82
+
83
+ def pipeline_batch_delay=(pipeline_batch_delay_value)
84
+ @pipeline_settings[:pipeline_batch_delay] = validate_positive_integer(pipeline_batch_delay_value)
85
+ end
86
+
87
+ def validate_positive_integer(str_arg)
88
+ int_arg = str_arg.to_i
89
+ if str_arg !~ /^\d+$/ || int_arg < 1
90
+ raise ArgumentError, "Expected a positive integer, got '#{str_arg}'"
91
+ end
92
+
93
+ int_arg
94
+ end
95
+
69
96
  # Emit a warning message.
70
97
  def warn(message)
71
98
  # For now, all warnings are fatal.
@@ -132,12 +159,7 @@ class LogStash::Agent < Clamp::Command
132
159
  end
133
160
 
134
161
  begin
135
- pipeline = LogStash::Pipeline.new(@config_string, {
136
- :pipeline_workers => pipeline_workers,
137
- :pipeline_batch_size => pipeline_batch_size,
138
- :pipeline_batch_delay => pipeline_batch_delay,
139
- :pipeline_id => "base"
140
- })
162
+ pipeline = LogStash::Pipeline.new(@config_string, @pipeline_settings)
141
163
  rescue LoadError => e
142
164
  fail("Configuration problem.")
143
165
  end
@@ -11,7 +11,7 @@ module LogStash::Codecs; class Base < LogStash::Plugin
11
11
 
12
12
  def initialize(params={})
13
13
  super
14
- config_init(params)
14
+ config_init(@params)
15
15
  register if respond_to?(:register)
16
16
  end
17
17
 
@@ -27,7 +27,7 @@ module LogStash::Codecs; class Base < LogStash::Plugin
27
27
  raise "#{self.class}#encode must be overidden"
28
28
  end # def encode
29
29
 
30
- public
30
+ public
31
31
  def close; end;
32
32
 
33
33
  # @param block [Proc(event, data)] the callback proc passing the original event and the encoded event
@@ -120,7 +120,7 @@ class LogStash::Filters::Base < LogStash::Plugin
120
120
  public
121
121
  def initialize(params)
122
122
  super
123
- config_init(params)
123
+ config_init(@params)
124
124
  @threadsafe = true
125
125
  end # def initialize
126
126
 
@@ -53,7 +53,7 @@ class LogStash::Inputs::Base < LogStash::Plugin
53
53
  super
54
54
  @threadable = false
55
55
  @stop_called = Concurrent::AtomicBoolean.new(false)
56
- config_init(params)
56
+ config_init(@params)
57
57
  @tags ||= []
58
58
  end # def initialize
59
59
 
@@ -60,7 +60,7 @@ class LogStash::Outputs::Base < LogStash::Plugin
60
60
  public
61
61
  def initialize(params={})
62
62
  super
63
- config_init(params)
63
+ config_init(@params)
64
64
 
65
65
  # If we're running with a single thread we must enforce single-threaded concurrency by default
66
66
  # Maybe in a future version we'll assume output plugins are threadsafe
@@ -88,4 +88,4 @@ class LogStash::Outputs::Base < LogStash::Plugin
88
88
  # TODO: noop for now, remove this once we delete this call from all plugins
89
89
  true
90
90
  end # def output?
91
- end # class LogStash::Outputs::Base
91
+ end # class LogStash::Outputs::Base
@@ -24,7 +24,7 @@ class LogStash::Plugin
24
24
 
25
25
  public
26
26
  def initialize(params=nil)
27
- @params = params
27
+ @params = LogStash::Util.deep_clone(params)
28
28
  @logger = Cabin::Channel.get(LogStash)
29
29
  end
30
30
 
@@ -183,4 +183,21 @@ module LogStash::Util
183
183
  o
184
184
  end
185
185
  end
186
+
187
+ def self.deep_clone(o)
188
+ case o
189
+ when Hash
190
+ o.inject({}) {|h, (k,v)| h[k] = deep_clone(v); h }
191
+ when Array
192
+ o.map {|v| deep_clone(v) }
193
+ when Fixnum, Symbol, IO, TrueClass, FalseClass, NilClass
194
+ o
195
+ when LogStash::Codecs::Base
196
+ o.clone.tap {|c| c.register }
197
+ when String
198
+ o.clone #need to keep internal state e.g. frozen
199
+ else
200
+ Marshal.load(Marshal.dump(o))
201
+ end
202
+ end
186
203
  end # module LogStash::Util
@@ -11,4 +11,4 @@
11
11
  # eventually this file should be in the root logstash lib fir and dependencies in logstash-core should be
12
12
  # fixed.
13
13
 
14
- LOGSTASH_VERSION = "2.2.0.snapshot2"
14
+ LOGSTASH_VERSION = "2.2.0.snapshot3"
@@ -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.0.snapshot2"
20
+ gem.add_runtime_dependency "logstash-core-event", "~> 2.2.0.snapshot3"
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)
@@ -108,7 +108,7 @@ describe LogStash::Plugin do
108
108
 
109
109
  subject.validate({})
110
110
  end
111
-
111
+
112
112
 
113
113
  it 'logs a warning if the plugin use the milestone option' do
114
114
  expect_any_instance_of(Cabin::Channel).to receive(:warn)
@@ -120,4 +120,33 @@ describe LogStash::Plugin do
120
120
  end
121
121
  end
122
122
  end
123
+
124
+ describe "subclass initialize" do
125
+ let(:args) { Hash.new }
126
+
127
+ [
128
+ StromaeCodec = Class.new(LogStash::Codecs::Base) do
129
+ config_name "stromae"
130
+ config :foo_tag, :validate => :string, :default => "bar"
131
+ end,
132
+ StromaeFilter = Class.new(LogStash::Filters::Base) do
133
+ config_name "stromae"
134
+ config :foo_tag, :validate => :string, :default => "bar"
135
+ end,
136
+ StromaeInput = Class.new(LogStash::Inputs::Base) do
137
+ config_name "stromae"
138
+ config :foo_tag, :validate => :string, :default => "bar"
139
+ end,
140
+ StromaeOutput = Class.new(LogStash::Outputs::Base) do
141
+ config_name "stromae"
142
+ config :foo_tag, :validate => :string, :default => "bar"
143
+ end
144
+ ].each do |klass|
145
+
146
+ it "subclass #{klass.name} does not modify params" do
147
+ instance = klass.new(args)
148
+ expect(args).to be_empty
149
+ end
150
+ end
151
+ end
123
152
  end
@@ -2,6 +2,7 @@
2
2
  require "spec_helper"
3
3
  require "logstash/runner"
4
4
  require "stud/task"
5
+ require "stud/trap"
5
6
 
6
7
  class NullRunner
7
8
  def run(args); end
@@ -35,6 +36,33 @@ describe LogStash::Runner do
35
36
  args = ["welp"]
36
37
  expect(subject.run(args).wait).to eq(1)
37
38
  end
39
+ end
40
+
41
+ describe "pipeline settings" do
42
+ let(:pipeline_string) { "input { stdin {} } output { stdout {} }" }
43
+ let(:base_pipeline_settings) { { :pipeline_id => "base" } }
44
+ let(:pipeline) { double("pipeline") }
45
+
46
+ before(:each) do
47
+ task = Stud::Task.new { 1 }
48
+ allow(pipeline).to receive(:run).and_return(task)
49
+ end
38
50
 
51
+ context "when pipeline workers is not defined by the user" do
52
+ it "should not pass the value to the pipeline" do
53
+ expect(LogStash::Pipeline).to receive(:new).with(pipeline_string, base_pipeline_settings).and_return(pipeline)
54
+ args = ["agent", "-e", pipeline_string]
55
+ subject.run(args).wait
56
+ end
57
+ end
58
+
59
+ context "when pipeline workers is defined by the user" do
60
+ it "should pass the value to the pipeline" do
61
+ base_pipeline_settings[:pipeline_workers] = 2
62
+ expect(LogStash::Pipeline).to receive(:new).with(pipeline_string, base_pipeline_settings).and_return(pipeline)
63
+ args = ["agent", "-w", "2", "-e", pipeline_string]
64
+ subject.run(args).wait
65
+ end
66
+ end
39
67
  end
40
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0.snapshot2
4
+ version: 2.2.0.snapshot3
5
5
  platform: java
6
6
  authors:
7
7
  - Jordan Sissel
@@ -10,14 +10,14 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-01-08 00:00:00.000000000 Z
13
+ date: 2016-01-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
18
  - - ~>
19
19
  - !ruby/object:Gem::Version
20
- version: 2.2.0.snapshot2
20
+ version: 2.2.0.snapshot3
21
21
  name: logstash-core-event
22
22
  prerelease: false
23
23
  type: :runtime
@@ -25,7 +25,7 @@ dependencies:
25
25
  requirements:
26
26
  - - ~>
27
27
  - !ruby/object:Gem::Version
28
- version: 2.2.0.snapshot2
28
+ version: 2.2.0.snapshot3
29
29
  - !ruby/object:Gem::Dependency
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements: