fluent-plugin-td 0.10.16 → 0.10.17

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ Release 0.10.17 - 2013/12/05
2
+
3
+ * Change table create / check mechanizm
4
+ * Update td-client to v0.8.56
5
+
6
+
1
7
  Release 0.10.16 - 2013/09/25
2
8
 
3
9
  * Add connect_timeout / read_timeout / send_timeout parameters
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.10.16
1
+ 0.10.17
@@ -3,8 +3,8 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = "fluent-plugin-td"
6
- gem.description = "Treasure Data Big Data as a Service plugin for Fluentd"
7
- gem.homepage = "http://treasure-data.com/"
6
+ gem.description = "Treasure Data Cloud Data Service plugin for Fluentd"
7
+ gem.homepage = "http://www.treasuredata.com/"
8
8
  gem.summary = gem.description
9
9
  gem.version = File.read("VERSION").strip
10
10
  gem.authors = ["Treasure Data, Inc."]
@@ -17,6 +17,6 @@ Gem::Specification.new do |gem|
17
17
  gem.require_paths = ['lib']
18
18
 
19
19
  gem.add_dependency "fluentd", "~> 0.10.27"
20
- gem.add_dependency "td-client", "~> 0.8.55"
20
+ gem.add_dependency "td-client", "~> 0.8.56"
21
21
  gem.add_development_dependency "rake", ">= 0.9.2"
22
22
  end
@@ -74,17 +74,19 @@ class TreasureDataLogOutput < BufferedOutput
74
74
  require 'time' # Time#rfc2822
75
75
  require 'td-client'
76
76
  require 'digest/md5'
77
+ require 'stringio'
77
78
  super
78
79
  @tmpdir = nil
79
80
  @apikey = nil
80
81
  @key = nil
81
82
  @key_num_limit = 5120 # TODO
82
83
  @record_size_limit = 32*1024*1024 # TODO
83
- @table_list = []
84
+ @table_list = {}
84
85
  @auto_create_table = true
85
86
  @use_ssl = false
86
87
  @buffer_type = 'file' # overwrite default buffer_type
87
88
  @flush_interval = 300 # overwrite default flush_interval to 5mins
89
+ @empty_gz_data = create_empty_gz_data
88
90
  end
89
91
 
90
92
  def configure(conf)
@@ -132,8 +134,6 @@ class TreasureDataLogOutput < BufferedOutput
132
134
  if database && table
133
135
  validate_database_and_table_name(database, table, conf)
134
136
  @key = "#{database}.#{table}"
135
- else
136
- raise ConfigError, "'database' and 'table' parameter are required on tdlog output without auto_create_table" unless @auto_create_table
137
137
  end
138
138
 
139
139
  @anonymizes = {}
@@ -159,7 +159,7 @@ class TreasureDataLogOutput < BufferedOutput
159
159
  @anonymizes = nil if @anonymizes.empty?
160
160
 
161
161
  @http_proxy = conf['http_proxy']
162
- @user_agent = "fluent-plugin-td: 0.10.15" # TODO: automatic increment version
162
+ @user_agent = "fluent-plugin-td: 0.10.17" # TODO: automatic increment version
163
163
  end
164
164
 
165
165
  def start
@@ -167,14 +167,13 @@ class TreasureDataLogOutput < BufferedOutput
167
167
 
168
168
  @client = TreasureData::Client.new(@apikey, :ssl => @use_ssl, :http_proxy => @http_proxy, :user_agent => @user_agent,
169
169
  :connect_timeout => @connect_timeout, :read_timeout => @read_timeout, :send_timeout => @send_timeout)
170
- begin
171
- check_table_exists(@key) if @key
172
- rescue => e
170
+
171
+ if @key
173
172
  if @auto_create_table
174
- database, table = @key.split('.', 2)
173
+ database, table = @key.split('.',2)
175
174
  ensure_database_and_table(database, table)
176
175
  else
177
- raise e
176
+ check_table_exists(@key)
178
177
  end
179
178
  end
180
179
  end
@@ -272,6 +271,12 @@ class TreasureDataLogOutput < BufferedOutput
272
271
  f.close if f
273
272
  end
274
273
 
274
+ def create_empty_gz_data
275
+ io = StringIO.new
276
+ Zlib::GzipWriter.new(io).close
277
+ io.string
278
+ end
279
+
275
280
  def upload(database, table, io, size, unique_id)
276
281
  unique_str = unique_id.unpack('C*').map {|x| "%02x" % x }.join
277
282
  $log.trace { "uploading logs to Treasure Data database=#{database} table=#{table} (#{size}bytes)" }
@@ -297,31 +302,22 @@ class TreasureDataLogOutput < BufferedOutput
297
302
  end
298
303
 
299
304
  def check_table_exists(key)
