logstash-input-jdbc 4.3.1 → 4.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/logstash/inputs/jdbc.rb +1 -2
- data/lib/logstash/plugin_mixins/jdbc.rb +38 -27
- data/logstash-input-jdbc.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbcee49388bb159c11488cba2030c74f0d51f6e52615c1190a7f0bc9d2d84dda
|
4
|
+
data.tar.gz: 615585ac894d3a2bbb8677848b9d518d68594d53477dbc6c71413044373ffa51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 816c79b9ac881b3fe8b2524323e8b67321d21dfda0c82efa638a8b2a3bccaa7e9aeebe920385cb33b4ba01e19f60cb368fbcdca9fe43aba6dc84df4e891ef46b
|
7
|
+
data.tar.gz: 6c2f68235f963c58bbbaf523b09cdfb7dae004fee7a6973de860761b394579f6aae4efab07259f4ed923d3f78c9d04cb1cde39ead37c6376e882151c2065dad0
|
data/CHANGELOG.md
CHANGED
data/lib/logstash/inputs/jdbc.rb
CHANGED
@@ -4,6 +4,8 @@ require "logstash/config/mixin"
|
|
4
4
|
require "time"
|
5
5
|
require "date"
|
6
6
|
|
7
|
+
java_import java.util.concurrent.locks.ReentrantLock
|
8
|
+
|
7
9
|
# Tentative of abstracting JDBC logic to a mixin
|
8
10
|
# for potential reuse in other plugins (input/output)
|
9
11
|
module LogStash::PluginMixins::Jdbc
|
@@ -191,6 +193,7 @@ module LogStash::PluginMixins::Jdbc
|
|
191
193
|
|
192
194
|
public
|
193
195
|
def prepare_jdbc_connection
|
196
|
+
@connection_lock = ReentrantLock.new
|
194
197
|
if @use_column_value
|
195
198
|
case @tracking_column_type
|
196
199
|
when "numeric"
|
@@ -206,26 +209,41 @@ module LogStash::PluginMixins::Jdbc
|
|
206
209
|
public
|
207
210
|
def close_jdbc_connection
|
208
211
|
begin
|
212
|
+
# pipeline restarts can also close the jdbc connection, block until the current executing statement is finished to avoid leaking connections
|
213
|
+
# connections in use won't really get closed
|
214
|
+
@connection_lock.lock
|
209
215
|
@database.disconnect if @database
|
210
216
|
rescue => e
|
211
217
|
@logger.warn("Failed to close connection", :exception => e)
|
218
|
+
ensure
|
219
|
+
@connection_lock.unlock
|
212
220
|
end
|
213
221
|
end
|
214
222
|
|
215
223
|
public
|
216
224
|
def execute_statement(statement, parameters)
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
225
|
+
success = false
|
226
|
+
@connection_lock.lock
|
227
|
+
open_jdbc_connection
|
228
|
+
begin
|
229
|
+
parameters = symbolized_params(parameters)
|
230
|
+
query = @database[statement, parameters]
|
231
|
+
sql_last_value = @use_column_value ? @sql_last_value : Time.now.utc
|
232
|
+
@tracking_column_warning_sent = false
|
233
|
+
@logger.debug? and @logger.debug("Executing JDBC query", :statement => statement, :parameters => parameters, :count => query.count)
|
234
|
+
|
235
|
+
if @jdbc_paging_enabled
|
236
|
+
query.each_page(@jdbc_page_size) do |paged_dataset|
|
237
|
+
paged_dataset.each do |row|
|
238
|
+
sql_last_value = get_column_value(row) if @use_column_value
|
239
|
+
if @tracking_column_type=="timestamp" and @use_column_value and sql_last_value.is_a?(DateTime)
|
240
|
+
sql_last_value=Time.parse(sql_last_value.to_s) # Coerce the timestamp to a `Time`
|
241
|
+
end
|
242
|
+
yield extract_values_from(row)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
else
|
246
|
+
query.each do |row|
|
229
247
|
sql_last_value = get_column_value(row) if @use_column_value
|
230
248
|
if @tracking_column_type=="timestamp" and @use_column_value and sql_last_value.is_a?(DateTime)
|
231
249
|
sql_last_value=Time.parse(sql_last_value.to_s) # Coerce the timestamp to a `Time`
|
@@ -233,23 +251,16 @@ module LogStash::PluginMixins::Jdbc
|
|
233
251
|
yield extract_values_from(row)
|
234
252
|
end
|
235
253
|
end
|
254
|
+
success = true
|
255
|
+
rescue Sequel::DatabaseConnectionError, Sequel::DatabaseError => e
|
256
|
+
@logger.warn("Exception when executing JDBC query", :exception => e)
|
236
257
|
else
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
end
|
242
|
-
yield extract_values_from(row)
|
243
|
-
end
|
258
|
+
@sql_last_value = sql_last_value
|
259
|
+
ensure
|
260
|
+
close_jdbc_connection
|
261
|
+
@connection_lock.unlock
|
244
262
|
end
|
245
|
-
success
|
246
|
-
rescue Sequel::DatabaseConnectionError, Sequel::DatabaseError => e
|
247
|
-
@logger.warn("Exception when executing JDBC query", :exception => e)
|
248
|
-
else
|
249
|
-
@sql_last_value = sql_last_value
|
250
|
-
end
|
251
|
-
close_jdbc_connection
|
252
|
-
return success
|
263
|
+
return success
|
253
264
|
end
|
254
265
|
|
255
266
|
public
|
data/logstash-input-jdbc.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-input-jdbc'
|
3
|
-
s.version = '4.3.
|
3
|
+
s.version = '4.3.2'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "Creates events from JDBC data"
|
6
6
|
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-jdbc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.3.
|
4
|
+
version: 4.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
196
|
version: '0'
|
197
197
|
requirements: []
|
198
198
|
rubyforge_project:
|
199
|
-
rubygems_version: 2.6.
|
199
|
+
rubygems_version: 2.6.13
|
200
200
|
signing_key:
|
201
201
|
specification_version: 4
|
202
202
|
summary: Creates events from JDBC data
|