lib/logstash/inputs/jdbc.rb in logstash-integration-jdbc-5.2.6 vs lib/logstash/inputs/jdbc.rb in logstash-integration-jdbc-5.3.0

- old
+ new

@@ -1,16 +1,15 @@ # encoding: utf-8 require "logstash/inputs/base" require "logstash/namespace" require "logstash/plugin_mixins/jdbc/common" require "logstash/plugin_mixins/jdbc/jdbc" -require "logstash/plugin_mixins/jdbc/scheduler" require "logstash/plugin_mixins/ecs_compatibility_support" require "logstash/plugin_mixins/ecs_compatibility_support/target_check" require "logstash/plugin_mixins/validator_support/field_reference_validation_adapter" - require "logstash/plugin_mixins/event_support/event_factory_adapter" +require "logstash/plugin_mixins/scheduler" require "fileutils" # this require_relative returns early unless the JRuby version is between 9.2.0.0 and 9.2.8.0 require_relative "tzinfo_jruby_patch" @@ -145,10 +144,12 @@ include LogStash::PluginMixins::EventSupport::EventFactoryAdapter # adds :field_reference validator adapter extend LogStash::PluginMixins::ValidatorSupport::FieldReferenceValidationAdapter + include LogStash::PluginMixins::Scheduler + config_name "jdbc" # If undefined, Logstash will complain, even if codec is unused. default :codec, "plain" @@ -258,11 +259,10 @@ end @last_run_metadata_file_path = @last_run_metadata_path end end - require "rufus/scheduler" prepare_jdbc_connection if @use_column_value # Raise an error if @use_column_value is true, but no @tracking_column is set if @tracking_column.nil? @@ -317,25 +317,19 @@ end def run(queue) load_driver if @schedule - # input thread (Java) name example "[my-oracle]<jdbc" - @scheduler = LogStash::PluginMixins::Jdbc::Scheduler. - start_cron_scheduler(@schedule, thread_name: "[#{id}]<jdbc__scheduler") { execute_query(queue) } - @scheduler.join + # scheduler input thread name example: "[my-oracle]|input|jdbc|scheduler" + scheduler.cron(@schedule) { execute_query(queue) } + scheduler.join else execute_query(queue) end end # def run - def close - @scheduler.shutdown if @scheduler - end - def stop close_jdbc_connection - @scheduler.shutdown(:wait) if @scheduler end private def validate_prepared_statement_mode