logstash-input-jdbc 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 12acaddce06cd026085f24f5a2f3a98e7ed4601c
4
- data.tar.gz: d3d94c320ded529e75f61bb179eec4e1a208c020
3
+ metadata.gz: f9a172f33d553e84914b76176ea860be37621cb1
4
+ data.tar.gz: 1ae5eedcd6b6d392c33b49f6050a661c1a564c4c
5
5
  SHA512:
6
- metadata.gz: 3c3326f38200479396f9cc6c8baa547277d349f340262f958b4dc050c273d284f2d8f86b5fe219239d0508ce8615983ad7b0f6daa56c269aca66610dbb53caf5
7
- data.tar.gz: a216617f9e1a6f25600cd4c35f0ff7dbcd32e2f0d14cfc2dd0d4dd9123b5a2204760b7e905e9ae269d06b8f54ddb702932b246d828033608c4ee1f5362a09588
6
+ metadata.gz: 7d2873101ca8ac7491d897317cd8e74dfb1681fd97fc574a4a9f21c1ea186e05278e942697a9c23420f949b4877084fc13d596da3dfafb44bb97d70e84f0f314
7
+ data.tar.gz: 607a3fcb288f023ae56cc6f3668c318e15addf16b4ec2911351ec82f099f0636a7409bce584b97743f22e78c6115d07c4f2d7ef7f295253f0463c11fb828cbc4
data/CHANGELOG.md CHANGED
@@ -1,7 +1,11 @@
1
+ ## 2.0.3
2
+ - Added ability to configure timeout
3
+ - Added catch-all configuration option for any other options that Sequel lib supports
4
+
1
5
  ## 2.0.0
2
6
  - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
3
7
  instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
4
8
  - Dependency on logstash-core update to 2.0
5
9
 
6
- * 1.0.0
7
- - Initial release
10
+ * 1.0.0
11
+ - Initial release
@@ -57,6 +57,37 @@ module LogStash::PluginMixins::Jdbc
57
57
  # Connection pool configuration.
58
58
  # How often to validate a connection (in seconds)
59
59
  config :jdbc_validation_timeout, :validate => :number, :default => 3600
60
+
61
+ # Connection pool configuration.
62
+ # The amount of seconds to wait to acquire a connection before raising a PoolTimeoutError (default 5)
63
+ config :jdbc_pool_timeout, :validate => :number, :default => 5
64
+
65
+ # General/Vendor-specific Sequel configuration options.
66
+ #
67
+ # An example of an optional connection pool configuration
68
+ # max_connections - The maximum number of connections the connection pool
69
+ #
70
+ # examples of vendor-specific options can be found in this
71
+ # documentation page: https://github.com/jeremyevans/sequel/blob/master/doc/opening_databases.rdoc
72
+ config :sequel_opts, :validate => :hash, :default => {}
73
+ end
74
+
75
+ private
76
+ def jdbc_connect
77
+ opts = {
78
+ :user => @jdbc_user,
79
+ :password => @jdbc_password,
80
+ :pool_timeout => @jdbc_pool_timeout
81
+ }.merge(@sequel_opts)
82
+ begin
83
+ Sequel.connect(@jdbc_connection_string, opts=opts)
84
+ rescue Sequel::PoolTimeout => e
85
+ @logger.error("Failed to connect to database. #{@jdbc_pool_timeout} second timeout exceeded.")
86
+ raise e
87
+ rescue Sequel::Error => e
88
+ @logger.error("Unable to connect to database", :error_message => e.message)
89
+ raise e
90
+ end
60
91
  end
61
92
 
62
93
  public
@@ -76,7 +107,7 @@ module LogStash::PluginMixins::Jdbc
76
107
  end
77
108
  raise LogStash::ConfigurationError, "#{e}. #{message}"
78
109
  end
79
- @database = Sequel.connect(@jdbc_connection_string, :user=> @jdbc_user, :password=> @jdbc_password.nil? ? nil : @jdbc_password.value)
110
+ @database = jdbc_connect()
80
111
  @database.extension(:pagination)
81
112
  if @jdbc_validate_connection
82
113
  @database.extension(:connection_validator)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-input-jdbc'
