fluent-plugin-hash-forward 0.3.2 → 0.3.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: dc5f372dbd73daa73bc4a7da282a7edf386195a6
4
- data.tar.gz: bff3830548afa79073a48dab264cb7a484f36cab
3
+ metadata.gz: d01dea2a66bc0f774fc40e36ccb1ebf6e2a01e49
4
+ data.tar.gz: aca6bf525e53870912ed253c7aff0dceda19826d
5
5
  SHA512:
6
- metadata.gz: 513d76863848a0de51a6675eb9b2e7b472d371e2ab69a0c1c47b3769ffc9dc2c75a005a064b5c3a8fd8bf8b4aaa43ca38365310d2f344f41ddf1fb319eef2fc7
7
- data.tar.gz: 5f8e77d7b1eb80719aad7b9ce1a8981dc84526b9451619074ec2920f595e25833b25652ff8a6e9dc16fa18efa9e4f1855f1c60edf4c7a4e7c92120793dce9dae
6
+ metadata.gz: 95dd5908ae5750478ace61a0e940d177993326645d01ea24dd948d2e54e52ec5d16b91581390265e6056dab17a902928e187043757bd998117cd78f98b5ed6d2
7
+ data.tar.gz: 362fd432c9a0898905154e3cf530cd689e10729556ac746283e952b31ffd22b71a5e26d974cf798959b9a88b10c8bc4086b487f71b02ad9e4aa2a7b7de88f1c1
@@ -1,3 +1,9 @@
1
+ # 0.3.3 (2014/03/17)
2
+
3
+ Enhancement:
4
+
5
+ * Support `heartbeat_type` `none`
6
+
1
7
  # 0.3.2 (2014/02/04)
2
8
 
3
9
  Enhancement:
data/README.md CHANGED
@@ -40,6 +40,11 @@ Following parameters are additionally available:
40
40
 
41
41
  Keepalive expired time. Default is nil (which means to keep connection as long as possible).
42
42
 
43
+ * heartbeat_type
44
+
45
+ The transport protocol to use for heartbeats. The default is “udp”, but you can select “tcp” as well.
46
+ Furthermore, in hash_forward, you can also select "none" to disable heartbeat.
47
+
43
48
  * hash\_key\_slice *min*..*max*
44
49
 
45
50
  Use sliced `tag` as a hash key to determine a forwarding node. Default: use entire `tag`.
@@ -0,0 +1,39 @@
1
+ <source>
2
+ type tail
3
+ path dummy.log
4
+ pos_file /var/tmp/_var_log_dummy.pos
5
+ format none
6
+ tag dummy.localhost
7
+ </source>
8
+ <match dummy.localhost>
9
+ type copy
10
+ <store>
11
+ type stdout
12
+ </store>
13
+ <store>
14
+ type hash_forward
15
+ flush_interval 0
16
+ buffer_queue_limit 312
17
+ buffer_chunk_limit 10m
18
+ num_threads 1
19
+ retry_wait 0.1
20
+ retry_limit 17
21
+ # max_retry_wait 131072
22
+ send_timeout 60s # 60s
23
+ # recover_wait 10s
24
+ heartbeat_type none # udp
25
+ # heartbeat_interval 1s
26
+ phi_threshold 70 # 8
27
+ hard_timeout 60s # 60s
28
+ hash_key_slice 0..-2
29
+ <server>
30
+ host localhost
31
+ port 26000
32
+ </server>
33
+ <server>
34
+ host localhost
35
+ port 27000
36
+ standby true
37
+ </server>
38
+ </store>
39
+ </match>
@@ -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.2"
6
+ s.version = "0.3.3"
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"
@@ -1,4 +1,5 @@
1
1
  require 'fluent/plugin/out_forward'
2
+ require 'forwardable'
2
3
 
3
4
  class Fluent::HashForwardOutput < Fluent::ForwardOutput
4
5
  Fluent::Plugin.register_output('hash_forward', self)
@@ -11,6 +12,18 @@ class Fluent::HashForwardOutput < Fluent::ForwardOutput
11
12
  config_param :hash_key_slice, :string, :default => nil
12
13
  config_param :keepalive, :bool, :default => false
13
14
  config_param :keepalive_time, :time, :default => nil # infinite
