logstash-output-lumberjack 2.0.1 → 2.0.2

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: e94ffcc38f558649f2e489412d98459ba46bf279
4
- data.tar.gz: 61f1263d52b98610ed31197789f49c8aeb84f1af
3
+ metadata.gz: 8c8044024e6b89b6491757db35d6d097113bbca0
4
+ data.tar.gz: bf90326647ded879e8c14c95ee61e216d54117e2
5
5
  SHA512:
6
- metadata.gz: 1c9f7248e519bd11179e506ad21e445971ad5501487dbd9fc7a0dc78fd293f84ffa8b06402eb62099ae9ddcf053d7a3fa8ae2cf7a5a69b886fbf7b5640881d35
7
- data.tar.gz: ab4e974e739de5efc97fd52a271f30a9fa9b5396d324640f4494b04da40139da070cfbe66a2547d69ce7687664ea2f0f5314be1616ab874bd7cd9c8646a30652
6
+ metadata.gz: 0c3d0155764e37a51baa59238c21d82d11ae2d60d04a92ddbef1c5b2efbfab53d8d5d1fa94680b75ce8b7e86bda5bd9c44a1c8e7aceb8cce4305748903755089
7
+ data.tar.gz: c864f21d58dfa375d50395f7e9386328053f558ef20f942ab1a7b86cfcdbb13db5c6e934741d2b76a7997fb3c4fa2493748495b958efbcd5c4d6a965f21bef03
@@ -1,5 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require "logstash/outputs/base"
3
+ require "logstash/errors"
3
4
  require "stud/buffer"
4
5
  require "thread"
5
6
 
@@ -19,9 +20,9 @@ class LogStash::Outputs::Lumberjack < LogStash::Outputs::Base
19
20
 
20
21
  # window size
21
22
  config :window_size, :validate => :number, :deprecated => "Use `flush_size`", :require => false
22
-
23
- # To make efficient calls to the lumberjack output we are buffering events locally.
24
- # if the number of events exceed the number the declared `flush_size` we will
23
+
24
+ # To make efficient calls to the lumberjack output we are buffering events locally.
25
+ # if the number of events exceed the number the declared `flush_size` we will
25
26
  # send them to the logstash server.
26
27
  config :flush_size, :validate => :number, :default => 1024
27
28
 
@@ -57,7 +58,6 @@ class LogStash::Outputs::Lumberjack < LogStash::Outputs::Base
57
58
 
58
59
  public
59
60
  def receive(event)
60
-
61
61
  return if event == LogStash::SHUTDOWN
62
62
  @codec.encode(event)
63
63
  end # def receive
@@ -73,23 +73,27 @@ class LogStash::Outputs::Lumberjack < LogStash::Outputs::Base
73
73
  retry
74
74
  end # begin
75
75
  end
76
-
77
- private
76
+
77
+ def close
78
+ buffer_flush(:force => true)
79
+ end
80
+
81
+ private
78
82
  def max_items
79
83
  @window_size || @flush_size
80
84
  end
81
85
 
82
86
  def connect
83
87
  require 'resolv'
