fluentd 0.10.45 → 0.10.46

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fluentd might be problematic. Click here for more details.

Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -1
  3. data/ChangeLog +13 -0
  4. data/Rakefile +18 -2
  5. data/fluentd.gemspec +3 -1
  6. data/lib/fluent/command/fluentd.rb +5 -0
  7. data/lib/fluent/config.rb +17 -333
  8. data/lib/fluent/config/basic_parser.rb +108 -0
  9. data/lib/fluent/config/configure_proxy.rb +145 -0
  10. data/lib/fluent/{config_dsl.rb → config/dsl.rb} +5 -1
  11. data/lib/fluent/config/element.rb +82 -0
  12. data/lib/fluent/config/error.rb +7 -0
  13. data/lib/fluent/config/literal_parser.rb +158 -0
  14. data/lib/fluent/config/parser.rb +96 -0
  15. data/lib/fluent/config/section.rb +115 -0
  16. data/lib/fluent/config/types.rb +86 -0
  17. data/lib/fluent/config/v1_parser.rb +156 -0
  18. data/lib/fluent/configurable.rb +108 -0
  19. data/lib/fluent/engine.rb +4 -3
  20. data/lib/fluent/load.rb +0 -1
  21. data/lib/fluent/parser.rb +15 -5
  22. data/lib/fluent/plugin/buf_memory.rb +13 -5
  23. data/lib/fluent/plugin/in_forward.rb +18 -5
  24. data/lib/fluent/plugin/in_http.rb +4 -2
  25. data/lib/fluent/plugin/in_tail.rb +1 -1
  26. data/lib/fluent/plugin/out_forward.rb +33 -29
  27. data/lib/fluent/registry.rb +76 -0
  28. data/lib/fluent/supervisor.rb +2 -1
  29. data/lib/fluent/test/base.rb +3 -1
  30. data/lib/fluent/version.rb +1 -1
  31. data/spec/config/config_parser_spec.rb +176 -0
  32. data/spec/config/configurable_spec.rb +373 -0
  33. data/spec/config/configure_proxy_spec.rb +96 -0
  34. data/spec/config/dsl_spec.rb +239 -0
  35. data/spec/config/helper.rb +50 -0
  36. data/spec/config/literal_parser_spec.rb +190 -0
  37. data/spec/config/section_spec.rb +97 -0
  38. data/spec/spec_helper.rb +60 -0
  39. data/test/plugin/{in_exec.rb → test_in_exec.rb} +0 -0
  40. data/test/plugin/{in_forward.rb → test_in_forward.rb} +5 -0
  41. data/test/plugin/{in_gc_stat.rb → test_in_gc_stat.rb} +0 -0
  42. data/test/plugin/{in_http.rb → test_in_http.rb} +0 -0
  43. data/test/plugin/{in_object_space.rb → test_in_object_space.rb} +0 -0
  44. data/test/plugin/{in_status.rb → test_in_status.rb} +0 -0
  45. data/test/plugin/{in_stream.rb → test_in_stream.rb} +0 -0
  46. data/test/plugin/{in_syslog.rb → test_in_syslog.rb} +0 -0
  47. data/test/plugin/{in_tail.rb → test_in_tail.rb} +0 -0
  48. data/test/plugin/{out_copy.rb → test_out_copy.rb} +0 -0
  49. data/test/plugin/{out_exec.rb → test_out_exec.rb} +0 -0
  50. data/test/plugin/{out_exec_filter.rb → test_out_exec_filter.rb} +0 -0
  51. data/test/plugin/{out_file.rb → test_out_file.rb} +0 -0
  52. data/test/plugin/{out_forward.rb → test_out_forward.rb} +15 -0
  53. data/test/plugin/{out_roundrobin.rb → test_out_roundrobin.rb} +0 -0
  54. data/test/plugin/{out_stdout.rb → test_out_stdout.rb} +0 -0
  55. data/test/plugin/{out_stream.rb → test_out_stream.rb} +0 -0
  56. data/test/scripts/fluent/plugin/parser_known.rb +3 -0
  57. data/test/{config.rb → test_config.rb} +1 -0
  58. data/test/{configdsl.rb → test_configdsl.rb} +1 -1
  59. data/test/{match.rb → test_match.rb} +0 -0
  60. data/test/{mixin.rb → test_mixin.rb} +0 -0
  61. data/test/{output.rb → test_output.rb} +0 -0
  62. data/test/{parser.rb → test_parser.rb} +22 -5
  63. metadata +114 -51
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df6457fef8673bd624e1baa875292fd83ee71f56
4
- data.tar.gz: 829ece938ca14738720a69d9642c3f24859a595a
3
+ metadata.gz: f5c5c7236589cb3aa5fadf040dbee965523f6ef0
4
+ data.tar.gz: 392f590233abe73edab6c425556de56ab7ddd6f3
5
5
  SHA512:
