fluent-plugin-buffer-event_limited 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fluent-plugin-buffer-event_limited.gemspec +1 -1
- data/lib/fluent/plugin/buf_event_limited.rb +35 -30
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9837aeb9ac272dabafad51da6d4e94209894cb2
|
4
|
+
data.tar.gz: ccc9d6a9d68ae52e67679c8d0a23ad2907bb47c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22ddeaedff64fd9c1bea85e4f54e2c3ad44f24f1b4d844e9d2413103abb506322420d326b8efb20c260b8935f567d70d5cd53be0796cc75b82ea2c4a8a315317
|
7
|
+
data.tar.gz: 2e7ff811aeb6f0397bcd2d62d8dd373fa034939ee7c8513c2a3e181165cce725fc6a3ab3d98f16727b46022c3ae835717452196b4a7eea68db9b7cef6c6340df
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "fluent-plugin-buffer-event_limited"
|
5
|
-
spec.version = "0.1.
|
5
|
+
spec.version = "0.1.4"
|
6
6
|
spec.authors = ["TAGOMORI Satoshi", 'Gergo Sulymosi']
|
7
7
|
spec.email = ["tagomoris@gmail.com", 'gergo.sulymosi@gmail.com']
|
8
8
|
spec.description = %q{Fluentd memory buffer plugin with many types of chunk limits}
|
@@ -6,7 +6,7 @@ module Fluent
|
|
6
6
|
|
7
7
|
def initialize(key, path, unique_id, separator, mode = "a+", symlink_path = nil)
|
8
8
|
super(key, path, unique_id, mode = "a+", symlink_path = nil)
|
9
|
-
init_counter(
|
9
|
+
init_counter(separator)
|
10
10
|
end
|
11
11
|
|
12
12
|
def <<(data)
|
@@ -18,18 +18,22 @@ module Fluent
|
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
|
-
def init_counter(
|
22
|
-
|
21
|
+
def init_counter(separator)
|
22
|
+
old_pos = @file.pos
|
23
|
+
@file.rewind
|
24
|
+
|
25
|
+
@record_counter = (
|
23
26
|
case separator
|
24
|
-
when 'msgpack'
|
25
|
-
|
26
|
-
when '
|
27
|
-
File.foreach(path, $/).inject(0) { |c, _| c + 1 }
|
28
|
-
when 'tab'
|
29
|
-
File.foreach(path, "\t").inject(0) { |c, _| c + 1 }
|
27
|
+
when 'msgpack' then MessagePack::Unpacker.new(@file).each
|
28
|
+
when 'newline' then @file.each($/)
|
29
|
+
when 'tab' then @file.each("\t")
|
30
30
|
else
|
31
31
|
raise ArgumentError, "Separator #{separator.inspect} is not supported"
|
32
32
|
end
|
33
|
+
).inject(0) { |c, _| c + 1 }
|
34
|
+
|
35
|
+
@file.pos = old_pos
|
36
|
+
$log.trace("#init_counter(#{[path, separator].join(', ')}) => #{@record_counter}")
|
33
37
|
end
|
34
38
|
end
|
35
39
|
|
@@ -39,6 +43,11 @@ module Fluent
|
|
39
43
|
config_param :buffer_chunk_records_limit, :integer, :default => Float::INFINITY
|
40
44
|
config_param :buffer_chunk_message_separator, :string, :default => 'msgpack'
|
41
45
|
|
46
|
+
def storable?(chunk, data)
|
47
|
+
(chunk.record_counter < @buffer_chunk_records_limit) &&
|
48
|
+
((chunk.size + data.bytesize) <= @buffer_chunk_limit)
|
49
|
+
end
|
50
|
+
|
42
51
|
def new_chunk(key)
|
43
52
|
encoded_key = encode_key(key)
|
44
53
|
path, tsuffix = make_path(encoded_key, 'b')
|
@@ -53,24 +62,25 @@ module Fluent
|
|
53
62
|
maps = []
|
54
63
|
queues = []
|
55
64
|
|
56
|
-
Dir.glob("#{@buffer_path_prefix}*#{@buffer_path_suffix}")
|
65
|
+
Dir.glob("#{@buffer_path_prefix}*#{@buffer_path_suffix}") do |path|
|
57
66
|
identifier_part = chunk_identifier_in_path(path)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
67
|
+
next unless (m = PATH_MATCH.match(identifier_part))
|
68
|
+
|
69
|
+
key = decode_key(m[1])
|
70
|
+
bq = m[2]
|
71
|
+
tsuffix = m[3]
|
72
|
+
timestamp = m[3].to_i(16)
|
73
|
+
unique_id = tsuffix_to_unique_id(tsuffix)
|
74
|
+
|
75
|
+
case bq
|
76
|
+
when 'b'
|
77
|
+
chunk = EventLimitedBufferChunk.new(key, path, unique_id, @buffer_chunk_message_separator, "a+")
|
78
|
+
maps << [timestamp, chunk]
|
79
|
+
when 'q'
|
80
|
+
chunk = EventLimitedBufferChunk.new(key, path, unique_id, @buffer_chunk_message_separator, "r")
|
81
|
+
queues << [timestamp, chunk]
|
72
82
|
end
|
73
|
-
|
83
|
+
end
|
74
84
|
|
75
85
|
map = {}
|
76
86
|
maps
|
@@ -83,10 +93,5 @@ module Fluent
|
|
83
93
|
|
84
94
|
return queue, map
|
85
95
|
end
|
86
|
-
|
87
|
-
def storable?(chunk, data)
|
88
|
-
chunk.record_counter < @buffer_chunk_records_limit &&
|
89
|
-
(chunk.size + data.bytesize) <= @buffer_chunk_limit
|
90
|
-
end
|
91
96
|
end
|
92
97
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-buffer-event_limited
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TAGOMORI Satoshi
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-11-
|
12
|
+
date: 2015-11-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|