84
- @logger.info("Connecting to lumberjack server.", :addresses => @hosts, :port => @port,
88
+ @logger.info("Connecting to lumberjack server.", :addresses => @hosts, :port => @port,
85
89
  :ssl_certificate => @ssl_certificate, :window_size => @window_size)
86
90
  begin
87
91
  ips = []
88
92
  @hosts.each { |host| ips += Resolv.getaddresses host }
89
- @client = Lumberjack::Client.new(:addresses => ips.uniq, :port => @port,
93
+ @client = Lumberjack::Client.new(:addresses => ips.uniq, :port => @port,
90
94
  :ssl_certificate => @ssl_certificate, :window_size => @window_size)
91
95
  rescue Exception => e
92
- @logger.error("All hosts unavailable, sleeping", :hosts => ips.uniq, :e => e,
96
+ @logger.error("All hosts unavailable, sleeping", :hosts => ips.uniq, :e => e,
93
97
  :backtrace => e.backtrace)
94
98
  sleep(10)
95
99
  retry
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-output-lumberjack'
4
- s.version = '2.0.1'
4
+ s.version = '2.0.2'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Send events using the lumberjack protocol"
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/plugin install gemname. This gem is not a stand-alone program"
@@ -1,5 +1,6 @@
1
1
  # encoding: utf-8
2
2
  require "logstash/outputs/lumberjack"
3
+ require "logstash/errors"
3
4
  require "logstash/event"
4
5
  require "logstash/devutils/rspec/spec_helper"
5
6
  require "lumberjack/server"
@@ -20,7 +21,6 @@ describe "Sending events" do
20
21
  let(:port) { Flores::Random.integer(1024..65535) }
21
22
  let(:host) { "127.0.0.1" }
22
23
  let(:queue) { [] }
23
-
24
24
  let(:client_options) {
25
25
  {
26
26
  "hosts" => [host],
@@ -29,19 +29,32 @@ describe "Sending events" do
29
29
  "flush_size" => batch_size
30
30
  }
31
31
  }
32
+
32
33
  let(:output) { LogStash::Outputs::Lumberjack.new(client_options) }
33
34
 
34
- context "when the server closes the connection" do
35
- before do
36
- File.open(certificate_file_crt, "a") { |f| f.write(certificate.first) }
37
- File.open(certificate_file_key, "a") { |f| f.write(certificate.last) }
35
+ let(:server) {
36
+ Lumberjack::Server.new(:port => port,
37
+ :address => host,
38
+ :ssl_certificate => certificate_file_crt,
39
+ :ssl_key => certificate_file_key)
40
+
41
+ }
38
42
 
39
- server = Lumberjack::Server.new(:port => port,
40
- :address => host,
41
- :ssl_certificate => certificate_file_crt,
42
- :ssl_key => certificate_file_key)
43
43
 
44
+ before do
45
+ File.open(certificate_file_crt, "a") { |f| f.write(certificate.first) }
46
+ File.open(certificate_file_key, "a") { |f| f.write(certificate.last) }
47
+ end
48
+
49
+ after do
50
+ FileUtils.rm_rf(certificate_file_crt)
51
+ FileUtils.rm_rf(certificate_file_key)
52
+ end
53
+
54
+ context "when the server closes the connection" do
55
+ before do
44
56
  crashed_count = 0
57
+
45
58
  @server = Thread.new do
46
59
  begin
47
60
  server.run do |data|
@@ -59,11 +72,6 @@ describe "Sending events" do
59
72
  output.register
60
73
  end
61
74
 
62
- after do
63
- FileUtils.rm_rf(certificate_file_crt)
64
- FileUtils.rm_rf(certificate_file_key)
65
- end
66
-
67
75
  it "reconnects and resend the payload" do
68
76
  # We guarantee at least once,
69
77
  # duplicates can happen in this scenario.
@@ -73,4 +81,26 @@ describe "Sending events" do
73
81
  expect(queue.map { |e| e["line"] }).to include(*batch_payload.map(&:to_s))
74
82
  end
75
83
  end
84
+
85
+ context "when shutting down" do
86
+ let(:queue) { [] }
87
+ let(:event) { LogStash::Event.new("line" => "Hello") }
88
+ let(:number_of_events) { 50 }
89
+
90
+ before do
91
+ @server = Thread.new do
92
+ server.run do |data|
93
+ queue << data
94
+ end
95
+ end
96
+
97
+ output.register
98
+ end
99
+
100
+ it "flushes the events in the buffer" do
101
+ number_of_events.times { output.receive(event) }
102
+ output.close
103
+ expect(queue.size).to eq(number_of_events)
104
+ end
105
+ end
76
106
  end
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-lumberjack
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
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-08 00:00:00.000000000 Z
11
+ date: 2015-10-13 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,105 +28,107 @@ 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: jls-lumberjack
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: 0.0.24
34
40
  requirement: !ruby/object:Gem::Requirement
35
41
  requirements:
36
42
  - - '>='
37
43
  - !ruby/object:Gem::Version
38
44
  version: 0.0.24
39
- name: jls-lumberjack
40
45
  prerelease: false
41
46
  type: :runtime
47
+ - !ruby/object:Gem::Dependency
48
+ name: stud
42
49
  version_requirements: !ruby/object:Gem::Requirement
43
50
  requirements:
44
51
  - - '>='
45
52
  - !ruby/object:Gem::Version
46
- version: 0.0.24
47
- - !ruby/object:Gem::Dependency
53
+ version: '0'
48
54
  requirement: !ruby/object:Gem::Requirement
49
55
  requirements:
50
56
  - - '>='
51
57
  - !ruby/object:Gem::Version
52
58
  version: '0'
53
- name: stud
54
59
  prerelease: false
55
60
  type: :runtime
61
+ - !ruby/object:Gem::Dependency
62
+ name: logstash-devutils
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: logstash-devutils
68
73
  prerelease: false
69
74
  type: :development
75
+ - !ruby/object:Gem::Dependency
76
+ name: logstash-output-lumberjack
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-output-lumberjack
82
87
  prerelease: false
83
88
  type: :development
89
+ - !ruby/object:Gem::Dependency
90
+ name: logstash-codec-plain
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: logstash-codec-plain
96
101
  prerelease: false
97
102
  type: :development
103
+ - !ruby/object:Gem::Dependency
104
+ name: flores
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: flores
110
115
  prerelease: false
111
116
  type: :development
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - '>='
115
- - !ruby/object:Gem::Version
116
- version: '0'
117
117
  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
118
118
  email: info@elastic.co
119
119
  executables: []
120
120
  extensions: []
121
121
  extra_rdoc_files: []
122
122
  files:
123
+ - lib/logstash/outputs/lumberjack.rb
124
+ - spec/outputs/lumberjack_spec.rb
125
+ - logstash-output-lumberjack.gemspec
123
126
  - CHANGELOG.md
127
+ - README.md
124
128
  - CONTRIBUTORS
125
129
  - Gemfile
126
130
  - LICENSE
127
131
  - NOTICE.TXT
128
- - README.md
129
- - lib/logstash/outputs/lumberjack.rb
130
- - logstash-output-lumberjack.gemspec
131
- - spec/outputs/lumberjack_spec.rb
132
132
  homepage: http://www.elastic.co/guide/en/logstash/current/index.html
133
133
  licenses:
134
134
  - Apache License (2.0)
@@ -151,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  version: '0'
152
152
  requirements: []
153
153
  rubyforge_project:
154
- rubygems_version: 2.4.8
154
+ rubygems_version: 2.1.9
155
155
  signing_key:
156
156
  specification_version: 4
157
157
  summary: Send events using the lumberjack protocol