Skip to content

Commit

Permalink
Add transparent support for count query embargo on failure. (#294)
Browse files Browse the repository at this point in the history
* Add transparent support for count query embargo on failure.

* changes as per review

Fixes #161
Fixes #164 
Fixes #226 
Fixes #236 
Fixes #254 
Fixes #286 
Fixes #287
  • Loading branch information
Guy Boertje authored Aug 29, 2018
1 parent c38b6fd commit 36d2279
Show file tree
Hide file tree
Showing 10 changed files with 465 additions and 324 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 4.3.12
- Added check to prevent count sql syntax errors when debug logging [Issue #287](https://github.com/logstash-plugins/logstash-input-jdbc/issue/287) and [Pull Request #294](https://github.com/logstash-plugins/logstash-input-jdbc/pull/294)

## 4.3.11
- Fixed crash that occurs when receiving string input that cannot be coerced to UTF-8 (such as BLOB data) [#291](https://github.com/logstash-plugins/logstash-input-jdbc/pull/291)

Expand Down
2 changes: 1 addition & 1 deletion NOTICE.TXT
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Elasticsearch
Copyright 2012-2015 Elasticsearch
Copyright 2012-2018 Elasticsearch

This product includes software developed by The Apache Software
Foundation (http://www.apache.org/).
24 changes: 17 additions & 7 deletions lib/logstash/inputs/jdbc.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# encoding: utf-8
require "logstash/inputs/base"
require "logstash/namespace"
require "logstash/plugin_mixins/jdbc"
require "logstash/plugin_mixins/jdbc/jdbc"


# This plugin was created as a way to ingest data from any database
Expand Down Expand Up @@ -123,8 +123,8 @@
# }
# ---------------------------------------------------------------------------------------------------
#
class LogStash::Inputs::Jdbc < LogStash::Inputs::Base
include LogStash::PluginMixins::Jdbc
module LogStash module Inputs class Jdbc < LogStash::Inputs::Base
include LogStash::PluginMixins::Jdbc::Jdbc
config_name "jdbc"

# If undefined, Logstash will complain, even if codec is unused.
Expand Down Expand Up @@ -213,21 +213,22 @@ def register
end
end

@value_tracker = LogStash::PluginMixins::ValueTracking.build_last_value_tracker(self)
set_value_tracker(LogStash::PluginMixins::Jdbc::ValueTracking.build_last_value_tracker(self))
set_statement_logger(LogStash::PluginMixins::Jdbc::CheckedCountLogger.new(@logger))

@enable_encoding = !@charset.nil? || !@columns_charset.empty?

unless @statement.nil? ^ @statement_filepath.nil?
raise(LogStash::ConfigurationError, "Must set either :statement or :statement_filepath. Only one may be set at a time.")
end

@statement = File.read(@statement_filepath) if @statement_filepath
@statement = ::File.read(@statement_filepath) if @statement_filepath

if (@jdbc_password_filepath and @jdbc_password)
raise(LogStash::ConfigurationError, "Only one of :jdbc_password, :jdbc_password_filepath may be set at a time.")
end

@jdbc_password = LogStash::Util::Password.new(File.read(@jdbc_password_filepath).strip) if @jdbc_password_filepath
@jdbc_password = LogStash::Util::Password.new(::File.read(@jdbc_password_filepath).strip) if @jdbc_password_filepath

if enable_encoding?
encodings = @columns_charset.values
Expand All @@ -241,6 +242,15 @@ def register
end
end # def register

# test injection points
def set_statement_logger(instance)
@statement_logger = instance
end

def set_value_tracker(instance)
@value_tracker = instance
end

def run(queue)
if @schedule
@scheduler = Rufus::Scheduler.new(:max_work_threads => 1)
Expand Down Expand Up @@ -296,4 +306,4 @@ def convert(column_name, value)
value
end
end
end # class LogStash::Inputs::Jdbc
end end end # class LogStash::Inputs::Jdbc
313 changes: 0 additions & 313 deletions lib/logstash/plugin_mixins/jdbc.rb

This file was deleted.

Loading

0 comments on commit 36d2279

Please sign in to comment.