Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da5a3d8be3 | ||
|
|
b10462dacd | ||
|
|
61c7a1307e | ||
|
|
b5419813ba |
@@ -1,6 +1,14 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
All notable changes to this project will be documented in this file, from 0.2.0.
|
All notable changes to this project will be documented in this file, from 0.2.0.
|
||||||
|
|
||||||
|
## [0.2.10] - 2016-07-07
|
||||||
|
- Support non-string entries in statement array
|
||||||
|
- Adds backtrace to exception logging
|
||||||
|
|
||||||
|
## [0.2.9] - 2016-06-29
|
||||||
|
- Fix NameError exception.
|
||||||
|
- Moved log_jdbc_exception calls
|
||||||
|
|
||||||
## [0.2.7] - 2016-05-29
|
## [0.2.7] - 2016-05-29
|
||||||
- Backport retry exception logic from v5 branch
|
- Backport retry exception logic from v5 branch
|
||||||
- Backport improved timestamp compatibility from v5 branch
|
- Backport improved timestamp compatibility from v5 branch
|
||||||
|
|||||||
@@ -151,7 +151,6 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
|
|||||||
|
|
||||||
if @exceptions_tracker.reject { |i| i.nil? }.count >= @max_flush_exceptions
|
if @exceptions_tracker.reject { |i| i.nil? }.count >= @max_flush_exceptions
|
||||||
@logger.error("JDBC - max_flush_exceptions has been reached")
|
@logger.error("JDBC - max_flush_exceptions has been reached")
|
||||||
log_jdbc_exception(e)
|
|
||||||
raise LogStash::ShutdownSignal.new
|
raise LogStash::ShutdownSignal.new
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -223,7 +222,7 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
|
|||||||
begin
|
begin
|
||||||
connection = @pool.getConnection()
|
connection = @pool.getConnection()
|
||||||
rescue => e
|
rescue => e
|
||||||
log_jdbc_exception(e)
|
log_jdbc_exception(e, true)
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -242,7 +241,6 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
|
|||||||
statement.close()
|
statement.close()
|
||||||
@exceptions_tracker << nil
|
@exceptions_tracker << nil
|
||||||
rescue => e
|
rescue => e
|
||||||
log_jdbc_exception(e)
|
|
||||||
if retry_exception?(e)
|
if retry_exception?(e)
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
@@ -258,7 +256,7 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
|
|||||||
begin
|
begin
|
||||||
connection = @pool.getConnection()
|
connection = @pool.getConnection()
|
||||||
rescue => e
|
rescue => e
|
||||||
log_jdbc_exception(e)
|
log_jdbc_exception(e, true)
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -277,7 +275,6 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
|
|||||||
@exceptions_tracker << nil
|
@exceptions_tracker << nil
|
||||||
end
|
end
|
||||||
rescue => e
|
rescue => e
|
||||||
log_jdbc_exception(e)
|
|
||||||
if retry_exception?(e)
|
if retry_exception?(e)
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
@@ -289,10 +286,19 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
|
|||||||
|
|
||||||
def add_statement_event_params(statement, event)
|
def add_statement_event_params(statement, event)
|
||||||
@statement[1..-1].each_with_index do |i, idx|
|
@statement[1..-1].each_with_index do |i, idx|
|
||||||
case event[i]
|
if i.is_a? String
|
||||||
|
value = event[i]
|
||||||
|
if value.nil? and i =~ /%\{/
|
||||||
|
value = event.sprintf(i)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
value = i
|
||||||
|
end
|
||||||
|
|
||||||
|
case value
|
||||||
when Time
|
when Time
|
||||||
# See LogStash::Timestamp, below, for the why behind strftime.
|
# See LogStash::Timestamp, below, for the why behind strftime.
|
||||||
statement.setString(idx + 1, event[i].strftime(STRFTIME_FMT))
|
statement.setString(idx + 1, value.strftime(STRFTIME_FMT))
|
||||||
when LogStash::Timestamp
|
when LogStash::Timestamp
|
||||||
# XXX: Using setString as opposed to setTimestamp, because setTimestamp
|
# XXX: Using setString as opposed to setTimestamp, because setTimestamp
|
||||||
# doesn't behave correctly in some drivers (Known: sqlite)
|
# doesn't behave correctly in some drivers (Known: sqlite)
|
||||||
@@ -301,43 +307,46 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base
|
|||||||
# choke on the 'T' in the string (Known: Derby).
|
# choke on the 'T' in the string (Known: Derby).
|
||||||
#
|
#
|
||||||
# strftime appears to be the most reliable across drivers.
|
# strftime appears to be the most reliable across drivers.
|
||||||
statement.setString(idx + 1, event[i].time.strftime(STRFTIME_FMT))
|
statement.setString(idx + 1, value.time.strftime(STRFTIME_FMT))
|
||||||
when Fixnum, Integer
|
when Fixnum, Integer
|
||||||
statement.setInt(idx + 1, event[i])
|
statement.setInt(idx + 1, value)
|
||||||
when Float
|
when Float
|
||||||
statement.setFloat(idx + 1, event[i])
|
statement.setFloat(idx + 1, value)
|
||||||
when String
|
when String
|
||||||
statement.setString(idx + 1, event[i])
|
statement.setString(idx + 1, value)
|
||||||
when true
|
when true, false
|
||||||
statement.setBoolean(idx + 1, true)
|
statement.setBoolean(idx + 1, value)
|
||||||
when false
|
|
||||||
statement.setBoolean(idx + 1, false)
|
|
||||||
else
|
else
|
||||||
if event[i].nil? and i =~ /%\{/
|
statement.setString(idx + 1, nil)
|
||||||
statement.setString(idx + 1, event.sprintf(i))
|
|
||||||
else
|
|
||||||
statement.setString(idx + 1, nil)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
statement
|
statement
|
||||||
end
|
end
|
||||||
|
|
||||||
def log_jdbc_exception(exception)
|
|
||||||
|
def log_jdbc_exception(exception, retrying)
|
||||||
current_exception = exception
|
current_exception = exception
|
||||||
|
log_text = 'JDBC - Exception. ' + (retrying ? 'Retrying' : 'Not retrying') + '.'
|
||||||
|
log_method = (retrying ? 'warn' : 'error')
|
||||||
|
|
||||||
loop do
|
loop do
|
||||||
@logger.error("JDBC Exception encountered: Will automatically retry.", :exception => current_exception)
|
@logger.send(log_method, log_text, :exception => current_exception, :backtrace => current_exception.backtrace)
|
||||||
current_exception = current_exception.getNextException()
|
|
||||||
|
if current_exception.respond_to? 'getNextException'
|
||||||
|
current_exception = current_exception.getNextException()
|
||||||
|
else
|
||||||
|
current_exception = nil
|
||||||
|
end
|
||||||
|
|
||||||
break if current_exception == nil
|
break if current_exception == nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def retry_exception?(exception)
|
def retry_exception?(exception)
|
||||||
if exception.respond_to? 'getSQLState'
|
retrying = (exception.respond_to? 'getSQLState' and RETRYABLE_SQLSTATE_CLASSES.include?(exception.getSQLState.to_s[0,2]))
|
||||||
return RETRYABLE_SQLSTATE_CLASSES.include?(e.getSQLState[0,2])
|
log_jdbc_exception(exception, retrying)
|
||||||
end
|
|
||||||
|
|
||||||
true
|
retrying
|
||||||
end
|
end
|
||||||
end # class LogStash::Outputs::jdbc
|
end # class LogStash::Outputs::jdbc
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = 'logstash-output-jdbc'
|
s.name = 'logstash-output-jdbc'
|
||||||
s.version = "0.2.8"
|
s.version = "0.2.10"
|
||||||
s.licenses = [ "Apache License (2.0)" ]
|
s.licenses = [ "Apache License (2.0)" ]
|
||||||
s.summary = "This plugin allows you to output to SQL, via JDBC"
|
s.summary = "This plugin allows you to output to SQL, via JDBC"
|
||||||
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
|
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
|
||||||
@@ -19,11 +19,11 @@ Gem::Specification.new do |s|
|
|||||||
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
|
||||||
|
|
||||||
# Gem dependencies
|
# Gem dependencies
|
||||||
s.add_runtime_dependency "logstash-core", ">= 2.0.0.beta2", "< 3.0.0"
|
|
||||||
s.add_runtime_dependency 'stud'
|
s.add_runtime_dependency 'stud'
|
||||||
|
|
||||||
|
s.add_runtime_dependency "logstash-core", ">= 2.0.0", "< 3.0.0"
|
||||||
s.add_runtime_dependency "logstash-codec-plain"
|
s.add_runtime_dependency "logstash-codec-plain"
|
||||||
|
|
||||||
s.add_development_dependency "logstash-devutils"
|
# https://github.com/elastic/logstash-devutils/issues/48
|
||||||
|
s.add_development_dependency "logstash-devutils", '0.0.18'
|
||||||
s.post_install_message = "logstash-output-jdbc 0.2.0 introduces several new features - please ensure you check the documentation in the README file"
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user