fluent-plugin-datacounter 0.4.3 → 0.4.4

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: 1b4d91d5c90fe127587b87a6422a51c7615d4d35
4
- data.tar.gz: 44286a9f86f2d5261090a4757abe2e5c5ca5bca1
3
+ metadata.gz: 64d80ad86bd2585306cd7f6e9ba750f7949d1740
4
+ data.tar.gz: dc801aa3ae66d93fd1e476743629a06d9dd9df75
5
5
  SHA512:
6
- metadata.gz: a6f91229701fe9beb94961b5e080669a93d742aa870e50f776fcef86a0c7f9575be603524bbc44c5f6c9a8a09395eb4b1bfa0d42d33af34c00a7891b5b0a98f9
7
- data.tar.gz: 190f1d713ba82566fb9ac4d8d47c944daf84e40d86abc8969158a0cfbb72e31e32d90f6397512875b119541c0b4f10b2bcd1c9ffa113073909840fab65b08f94
6
+ metadata.gz: 99dea601abca6ae123a04e568e5ead302af893f86c4ab9b0682a9f4a6993896aee5cd3f524a03dfcde536905e25a2ed0d1d5e70577161c2e5032b1fc3c46f02b
7
+ data.tar.gz: 7cc35142eb8ec3484188f4a95656d22ba8983ed994a6d69ce46050925eded3cb22e7f2a16f9bcfe778492d7721791f6546d03cd3514ac228873e5ead521aced7
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |gem|
3
3
  gem.name = "fluent-plugin-datacounter"
4
- gem.version = "0.4.3"
4
+ gem.version = "0.4.4"
5
5
  gem.authors = ["TAGOMORI Satoshi"]
6
6
  gem.email = ["tagomoris@gmail.com"]
7
7
  gem.homepage = "https://github.com/tagomoris/fluent-plugin-datacounter"
@@ -18,5 +18,6 @@ Gem::Specification.new do |gem|
18
18
 
19
19
  gem.add_development_dependency "bundler"
20
20
  gem.add_development_dependency "rake"
21
+ gem.add_development_dependency "test-unit"
21
22
  gem.add_development_dependency "delorean"
22
23
  end
@@ -47,7 +47,7 @@ class Fluent::DataCounterOutput < Fluent::Output
47
47
  when 'minute' then 60
48
48
  when 'hour' then 3600
49
49
  when 'day' then 86400
50
- else
50
+ else
51
51
  raise RuntimeError, "@unit must be one of minute/hour/day"
52
52
  end
53
53
  end
@@ -134,7 +134,7 @@ class Fluent::DataCounterOutput < Fluent::Output
134
134
  if @aggregate == :all
135
135
  tag = 'all'
136
136
  end
137
-
137
+
138
138
  @mutex.synchronize {
139
139
  @counts[tag] ||= [0] * (@patterns.length + 1)
140
140
  sum = 0
@@ -201,12 +201,18 @@ class Fluent::DataCounterOutput < Fluent::Output
201
201
  end
202
202
 
203
203
  def flush(step) # returns one message
204
- flushed,@counts = @counts,count_initialized(@counts.keys.dup.select{|k| @counts[k][-1] > 0})
204
+ flushed = nil
205
+ @mutex.synchronize {
206
+ flushed,@counts = @counts,count_initialized(@counts.keys.dup.select{|k| @counts[k][-1] > 0})
207
+ }
205
208
  generate_output(flushed, step)
206
209
  end
207
210
 
208
211
  def flush_per_tags(step) # returns map of tag - message
209
- flushed,@counts = @counts,count_initialized(@counts.keys.dup.select{|k| @counts[k][-1] > 0})
212
+ flushed = nil
213
+ @mutex.synchronize {
214
+ flushed,@counts = @counts,count_initialized(@counts.keys.dup.select{|k| @counts[k][-1] > 0})
215
+ }
210
216
  generate_output_per_tags(flushed, step)
211
217
  end
212
218
 
@@ -229,7 +235,7 @@ class Fluent::DataCounterOutput < Fluent::Output
229
235
  # for internal, or tests only
230
236
  @watcher = Thread.new(&method(:watch))
231
237
  end
232
-
238
+
233
239
  def watch
234
240
  # instance variable, and public accessable, for test
235
241
  @last_checked ||= Fluent::Engine.now
@@ -302,12 +308,14 @@ class Fluent::DataCounterOutput < Fluent::Output
302
308
  stored[:patterns] == @patterns
303
309
 
304
310
  if Fluent::Engine.now <= stored[:saved_at] + tick
305
- @counts = stored[:counts]
306
- @saved_at = stored[:saved_at]
307
- @saved_duration = stored[:saved_duration]
308
-
309
- # skip the saved duration to continue counting
310
- @last_checked = Fluent::Engine.now - @saved_duration
311
+ @mutex.synchronize {
312
+ @counts = stored[:counts]
313
+ @saved_at = stored[:saved_at]
314
+ @saved_duration = stored[:saved_duration]
315
+
316
+ # skip the saved duration to continue counting
317
+ @last_checked = Fluent::Engine.now - @saved_duration
318
+ }
311
319
  else
312
320
  log.warn "out_datacounter: stored data is outdated. ignore stored data"
313
321
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-datacounter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - TAGOMORI Satoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-07 00:00:00.000000000 Z
11
+ date: 2015-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit
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'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: delorean
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -105,10 +119,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
119
  version: '0'
106
120
  requirements: []
107
121
  rubyforge_project:
108
- rubygems_version: 2.2.2
122
+ rubygems_version: 2.4.5
109
123
  signing_key:
110
124
  specification_version: 4
111
125
  summary: Fluentd plugin to count records with specified regexp patterns
112
126
  test_files:
113
127
  - test/helper.rb
114
128
  - test/plugin/test_out_datacounter.rb
129
+ has_rdoc: