fluent-plugin-keep-forward 0.1.3 → 0.1.4

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: 9c2af8c036f4fd144a1db429d94cc08988eec860
4
- data.tar.gz: 376bb6ac2acceab104079b72c214e619e1f8afac
3
+ metadata.gz: 04dd9735323e7d372ac1de93fb8e68388adcb829
4
+ data.tar.gz: f5d686d0988c06a1872779d52942a87ac7e3c7dd
5
5
  SHA512:
6
- metadata.gz: 51070129d6930e68aabad1e66c195f1355b3548302673c6bf3bf82585a4f9b3f3df31fdff45c5ce22da00b13c4c31154269f7285d066dcee1c8b19b3aaf5457a
7
- data.tar.gz: 7708a5f03c1dae8c93b35525610f1cee0b3f9025aa2519b8fc58e6937dc421c779a3937262693736aa622d10cbd0db74ff4f31f1826d27059cac1d7d0f582630
6
+ metadata.gz: 328e26c80f20cfbb506a6b777e7bdac47a927ae3280d24ccd351295941a91c67d48a20c4f5da5cd697ba05027a88723d8ef1ab41018fa7a9d974d5ef7e23ffc8
7
+ data.tar.gz: d732e0a855fd81d8b5536c2a7aaa9edf9b038e33f5234b0e0af8ccfd38e732c9f2f947b2f8ec205cc07db73f9f537c967a8a8711b3375b2102e5e91dca399845
@@ -1,3 +1,9 @@
1
+ ## 0.1.4 (2014/03/20)
2
+
3
+ Fixes
4
+
5
+ * More explicitly close socket the case of non-keepalive
6
+
1
7
  ## 0.1.3 (2014/03/19)
2
8
 
3
9
  Enhancement
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fluent-plugin-keep-forward"
6
- s.version = "0.1.3"
6
+ s.version = "0.1.4"
7
7
  s.authors = ["Naotoshi Seo"]
8
8
  s.email = ["sonots@gmail.com"]
9
9
  s.homepage = "https://github.com/sonots/fluent-plugin-keep-forward"
@@ -81,22 +81,16 @@ class Fluent::KeepForwardOutput < Fluent::ForwardOutput
81
81
  send_data(node, tag, chunk)
82
82
  return
83
83
  rescue
84
- node = weight_send_data(tag, chunk, error_node = node)
85
- cache_node(tag, node)
84
+ weight_send_data(tag, chunk)
86
85
  end
87
86
  else
88
- node = weight_send_data(tag, chunk, error_node = node)
89
- cache_node(tag, node)
87
+ weight_send_data(tag, chunk)
90
88
  end
91
89
  end
92
90
 
93
- def weight_send_data(tag, chunk, error_node = nil)
91
+ def weight_send_data(tag, chunk)
94
92
  error = nil
95
93
 
96
- if error_node
97
- sock_close(error_node) if @keepalive and @keepforward == :one
98
- end
99
-
100
94
  wlen = @weight_array.length
101
95
  wlen.times do
102
96
  @rr = (@rr + 1) % wlen
@@ -105,7 +99,8 @@ class Fluent::KeepForwardOutput < Fluent::ForwardOutput
105
99
  if node.available?
106
100
  begin
107
101
  send_data(node, tag, chunk)
108
- return node
102
+ cache_node(tag, node)
103
+ return
109
104
  rescue
110
105
  # for load balancing during detecting crashed servers
111
106
  error = $! # use the latest error
@@ -123,8 +118,9 @@ class Fluent::KeepForwardOutput < Fluent::ForwardOutput
123
118
 
124
119
  # Override for keepalive
125
120
  def send_data(node, tag, chunk)
121
+ sock = nil
126
122
  get_mutex(node).synchronize do
127
- sock = get_sock[node]
123
+ sock = get_sock[node] if @keepalive
128
124
  unless sock
129
125
  sock = reconnect(node)
130
126
  cache_sock(node, sock) if @keepalive
@@ -133,14 +129,18 @@ class Fluent::KeepForwardOutput < Fluent::ForwardOutput
133
129
  begin
134
130
  sock_write(sock, tag, chunk)
135
131
  node.heartbeat(false)
132
+ log.debug "out_keep_forward: write to", :host=>node.host, :port=>node.port
136
133
  rescue Errno::EPIPE, Errno::ECONNRESET, Errno::ECONNABORTED, Errno::ETIMEDOUT => e
137
- log.warn "out_keep_forward: send_data failed #{e.class} #{e.message}, try to reconnect", :host=>node.host, :port=>node.port
138
- sock.close rescue IOError
139
- sock = reconnect(node)
140
- cache_sock(node, sock) if @keepalive
141
- retry
134
+ log.warn "out_keep_forward: send_data failed #{e.class} #{e.message}", :host=>node.host, :port=>node.port
135
+ if @keepalive
136
+ sock.close rescue IOError
137
+ cache_sock(node, nil)
138
+ end
139
+ raise e
142
140
  ensure
143
- sock.close if sock and !@keepalive
141
+ unless @keepalive
142
+ sock.close if sock
143
+ end
144
144
  end
145
145
  end
146
146
  end
@@ -193,21 +193,13 @@ class Fluent::KeepForwardOutput < Fluent::ForwardOutput
193
193
  sock.close rescue IOError if sock
194
194
  @sock[thread_id][node] = nil
195
195
  @sock_expired_at[thread_id][node] = nil
196
+ log.debug "out_keep_forward: keepalive connection closed", :host=>node.host, :port=>node.port, :thread_id=>thread_id
196
197
  end
197
198
  end
198
199
  end
199
200
  end
200
201
  end
201
202
 
202
- def sock_close(node)
203
- get_mutex(node).synchronize do
204
- sock = get_sock[node]
205
- sock.close rescue IOError if sock
206
- get_sock[node] = nil
207
- get_sock_expired_at[node] = nil
208
- end
209
- end
210
-
211
203
  def get_mutex(node)
212
204
  thread_id = Thread.current.object_id
213
205
  @mutex[thread_id] ||= {}
@@ -215,8 +207,14 @@ class Fluent::KeepForwardOutput < Fluent::ForwardOutput
215
207
  end
216
208
 
217
209
  def cache_sock(node, sock)
218
- get_sock[node] = sock
219
- get_sock_expired_at[node] = Time.now + @keepalive_time if @keepalive_time
210
+ if sock
211
+ get_sock[node] = sock
212
+ get_sock_expired_at[node] = Time.now + @keepalive_time if @keepalive_time
213
+ log.info "out_keep_forward: keepalive connection opened", :host=>node.host, :port=>node.port
214
+ else
215
+ get_sock[node] = nil
216
+ get_sock_expired_at[node] = nil
217
+ end
220
218
  end
221
219
 
222
220
  def get_sock
@@ -86,7 +86,7 @@ describe Fluent::KeepForwardOutput do
86
86
  before { driver.should_receive(:send_data).with(keep_node, tag, chunk) }
87
87
  end
88
88
  it_should_behave_like 'error_occurs' do
89
- before { driver.stub(:weight_send_data).with(tag, chunk, keep_node) } # re-call weight_send_data
89
+ before { driver.stub(:weight_send_data).with(tag, chunk) } # re-call weight_send_data
90
90
  end
91
91
  end
92
92
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-keep-forward
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-19 00:00:00.000000000 Z
11
+ date: 2014-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd