logstash-devutils 2.0.0-java → 2.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: 9529292d4be6bf7ae845758206433d9fff38a8fdf068d4eee49581a595022563
4
- data.tar.gz: '09bac2f78a40a15e156f893929a0113bb815234f5e24dacd0b806d94a7db7784'
3
+ metadata.gz: bbe4f7fcac7be8836722ca86c35bfb15ee88755b3e86090a48dc06c4956d8924
4
+ data.tar.gz: 9d0878398c1ea6025c093c4a5d52fa0dd44610337e236565b2801b301bfcdbf4
5
5
  SHA512:
6
- metadata.gz: 2c1f07ee224a06900492e5421031b1f8e4a15705edf0feb91bfe4279853cb30a3bd248933209e20e16d91e19c65f7b8dd6e29b5a75ee293b80c5e3c5032aa4b9
7
- data.tar.gz: 1b151df23dd77671425a0874a4b0903de5460d10f93a8b521c8019ff4f71965b8ff52089d2978eebe3dfd0b91e1342dac9ecaffbde6a3fa3735a7a938482b81e
6
+ metadata.gz: d01f4d24ac50a2b5cb26037e85035d6201626de2f3caf059e12166589f9a1f45b7e4043b887d3894befd9084858a00d1e0e1f2884a2dfa2c9acc36d3d2656638
7
+ data.tar.gz: fc51d639ee289af95294609389be443dd264603b03c31432def9552b9d30a6274f29c0390f2b1a97fa7470a02bb8271b4283c3796355a017e95010cfd0b41960
@@ -88,16 +88,21 @@ module LogStashHelper
88
88
  end
89
89
  end # def sample
90
90
 
91
+ org.logstash.config.ir.compiler.OutputStrategyExt::SimpleAbstractOutputStrategyExt.class_eval do
92
+ field_reader :output # available since LS 6.3
93
+ end
94
+
91
95
  def input(config_string, test_sink: {}, &block); require 'logstash/outputs/test_sink'
92
96
  config_parts = [ config_source(config_string), test_sink_output_source(**test_sink) ]
93
97
 
94
- # TODO unwrapping output from LogStash::OutputDelegator is cumbersome
95
- instances = LogStash::Outputs::TestSink::TRACKER.keys.to_a
96
98
  pipeline = new_pipeline(config_parts)
97
99
 
98
- start_thread = pipeline.start_and_wait
100
+ output_delegator = pipeline.outputs.last # LogStash::OutputDelegator
101
+ fail('test_sink output expected') unless output_delegator.config_name.eql?('test_sink')
102
+ test_sink_output = output_delegator.strategy.to_java.output
103
+ queue = test_sink_output.init_event_store
99
104
 
100
- queue = (LogStash::Outputs::TestSink::TRACKER.keys.to_a - instances).first.event_store
105
+ start_thread = pipeline.start_and_wait
101
106
 
102
107
  # NOTE: we used to pass a Queue here, now its a Java List/Queue collection
103
108
  result = block.call(pipeline, queue)
@@ -22,7 +22,7 @@ class LogStash::Outputs::TestSink < LogStash::Outputs::Base
22
22
 
23
23
  # @override plugin hook
24
24
  def register
25
- TRACKER[self] = Queue.new(@event_poll_timeout.to_f * 1000)
25
+ TRACKER[self] = @_event_store || init_event_store
26
26
  end
27
27
 
28
28
  # @override plugin impl
@@ -32,7 +32,8 @@ class LogStash::Outputs::TestSink < LogStash::Outputs::Base
32
32
 
33
33
  # @override plugin hook
34
34
  def close
35
- TRACKER.delete(self) if release_on_close?
35
+ TRACKER.delete(self)
36
+ @_event_store = false if release_on_close?
36
37
  end
37
38
 
38
39
  def store_events?
@@ -50,7 +51,24 @@ class LogStash::Outputs::TestSink < LogStash::Outputs::Base
50
51
 
51
52
  # @return [Queue] (enumerable) event store
52
53
  def event_store
53
- TRACKER[self] || raise("#{self} not registered; please call plugin.register before use")
54
+ if @_event_store.nil?
55
+ warn("#{self} event store not initialized (call plugin.register to initialize)", caller_locations(2))
56
+ return init_event_store
57
+ elsif @_event_store.eql?(false)
58
+ warn("#{self} closed - event store no longer available (release_on_close => false if you need to retain events)", caller_locations(2))
59
+ return nil
60
+ end
61
+ @_event_store
62
+ end
63
+
64
+ def init_event_store
65
+ @_event_store = Queue.new(@event_poll_timeout.to_f * 1000)
66
+ end
67
+
68
+ private
69
+
70
+ def warn(msg, callstack = nil)
71
+ Kernel.warn("#{msg}#{callstack ? " called from #{callstack.first}" : nil}")
54
72
  end
55
73
 
56
74
  # TODO refactor to java.util.concurrent.ConcurrentLinkedQueue
@@ -4,7 +4,7 @@ Gem::Specification.new do |spec|
4
4
  files = %x{git ls-files}.split("\n")
5
5
 
6
6
  spec.name = "logstash-devutils"
7
- spec.version = "2.0.0"
7
+ spec.version = "2.0.1"
8
8
  spec.license = "Apache-2.0"
9
9
  spec.authors = ["Elastic"]
10
10
  spec.email = "info@elastic.co"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-devutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.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: 2020-02-11 00:00:00.000000000 Z
11
+ date: 2020-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement