logstash-input-stomp 3.0.5 → 3.0.6

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: 503865c8c2b88f201914aac8cb164194e50efeb2
4
- data.tar.gz: 7aa43e6a686c31ab5a8b31ea48c6391f5c14f64d
3
+ metadata.gz: b99721a442817dbc133e72433f9522f0db4139b9
4
+ data.tar.gz: 307485148adf50b3e1a78fc4c4b8e5d3074a7dc2
5
5
  SHA512:
6
- metadata.gz: d32ac232a7c72502e94f3309232c8f25b8925338e5a64556f1ca671abc8b42d51495c28e8ccb9538996f6bd95c2b7cfb58afa772e8a5f44eb0dc7b2eeb0d6090
7
- data.tar.gz: 63681a165a9668be4cb33c1235b46b5b09a8d2d35af79a5554984bde087a4e98437e38c8dfbc75735616af98bb173e410acfd4fa998f305a789dc99d337ce09e
6
+ metadata.gz: dea43df7013a335009bc0cd673731837480dda5d92a958a30844b6260a35f294c4c4d105001311155da78456e1f6b6b081db9cf3039a6ceedbd484784d22c803
7
+ data.tar.gz: afdf310ac9ca54a69ebccc88a76ef7290134036a5792c11595adbbd1ec57680da0b946329f95ac5dd3cd6a7b0bca09aa83396b81d5d18c14f4e25b9d56b64381
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 3.0.6
2
+ - Wait till pipeline is in run state to connect. Before this patch this plugin
3
+ could block logstash indefinitely due to a connect method that never finishes.
4
+
1
5
  ## 3.0.5
2
6
  - Fix some documentation issues
3
7
 
@@ -46,15 +46,15 @@ class LogStash::Inputs::Stomp < LogStash::Inputs::Base
46
46
  @client.connect
47
47
  @logger.info("Connected to stomp server") if @client.connected?
48
48
  rescue OnStomp::ConnectFailedError, OnStomp::UnsupportedProtocolVersionError, Errno::ECONNREFUSED => e
49
- if @reconnect
50
- @logger.warn("Failed to connect to stomp server. Retry in #{@reconnect_interval} seconds. #{e.inspect}")
51
- @logger.debug("#{e.backtrace.join("\n")}") if @debug
52
- sleep @reconnect_interval
49
+ if @reconnect && !stop?
50
+ @logger.warn("Failed to connect to stomp server. Retry in #{@reconnect_interval} seconds. #{e.inspect}")
51
+ @logger.debug("#{e.backtrace.join("\n")}") if @debug
52
+ sleep @reconnect_interval
53
53
  retry
54
54
  end
55
+
55
56
  @logger.warn("Failed to connect to stomp server. Exiting with error: #{e.inspect}")
56
57
  @logger.debug("#{e.backtrace.join("\n")}") if @debug
57
- stop?
58
58
  end
59
59
  end
60
60
 
@@ -65,14 +65,6 @@ class LogStash::Inputs::Stomp < LogStash::Inputs::Base
65
65
  @client = new_client
66
66
  @client.host = @vhost if @vhost
67
67
  @stomp_url = "stomp://#{@user}:#{@password}@#{@host}:#{@port}/#{@destination}"
68
-
69
- # Handle disconnects
70
- @client.on_connection_closed {
71
- connect
72
- subscription_handler # is required for re-subscribing to the destination
73
- }
74
-
75
- connect
76
68
  end # def register
77
69
 
78
70
  def new_client
@@ -103,7 +95,18 @@ class LogStash::Inputs::Stomp < LogStash::Inputs::Base
103
95
 
104
96
  public
105
97
  def run(output_queue)
98
+ # Handle disconnects
99
+ @client.on_connection_closed {
100
+ self.connect
101
+ subscription_handler # is required for re-subscribing to the destination
102
+ }
103
+
104
+ connect
106
105
  @output_queue = output_queue
107
106
  subscription_handler
108
107
  end # def run
108
+
109
+ def stop
110
+ @client.disconnect if @client && @client.connected?
111
+ end
109
112
  end # class LogStash::Inputs::Stomp
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-input-stomp'
4
- s.version = '3.0.5'
4
+ s.version = '3.0.6'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Pull events from a stomp server"
7
7
  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"
@@ -2,7 +2,6 @@ require "logstash/devutils/rspec/spec_helper"
2
2
  require "logstash/inputs/stomp"
3
3
 
4
4
  describe LogStash::Inputs::Stomp do
5
- let(:klass) { LogStash::Inputs::Stomp }
6
5
  let(:host) { "localhost" }
7
6
  let(:destination) { "/foo" }
8
7
  let(:stomp_settings) {
@@ -11,34 +10,37 @@ describe LogStash::Inputs::Stomp do
11
10
  "destination" => destination
12
11
  }
13
12
  }
14
- let(:instance) { klass.new(stomp_settings) }
13
+ subject(:instance) { described_class.new(stomp_settings) }
14
+ let(:client) { double("client") }
15
15
 
16
- context "when connected" do
17
- let(:client) { double("client") }
18
-
19
- before do
20
- allow(instance).to receive(:new_client).and_return(client)
21
- allow(client).to receive(:connect)
22
- allow(client).to receive(:connected?).and_return(true)
23
- allow(client).to receive(:on_connection_closed)
24
- end
16
+ before do
17
+ allow(instance).to receive(:new_client).and_return(client)
18
+ allow(client).to receive(:on_connection_closed)
19
+ allow(instance).to receive(:new_client).and_return(client)
20
+ end
25
21
 
22
+ context "when registered" do
26
23
  it "should register without error" do
27
24
  instance.register
28
25
  end
29
26
  end
30
27
 
31
- describe "stopping" do
32
- let(:config) { {"host" => "localhost", "destination" => "/foo"} }
33
- let(:client) { double("client") }
28
+ context "connecting and disconnecting" do
34
29
  before do
35
- allow(subject).to receive(:new_client).and_return(client)
36
- allow(subject).to receive(:connect)
37
30
  allow(client).to receive(:connect)
38
31
  allow(client).to receive(:connected?).and_return(true)
39
- allow(client).to receive(:on_connection_closed)
40
32
  allow(client).to receive(:subscribe)
33
+ allow(client).to receive(:disconnect)
34
+ end
35
+
36
+ it "should connect and disconnect" do
37
+ instance.register
38
+ t = Thread.new { instance.run(Queue.new) }
39
+ sleep 5
40
+ expect(client).to have_received(:connect)
41
+ instance.do_stop
42
+ expect(client).to have_received(:disconnect)
43
+ t.join
41
44
  end
42
- it_behaves_like "an interruptible input plugin"
43
45
  end
44
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-input-stomp
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.5
4
+ version: 3.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-16 00:00:00.000000000 Z
11
+ date: 2017-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement