logstash-core 6.0.0.rc2-java → 6.0.1-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be7703ae1e02681bf68ba3dfd591f85886b15f271b2bce6cc17e49dddcd88c4c
4
- data.tar.gz: 7c49c07b0af3dd06f605acb08243911e65f1be78108ee6fdb1cc4723dca694a6
3
+ metadata.gz: 9948f10f7f434f0e67b751dca73b6bc83f577f1b933985b1251dbc6bca7a59dc
4
+ data.tar.gz: 405b2588cab170eaea4e861e2f559c8698ad40ea3bcc4468e4fcd0e84e869269
5
5
  SHA512:
6
- metadata.gz: dc9b5bc1db75cfb1236aef3072ac38f2d943fb24aa752fd9a525bec60391e06f000f77d7fd8ac48d00744a0ff249c5edd6e7bec1c87ee7475d471999e4e4c032
7
- data.tar.gz: e856579b5da5a494d8493e6863a96f6ced47e7442ce822bc94144a3dcf39ef0f5d3d5a5f9f99fafceb0ca1d070da0975ed6d33682b8191eb653c1dbc22227fed
6
+ metadata.gz: 61314838211ae44135b607178f642b449b86ca2dd83f38c5a5d9979438f5ae77b1c1f692dd5384fdf4f9069a8caf521f111b8e22ea17778166b23a33e3389502
7
+ data.tar.gz: e8660a1b7f2781cc4fa2df9299c50f3c4f31ecec1921a884867c7004264d12bffa1f18959675a81f98802897c63e46e10b44c6b4b7f83763eec62a3e91786734
@@ -101,9 +101,21 @@ module LogStashCompilerLSCLGrammar; module LogStash; module Compiler; module LSC
101
101
  else
102
102
  [k,v]
103
103
  end
104
- }.reduce({}) do |hash,kv|
105
- k,v = kv
106
- hash[k] = v
104
+ }.reduce({}) do |hash, kv|
105
+ k, v = kv
106
+ existing = hash[k]
107
+ if existing.nil?
108
+ hash[k] = v
109
+ elsif existing.kind_of?(::Hash)
110
+ # For legacy reasons, a config can contain multiple `AST::Attribute`s with the same name
111
+ # and a hash-type value (e.g., "match" in the grok filter), which are merged into a single
112
+ # hash value; e.g., `{"match" => {"baz" => "bar"}, "match" => {"foo" => "bulb"}}` is
113
+ # interpreted as `{"match" => {"baz" => "bar", "foo" => "blub"}}`.
114
+ # (NOTE: this bypasses `AST::Hash`'s ability to detect duplicate keys)
115
+ hash[k] = existing.merge(v)
116
+ else
117
+ hash[k] = existing + v
118
+ end
107
119
  hash
108
120
  end
109
121
 
@@ -187,7 +199,7 @@ module LogStashCompilerLSCLGrammar; module LogStash; module Compiler; module LSC
187
199
 
188
200
  def expr
189
201
  validate!
190
- ::Hash[recursive_select(HashEntry).map(&:expr)]
202
+ jdsl.eValue(source_meta, ::Hash[recursive_select(HashEntry).map(&:expr)])
191
203
  end
192
204
  end
193
205
 
@@ -44,9 +44,9 @@ module LogStash
44
44
  def multi_filter(events)
45
45
  @metric_events_in.increment(events.size)
46
46
 
47
- start_time = java.lang.System.current_time_millis
47
+ start_time = java.lang.System.nano_time
48
48
  new_events = @filter.multi_filter(events)
49
- @metric_events_time.increment(java.lang.System.current_time_millis - start_time)
49
+ @metric_events_time.increment((java.lang.System.nano_time - start_time) / 1_000_000)
50
50
 
51
51
  # There is no guarantee in the context of filter
52
52
  # that EVENTS_INT == EVENTS_OUT, see the aggregates and
@@ -25,7 +25,7 @@ module LogStash module Instrument
25
25
 
26
26
  def push(event)
27
27
  increment_counters(1)
28
- start_time = java.lang.System.current_time_millis
28
+ start_time = java.lang.System.nano_time
29
29
  result = @write_client.push(event)
30
30
  report_execution_time(start_time)
31
31
  result
@@ -35,7 +35,7 @@ module LogStash module Instrument
35
35
 
36
36
  def push_batch(batch)
37
37
  increment_counters(batch.size)
38
- start_time = java.lang.System.current_time_millis
38
+ start_time = java.lang.System.nano_time
39
39
  result = @write_client.push_batch(batch)
40
40
  report_execution_time(start_time)
41
41
  result
@@ -50,7 +50,7 @@ module LogStash module Instrument
50
50
  end
51
51
 
52
52
  def report_execution_time(start_time)
53
- execution_time = java.lang.System.current_time_millis - start_time
53
+ execution_time = (java.lang.System.nano_time - start_time) / 1_000_000
54
54
  @events_metrics_time.increment(execution_time)
