fluent-plugin-hash-forward 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/fluent-plugin-hash-forward.gemspec +1 -1
- data/lib/fluent/plugin/out_hash_forward.rb +43 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58c1901df40204d868036947204e3ddba0b9deb8
|
4
|
+
data.tar.gz: 49c26894fa7146c4e325421a95cb0fdd18b0c44c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ae92af4933774b82d51672c97b1a1e7f40b2f0a71bf135e18136771c050f506c3fc773fb5310a84ea0200906ca51079393dbdba5ee60db9d40f447dee76d056
|
7
|
+
data.tar.gz: d592184b580aa7adfaac3cca70ec7681b066d581d0a61336f1d5404a2fa9417e16e454b8f27573048299e9652296dff7f59770d2947a3092539e6d4321f244c0
|
data/CHANGELOG.md
CHANGED
@@ -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-hash-forward"
|
6
|
-
s.version = "0.3.
|
6
|
+
s.version = "0.3.5"
|
7
7
|
s.authors = ["Ryosuke IWANAGA", "Naotoshi Seo"]
|
8
8
|
s.email = ["riywo.jp@gmail.com", "sonots@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/riywo/fluent-plugin-hash-forward"
|
@@ -125,6 +125,9 @@ class Fluent::HashForwardOutput < Fluent::ForwardOutput
|
|
125
125
|
error = nil
|
126
126
|
nodes = nodes(tag)
|
127
127
|
|
128
|
+
if @keepalive and primary_available?(nodes)
|
129
|
+
sock_close(nodes.last) # close standby
|
130
|
+
end
|
128
131
|
# below is just copy from out_forward
|
129
132
|
nodes.each do |node|
|
130
133
|
if node.available?
|
@@ -173,6 +176,10 @@ class Fluent::HashForwardOutput < Fluent::ForwardOutput
|
|
173
176
|
@cache_nodes[tag] = nodes
|
174
177
|
end
|
175
178
|
|
179
|
+
def primary_available?(nodes)
|
180
|
+
nodes.size > 1 && nodes.first.available?
|
181
|
+
end
|
182
|
+
|
176
183
|
# hashing(key) mod N
|
177
184
|
def get_index(key, size)
|
178
185
|
str_hash(key) % size
|
@@ -192,21 +199,29 @@ class Fluent::HashForwardOutput < Fluent::ForwardOutput
|
|
192
199
|
|
193
200
|
# Override for keepalive
|
194
201
|
def send_data(node, tag, chunk)
|
202
|
+
sock = nil
|
195
203
|
get_mutex(node).synchronize do
|
196
|
-
sock = get_sock[node]
|
204
|
+
sock = get_sock[node] if @keepalive
|
197
205
|
unless sock
|
198
206
|
sock = reconnect(node)
|
207
|
+
cache_sock(node, sock) if @keepalive
|
199
208
|
end
|
200
209
|
|
201
210
|
begin
|
202
211
|
sock_write(sock, tag, chunk)
|
203
212
|
node.heartbeat(false)
|
213
|
+
log.debug "out_hash_forward: write to", :host=>node.host, :port=>node.port
|
204
214
|
rescue Errno::EPIPE, Errno::ECONNRESET, Errno::ECONNABORTED, Errno::ETIMEDOUT => e
|
205
|
-
log.warn "out_hash_forward: send_data failed #{e.class} #{e.message}
|
206
|
-
|
207
|
-
|
215
|
+
log.warn "out_hash_forward: send_data failed #{e.class} #{e.message}", :host=>node.host, :port=>node.port
|
216
|
+
if @keepalive
|
217
|
+
sock.close rescue IOError
|
218
|
+
cache_sock(node, nil)
|
219
|
+
end
|
220
|
+
raise e
|
208
221
|
ensure
|
209
|
-
|
222
|
+
unless @keepalive
|
223
|
+
sock.close if sock
|
224
|
+
end
|
210
225
|
end
|
211
226
|
end
|
212
227
|
end
|
@@ -219,11 +234,6 @@ class Fluent::HashForwardOutput < Fluent::ForwardOutput
|
|
219
234
|
opt = [@send_timeout.to_i, 0].pack('L!L!') # struct timeval
|
220
235
|
sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDTIMEO, opt)
|
221
236
|
|
222
|
-
if @keepalive
|
223
|
-
get_sock[node] = sock
|
224
|
-
get_sock_expired_at[node] = Time.now + @keepalive_time if @keepalive_time
|
225
|
-
end
|
226
|
-
|
227
237
|
sock
|
228
238
|
end
|
229
239
|
|
@@ -264,18 +274,41 @@ class Fluent::HashForwardOutput < Fluent::ForwardOutput
|
|
264
274
|
sock.close rescue IOError if sock
|
265
275
|
@sock[thread_id][node] = nil
|
266
276
|
@sock_expired_at[thread_id][node] = nil
|
277
|
+
log.debug "out_hash_forward: keepalive connection closed", :host=>node.host, :port=>node.port, :thread_id=>thread_id
|
267
278
|
end
|
268
279
|
end
|
269
280
|
end
|
270
281
|
end
|
271
282
|
end
|
272
283
|
|
284
|
+
def sock_close(node)
|
285
|
+
get_mutex(node).synchronize do
|
286
|
+
if sock = get_sock[node]
|
287
|
+
sock.close rescue IOError
|
288
|
+
log.info "out_hash_forward: keepalive connection closed", :host=>node.host, :port=>node.port
|
289
|
+
end
|
290
|
+
get_sock[node] = nil
|
291
|
+
get_sock_expired_at[node] = nil
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
273
295
|
def get_mutex(node)
|
274
296
|
thread_id = Thread.current.object_id
|
275
297
|
@mutex[thread_id] ||= {}
|
276
298
|
@mutex[thread_id][node] ||= Mutex.new
|
277
299
|
end
|
278
300
|
|
301
|
+
def cache_sock(node, sock)
|
302
|
+
if sock
|
303
|
+
get_sock[node] = sock
|
304
|
+
get_sock_expired_at[node] = Time.now + @keepalive_time if @keepalive_time
|
305
|
+
log.info "out_hash_forward: keepalive connection opened", :host=>node.host, :port=>node.port
|
306
|
+
else
|
307
|
+
get_sock[node] = nil
|
308
|
+
get_sock_expired_at[node] = nil
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
279
312
|
def get_sock
|
280
313
|
@sock[Thread.current.object_id] ||= {}
|
281
314
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-hash-forward
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryosuke IWANAGA
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
12
|
+
date: 2014-03-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|