6
- metadata.gz: ffe86b09fb5aef434fc97fda76ba8697d48aadd8954cea28285cdb419447800e46b1df868faa549185ba7d058dae7058bec0338b87a2330eebbb8bd5e5c76539
7
- data.tar.gz: 3949343e2b31f9eef4e6edc045e5e84f58adc4db9546ea30966116ef9457897dd3f291bca75260407197a6952682f69cef8da8862f49841c7582695725419737
6
+ metadata.gz: ea036af28812b5a21fafe9731fe93959f85c2529e88feff2347d1ebfb0724c54a93a65bd738371cc924247e43ef9c6f997dd88792893fbb94c2fbdfc52fa362d
7
+ data.tar.gz: 6087c6298709c8f0e32f79830c8950ab5378225c8a68ecf8ae236accdf2e08b670e51dbd7c08ac2e4397a36d704e4219a4585ceebb67ab974428cdce578e806d
@@ -4,12 +4,13 @@ rvm:
4
4
  - 1.9.3
5
5
  - 2.0.0
6
6
  - 2.1.0
7
+ - 2.1.1
8
+ - ruby-head
7
9
  - rbx
8
10
 
9
11
  branches:
10
12
  only:
11
13
  - master
12
- - v11
13
14
 
14
15
  gemfile:
15
16
  - Gemfile
@@ -19,4 +20,5 @@ script: bundle exec rake
19
20
 
20
21
  matrix:
21
22
  allow_failures:
23
+ - rvm: ruby-head
22
24
  - rvm: rbx
data/ChangeLog CHANGED
@@ -1,3 +1,16 @@
1
+ Release 0.10.46 - 2014/04/21
2
+
3
+ * in_tail: Fix typo in rescue for dumping backtrace
4
+ * in_forward: Add blocking_timeout option to avoid Cool.io loop stuck in shutdown
5
+ * out_forward: Add phi_failure_detector option to disable "The Phi accrual failure detector"
6
+ * buf_memory: Add flush_at_shutdown option to discard buffered event at shutdown
7
+ * parser: Use Engine.now when time_key is missing in ValuesParser
8
+ * parser: TextParser loads fluent/plugin/parser_xxx.rb automatically when 'xxx' format not found
9
+ * Fix match cache expiration
10
+ * Add new v1 configuration format and --use-v1-config option to enable v1 configuration format
11
+ * Add config_section to Configurable to support nested parameters in plugins
12
+ * Relax http_parser.rb gem version to support 0.6 series
13
+
1
14
  Release 0.10.45 - 2014/03/28
2
15
 
3
16
  * in_tail: Merge in_tail_ex and in_tail_multiline features
data/Rakefile CHANGED
@@ -4,12 +4,15 @@ require "bundler/gem_tasks"
4
4
  require 'fileutils'
5
5
  require 'rake/testtask'
6
6
  require 'rake/clean'
7
+ require 'rspec/core'
8
+ require 'rspec/core/rake_task'
7
9
 
8
- task :test => [:base_test]
10
+ task :test => [:base_test, :spec]
9
11
 
12
+ desc 'Run test_unit based test'
10
13
  Rake::TestTask.new(:base_test) do |t|
11
14
  t.libs << "test"
12
- t.test_files = (Dir["test/*.rb"] + Dir["test/plugin/*.rb"] - ["helper.rb"]).sort
15
+ t.test_files = (Dir["test/test_*.rb"] + Dir["test/plugin/test_*.rb"] - ["helper.rb"]).sort
13
16
  t.verbose = true
14
17
  #t.warning = true
15
18
  end
@@ -20,4 +23,17 @@ task :parallel_test do
20
23
  FileUtils.rm_rf('./test/tmp')
21
24
  end
22
25
 
26
+ desc 'Run rspec based test'
27
+ RSpec::Core::RakeTask.new(:spec) do |t|
28
+ t.rspec_opts = %w[-c -f progress -r ./spec/spec_helper.rb]
29
+ t.pattern = 'spec/**/*_spec.rb'
30
+ t.verbose = true
31
+ end
32
+
33
+ desc 'Run rspec with simplecov'
34
+ task :coverage do |t|
35
+ ENV['SIMPLE_COV'] = '1'
36
+ Rake::Task["spec"].invoke
37
+ end
38
+
23
39
  task :default => [:test, :build]