55
55
  @pipeline_metrics_time.increment(execution_time)
56
56
  @plugin_events_metrics_time.increment(execution_time)
@@ -45,9 +45,9 @@ module LogStash class OutputDelegator
45
45
 
46
46
  def multi_receive(events)
47
47
  @in_counter.increment(events.length)
48
- start_time = java.lang.System.current_time_millis
48
+ start_time = java.lang.System.nano_time
49
49
  @strategy.multi_receive(events)
50
- @time_metric.increment(java.lang.System.current_time_millis - start_time)
50
+ @time_metric.increment((java.lang.System.nano_time - start_time) / 1_000_000)
51
51
  @out_counter.increment(events.length)
52
52
  end
53
53
 
@@ -484,7 +484,10 @@ class LogStash::Runner < Clamp::StrictCommand
484
484
  Stud::trap("INT") do
485
485
  if @interrupted_once
486
486
  logger.fatal(I18n.t("logstash.agent.forced_sigint"))
487
- exit(1)
487
+ # calling just Kernel.exit only raises SystemExit exception
488
+ # and doesn't guarantee the process will terminate
489
+ # We must call Kernel.exit! so java.lang.System.exit is called
490
+ exit!(1)
488
491
  else
489
492
  logger.warn(I18n.t("logstash.agent.sigint"))
490
493
  Thread.new(logger) {|lg| sleep 5; lg.warn(I18n.t("logstash.agent.slow_shutdown")) }
@@ -8,11 +8,6 @@ module LogStash
8
8
  class Timestamp
9
9
  include Comparable
10
10
 
11
- # TODO (colin) implement in Java
12
- def <=>(other)
13
- self.time <=> other.time
14
- end
15
-
16
11
  def eql?(other)
17
12
  self.== other
18
13
  end
@@ -205,7 +205,7 @@ module LogStash; module Util
205
205
  end
206
206
 
207
207
  def start_clock
208
- @inflight_clocks[Thread.current] = java.lang.System.current_time_millis
208
+ @inflight_clocks[Thread.current] = java.lang.System.nano_time
209
209
  end
210
210
 
211
211
  def stop_clock(batch)
@@ -214,7 +214,7 @@ module LogStash; module Util
214
214
  # only stop (which also records) the metrics if the batch is non-empty.
215
215
  # start_clock is now called at empty batch creation and an empty batch could
216
216
  # stay empty all the way down to the close_batch call.
217
- time_taken = java.lang.System.current_time_millis - @inflight_clocks[Thread.current]
217
+ time_taken = (java.lang.System.nano_time - @inflight_clocks[Thread.current]) / 1_000_000
218
218
  @event_metric.report_time(:duration_in_millis, time_taken)
219
219
  @pipeline_metric.report_time(:duration_in_millis, time_taken)
220
220
  end
@@ -146,7 +146,7 @@ module LogStash; module Util
146
146
  end
147
147
 
148
148
  def start_clock
149
- @inflight_clocks[Thread.current] = java.lang.System.current_time_millis
149
+ @inflight_clocks[Thread.current] = java.lang.System.nano_time
150
150
  end
151
151
 
152
152
  def stop_clock(batch)
@@ -155,7 +155,7 @@ module LogStash; module Util
155
155
  # only stop (which also records) the metrics if the batch is non-empty.
156
156
  # start_clock is now called at empty batch creation and an empty batch could
157
157
  # stay empty all the way down to the close_batch call.
158
- time_taken = java.lang.System.current_time_millis - @inflight_clocks[Thread.current]
158
+ time_taken = (java.lang.System.nano_time - @inflight_clocks[Thread.current]) / 1_000_000
159
159
  @event_metric_time.increment(time_taken)
160
160
  @pipeline_metric_time.increment(time_taken)
161
161
  end
@@ -64,7 +64,7 @@ Gem::Specification.new do |gem|
64
64
  gem.add_runtime_dependency "i18n", "= 0.6.9" #(MIT license)
65
65
 
66
66
  # filetools and rakelib
67
- gem.add_runtime_dependency "minitar", "~> 0.5.4"
67
+ gem.add_runtime_dependency "minitar", "~> 0.6.1"
68
68
  gem.add_runtime_dependency "rubyzip", "~> 1.2.1"
69
69
  gem.add_runtime_dependency "thread_safe", "~> 0.3.5" #(Apache 2.0 license)
70
70
 
@@ -193,6 +193,91 @@ describe LogStash::Compiler do
193
193
  expect(c_plugin).to ir_eql(j.iPlugin(INPUT, "generator", expected_plugin_args))
194
194
  end
195
195
  end
