logstash-core 7.5.1-java → 7.5.2-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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 756c0e499f413c9abe6d5abb1f0525aac99667ee6a04ae1d0fd56d7c60e9a31a
4
- data.tar.gz: f132194d43addcbd27e7bd9a7ac851441cd28070af0798e0a6fad9417a3baf25
3
+ metadata.gz: 56e5fd3d10f5c62d82169fa91cca236337aacfe3935e631a466dd714f30d6430
4
+ data.tar.gz: 6c5f1b41c256f31050b8458dd529df41ef6d9f5e4eec2f1fd97608f128e5d839
5
5
  SHA512:
6
- metadata.gz: 6f337f1b1f0eb5e3d663afeae860db418fec5d261e59d8a6ae3b6baf9865d79e0d3715918c58cf923ac2d9895fbe1e4b1c477a3f522994cd7fa3af994ae3ccda
7
- data.tar.gz: 93caa27c18905b0a5073b74d732276ea63c6421c579c973a1f350e415bfe1de3d7901080ba0dd76e60402412c53fb1aa05e8ccea88b7f049bd6798f4952c878c
6
+ metadata.gz: b3800c188c11e0988c3c3e68edee3ff405c0f3f0ceb2d7cbfed8284650d15074ee355eb68f59d390ace8804ded4adc0a0ccd9f7b2966f01c1cdea67243971602
7
+ data.tar.gz: 107be1d79cb1d8914a48c24bc2f78f69c0839e1eab49b1a8cf1272031d3ea609345a5a58bd2b140494660d2b45006de7b77943fc9b25a55fb390631ef9060864
@@ -244,18 +244,28 @@ module LogStash; class JavaPipeline < JavaBasePipeline
244
244
 
245
245
  filter_queue_client.set_batch_dimensions(batch_size, batch_delay)
246
246
 
247
- pipeline_workers.times do |t|
247
+ # First launch WorkerLoop initialization in separate threads which concurrently
248
+ # compiles and initializes the worker pipelines
249
+
250
+ worker_loops = pipeline_workers.times
251
+ .map { Thread.new { init_worker_loop } }
252
+ .map(&:value)
253
+
254
+ fail("Some worker(s) were not correctly initialized") if worker_loops.any?{|v| v.nil?}
255
+
256
+ # Once all WorkerLoop have been initialized run them in separate threads
257
+
258
+ worker_loops.each_with_index do |worker_loop, t|
248
259
  thread = Thread.new do
249
260
  Util.set_thread_name("[#{pipeline_id}]>worker#{t}")
250
261
  ThreadContext.put("pipeline.id", pipeline_id)
251
- org.logstash.execution.WorkerLoop.new(
252
- lir_execution, filter_queue_client, @events_filtered, @events_consumed,
253
- @flushRequested, @flushing, @shutdownRequested, @drain_queue).run
262
+ worker_loop.run
254
263
  end
255
264
  @worker_threads << thread
256
265
  end
257
266
 
258
- # inputs should be started last, after all workers
267
+ # Finally inputs should be started last, after all workers have been initialized and started
268
+
259
269
  begin
260
270
  start_inputs
261
271
  rescue => e
@@ -470,6 +480,26 @@ module LogStash; class JavaPipeline < JavaBasePipeline
470
480
 
471
481
  private
472
482
 
483
+ # @return [WorkerLoop] a new WorkerLoop instance or nil upon construction exception
484
+ def init_worker_loop
485
+ begin
486
+ org.logstash.execution.WorkerLoop.new(
487
+ lir_execution,
488
+ filter_queue_client,
489
+ @events_filtered,
490
+ @events_consumed,
491
+ @flushRequested,
492
+ @flushing,
493
+ @shutdownRequested,
494
+ @drain_queue)
495
+ rescue => e
496
+ @logger.error(
497
+ "Worker loop initialization error",
498
+ default_logging_keys(:error => e.message, :exception => e.class, :stacktrace => e.backtrace.join("\n")))
499
+ nil
500
+ end
501
+ end
502
+
473
503
  def maybe_setup_out_plugins
474
504
  if @outputs_registered.make_true
475
505
  register_plugins(outputs)
@@ -11,10 +11,8 @@ module LogStash::Util
11
11
  def self.set_thread_name(name)
12
12
  previous_name = Java::java.lang.Thread.currentThread.getName() if block_given?
13
13
 