@@ -22,12 +22,14 @@ Gem::Specification.new do |gem|
22
22
  gem.add_runtime_dependency("json", [">= 1.4.3"])
23
23
  gem.add_runtime_dependency("yajl-ruby", ["~> 1.0"])
24
24
  gem.add_runtime_dependency("cool.io", [">= 1.1.1", "!= 1.2.0", "< 2.0.0"])
25
- gem.add_runtime_dependency("http_parser.rb", ["~> 0.5.1"])
25
+ gem.add_runtime_dependency("http_parser.rb", [">= 0.5.1", "< 0.7.0"])
26
26
  gem.add_runtime_dependency("sigdump", ["~> 0.2.2"])
27
27
 
28
28
  gem.add_development_dependency("rake", [">= 0.9.2"])
29
29
  gem.add_development_dependency("flexmock")
30
30
  gem.add_development_dependency("parallel_tests", [">= 0.15.3"])
31
+ gem.add_development_dependency("rspec", ["~> 2.13"])
32
+ gem.add_development_dependency("simplecov", ["~> 0.6.4"])
31
33
  gem.add_development_dependency("rr", [">= 1.0.0"])
32
34
  gem.add_development_dependency("timecop", [">= 0.3.0"])
33
35
  end
@@ -37,6 +37,7 @@ opts = {
37
37
  :chgroup => nil,
38
38
  :suppress_interval => 0,
39
39
  :suppress_repeated_stacktrace => false,
40
+ :use_v1_config => false,
40
41
  }
41
42
 