196
+
197
+ describe "a filter plugin that repeats a Hash directive" do
198
+ let(:source) { "input { } filter { #{plugin_source} } output { } " }
199
+ subject(:c_plugin) { compiled[:filter] }
200
+
201
+ let(:plugin_source) do
202
+ %q[
203
+ grok {
204
+ match => { "message" => "%{WORD:word}" }
205
+ match => { "examplefield" => "%{NUMBER:num}" }
206
+ break_on_match => false
207
+ }
208
+ ]
209
+ end
210
+
211
+ let(:expected_plugin_args) do
212
+ {
213
+ "match" => {
214
+ "message" => "%{WORD:word}",
215
+ "examplefield" => "%{NUMBER:num}"
216
+ },
217
+ "break_on_match" => "false"
218
+ }
219
+ end
220
+
221
+ it "should merge the contents of the individual directives" do
222
+ expect(c_plugin).to ir_eql(j.iPlugin(FILTER, "grok", expected_plugin_args))
223
+ end
224
+
225
+ describe "a filter plugin that has nested Hash directives" do
226
+ let(:source) { "input { } filter { #{plugin_source} } output { } " }
227
+ let(:plugin_source) do
228
+ <<-FILTER
229
+ matryoshka {
230
+ key => "%{host}"
231
+ filter_options => {
232
+ string => "string"
233
+ integer => 3
234
+ nested => { # <-- This is nested hash!
235
+ string => "nested-string"
236
+ integer => 7
237
+ "quoted-key-string" => "nested-quoted-key-string"
238
+ "quoted-key-integer" => 31
239
+ deep => { # <-- This is deeper nested hash!
240
+ string => "deeply-nested-string"
241
+ integer => 127
242
+ "quoted-key-string" => "deeply-nested-quoted-key-string"
243
+ "quoted-key-integer" => 8191
244
+ }
245
+ }
246
+ }
247
+ ttl => 5
248
+ }
249
+ FILTER
250
+ end
251
+ subject(:c_plugin) { compiled[:filter] }
252
+
253
+ let(:expected_plugin_args) do
254
+ {
255
+ "key" => "%{host}",
256
+ "filter_options" => {
257
+ "string" => "string",
258
+ "integer" => 3,
259
+ "nested" => { # <-- This is nested hash!
260
+ "string" => "nested-string",
261
+ "integer" => 7,
262
+ "quoted-key-string" => "nested-quoted-key-string",
263
+ "quoted-key-integer" => 31,
264
+ "deep" => { # <-- This is deeper nested hash!
265
+ "string" => "deeply-nested-string",
266
+ "integer" => 127,
267
+ "quoted-key-string" => "deeply-nested-quoted-key-string",
268
+ "quoted-key-integer" => 8191
269
+ }
270
+ }
271
+ },
272
+ "ttl" => 5
273
+ }
274
+ end
275
+
276
+ it "should produce a nested ::Hash object" do
277
+ expect(c_plugin).to ir_eql(j.iPlugin(FILTER, "matryoshka", expected_plugin_args))
278
+ end
279
+ end
280
+ end
196
281
  end
197
282
 
198
283
  context "inputs" do
@@ -36,6 +36,11 @@ describe LogStash::Timestamp do
36
36
  expect{LogStash::Timestamp.new("foobar")}.to raise_error
37
37
  end
38
38
 
39
+ it "compares to any type" do
40
+ t = LogStash::Timestamp.new
41
+ expect(t == '-').to be_falsey
42
+ end
43
+
39
44
  end
40
45
 
41
46
  end
@@ -1,6 +1,6 @@
1
1
  ---
2
- logstash: 6.0.0-rc2
3
- logstash-core: 6.0.0-rc2
2
+ logstash: 6.0.1
3
+ logstash-core: 6.0.1
4
4
  logstash-core-plugin-api: 2.1.16
5
5
  jruby:
6
6
  version: 9.1.13.0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0.rc2
4
+ version: 6.0.1
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-29 00:00:00.000000000 Z
11
+ date: 2017-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -209,7 +209,7 @@ dependencies:
209
209
  requirements:
210
210
  - - "~>"
211
211
  - !ruby/object:Gem::Version
212
- version: 0.5.4
212
+ version: 0.6.1
213
213
  name: minitar
214
214
  prerelease: false
215
215
  type: :runtime
@@ -217,7 +217,7 @@ dependencies:
217
217
  requirements:
218
218
  - - "~>"
219
219
  - !ruby/object:Gem::Version
220
- version: 0.5.4
220
+ version: 0.6.1
221
221
  - !ruby/object:Gem::Dependency
222
222
  requirement: !ruby/object:Gem::Requirement
223
223
  requirements:
@@ -627,9 +627,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
627
627
  version: '0'
628
628
  required_rubygems_version: !ruby/object:Gem::Requirement
629
629
  requirements:
630
- - - ">"
630
+ - - ">="
631
631
  - !ruby/object:Gem::Version
632
- version: 1.3.1
632
+ version: '0'
633
633
  requirements:
634
634
  - jar org.apache.logging.log4j:log4j-slf4j-impl, 2.6.2
635
635
  - jar org.apache.logging.log4j:log4j-api, 2.6.2