logstash-integration-jdbc 5.1.3 → 5.1.7

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: 629c09f028a534cb970327b8d98eb85d8ae0371f4e9c7ccc8c5c9194d2942293
4
- data.tar.gz: 9fddcb34b38b9be0bdc80cfc9c9385dacbcb821530be8c78c21024414b70f0ba
3
+ metadata.gz: 631bf72cc9e0bb40840f5e7537919e0501a766ddc020a970508004dbebe19d9e
4
+ data.tar.gz: d712fc0933239f37b56c88b3cfb7de121452ea07901ed7a17ce6339b0f351fc5
5
5
  SHA512:
6
- metadata.gz: 06f23b86b0f5f15bb5c0b93cca5068199df24e9867e891d72d930dd87c7f9faf891a2d0937f55d92e74a3769b432f87c5559e07cc028bbc64652631d927f4ebb
7
- data.tar.gz: 969df6533a1c1afcd01ff89283195cde0865ee72bae75ed77e9ef7abfb129af9eb62b485d5a0d293189d5348df71b546dd911146d9e46ea0b481369b938959ca
6
+ metadata.gz: 304d561709459feb36273bfb95cfb8dcc50aa86f2fe39d9f0af7153cdef5dbdbe91c934d8bf5c015f2c7b16ccba679042e8713f6460101b626bce79c7d2d1d3a
7
+ data.tar.gz: 220f00788a142ec81d5b00b0fd370ae15a02709553a28679351e04d1551252c080f2a6f62a11d1a61fe832f2e77ca0259d31b570834242277d18a09670ee38c3
data/CHANGELOG.md CHANGED
@@ -1,9 +1,23 @@
1
+ ## 5.1.7
2
+ - Normalize jdbc_driver_class loading to support any top-level java packages [#86](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/86)
3
+
4
+ ## 5.1.6
5
+ - Fix, serialize the JDBC driver loading steps to avoid concurrency issues [#84](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/84)
6
+
7
+ ## 5.1.5
8
+ - Refined ECS support [#82](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/82)
9
+ - Uses shared `target` guidance when ECS compatibility is enabled
10
+ - Uses Logstash's EventFactory instead of instantiating events directly
11
+
12
+ ## 5.1.4
13
+ - [DOC] Update filter-jdbc_static doc to describe ECS compatibility [#79](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/79)
14
+
1
15
  ## 5.1.3
2
16
  - Improve robustness when handling errors from `sequel` library in jdbc static and streaming
3
- filters[#78](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/78)
17
+ filters [#78](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/78)
4
18
 
5
19
  ## 5.1.2
6
- - Fix `prepared_statement_bind_values` in streaming filter to resolve nested event's fields[#76](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/76)
20
+ - Fix `prepared_statement_bind_values` in streaming filter to resolve nested event's fields [#76](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/76)
7
21
 
8
22
  ## 5.1.1
9
23
  - [DOC] Changed docs to indicate that logstash-jdbc-static requires local_table [#56](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/56). Fixes [#55](https://github.com/logstash-plugins/logstash-integration-jdbc/issues/55).
@@ -264,8 +264,17 @@ order is in place.
264
264
  ===============================
265
265
 
266
266
 
267
+ [id="plugins-{type}s-{plugin}-ecs"]
268
+ ==== Compatibility with the Elastic Common Schema (ECS)
269
+
270
+ This plugin is compatible with the {ecs-ref}[Elastic Common Schema (ECS)].
271
+ It behaves the same regardless of ECS compatibility, except giving a warning when ECS is enabled and `target` isn't set.
272
+
273
+ TIP: Set the `target` option to avoid potential schema conflicts.
274
+
275
+
267
276
  [id="plugins-{type}s-{plugin}-options"]
268
- ==== Jdbc_static Filter Configuration Options
277
+ ==== Jdbc_static filter configuration options
269
278
 
270
279
  This plugin supports the following configuration options plus the <<plugins-{type}s-{plugin}-common-options>> described later.
271
280
 
@@ -4,8 +4,11 @@ require "logstash/namespace"
4
4
  require "logstash/plugin_mixins/jdbc/common"
5
5
  require "logstash/plugin_mixins/jdbc/jdbc"
6
6
  require "logstash/plugin_mixins/ecs_compatibility_support"
7
+ require "logstash/plugin_mixins/ecs_compatibility_support/target_check"
7
8
  require "logstash/plugin_mixins/validator_support/field_reference_validation_adapter"
8
9
 
10
+ require "logstash/plugin_mixins/event_support/event_factory_adapter"
11
+
9
12
  # this require_relative returns early unless the JRuby version is between 9.2.0.0 and 9.2.8.0
10
13
  require_relative "tzinfo_jruby_patch"
11
14
 
@@ -131,8 +134,14 @@ require_relative "tzinfo_jruby_patch"
131
134
  module LogStash module Inputs class Jdbc < LogStash::Inputs::Base
132
135
  include LogStash::PluginMixins::Jdbc::Common
133
136
  include LogStash::PluginMixins::Jdbc::Jdbc
137
+
134
138
  # adds ecs_compatibility config which could be :disabled or :v1
135
139
  include LogStash::PluginMixins::ECSCompatibilitySupport(:disabled,:v1,:v8 => :v1)
140
+ include LogStash::PluginMixins::ECSCompatibilitySupport::TargetCheck
141
+
142
+ # adds `event_factory` and `targeted_event_factory
143
+ include LogStash::PluginMixins::EventSupport::EventFactoryAdapter
144
+
136
145
  # adds :field_reference validator adapter
137
146
  extend LogStash::PluginMixins::ValidatorSupport::FieldReferenceValidationAdapter
138
147
 
@@ -270,13 +279,6 @@ module LogStash module Inputs class Jdbc < LogStash::Inputs::Base
270
279
  converters[encoding] = converter
271
280
  end
272
281
  end
273
-
274
- # target must be populated if ecs_compatibility is not :disabled
275
- if @target.nil? && ecs_compatibility != :disabled
276
- logger.info('ECS compatibility is enabled but no ``target`` option was specified, it is recommended'\
277
- ' to set the option to avoid potential schema conflicts (if your data is ECS compliant or'\
278
- ' non-conflicting feel free to ignore this message)')
279
- end
280
282
  end # def register
281
283
 
282
284
  # test injection points
@@ -335,12 +337,7 @@ module LogStash module Inputs class Jdbc < LogStash::Inputs::Base
335
337
  ## do the necessary conversions to string elements
336
338
  row = Hash[row.map { |k, v| [k.to_s, convert(k, v)] }]
337
339
  end
338
- if @target
339
- event = LogStash::Event.new
340
- event.set(@target, row)
341
- else
342
- event = LogStash::Event.new(row)
343
- end
340
+ event = targeted_event_factory.new_event(row)
344
341
  decorate(event)
345
342
  queue << event
346
343
  end
@@ -4,6 +4,8 @@ module LogStash module PluginMixins module Jdbc
4
4
 
5
5
  private
6
6
 
7
+ DRIVERS_LOADING_LOCK = java.util.concurrent.locks.ReentrantLock.new()
8
+
7
9
  def complete_sequel_opts(defaults = {})
8
10
  sequel_opts = @sequel_opts.
9
11
  map { |key,val| [key.is_a?(String) ? key.to_sym : key, val] }.
@@ -22,18 +24,25 @@ module LogStash module PluginMixins module Jdbc
22
24
  require "sequel"
23
25
  require "sequel/adapters/jdbc"
24
26
 
25
- load_driver_jars
27
+ # execute all the driver loading related duties in a serial fashion to avoid
28
+ # concurrency related problems with multiple pipelines and multiple drivers
29
+ DRIVERS_LOADING_LOCK.lock()
26
30
  begin
27
- @driver_impl = Sequel::JDBC.load_driver(@jdbc_driver_class)
28
- rescue Sequel::AdapterNotFound => e # Sequel::AdapterNotFound, "#{@jdbc_driver_class} not loaded"
29
- # fix this !!!
30
- message = if jdbc_driver_library_set?
31
- "Are you sure you've included the correct jdbc driver in :jdbc_driver_library?"
32
- else
33
- ":jdbc_driver_library is not set, are you sure you included " +
34
- "the proper driver client libraries in your classpath?"
35
- end
36
- raise LogStash::PluginLoadingError, "#{e}. #{message}"
31
+ load_driver_jars
32
+ begin
33
+ @driver_impl = Sequel::JDBC.load_driver(normalized_driver_class)
34
+ rescue Sequel::AdapterNotFound => e # Sequel::AdapterNotFound, "#{@jdbc_driver_class} not loaded"
35
+ # fix this !!!
36
+ message = if jdbc_driver_library_set?
37
+ "Are you sure you've included the correct jdbc driver in :jdbc_driver_library?"
38
+ else
39
+ ":jdbc_driver_library is not set, are you sure you included " +
40
+ "the proper driver client libraries in your classpath?"
41
+ end
42
+ raise LogStash::PluginLoadingError, "#{e}. #{message} #{e.backtrace}"
43
+ end
44
+ ensure
45
+ DRIVERS_LOADING_LOCK.unlock()
37
46
  end
38
47
  end
39
48
 
@@ -62,5 +71,16 @@ module LogStash module PluginMixins module Jdbc
62
71
  !@jdbc_driver_library.nil? && !@jdbc_driver_library.empty?
63
72
  end
64
73
 
74
+ # normalizing the class name to always have a Java:: prefix
75
+ # is helpful since JRuby is only able to directly load class names
76
+ # whose top-level package is com, org, java, javax
77
+ # There are many jdbc drivers that use cc, io, net, etc.
78
+ def normalized_driver_class
79
+ if @jdbc_driver_class.start_with?("Java::", "Java.")
80
+ @jdbc_driver_class
81
+ else
82
+ "Java::#{@jdbc_driver_class}"
83
+ end
84
+ end
65
85
  end
66
86
  end end end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-integration-jdbc'
3
- s.version = '5.1.3'
3
+ s.version = '5.1.7'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "Integration with JDBC - input and filter plugins"
6
6
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -36,8 +36,9 @@ Gem::Specification.new do |s|
36
36
  s.add_runtime_dependency 'tzinfo-data'
37
37
  # 3.5 limitation is required for jdbc-static loading schedule
38
38
  s.add_runtime_dependency 'rufus-scheduler', '< 3.5'
39
- s.add_runtime_dependency 'logstash-mixin-ecs_compatibility_support', '~>1.2'
39
+ s.add_runtime_dependency 'logstash-mixin-ecs_compatibility_support', '~>1.3'
40
40
  s.add_runtime_dependency "logstash-mixin-validator_support", '~> 1.0'
41
+ s.add_runtime_dependency "logstash-mixin-event_support", '~> 1.0'
41
42
 
42
43
  s.add_development_dependency "childprocess"
43
44
  s.add_development_dependency 'logstash-devutils'
@@ -14,10 +14,11 @@ require "date"
14
14
 
15
15
  describe LogStash::Inputs::Jdbc do
16
16
  let(:connection_string) { "jdbc:derby:memory:testdb;create=true" }
17
+ let(:jdbc_driver_class) { "org.apache.derby.jdbc.EmbeddedDriver" }
17
18
  let(:mixin_settings) do
18
19
  {
19
20
  "jdbc_user" => ENV['USER'],
20
- "jdbc_driver_class" => "org.apache.derby.jdbc.EmbeddedDriver",
21
+ "jdbc_driver_class" => jdbc_driver_class,
21
22
  "jdbc_connection_string" => connection_string
22
23
  }
23
24
  end
@@ -364,7 +365,7 @@ describe LogStash::Inputs::Jdbc do
364
365
  end
365
366
 
366
367
  it "should log a warn of missed target usage" do
367
- expect(plugin.logger).to receive(:info).once.with(/ECS compatibility is enabled but no .*?target.*? was specified/)
368
+ expect(plugin.logger).to receive(:info).once.with(a_string_including("ECS compatibility is enabled").and(including("target")))
368
369
 
369
370
  plugin.register
370
371
  end
@@ -1619,4 +1620,21 @@ describe LogStash::Inputs::Jdbc do
1619
1620
  end
1620
1621
  end
1621
1622
  end
1623
+
1624
+ describe "jdbc_driver_class" do
1625
+ context "when not prefixed with Java::" do
1626
+ let(:jdbc_driver_class) { "org.apache.derby.jdbc.EmbeddedDriver" }
1627
+ it "loads the class prefixed with Java::" do
1628
+ expect(Sequel::JDBC).to receive(:load_driver).with(/^Java::/)
1629
+ plugin.send(:load_driver)
1630
+ end
1631
+ end
1632
+ context "when prefixed with Java::" do
1633
+ let(:jdbc_driver_class) { "Java::org.apache.derby.jdbc.EmbeddedDriver" }
1634
+ it "loads the class as-is" do
1635
+ expect(Sequel::JDBC).to receive(:load_driver).with(jdbc_driver_class)
1636
+ plugin.send(:load_driver)
1637
+ end
1638
+ end
1639
+ end
1622
1640
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-integration-jdbc
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.3
4
+ version: 5.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-09 00:00:00.000000000 Z
11
+ date: 2021-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -147,7 +147,7 @@ dependencies:
147
147
  requirements:
148
148
  - - "~>"
149
149
  - !ruby/object:Gem::Version
150
- version: '1.2'
150
+ version: '1.3'
151
151
  name: logstash-mixin-ecs_compatibility_support
152
152
  prerelease: false
153
153
  type: :runtime
@@ -155,7 +155,7 @@ dependencies:
155
155
  requirements:
156
156
  - - "~>"
157
157
  - !ruby/object:Gem::Version
158
- version: '1.2'
158
+ version: '1.3'
159
159
  - !ruby/object:Gem::Dependency
160
160
  requirement: !ruby/object:Gem::Requirement
161
161
  requirements:
@@ -170,6 +170,20 @@ dependencies:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
172
  version: '1.0'
173
+ - !ruby/object:Gem::Dependency
174
+ requirement: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - "~>"
177
+ - !ruby/object:Gem::Version
178
+ version: '1.0'
179
+ name: logstash-mixin-event_support
180
+ prerelease: false
181
+ type: :runtime
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - "~>"
185
+ - !ruby/object:Gem::Version
186
+ version: '1.0'
173
187
  - !ruby/object:Gem::Dependency
174
188
  requirement: !ruby/object:Gem::Requirement
175
189
  requirements:
@@ -318,8 +332,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
318
332
  - !ruby/object:Gem::Version
319
333
  version: '0'
320
334
  requirements: []
321
- rubyforge_project:
322
- rubygems_version: 2.6.13
335
+ rubygems_version: 3.1.6
323
336
  signing_key:
324
337
  specification_version: 4
325
338
  summary: Integration with JDBC - input and filter plugins