15
+ config_param :heartbeat_type, :default => :udp do |val|
16
+ case val.downcase
17
+ when 'tcp'
18
+ :tcp
19
+ when 'udp'
20
+ :udp
21
+ when 'none' # custom
22
+ :none
23
+ else
24
+ raise ConfigError, "forward output heartbeat type should be 'tcp' or 'udp', or 'none'"
25
+ end
26
+ end
14
27
 
15
28
  def configure(conf)
16
29
  super
@@ -24,6 +37,10 @@ class Fluent::HashForwardOutput < Fluent::ForwardOutput
24
37
  end
25
38
  end
26
39
 
40
+ if @heartbeat_type == :none
41
+ @nodes = @nodes.map {|node| NonHeartbeatNode.new(node) }
42
+ end
43
+
27
44
  @standby_nodes, @regular_nodes = @nodes.partition {|n| n.standby? }
28
45
  @regular_weight_array = build_weight_array(@regular_nodes)
29
46
  @standby_weight_array = build_weight_array(@standby_nodes)
@@ -50,7 +67,11 @@ class Fluent::HashForwardOutput < Fluent::ForwardOutput
50
67
  end
51
68
 
52
69
  def shutdown
53
- super
70
+ @finished = true
71
+ @loop.watchers.each {|w| w.detach }
72
+ @loop.stop unless @heartbeat_type == :none # custom
73
+ @thread.join
74
+ @usock.close if @usock
54
75
  stop_watcher
55
76
  end
56
77
 
@@ -67,6 +88,37 @@ class Fluent::HashForwardOutput < Fluent::ForwardOutput
67
88
  end
68
89
  end
69
90
 
91
+ # Override to disable heartbeat
92
+ def run
93
+ unless @heartbeat_type == :none
94
+ super
95
+ end
96
+ end
97
+
98
+ # Delegate to Node instance disabling heartbeat
99
+ class NonHeartbeatNode
100
+ extend Forwardable
101
+ attr_reader :node
102
+ def_delegators :@node, :standby?, :resolved_host, :resolve_dns!, :to_msgpack,
103
+ :name, :host, :port, :weight, :weight=, :standby=, :available=, :sockaddr
104
+
105
+ def initialize(node)
106
+ @node = node
107
+ end
108
+
109
+ def available?
110
+ true
111
+ end
112
+
113
+ def tick
114
+ false
115
+ end
116
+
117
+ def heartbeat(detect=true)
118
+ true
119
+ end
120
+ end
121
+
70
122
  # Override
71
123
  def write_objects(tag, chunk)
72
124
  return if chunk.empty?
@@ -150,7 +202,7 @@ class Fluent::HashForwardOutput < Fluent::ForwardOutput
150
202
  sock_write(sock, tag, chunk)
151
203
  node.heartbeat(false)
152
204
  rescue Errno::EPIPE, Errno::ECONNRESET, Errno::ECONNABORTED, Errno::ETIMEDOUT => e
153
- log.warn "out_hash_forward: #{e.class} #{e.message}"
205
+ log.warn "out_hash_forward: send_data failed #{e.class} #{e.message}, try to reconnect", :host=>node.host, :port=>node.port
154
206
  sock = reconnect(node)
155
207
  retry
156
208
  end
@@ -314,5 +314,16 @@ describe Fluent::HashForwardOutput do
314
314
  end
315
315
  end
316
316
  end
317
+
318
+ describe 'test heartbeat_type :none' do
319
+ let(:tag) { 'test.tag' }
320
+ let(:es) { Array.new(1) }
321
+ let(:chain) { Fluent::NullOutputChain.instance }
322
+ let(:config) { CONFIG + %[heartbeat_type none] }
323
+
324
+ context 'NonHeartbeatNode' do
325
+ it { driver.nodes(tag).first.class.should == Fluent::HashForwardOutput::NonHeartbeatNode }
326
+ end
327
+ end
317
328
  end
318
329
 
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.2
4
+ version: 0.3.3
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-02-04 00:00:00.000000000 Z
12
+ date: 2014-03-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
@@ -95,6 +95,7 @@ files:
95
95
  - Gemfile
96
96
  - README.md
97
97
  - Rakefile
98
+ - example/fluent.conf
98
99
  - fluent-plugin-hash-forward.gemspec
99
100
  - lib/fluent/plugin/out_hash_forward.rb
100
101
  - spec/out_hash_forward_spec.rb