fluent-plugin-dummydata-producer 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 42573922571f2916c01f945033169b6deb258a0e
4
+ data.tar.gz: de27471e2548b040b6d2b0557473c10fd9857638
5
+ SHA512:
6
+ metadata.gz: ed38b100af832fc9882a1f9b9574598a6fe98730ee83605d381ac7950ec0e20f140d1a35a8bb215eb21238d0c01019e50728fe8251afe76bbd5297bf119009f4
7
+ data.tar.gz: b17724750d15bdf8ab38e2b3aa407373583a1f5e86901570041a3c32ef16e4ff824cd28c2928cbd19b7ea0ce1cf0a5856d5d7d69d11954494e30a3bc246b8da2
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-dummydata-producer.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 TAGOMORI Satoshi
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # fluent-plugin-dummydata-producer
2
+
3
+ ## DummyDataProducerInput
4
+
5
+ Fluentd plugin to produce/generate dummy data and emits these data into Fluentd.
6
+
7
+ ## Configuration
8
+
9
+ Configuration to emit dummy data with 3 variation:
10
+
11
+ <source>
12
+ type dummydata_producer
13
+ tag dummy.data
14
+ rate 500 # messages per second
15
+ dummydata0 {"type":"sample","code":50,"format":"json string allowed"}
16
+ dummydata1 {"message":"other format needed?"}
17
+ dummydata2 {"comment":"N of dummydataN is number and not limited"}
18
+ </source>
19
+
20
+ With this configuration, this plugin emits about 500 messages in 1 second (0 -> 1 -> 2 -> 0 -> ...).
21
+
22
+ If you need message id for acknowledgement tests, incremental id feature available.
23
+
24
+ <source>
25
+ type dummydata_producer
26
+ tag dummy.data
27
+ rate 500 # messages per second
28
+
29
+ dummydata0 {"type":"sample","code":50,"format":"json string allowed"}
30
+ dummydata1 {"message":"other format needed?"}
31
+ dummydata2 {"comment":"N of dummydataN is number and not limited"}
32
+
33
+ auto_increment_key id
34
+ </source>
35
+
36
+ ## TODO
37
+
38
+ * patches welcome!
39
+
40
+ ## Copyright
41
+
42
+ * Copyright
43
+ * Copyright (c) 2013- TAGOMORI Satoshi (tagomoris)
44
+ * License
45
+ * Apache License, Version 2.0
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "fluent-plugin-dummydata-producer"
5
+ spec.version = "0.0.1"
6
+ spec.authors = ["TAGOMORI Satoshi"]
7
+ spec.email = ["tagomoris@gmail.com"]
8
+ spec.description = %q{Emits dummy data to do bench marks and other tests}
9
+ spec.summary = %q{Fluentd plugin to produce dummy data and emit it}
10
+ spec.homepage = "https://github.com/tagomoris/fluent-plugin-dummydata-producer"
11
+ spec.license = "APLv2"
12
+
13
+ spec.files = `git ls-files`.split($/)
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_runtime_dependency "fluentd"
19
+ spec.add_runtime_dependency "fluent-mixin-config-placeholders"
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,83 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'fluent/mixin/config_placeholders'
4
+
5
+ module Fluent
6
+ class DummyDataProducerInput < Input
7
+ Fluent::Plugin.register_input('dummydata_producer', self)
8
+
9
+ include Fluent::Mixin::ConfigPlaceholders
10
+
11
+ config_param :tag, :string
12
+ config_param :rate, :integer
13
+
14
+ config_param :auto_increment_key, :string, :default => nil
15
+ # X: number
16
+ # dummydataX {"field1":"data1","field2":"data2"}
17
+
18
+ attr_reader :dummydata
19
+
20
+ def configure(conf)
21
+ super
22
+
23
+ @increment_value = 0
24
+
25
+ @dummydata = []
26
+ re = /^dummydata(\d+)$/
27
+ conf.keys.select{|key| key =~ re}.sort{|a,b| re.match(a)[1].to_i <=> re.match(b)[1].to_i}.each do |key|
28
+ @dummydata.push(JSON.parse(conf[key]))
29
+ end
30
+
31
+ if @dummydata.size < 1
32
+ raise Fluent::ConfigError, "no one dummydata exists"
33
+ end
34
+ @dummydata_index = 0
35
+ end
36
+
37
+ def start
38
+ super
39
+ @running = true
40
+ @producer = Thread.new(&method(:run))
41
+ end
42
+
43
+ def shutdown
44
+ @running = false
45
+ @producer.join
46
+ end
47
+
48
+ def generate
49
+ d = @dummydata[@dummydata_index]
50
+ unless d
51
+ @dummydata_index = 0
52
+ d = @dummydata[0]
53
+ end
54
+ @dummydata_index += 1
55
+ d = d.dup
56
+ if @auto_increment_key
57
+ d[@auto_increment_key] = @increment_value
58
+ @increment_value += 1
59
+ end
60
+ d
61
+ end
62
+
63
+ def run
64
+ batch_num = (@rate / 9).to_i + 1
65
+ while @running
66
+ current_time = Fluent::Engine.now
67
+ rate_count = 0
68
+
69
+ while @running && rate_count < @rate && Fluent::Engine.now == current_time
70
+ batch_num.times do
71
+ Fluent::Engine.emit(@tag, Fluent::Engine.now, generate())
72
+ end
73
+ rate_count += batch_num
74
+ sleep 0.1
75
+ end
76
+ # wait for next second
77
+ while @running && Fluent::Engine.now == current_time
78
+ sleep 0.04
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-dummydata-producer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - TAGOMORI Satoshi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fluentd
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: fluent-mixin-config-placeholders
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Emits dummy data to do bench marks and other tests
70
+ email:
71
+ - tagomoris@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - fluent-plugin-dummydata-producer.gemspec
82
+ - lib/fluent/plugin/in_dummydata_producer.rb
83
+ homepage: https://github.com/tagomoris/fluent-plugin-dummydata-producer
84
+ licenses:
85
+ - APLv2
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.0.2
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Fluentd plugin to produce dummy data and emit it
107
+ test_files: []
108
+ has_rdoc: