logstash-integration-jdbc 5.2.3 → 5.2.4
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 +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile +2 -0
- data/lib/logstash/filters/jdbc/loader_schedule.rb +11 -45
- data/lib/logstash/filters/jdbc/repeating_load_runner.rb +0 -2
- data/lib/logstash/filters/jdbc/single_load_runner.rb +0 -4
- data/lib/logstash/filters/jdbc_static.rb +7 -8
- data/lib/logstash/inputs/jdbc.rb +2 -13
- data/lib/logstash/plugin_mixins/jdbc/scheduler.rb +28 -0
- data/lib/logstash/plugin_mixins/jdbc/value_tracking.rb +0 -3
- data/logstash-integration-jdbc.gemspec +4 -2
- data/spec/filters/jdbc/repeating_load_runner_spec.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad77fc92ab07e1da7e4c6285075b6583f9f293c073199b614e3852cd22bbc6a9
|
4
|
+
data.tar.gz: 9e7b2c0f0c16930903bdee1f22b2651db7cf9f80d01a12f212b7a40155d4ebea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2928a01bbe1ef418f36d6ddc7847416fc6d43278b20242926037bef02e8a429ba1d4587f1bd88f8d52de2ec1fef26e749aeb358de82a8bf69c36e5c3c9d42f8e
|
7
|
+
data.tar.gz: 8aae596826ec1d9155e0f8bdfad9a882e92fa2be610f89d7c67a7b3f44f0e6937bcbafd78900457d92b20a5a28188163f7b4f25040d8deb229f505ab6faf2c22
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## 5.2.4
|
2
|
+
- Fix: compatibility with all (>= 3.0) rufus-scheduler versions [#97](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/97)
|
3
|
+
|
1
4
|
## 5.2.3
|
2
5
|
- Performance: avoid contention on scheduler execution [#103](https://github.com/logstash-plugins/logstash-integration-jdbc/pull/103)
|
3
6
|
|
data/Gemfile
CHANGED
@@ -9,3 +9,5 @@ if Dir.exist?(logstash_path) && use_logstash_source
|
|
9
9
|
gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
|
10
10
|
gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
|
11
11
|
end
|
12
|
+
|
13
|
+
gem 'rufus-scheduler', ENV['RUFUS_SCHEDULER_VERSION'] if ENV['RUFUS_SCHEDULER_VERSION']
|
@@ -4,60 +4,26 @@ require "rufus/scheduler"
|
|
4
4
|
|
5
5
|
module LogStash module Filters module Jdbc
|
6
6
|
class LoaderSchedule < Validatable
|
7
|
-
attr_reader :
|
8
|
-
|
9
|
-
def to_log_string
|
10
|
-
message = ""
|
11
|
-
message.concat "these months in the year [#{@cronline.months.to_a.join(", ")}];" unless @cronline.months.nil?
|
12
|
-
message.concat "these days in the month [#{@cronline.days.to_a.join(", ")}];" unless @cronline.days.nil?
|
13
|
-
message.concat "these hours in the day [#{@cronline.hours.to_a.join(", ")}];" unless @cronline.hours.nil?
|
14
|
-
message.concat "these minutes in the hour [#{@cronline.minutes.to_a.join(", ")}];" unless @cronline.minutes.nil?
|
15
|
-
message.concat "these seconds in the minute [#{@cronline.seconds.to_a.join(", ")}]" unless @cronline.seconds.nil?
|
16
|
-
if !message.empty?
|
17
|
-
message.prepend "Scheduled for: "
|
18
|
-
end
|
19
|
-
message
|
20
|
-
end
|
7
|
+
attr_reader :loader_schedule
|
21
8
|
|
22
9
|
private
|
23
10
|
|
24
|
-
|
25
|
-
if valid?
|
26
|
-
# From the Rufus::Scheduler docs:
|
27
|
-
# By default, rufus-scheduler sleeps 0.300 second between every step.
|
28
|
-
# At each step it checks for jobs to trigger and so on.
|
29
|
-
# set the frequency to 2.5 seconds if we are not reloading in the seconds timeframe
|
30
|
-
# rufus scheduler thread should respond to stop quickly enough.
|
31
|
-
if only_seconds_set?
|
32
|
-
@schedule_frequency = 0.3
|
33
|
-
else
|
34
|
-
@schedule_frequency = 2.5
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
|
40
|
-
def only_seconds_set?
|
41
|
-
@cronline.seconds &&
|
42
|
-
@cronline.minutes.nil? &&
|
43
|
-
@cronline.hours.nil? &&
|
44
|
-
@cronline.days.nil? &&
|
45
|
-
@cronline.months.nil?
|
46
|
-
end
|
47
|
-
|
11
|
+
# @overload
|
48
12
|
def parse_options
|
49
13
|
@loader_schedule = @options
|
50
14
|
|
51
|
-
|
15
|
+
if @loader_schedule.is_a?(String)
|
16
|
+
begin
|
17
|
+
# Rufus::Scheduler 3.0 - 3.6 methods signature: parse_cron(o, opts)
|
18
|
+
# since Rufus::Scheduler 3.7 methods signature: parse_cron(o, opts={})
|
19
|
+
@cronline = Rufus::Scheduler.parse_cron(@loader_schedule, {})
|
20
|
+
rescue => e
|
21
|
+
@option_errors << "The loader_schedule option is invalid: #{e.message}"
|
22
|
+
end
|
23
|
+
else
|
52
24
|
@option_errors << "The loader_schedule option must be a string"
|
53
25
|
end
|
54
26
|
|
55
|
-
begin
|
56
|
-
@cronline = Rufus::Scheduler::CronLine.new(@loader_schedule)
|
57
|
-
rescue => e
|
58
|
-
@option_errors << "The loader_schedule option is invalid: #{e.message}"
|
59
|
-
end
|
60
|
-
|
61
27
|
@valid = @option_errors.empty?
|
62
28
|
end
|
63
29
|
end
|
@@ -3,6 +3,7 @@ require "logstash-integration-jdbc_jars"
|
|
3
3
|
require "logstash/filters/base"
|
4
4
|
require "logstash/namespace"
|
5
5
|
require "logstash/plugin_mixins/ecs_compatibility_support"
|
6
|
+
require "logstash/plugin_mixins/jdbc/scheduler"
|
6
7
|
require_relative "jdbc/loader"
|
7
8
|
require_relative "jdbc/loader_schedule"
|
8
9
|
require_relative "jdbc/repeating_load_runner"
|
@@ -191,17 +192,15 @@ module LogStash module Filters class JdbcStatic < LogStash::Filters::Base
|
|
191
192
|
@processor = Jdbc::LookupProcessor.new(@local_lookups, global_lookup_options)
|
192
193
|
runner_args.unshift(@processor.local)
|
193
194
|
if @loader_schedule
|
194
|
-
args = []
|
195
195
|
@loader_runner = Jdbc::RepeatingLoadRunner.new(*runner_args)
|
196
196
|
@loader_runner.initial_load
|
197
|
-
|
198
|
-
|
199
|
-
|
197
|
+
@scheduler = LogStash::PluginMixins::Jdbc::Scheduler.
|
198
|
+
start_cron_scheduler(@loader_schedule, thread_name: "[#{id}]-jdbc_static__scheduler") { @loader_runner.repeated_load }
|
199
|
+
cron_job = @scheduler.cron_jobs.first
|
200
|
+
if cron_job
|
201
|
+
frequency = cron_job.respond_to?(:rough_frequency) ? cron_job.rough_frequency : cron_job.frequency
|
202
|
+
logger.info("Loaders will execute every #{frequency} seconds", loader_schedule: @loader_schedule)
|
200
203
|
end
|
201
|
-
logger.info("Scheduler scan for work frequency is: #{cronline.schedule_frequency}")
|
202
|
-
rufus_args = {:max_work_threads => 1, :frequency => cronline.schedule_frequency}
|
203
|
-
@scheduler = Rufus::Scheduler.new(rufus_args)
|
204
|
-
@scheduler.cron(cronline.loader_schedule, @loader_runner)
|
205
204
|
else
|
206
205
|
@loader_runner = Jdbc::SingleLoadRunner.new(*runner_args)
|
207
206
|
@loader_runner.initial_load
|
data/lib/logstash/inputs/jdbc.rb
CHANGED
@@ -295,19 +295,8 @@ module LogStash module Inputs class Jdbc < LogStash::Inputs::Base
|
|
295
295
|
load_driver
|
296
296
|
if @schedule
|
297
297
|
# input thread (Java) name example "[my-oracle]<jdbc"
|
298
|
-
@scheduler = LogStash::PluginMixins::Jdbc::Scheduler.
|
299
|
-
:
|
300
|
-
:thread_name => "[#{id}]<jdbc__scheduler",
|
301
|
-
# amount the scheduler thread sleeps between checking whether jobs
|
302
|
-
# should trigger, default is 0.3 which is a bit too often ...
|
303
|
-
# in theory the cron expression '* * * * * *' supports running jobs
|
304
|
-
# every second but this is very rare, we could potentially go higher
|
305
|
-
:frequency => 1.0,
|
306
|
-
)
|
307
|
-
@scheduler.schedule_cron @schedule do
|
308
|
-
execute_query(queue)
|
309
|
-
end
|
310
|
-
|
298
|
+
@scheduler = LogStash::PluginMixins::Jdbc::Scheduler.
|
299
|
+
start_cron_scheduler(@schedule, thread_name: "[#{id}]<jdbc__scheduler") { execute_query(queue) }
|
311
300
|
@scheduler.join
|
312
301
|
else
|
313
302
|
execute_query(queue)
|
@@ -12,6 +12,34 @@ module LogStash module PluginMixins module Jdbc
|
|
12
12
|
TimeImpl = defined?(Rufus::Scheduler::EoTime) ? Rufus::Scheduler::EoTime :
|
13
13
|
(defined?(Rufus::Scheduler::ZoTime) ? Rufus::Scheduler::ZoTime : ::Time)
|
14
14
|
|
15
|
+
# @param cron [String] cron-line
|
16
|
+
# @param opts [Hash] scheduler options
|
17
|
+
# @return scheduler instance
|
18
|
+
def self.start_cron_scheduler(cron, opts = {}, &block)
|
19
|
+
unless block_given?
|
20
|
+
raise ArgumentError, 'missing (cron scheduler) block - worker task to execute'
|
21
|
+
end
|
22
|
+
scheduler = new_scheduler(opts)
|
23
|
+
scheduler.schedule_cron(cron, &block)
|
24
|
+
scheduler
|
25
|
+
end
|
26
|
+
|
27
|
+
# @param opts [Hash] scheduler options
|
28
|
+
# @return scheduler instance
|
29
|
+
def self.new_scheduler(opts)
|
30
|
+
unless opts.key?(:thread_name)
|
31
|
+
raise ArgumentError, 'thread_name: option is required to be able to distinguish multiple scheduler threads'
|
32
|
+
end
|
33
|
+
opts[:max_work_threads] ||= 1
|
34
|
+
# amount the scheduler thread sleeps between checking whether jobs
|
35
|
+
# should trigger, default is 0.3 which is a bit too often ...
|
36
|
+
# in theory the cron expression '* * * * * *' supports running jobs
|
37
|
+
# every second but this is very rare, we could potentially go higher
|
38
|
+
opts[:frequency] ||= 1.0
|
39
|
+
|
40
|
+
new(opts)
|
41
|
+
end
|
42
|
+
|
15
43
|
# @overload
|
16
44
|
def timeout_jobs
|
17
45
|
# Rufus relies on `Thread.list` which is a blocking operation and with many schedulers
|
@@ -6,9 +6,6 @@ module LogStash module PluginMixins module Jdbc
|
|
6
6
|
|
7
7
|
def self.build_last_value_tracker(plugin)
|
8
8
|
handler = plugin.record_last_run ? FileHandler.new(plugin.last_run_metadata_path) : NullFileHandler.new(plugin.last_run_metadata_path)
|
9
|
-
if plugin.record_last_run
|
10
|
-
handler = FileHandler.new(plugin.last_run_metadata_path)
|
11
|
-
end
|
12
9
|
if plugin.clean_run
|
13
10
|
handler.clean
|
14
11
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-integration-jdbc'
|
3
|
-
s.version = '5.2.
|
3
|
+
s.version = '5.2.4'
|
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"
|
@@ -34,7 +34,9 @@ Gem::Specification.new do |s|
|
|
34
34
|
|
35
35
|
s.add_runtime_dependency 'tzinfo'
|
36
36
|
s.add_runtime_dependency 'tzinfo-data'
|
37
|
-
|
37
|
+
# plugin maintains compatibility with < 3.5 (3.0.9)
|
38
|
+
# but works with newer rufus-scheduler >= 3.5 as well
|
39
|
+
s.add_runtime_dependency 'rufus-scheduler'
|
38
40
|
s.add_runtime_dependency 'logstash-mixin-ecs_compatibility_support', '~>1.3'
|
39
41
|
s.add_runtime_dependency "logstash-mixin-validator_support", '~> 1.0'
|
40
42
|
s.add_runtime_dependency "logstash-mixin-event_support", '~> 1.0'
|
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.2.
|
4
|
+
version: 5.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,17 +131,17 @@ dependencies:
|
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
132
|
requirement: !ruby/object:Gem::Requirement
|
133
133
|
requirements:
|
134
|
-
- - "
|
134
|
+
- - ">="
|
135
135
|
- !ruby/object:Gem::Version
|
136
|
-
version:
|
136
|
+
version: '0'
|
137
137
|
name: rufus-scheduler
|
138
138
|
prerelease: false
|
139
139
|
type: :runtime
|
140
140
|
version_requirements: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
|
-
- - "
|
142
|
+
- - ">="
|
143
143
|
- !ruby/object:Gem::Version
|
144
|
-
version:
|
144
|
+
version: '0'
|
145
145
|
- !ruby/object:Gem::Dependency
|
146
146
|
requirement: !ruby/object:Gem::Requirement
|
147
147
|
requirements:
|