300
- unless @table_list.include?(key)
305
+ unless @table_list.has_key?(key)
306
+ database, table = key.split('.',2)
307
+ $log.debug "checking whether table '#{database}.#{table}' exists on Treasure Data"
308
+ io = StringIO.new(@empty_gz_data)
301
309
  begin
302
- @table_list = get_table_list
310
+ @client.import(database, table, "msgpack.gz", io, io.size)
311
+ @table_list[key] = true
312
+ rescue TreasureData::NotFoundError
313
+ raise "Table #{key.inspect} does not exist on Treasure Data. Use 'td table:create #{database} #{table}' to create it."
303
314
  rescue
304
- $log.warn "failed to update table list on Treasure Data", :error=>$!.to_s
315
+ $log.warn "failed to check table existence on Treasure Data", :error=>$!.to_s
305
316
  $log.debug_backtrace $!
306
317
  end
307
- unless @table_list.include?(key)
308
- database, table = key.split('.',2)
309
- raise "Table #{key.inspect} does not exist on Treasure Data. Use 'td create-log-table #{database} #{table}' to create it."
310
- end
311
318
  end
312
319
  end
313
320
 
314
- def get_table_list
315
- $log.info "updating table list from Treasure Data"
316
- list = []
317
- @client.databases.each {|db|
318
- db.tables.each {|tbl|
319
- list << "#{db.name}.#{tbl.name}"
320
- }
321
- }
322
- list
323
- end
324
-
325
321
  def validate_database_and_table_name(database, table, conf)
326
322
  begin
327
323
  TreasureData::API.validate_database_name(database)
@@ -342,6 +338,7 @@ class TreasureDataLogOutput < BufferedOutput
342
338
  rescue TreasureData::NotFoundError
343
339
  @client.create_database(database)
344
340
  @client.create_log_table(database, table)
341
+ rescue TreasureData::AlreadyExistsError
345
342
  end
346
343
  end
347
344
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-td
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.16
4
+ version: 0.10.17
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Treasure Data, Inc.
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-09-24 00:00:00.000000000 Z
12
+ date: 2013-12-05 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: fluentd
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,32 +30,36 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: td-client
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ~>
32
36
  - !ruby/object:Gem::Version
33
- version: 0.8.55
37
+ version: 0.8.56
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ~>
39
44
  - !ruby/object:Gem::Version
40
- version: 0.8.55
45
+ version: 0.8.56
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: rake
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: 0.9.2
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: 0.9.2
55
- description: Treasure Data Big Data as a Service plugin for Fluentd
62
+ description: Treasure Data Cloud Data Service plugin for Fluentd
56
63
  email: support@treasure-data.com
57
64
  executables: []
58
65
  extensions: []
@@ -69,28 +76,35 @@ files:
69
76
  - fluent-plugin-td.gemspec
70
77
  - lib/fluent/plugin/out_tdlog.rb
71
78
  - test/out_tdlog.rb
72
- homepage: http://treasure-data.com/
79
+ homepage: http://www.treasuredata.com/
73
80
  licenses: []
74
- metadata: {}
75
81
  post_install_message:
76
82
  rdoc_options: []
77
83
  require_paths:
78
84
  - lib
79
85
  required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
80
87
  requirements:
81
- - - '>='
88
+ - - ! '>='
82
89
  - !ruby/object:Gem::Version
83
90
  version: '0'
91
+ segments:
92
+ - 0
93
+ hash: 79461157441894892
84
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
85
96
  requirements:
86
- - - '>='
97
+ - - ! '>='
87
98
  - !ruby/object:Gem::Version
88
99
  version: '0'
100
+ segments:
101
+ - 0
102
+ hash: 79461157441894892
89
103
  requirements: []
90
104
  rubyforge_project:
91
- rubygems_version: 2.0.3
105
+ rubygems_version: 1.8.23
92
106
  signing_key:
93
- specification_version: 4
94
- summary: Treasure Data Big Data as a Service plugin for Fluentd
107
+ specification_version: 3
108
+ summary: Treasure Data Cloud Data Service plugin for Fluentd
95
109
  test_files:
96
110
  - test/out_tdlog.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 313c5a37b90313d1a1e805285da719c35951184b
4
- data.tar.gz: c0f9975f641434550a2d18a9374bb84fc117b37f
5
- SHA512:
6
- metadata.gz: 912b12246d9650b39137bb1ebd098b45ef9d6ecb4460c8a4667bf1daaaa40ec58ee5a5479a5d7a580b709a5aa5ecfd4b258f5394fbf47b98d1fff709f5d839c0
7
- data.tar.gz: 6d7ac160d26c13d97c49930cb8b9fd045f3a04bfac1a05066ff05877ecf12a82e5562b3a37c7da0acc3c39f6649bedc1b8aecdff984a2fd4df3d9b528b62179c