14
- if RUBY_ENGINE == "jruby"
15
- # Keep java and ruby thread names in sync.
16
- Java::java.lang.Thread.currentThread.setName(name)
17
- end
14
+ # Keep java and ruby thread names in sync.
15
+ Java::java.lang.Thread.currentThread.setName(name)
18
16
  Thread.current[:name] = name
19
17
 
20
18
  if UNAME == "linux"
@@ -37,18 +35,10 @@ module LogStash::Util
37
35
  Thread.current[:plugin] = plugin
38
36
  end
39
37
 
40
- def self.get_thread_id(thread)
41
- if RUBY_ENGINE == "jruby"
42
- JRuby.reference(thread).native_thread.id
43
- else
44
- raise Exception.new("Native thread IDs aren't supported outside of JRuby")
45
- end
46
- end
47
-
48
38
  def self.thread_info(thread)
49
39
  # When the `thread` is dead, `Thread#backtrace` returns `nil`; fall back to an empty array.
50
40
  backtrace = (thread.backtrace || []).map do |line|
51
- line.gsub(LogStash::Environment::LOGSTASH_HOME, "[...]")
41
+ line.sub(LogStash::Environment::LOGSTASH_HOME, "[...]")
52
42
  end
53
43
 
54
44
  blocked_on = case backtrace.first
@@ -58,7 +48,7 @@ module LogStash::Util
58
48
  end
59
49
 
60
50
  {
61
- "thread_id" => get_thread_id(thread),
51
+ "thread_id" => get_thread_id(thread), # might be nil for dead threads
62
52
  "name" => thread[:name],
63
53
  "plugin" => (thread[:plugin] ? thread[:plugin].debug_info : nil),
64
54
  "backtrace" => backtrace,
@@ -67,4 +67,24 @@ describe LogStash::Util do
67
67
  end
68
68
  end
69
69
  end
70
+
71
+ describe ".get_thread_id" do
72
+ it "returns native identifier" do
73
+ thread_id = LogStash::Util.get_thread_id(Thread.current)
74
+ expect( thread_id ).to be_a Integer
75
+ expect( thread_id ).to eq(java.lang.Thread.currentThread.getId)
76
+ end
77
+
78
+ context "when a (native) thread is collected" do
79
+ let(:dead_thread) { Thread.new { 42 }.tap { |t| sleep(0.01) while t.status } }
80
+
81
+ it "returns nil as id" do
82
+ thread = dead_thread
83
+ p thread if $VERBOSE
84
+ 2.times { java.lang.System.gc || sleep(0.01) } # we're assuming a full-gc to clear all weak-refs
85
+ # NOTE: if you notice this spec failing - remote it (a java.lang.Thread weak-ref might stick around)
86
+ expect(LogStash::Util.get_thread_id(thread)).to be nil
87
+ end
88
+ end
89
+ end
70
90
  end
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  # alpha and beta qualifiers are now added via VERSION_QUALIFIER environment var
3
- logstash: 7.5.1
4
- logstash-core: 7.5.1
3
+ logstash: 7.5.2
4
+ logstash-core: 7.5.2
5
5
  logstash-core-plugin-api: 2.1.16
6
6
 
7
7
  # jruby must reference a *released* version of jruby which can be downloaded from the official download url
@@ -21,8 +21,8 @@ jruby:
21
21
  # Note: this file is copied to the root of logstash-core because its gemspec needs it when
22
22
  # bundler evaluates the gemspec via bin/logstash
23
23
  # Ensure Jackson version here is kept in sync with version used by jrjackson gem
24
- jrjackson: 0.4.10
25
- jackson: 2.9.9
26
- jackson-databind: 2.9.9.3
24
+ jrjackson: 0.4.11
25
+ jackson: 2.9.10
26
+ jackson-databind: 2.9.10.1
27
27
 
28
28
  # This is a copy the project level versions.yml into this gem's root and it is created when the gemspec is evaluated.
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: 7.5.1
4
+ version: 7.5.2
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-17 00:00:00.000000000 Z
11
+ date: 2020-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -251,7 +251,7 @@ dependencies:
251
251
  requirements:
252
252
  - - '='
253
253
  - !ruby/object:Gem::Version
254
- version: 0.4.10
254
+ version: 0.4.11
255
255
  name: jrjackson
256
256
  prerelease: false
257
257
  type: :runtime
@@ -259,7 +259,7 @@ dependencies:
259
259
  requirements:
260
260
  - - '='
261
261
  - !ruby/object:Gem::Version
262
- version: 0.4.10
262
+ version: 0.4.11
263
263
  - !ruby/object:Gem::Dependency
264
264
  requirement: !ruby/object:Gem::Requirement
265
265
  requirements: