From 4e7985dafd00f438142c3471fbfb0aa6b47c7aff Mon Sep 17 00:00:00 2001 From: Karl Southern Date: Tue, 16 Feb 2016 15:29:08 +0000 Subject: [PATCH] Addresses #28 - connection timeout bug --- lib/logstash/outputs/jdbc.rb | 6 ++++-- logstash-output-jdbc.gemspec | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/logstash/outputs/jdbc.rb b/lib/logstash/outputs/jdbc.rb index ba41064..53a9adf 100644 --- a/lib/logstash/outputs/jdbc.rb +++ b/lib/logstash/outputs/jdbc.rb @@ -44,7 +44,7 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base config :max_pool_size, :validate => :number, :default => 5 # Connection timeout - config :connection_timeout, :validate => :number, :default => 2800 + config :connection_timeout, :validate => :number, :default => 10000 # We buffer a certain number of events before flushing that out to SQL. # This setting controls how many events will be buffered before sending a @@ -156,9 +156,11 @@ class LogStash::Outputs::Jdbc < LogStash::Outputs::Base @pool.setMaximumPoolSize(@max_pool_size) @pool.setConnectionTimeout(@connection_timeout) + validate_connection_timeout = (@connection_timeout / 1000) / 2 + # Test connection test_connection = @pool.getConnection() - unless test_connection.isValid(10) + unless test_connection.isValid(validate_connection_timeout) @logger.error("JDBC - Connection is not valid. Please check connection string or that your JDBC endpoint is available.") end test_connection.close() diff --git a/logstash-output-jdbc.gemspec b/logstash-output-jdbc.gemspec index f04d1e4..e6fdd94 100644 --- a/logstash-output-jdbc.gemspec +++ b/logstash-output-jdbc.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'logstash-output-jdbc' - s.version = "0.2.2" + s.version = "0.2.3" s.licenses = [ "Apache License (2.0)" ] 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"