42
43
  op.on('-s', "--setup [DIR=#{File.dirname(Fluent::DEFAULT_CONFIG_PATH)}]", "install sample configuration file to the directory") {|s|
@@ -91,6 +92,10 @@ op.on('--suppress-repeated-stacktrace', "suppress repeated stacktrace", TrueClas
91
92
  opts[:suppress_repeated_stacktrace] = b
92
93
  }
93
94
 
95
+ op.on('--use-v1-config', "Use v1 configuration format", TrueClass) {|b|
96
+ opts[:use_v1_config] = b
97
+ }
98
+
94
99
  op.on('-v', '--verbose', "increase verbose level (-v: debug, -vv: trace)", TrueClass) {|b|
95
100
  if b
96
101
  opts[:log_level] = [opts[:log_level] - 1, Fluent::Log::LEVEL_TRACE].max
@@ -16,351 +16,36 @@
16
16
  # limitations under the License.
17
17
  #
18
18
  module Fluent
19
- class ConfigError < StandardError
20
- end
21
-
22
- class ConfigParseError < ConfigError
23
- end
24
-
19
+ require 'fluent/config/error'
20
+ require 'fluent/config/element'
25
21
 
26
22
  module Config
27
- class Element < Hash
28
- def initialize(name, arg, attrs, elements, unused=nil)
29
- @name = name
30
- @arg = arg
31
- @elements = elements
32
- super()
33
- attrs.each {|k,v|
34
- self[k] = v
35
- }
36
- @unused = unused || attrs.keys
37
- end
38
-
39
- attr_accessor :name, :arg, :elements, :unused
40
-
41
- def add_element(name, arg='')
42
- e = Element.new(name, arg, {}, [])
43
- @elements << e
44
- e
45
- end
46
-
47
- def +(o)
48
- Element.new(@name.dup, @arg.dup, o.merge(self), @elements+o.elements, (@unused+o.unused).uniq)
49
- end
50
-
51
- def has_key?(key)
52
- @unused.delete(key)
53
- super
54
- end
55
-
56
- def [](key)
57
- @unused.delete(key)
58
- super
59
- end
60
-
61
- def check_not_fetched(&block)
62
- each_key {|key|
63
- if @unused.include?(key)
64
- block.call(key, self)
65
- end
66
- }
67
- @elements.each {|e|
68
- e.check_not_fetched(&block)
69
- }
70
- end
71
-
72
- def to_s(nest = 0)
73
- indent = " "*nest
74
- nindent = " "*(nest+1)
75
- out = ""
76
- if @arg.empty?
77
- out << "#{indent}<#{@name}>\n"
78
- else
79
- out << "#{indent}<#{@name} #{@arg}>\n"
80
- end
81
- each_pair {|k,v|
82
- out << "#{nindent}#{k} #{v}\n"
83
- }
84
- @elements.each {|e|
85
- out << e.to_s(nest+1)
86
- }
87
- out << "#{indent}</#{@name}>\n"
88
- out
89
- end
90
- end
91
-
92
- def self.read(path)
93
- Parser.read(path)
94
- end
95
-
96
- def self.parse(str, fname, basepath=Dir.pwd)
97
- Parser.parse(str, fname, basepath)
98
- end
99
-
100
- def self.new(name='')
101
- Element.new('', '', {}, [])
102
- end
103
-
104
- def self.size_value(str)
105
- case str.to_s
106
- when /([0-9]+)k/i
107
- $~[1].to_i * 1024
108
- when /([0-9]+)m/i
109
- $~[1].to_i * (1024**2)
110
- when /([0-9]+)g/i
111
- $~[1].to_i * (1024**3)
112
- when /([0-9]+)t/i
113
- $~[1].to_i * (1024**4)
114
- else
115
- str.to_i
116
- end
117
- end
118
-
119
- def self.time_value(str)
120
- case str.to_s
121
- when /([0-9]+)s/
122
- $~[1].to_i
123
- when /([0-9]+)m/
124
- $~[1].to_i * 60
125
- when /([0-9]+)h/
126
- $~[1].to_i * 60*60
127
- when /([0-9]+)d/
128
- $~[1].to_i * 24*60*60
23
+ def self.read(path, v1_config = false)
24
+ if v1_config
25
+ require 'fluent/config/v1_parser'
26
+ V1Parser.read(path)
129
27
  else
130
- str.to_f
28
+ require 'fluent/config/parser'
29
+ Parser.read(path)
131
30
  end
132
31
  end
133
32
 
134
- def self.bool_value(str)
135
- case str.to_s
136
- when 'true', 'yes'
137
- true
138
- when 'false', 'no'
139
- false
33
+ def self.parse(str, fname, basepath = Dir.pwd, v1_config = false)
34
+ if v1_config
35
+ require 'fluent/config/v1_parser'
36
+ V1Parser.parse(str, fname, basepath, Kernel.binding)
140
37
  else
141
- nil
142
- end
143
- end
144
-
145
- private
146
- class Parser
147
- def self.read(path)
148
- path = File.expand_path(path)
149
- File.open(path) {|io|
150
- parse(io, File.basename(path), File.dirname(path))
151
- }
152
- end
153
-
154
- def self.parse(io, fname, basepath=Dir.pwd)
155
- attrs, elems = Parser.new(basepath, io.each_line, fname).parse!(true)
156
- Element.new('ROOT', '', attrs, elems)
157
- end
158
-
159
- def initialize(basepath, iterator, fname, i=0)
160
- @basepath = basepath
161
- @iterator = iterator
162
- @i = i
163
- @fname = fname
164
- end
165
-
166
- def parse!(allow_include, elem_name=nil, attrs={}, elems=[])
167
- while line = @iterator.next
168
- line.force_encoding('UTF-8')
169
- @i += 1
170
- line.lstrip!
171
- line.gsub!(/\s*(?:\#.*)?$/,'')
172
- if line.empty?
173
- next
174
- elsif m = /^\<include\s*(.*)\s*\/\>$/.match(line)
175
- value = m[1].strip
176
- process_include(attrs, elems, value, allow_include)
177
- elsif m = /^\<([a-zA-Z0-9_]+)\s*(.+?)?\>$/.match(line)
178
- e_name = m[1]
179
- e_arg = m[2] || ""
180
- e_attrs, e_elems = parse!(false, e_name)
181
- elems << Element.new(e_name, e_arg, e_attrs, e_elems)
182
- elsif line == "</#{elem_name}>"
183
- break
184
- elsif m = /^([a-zA-Z0-9_]+)\s*(.*)$/.match(line)
185
- key = m[1]
186
- value = m[2]
187
- if allow_include && key == 'include'
188
- process_include(attrs, elems, value)
189
- else
190
- attrs[key] = value
191
- end
192
- next
193
- else
194
- raise ConfigParseError, "parse error at #{@fname} line #{@i}"
195
- end
196
- end
197
-
198
- return attrs, elems
199
- rescue StopIteration
200
- return attrs, elems
38
+ require 'fluent/config/parser'
39
+ Parser.parse(str, fname, basepath)
201
40
  end
202
-
203
- def process_include(attrs, elems, uri, allow_include = true)
204
- u = URI.parse(uri)
205
- if u.scheme == 'file' || u.path == uri # file path
206
- path = u.path
207
- if path[0] != ?/
208
- pattern = File.expand_path("#{@basepath}/#{path}")
209
- else
210
- pattern = path
211
- end
212
-
213
- Dir.glob(pattern).sort.each {|path|
214
- basepath = File.dirname(path)
215
- fname = File.basename(path)
216
- File.open(path) {|f|
217
- Parser.new(basepath, f.each_line, fname).parse!(allow_include, nil, attrs, elems)
218
- }
219
- }
220
-
221
- else
222
- basepath = '/'
223
- fname = path
224
- require 'open-uri'
225
- open(uri) {|f|
226
- Parser.new(basepath, f.each_line, fname).parse!(allow_include, nil, attrs, elems)
227
- }
228
- end
229
-
230
- rescue SystemCallError
231
- raise ConfigParseError, "include error at #{@fname} line #{@i}: #{$!.to_s}"
232
- end
233
- end
234
- end
235
-
236
-
237
- module Configurable
238
- attr_reader :config
239
-
240
- def self.included(mod)
241
- mod.extend(ClassMethods)
242
41
  end
243
42
 
244
- def initialize
245
- self.class.config_defaults.each_pair {|name,defval|
246
- varname = :"@#{name}"
247
- instance_variable_set(varname, defval)
248
- }
249
- end
250
-
251
- def configure(conf)
252
- @config = conf
253
-
254
- self.class.config_params.each_pair {|name,(block,opts)|
255
- varname = :"@#{name}"
256
- if val = conf[name.to_s]
257
- val = self.instance_exec(val, opts, name, &block)
258
- instance_variable_set(varname, val)
259
- end
260
- unless instance_variable_defined?(varname)
261
- $log.error "config error in:\n#{conf}"
262
- raise ConfigError, "'#{name}' parameter is required"
263
- end
264
- }
265
- end
266
-
267
- module ClassMethods
268
- def config_param(name, *args, &block)
269
- name = name.to_sym
270
-
271
- opts = {}
272
- args.each {|a|
273
- if a.is_a?(Symbol)
274
- opts[:type] = a
275
- elsif a.is_a?(Hash)
276
- opts.merge!(a)
277
- else
278
- raise ArgumentError, "wrong number of arguments (#{1+args.length} for #{block ? 2 : 3})"
279
- end
280
- }
281
-
282
- type = opts[:type]
283
- if block && type
284
- raise ArgumentError, "wrong number of arguments (#{1+args.length} for #{block ? 2 : 3})"
285
- end
286
-
287
- block ||= case type
288
- when :string, nil
289
- Proc.new {|val| val }
290
- when :integer
291
- Proc.new {|val| val.to_i }
292
- when :float
293
- Proc.new {|val| val.to_f }
294
- when :size
295
- Proc.new {|val| Config.size_value(val) }
296
- when :bool
297
- Proc.new {|val| Config.bool_value(val) }
298
- when :time
299
- Proc.new {|val| Config.time_value(val) }
300
- else
301
- raise ArgumentError, "unknown config_param type `#{type}'"
302
- end
303
-
304
- params = config_params_set
305
- params.delete(name)
306
- params[name] = [block, opts]
307
-
308
- if opts.has_key?(:default)
309
- config_set_default(name, opts[:default])
310
- end
311
-
312
- attr_accessor name
313
- end
314
-
315
- def config_set_default(name, defval)
316
- name = name.to_sym
317
-
318
- defaults = config_defaults_set
319
- defaults.delete(name)
320
- defaults[name] = defval
321
-
322
- nil
323
- end
324
-
325
- def config_params
326
- singleton_value(:_config_params)
327
- end
328
-
329
- def config_defaults
330
- singleton_value(:_config_defaults)
331
- end
332
-
333
- private
334
- def config_params_set
335
- singleton_value_set(:_config_params)
336
- end
337
-
338
- def config_defaults_set
339
- singleton_value_set(:_config_defaults)
340
- end
341
-
342
- def singleton_value_set(name)
343
- if methods(false).include?(name)
344
- __send__(name)
345
- else
346
- val = {}
347
- define_singleton_method(name) { val }
348
- val
349
- end
350
- end
351
-
352
- def singleton_value(name)
353
- val = {}
354
- ancestors.reverse_each {|c|
355
- if c.methods(false).include?(name)
356
- val.merge!(c.__send__(name))
357
- end
358
- }
359
- val
360
- end
43
+ def self.new(name = '')
44
+ Element.new(name, '', {}, [])
361
45
  end
362
46
  end
363
47
 
48
+ require 'fluent/configurable'
364
49
 
365
50
  module PluginId
366
51
  def configure(conf)
@@ -380,4 +65,3 @@ module Fluent
380
65
  end
381
66
  end
382
67
  end
383
-