Skip to content

Commit 36d2279

Browse files
author
Guy Boertje
authored
Add transparent support for count query embargo on failure. (#294)
* 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
1 parent c38b6fd commit 36d2279

File tree

10 files changed

+465
-324
lines changed

10 files changed

+465
-324
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 4.3.12
2+
- 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)
3+
14
## 4.3.11
25
- 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)
36

NOTICE.TXT

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Elasticsearch
2-
Copyright 2012-2015 Elasticsearch
2+
Copyright 2012-2018 Elasticsearch
33

44
This product includes software developed by The Apache Software
55
Foundation (http://www.apache.org/).

lib/logstash/inputs/jdbc.rb

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# encoding: utf-8
22
require "logstash/inputs/base"
33
require "logstash/namespace"
4-
require "logstash/plugin_mixins/jdbc"
4+
require "logstash/plugin_mixins/jdbc/jdbc"
55

66

77
# This plugin was created as a way to ingest data from any database
@@ -123,8 +123,8 @@
123123
# }
124124
# ---------------------------------------------------------------------------------------------------
125125
#
126-
class LogStash::Inputs::Jdbc < LogStash::Inputs::Base
127-
include LogStash::PluginMixins::Jdbc
126+
module LogStash module Inputs class Jdbc < LogStash::Inputs::Base
127+
include LogStash::PluginMixins::Jdbc::Jdbc
128128
config_name "jdbc"
129129

130130
# If undefined, Logstash will complain, even if codec is unused.
@@ -213,21 +213,22 @@ def register
213213
end
214214
end
215215

216-
@value_tracker = LogStash::PluginMixins::ValueTracking.build_last_value_tracker(self)
216+
set_value_tracker(LogStash::PluginMixins::Jdbc::ValueTracking.build_last_value_tracker(self))
217+
set_statement_logger(LogStash::PluginMixins::Jdbc::CheckedCountLogger.new(@logger))
217218

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

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

224-
@statement = File.read(@statement_filepath) if @statement_filepath
225+
@statement = ::File.read(@statement_filepath) if @statement_filepath
225226

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

230-
@jdbc_password = LogStash::Util::Password.new(File.read(@jdbc_password_filepath).strip) if @jdbc_password_filepath
231+
@jdbc_password = LogStash::Util::Password.new(::File.read(@jdbc_password_filepath).strip) if @jdbc_password_filepath
231232

232233
if enable_encoding?
233234
encodings = @columns_charset.values
@@ -241,6 +242,15 @@ def register
241242
end
242243
end # def register
243244

245+
# test injection points
246+
def set_statement_logger(instance)
247+
@statement_logger = instance
248+
end
249+
250+
def set_value_tracker(instance)
251+
@value_tracker = instance
252+
end
253+
244254
def run(queue)
245255
if @schedule
246256
@scheduler = Rufus::Scheduler.new(:max_work_threads => 1)
@@ -296,4 +306,4 @@ def convert(column_name, value)
296306
value
297307
end
298308
end
299-
end # class LogStash::Inputs::Jdbc
309+
end end end # class LogStash::Inputs::Jdbc

lib/logstash/plugin_mixins/jdbc.rb

Lines changed: 0 additions & 313 deletions
This file was deleted.

0 commit comments

Comments
 (0)