3
- s.version = '2.0.2'
3
+ s.version = '2.0.3'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "This example input streams a string at a definable interval."
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/plugin install gemname. This gem is not a stand-alone program"
@@ -310,4 +310,37 @@ describe LogStash::Inputs::Jdbc do
310
310
  expect { plugin.register }.to raise_error(LogStash::ConfigurationError)
311
311
  end
312
312
  end
313
+
314
+ context "when timing out on connection" do
315
+ let(:settings) do
316
+ {
317
+ "statement" => "SELECT * FROM test_table",
318
+ "jdbc_pool_timeout" => 0,
319
+ "jdbc_connection_string" => 'mock://localhost:1527/db',
320
+ "sequel_opts" => {
321
+ "max_connections" => 1
322
+ }
323
+ }
324
+ end
325
+
326
+ it "should raise PoolTimeout error" do
327
+ plugin.register
328
+ db = plugin.instance_variable_get(:@database)
329
+ expect(db.pool.instance_variable_get(:@timeout)).to eq(0)
330
+ expect(db.pool.instance_variable_get(:@max_size)).to eq(1)
331
+
332
+ q, q1 = Queue.new, Queue.new
333
+ t = Thread.new{db.pool.hold{|c| q1.push nil; q.pop}}
334
+ q1.pop
335
+ expect{db.pool.hold {|c|}}.to raise_error(Sequel::PoolTimeout)
336
+ q.push nil
337
+ t.join
338
+ end
339
+
340
+ it "should log error message" do
341
+ allow(Sequel).to receive(:connect).and_raise(Sequel::PoolTimeout)
342
+ expect(plugin.logger).to receive(:error).with("Failed to connect to database. 0 second timeout exceeded.")
343
+ expect { plugin.register }.to raise_error(Sequel::PoolTimeout)
344
+ end
345
+ end
313
346
  end
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-jdbc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-14 00:00:00.000000000 Z
11
+ date: 2015-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- requirement: !ruby/object:Gem::Requirement
14
+ name: logstash-core
15
+ version_requirements: !ruby/object:Gem::Requirement
15
16
  requirements:
16
17
  - - '>='
17
18
  - !ruby/object:Gem::Version
@@ -19,10 +20,7 @@ dependencies:
19
20
  - - <
20
21
  - !ruby/object:Gem::Version
21
22
  version: 3.0.0
22
- name: logstash-core
23
- prerelease: false
24
- type: :runtime
25
- version_requirements: !ruby/object:Gem::Requirement
23
+ requirement: !ruby/object:Gem::Requirement
26
24
  requirements:
27
25
  - - '>='
28
26
  - !ruby/object:Gem::Version
@@ -30,119 +28,121 @@ dependencies:
30
28
  - - <
31
29
  - !ruby/object:Gem::Version
32
30
  version: 3.0.0
31
+ prerelease: false
32
+ type: :runtime
33
33
  - !ruby/object:Gem::Dependency
34
+ name: logstash-codec-plain
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
34
40
  requirement: !ruby/object:Gem::Requirement
35
41
  requirements:
36
42
  - - '>='
37
43
  - !ruby/object:Gem::Version
38
44
  version: '0'
39
- name: logstash-codec-plain
40
45
  prerelease: false
41
46
  type: :runtime
47
+ - !ruby/object:Gem::Dependency
48
+ name: sequel
42
49
  version_requirements: !ruby/object:Gem::Requirement
43
50
  requirements:
44
51
  - - '>='
45
52
  - !ruby/object:Gem::Version
46
53
  version: '0'
47
- - !ruby/object:Gem::Dependency
48
54
  requirement: !ruby/object:Gem::Requirement
49
55
  requirements:
50
56
  - - '>='
51
57
  - !ruby/object:Gem::Version
52
58
  version: '0'
53
- name: sequel
54
59
  prerelease: false
55
60
  type: :runtime
61
+ - !ruby/object:Gem::Dependency
62
+ name: rufus-scheduler
56
63
  version_requirements: !ruby/object:Gem::Requirement
57
64
  requirements:
58
65
  - - '>='
59
66
  - !ruby/object:Gem::Version
60
67
  version: '0'
