fluent-plugin-td 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/ChangeLog +6 -0
- data/Gemfile +3 -0
- data/Rakefile +8 -52
- data/VERSION +1 -1
- data/fluent-plugin-td.gemspec +18 -47
- data/lib/fluent/plugin/out_tdlog.rb +29 -27
- data/test/out_tdlog.rb +17 -0
- metadata +45 -68
data/.gitignore
ADDED
data/ChangeLog
CHANGED
data/Gemfile
ADDED
data/Rakefile
CHANGED
@@ -1,58 +1,14 @@
|
|
1
|
-
require 'rake'
|
2
|
-
require 'rake/testtask'
|
3
|
-
require 'rake/clean'
|
4
1
|
|
5
|
-
|
6
|
-
|
7
|
-
Jeweler::Tasks.new do |gemspec|
|
8
|
-
gemspec.name = "fluent-plugin-td"
|
9
|
-
gemspec.summary = "Treasure Data plugin for Fluent event collector"
|
10
|
-
gemspec.author = "Sadayuki Furuhashi"
|
11
|
-
#gemspec.email = "frsyuki@gmail.com"
|
12
|
-
#gemspec.homepage = "http://fluent.github.com/"
|
13
|
-
gemspec.has_rdoc = false
|
14
|
-
gemspec.require_paths = ["lib"]
|
15
|
-
gemspec.add_dependency "fluentd", "~> 0.10.0"
|
16
|
-
gemspec.add_dependency "td-client", "~> 0.8.0"
|
17
|
-
gemspec.test_files = Dir["test/**/*.rb"]
|
18
|
-
gemspec.files = Dir["bin/**/*", "lib/**/*", "test/**/*.rb"] +
|
19
|
-
%w[example.conf VERSION AUTHORS Rakefile fluent-plugin-td.gemspec]
|
20
|
-
gemspec.executables = []
|
21
|
-
end
|
22
|
-
Jeweler::GemcutterTasks.new
|
23
|
-
rescue LoadError
|
24
|
-
puts "Jeweler not available. Install it with: gem install jeweler"
|
25
|
-
end
|
2
|
+
require 'bundler'
|
3
|
+
Bundler::GemHelper.install_tasks
|
26
4
|
|
27
|
-
|
28
|
-
t.test_files = Dir['test/*_test.rb']
|
29
|
-
t.ruby_opts = ['-rubygems'] if defined? Gem
|
30
|
-
t.ruby_opts << '-I.'
|
31
|
-
end
|
32
|
-
|
33
|
-
#VERSION_FILE = "lib/fluent/version.rb"
|
34
|
-
#
|
35
|
-
#file VERSION_FILE => ["VERSION"] do |t|
|
36
|
-
# version = File.read("VERSION").strip
|
37
|
-
# File.open(VERSION_FILE, "w") {|f|
|
38
|
-
# f.write <<EOF
|
39
|
-
#module Fluent
|
40
|
-
#
|
41
|
-
#VERSION = '#{version}'
|
42
|
-
#
|
43
|
-
#end
|
44
|
-
#EOF
|
45
|
-
# }
|
46
|
-
#end
|
47
|
-
#
|
48
|
-
#task :default => [VERSION_FILE, :build]
|
5
|
+
require 'rake/testtask'
|
49
6
|
|
50
|
-
Rake::TestTask.new(:test) do |
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
#t.warning = true
|
7
|
+
Rake::TestTask.new(:test) do |test|
|
8
|
+
test.libs << 'lib' << 'test'
|
9
|
+
test.test_files = FileList['test/*.rb']
|
10
|
+
test.verbose = true
|
55
11
|
end
|
56
12
|
|
57
|
-
task :default => [:build
|
13
|
+
task :default => [:build]
|
58
14
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.10.
|
1
|
+
0.10.1
|
data/fluent-plugin-td.gemspec
CHANGED
@@ -1,50 +1,21 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
1
|
+
# encoding: utf-8
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
5
3
|
|
6
|
-
Gem::Specification.new do |
|
7
|
-
|
8
|
-
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "fluent-plugin-td"
|
6
|
+
gem.description = "Treasure Data output plugin for Fluent event collector"
|
7
|
+
#gem.homepage = "http://fluentd.org/"
|
8
|
+
gem.summary = gem.description
|
9
|
+
gem.version = File.read("VERSION").strip
|
10
|
+
gem.authors = ["Sadayuki Furuhashi"]
|
11
|
+
#gem.email = "frsyuki@gmail.com"
|
12
|
+
gem.has_rdoc = false
|
13
|
+
#gem.platform = Gem::Platform::RUBY
|
14
|
+
gem.files = `git ls-files`.split("\n")
|
15
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
gem.require_paths = ['lib']
|
9
18
|
|
10
|
-
|
11
|
-
|
12
|
-
s.date = %q{2011-10-16}
|
13
|
-
s.extra_rdoc_files = [
|
14
|
-
"ChangeLog",
|
15
|
-
"README.rdoc"
|
16
|
-
]
|
17
|
-
s.files = [
|
18
|
-
"AUTHORS",
|
19
|
-
"Rakefile",
|
20
|
-
"VERSION",
|
21
|
-
"example.conf",
|
22
|
-
"fluent-plugin-td.gemspec",
|
23
|
-
"lib/fluent/plugin/out_tdlog.rb",
|
24
|
-
"test/out_tdlog.rb"
|
25
|
-
]
|
26
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
27
|
-
s.require_paths = ["lib"]
|
28
|
-
s.rubygems_version = %q{1.3.7}
|
29
|
-
s.summary = %q{Treasure Data plugin for Fluent event collector}
|
30
|
-
s.test_files = [
|
31
|
-
"test/out_tdlog.rb"
|
32
|
-
]
|
33
|
-
|
34
|
-
if s.respond_to? :specification_version then
|
35
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
36
|
-
s.specification_version = 3
|
37
|
-
|
38
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
39
|
-
s.add_runtime_dependency(%q<fluentd>, ["~> 0.10.0"])
|
40
|
-
s.add_runtime_dependency(%q<td-client>, ["~> 0.8.0"])
|
41
|
-
else
|
42
|
-
s.add_dependency(%q<fluentd>, ["~> 0.10.0"])
|
43
|
-
s.add_dependency(%q<td-client>, ["~> 0.8.0"])
|
44
|
-
end
|
45
|
-
else
|
46
|
-
s.add_dependency(%q<fluentd>, ["~> 0.10.0"])
|
47
|
-
s.add_dependency(%q<td-client>, ["~> 0.8.0"])
|
48
|
-
end
|
19
|
+
gem.add_dependency "fluentd", "~> 0.10.0"
|
20
|
+
gem.add_dependency "td-client", "~> 0.8.4"
|
49
21
|
end
|
50
|
-
|
@@ -67,11 +67,15 @@ class TreasureDataLogOutput < BufferedOutput
|
|
67
67
|
if !database || !table
|
68
68
|
raise ConfigError, "'database' and 'table' parameter are required on tdlog output"
|
69
69
|
end
|
70
|
-
|
71
|
-
|
70
|
+
begin
|
71
|
+
TreasureData::API.validate_database_name(database)
|
72
|
+
rescue
|
73
|
+
raise ConfigError, "Invalid database name #{database.inspect}: #{$!}: #{conf}"
|
72
74
|
end
|
73
|
-
|
74
|
-
|
75
|
+
begin
|
76
|
+
TreasureData::API.validate_table_name(table)
|
77
|
+
rescue
|
78
|
+
raise ConfigError, "Invalid table name #{table.inspect}: #{$!}: #{conf}"
|
75
79
|
end
|
76
80
|
@key = "#{database}.#{table}"
|
77
81
|
end
|
@@ -90,10 +94,8 @@ class TreasureDataLogOutput < BufferedOutput
|
|
90
94
|
key = @key
|
91
95
|
else
|
92
96
|
database, table = tag.split('.')[-2,2]
|
93
|
-
|
94
|
-
|
95
|
-
return
|
96
|
-
end
|
97
|
+
TreasureData::API.validate_database_name(database)
|
98
|
+
TreasureData::API.validate_table_name(table)
|
97
99
|
key = "#{database}.#{table}"
|
98
100
|
end
|
99
101
|
|
@@ -104,10 +106,6 @@ class TreasureDataLogOutput < BufferedOutput
|
|
104
106
|
super(tag, es, chain, key)
|
105
107
|
end
|
106
108
|
|
107
|
-
def validate_name(name)
|
108
|
-
true
|
109
|
-
end
|
110
|
-
|
111
109
|
def format_stream(tag, es)
|
112
110
|
out = ''
|
113
111
|
off = out.bytesize
|
@@ -132,10 +130,6 @@ class TreasureDataLogOutput < BufferedOutput
|
|
132
130
|
|
133
131
|
def write(chunk)
|
134
132
|
database, table = chunk.key.split('.',2)
|
135
|
-
if !validate_name(database) || !validate_name(table)
|
136
|
-
$log.error "Invalid key name #{chunk.key.inspect}"
|
137
|
-
return
|
138
|
-
end
|
139
133
|
|
140
134
|
f = Tempfile.new("tdlog-", @tmpdir)
|
141
135
|
w = Zlib::GzipWriter.new(f)
|
@@ -157,20 +151,28 @@ class TreasureDataLogOutput < BufferedOutput
|
|
157
151
|
$log.trace { "uploading logs to Treasure Data database=#{database} table=#{table} (#{size}bytes)" }
|
158
152
|
|
159
153
|
begin
|
160
|
-
@client.import(database, table, "msgpack.gz", io, size)
|
161
|
-
rescue TreasureData::NotFoundError
|
162
|
-
unless @auto_create_table
|
163
|
-
raise $!
|
164
|
-
end
|
165
|
-
$log.info "Creating table #{database}.#{table} on TreasureData"
|
166
154
|
begin
|
167
|
-
|
155
|
+
start = Time.now
|
156
|
+
@client.import(database, table, "msgpack.gz", io, size)
|
168
157
|
rescue TreasureData::NotFoundError
|
169
|
-
@
|
170
|
-
|
158
|
+
unless @auto_create_table
|
159
|
+
raise $!
|
160
|
+
end
|
161
|
+
$log.info "Creating table #{database}.#{table} on TreasureData"
|
162
|
+
begin
|
163
|
+
@client.create_log_table(database, table)
|
164
|
+
rescue TreasureData::NotFoundError
|
165
|
+
@client.create_database(database)
|
166
|
+
@client.create_log_table(database, table)
|
167
|
+
end
|
168
|
+
io.pos = 0
|
169
|
+
retry
|
171
170
|
end
|
172
|
-
|
173
|
-
|
171
|
+
rescue => e
|
172
|
+
elapsed = Time.now - start
|
173
|
+
ne = RuntimeError.new("Failed to upload to TreasureData: #{$!} (#{size} bytes; #{elapsed} seconds)")
|
174
|
+
ne.set_backtrace(e.backtrace)
|
175
|
+
raise ne
|
174
176
|
end
|
175
177
|
end
|
176
178
|
|
data/test/out_tdlog.rb
CHANGED
@@ -33,5 +33,22 @@ class TreasureDataLogOutputTest < Test::Unit::TestCase
|
|
33
33
|
d.emit({"a"=>2}, time)
|
34
34
|
d.run
|
35
35
|
end
|
36
|
+
|
37
|
+
def test_invalid_name
|
38
|
+
d = create_driver
|
39
|
+
d.instance.start
|
40
|
+
|
41
|
+
es = Fluent::OneEventStream.new(Time.now.to_i, {})
|
42
|
+
chain = Fluent::NullOutputChain.instance
|
43
|
+
assert_raise(RuntimeError) do
|
44
|
+
d.instance.emit("test.invalid-name", es, chain)
|
45
|
+
end
|
46
|
+
assert_raise(RuntimeError) do
|
47
|
+
d.instance.emit("empty", es, chain)
|
48
|
+
end
|
49
|
+
assert_raise(RuntimeError) do
|
50
|
+
d.instance.emit("", es, chain)
|
51
|
+
end
|
52
|
+
end
|
36
53
|
end
|
37
54
|
|
metadata
CHANGED
@@ -1,107 +1,84 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-td
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 10
|
9
|
-
- 0
|
10
|
-
version: 0.10.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.10.1
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Sadayuki Furuhashi
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-11-10 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: fluentd
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70114372869080 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
18
|
+
requirements:
|
27
19
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 55
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 10
|
33
|
-
- 0
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 0.10.0
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: td-client
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: *70114372869080
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: td-client
|
27
|
+
requirement: &70114372868600 !ruby/object:Gem::Requirement
|
41
28
|
none: false
|
42
|
-
requirements:
|
29
|
+
requirements:
|
43
30
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
- 8
|
49
|
-
- 0
|
50
|
-
version: 0.8.0
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.8.4
|
51
33
|
type: :runtime
|
52
|
-
|
53
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70114372868600
|
36
|
+
description: Treasure Data output plugin for Fluent event collector
|
54
37
|
email:
|
55
38
|
executables: []
|
56
|
-
|
57
39
|
extensions: []
|
58
|
-
|
59
|
-
|
40
|
+
extra_rdoc_files: []
|
41
|
+
files:
|
42
|
+
- .gitignore
|
43
|
+
- AUTHORS
|
60
44
|
- ChangeLog
|
45
|
+
- Gemfile
|
61
46
|
- README.rdoc
|
62
|
-
files:
|
63
|
-
- AUTHORS
|
64
47
|
- Rakefile
|
65
48
|
- VERSION
|
66
49
|
- example.conf
|
67
50
|
- fluent-plugin-td.gemspec
|
68
51
|
- lib/fluent/plugin/out_tdlog.rb
|
69
52
|
- test/out_tdlog.rb
|
70
|
-
- ChangeLog
|
71
|
-
- README.rdoc
|
72
|
-
has_rdoc: true
|
73
53
|
homepage:
|
74
54
|
licenses: []
|
75
|
-
|
76
55
|
post_install_message:
|
77
|
-
rdoc_options:
|
78
|
-
|
79
|
-
require_paths:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
80
58
|
- lib
|
81
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
60
|
none: false
|
83
|
-
requirements:
|
84
|
-
- -
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
|
87
|
-
segments:
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
segments:
|
88
66
|
- 0
|
89
|
-
|
90
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
hash: -747294659517590458
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
69
|
none: false
|
92
|
-
requirements:
|
93
|
-
- -
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
|
96
|
-
segments:
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
segments:
|
97
75
|
- 0
|
98
|
-
|
76
|
+
hash: -747294659517590458
|
99
77
|
requirements: []
|
100
|
-
|
101
78
|
rubyforge_project:
|
102
|
-
rubygems_version: 1.
|
79
|
+
rubygems_version: 1.8.10
|
103
80
|
signing_key:
|
104
81
|
specification_version: 3
|
105
|
-
summary: Treasure Data plugin for Fluent event collector
|
106
|
-
test_files:
|
82
|
+
summary: Treasure Data output plugin for Fluent event collector
|
83
|
+
test_files:
|
107
84
|
- test/out_tdlog.rb
|