61
- - !ruby/object:Gem::Dependency
62
68
  requirement: !ruby/object:Gem::Requirement
63
69
  requirements:
64
70
  - - '>='
65
71
  - !ruby/object:Gem::Version
66
72
  version: '0'
67
- name: rufus-scheduler
68
73
  prerelease: false
69
74
  type: :runtime
75
+ - !ruby/object:Gem::Dependency
76
+ name: logstash-devutils
70
77
  version_requirements: !ruby/object:Gem::Requirement
71
78
  requirements:
72
79
  - - '>='
73
80
  - !ruby/object:Gem::Version
74
81
  version: '0'
75
- - !ruby/object:Gem::Dependency
76
82
  requirement: !ruby/object:Gem::Requirement
77
83
  requirements:
78
84
  - - '>='
79
85
  - !ruby/object:Gem::Version
80
86
  version: '0'
81
- name: logstash-devutils
82
87
  prerelease: false
83
88
  type: :development
89
+ - !ruby/object:Gem::Dependency
90
+ name: timecop
84
91
  version_requirements: !ruby/object:Gem::Requirement
85
92
  requirements:
86
93
  - - '>='
87
94
  - !ruby/object:Gem::Version
88
95
  version: '0'
89
- - !ruby/object:Gem::Dependency
90
96
  requirement: !ruby/object:Gem::Requirement
91
97
  requirements:
92
98
  - - '>='
93
99
  - !ruby/object:Gem::Version
94
100
  version: '0'
95
- name: timecop
96
101
  prerelease: false
97
102
  type: :development
103
+ - !ruby/object:Gem::Dependency
104
+ name: jdbc-derby
98
105
  version_requirements: !ruby/object:Gem::Requirement
99
106
  requirements:
100
107
  - - '>='
101
108
  - !ruby/object:Gem::Version
102
109
  version: '0'
103
- - !ruby/object:Gem::Dependency
104
110
  requirement: !ruby/object:Gem::Requirement
105
111
  requirements:
106
112
  - - '>='
107
113
  - !ruby/object:Gem::Version
108
114
  version: '0'
109
- name: jdbc-derby
110
115
  prerelease: false
111
116
  type: :development
117
+ - !ruby/object:Gem::Dependency
118
+ name: docker-api
112
119
  version_requirements: !ruby/object:Gem::Requirement
113
120
  requirements:
114
121
  - - '>='
115
122
  - !ruby/object:Gem::Version
116
123
  version: '0'
117
- - !ruby/object:Gem::Dependency
118
124
  requirement: !ruby/object:Gem::Requirement
119
125
  requirements:
120
126
  - - '>='
121
127
  - !ruby/object:Gem::Version
122
128
  version: '0'
123
- name: docker-api
124
129
  prerelease: false
125
130
  type: :development
126
- version_requirements: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - '>='
129
- - !ruby/object:Gem::Version
130
- version: '0'
131
131
  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
132
132
  email: info@elastic.co
133
133
  executables: []
134
134
  extensions: []
135
135
  extra_rdoc_files: []
136
136
  files:
137
+ - lib/logstash/inputs/jdbc.rb
138
+ - lib/logstash/plugin_mixins/jdbc.rb
139
+ - spec/inputs/jdbc_spec.rb
140
+ - logstash-input-jdbc.gemspec
141
+ - README.md
137
142
  - CHANGELOG.md
138
143
  - Gemfile
139
144
  - LICENSE
140
145
  - NOTICE.TXT
141
- - README.md
142
- - lib/logstash/inputs/jdbc.rb
143
- - lib/logstash/plugin_mixins/jdbc.rb
144
- - logstash-input-jdbc.gemspec
145
- - spec/inputs/jdbc_spec.rb
146
146
  homepage: http://www.elastic.co/guide/en/logstash/current/index.html
147
147
  licenses:
148
148
  - Apache License (2.0)
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  version: '0'
166
166
  requirements: []
167
167
  rubyforge_project:
168
- rubygems_version: 2.4.8
168
+ rubygems_version: 2.1.9
169
169
  signing_key:
170
170
  specification_version: 4
171
171
  summary: This example input streams a string at a definable interval.