fluent-plugin-flume 0.2.0 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/fluent/plugin/out_flume.rb +29 -8
- data/test/plugin/test_out_flume.rb +54 -47
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c6c30fffafba5fabb5604d70ec69217d014e15b
|
4
|
+
data.tar.gz: 39e66e209a62569b43d5a5c9f505dab574918db0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1fbfb352b40f8f0d8822a085fc415fc376c834c2e44e2962840140c8cc4cb0b82ad72ccb8281e58a904fa119b3ef2dfdb9508536135fa49b4146dd6f04e0a3c
|
7
|
+
data.tar.gz: 59b805d33056fd27735e6c9d75c118c5453e854e40ee3a9dc709c4dd9185f3346e74a3ad2d222ae8e7debf28c60e876536fc4870a392e62c8c1d7f50095b5f8a
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0.rc1
|
@@ -16,21 +16,35 @@
|
|
16
16
|
# limitations under the License.
|
17
17
|
#
|
18
18
|
|
19
|
-
require 'fluent/output'
|
19
|
+
require 'fluent/plugin/output'
|
20
20
|
|
21
|
-
module Fluent
|
22
|
-
class FlumeOutput <
|
21
|
+
module Fluent::Plugin
|
22
|
+
class FlumeOutput < Output
|
23
23
|
Fluent::Plugin.register_output('flume', self)
|
24
24
|
|
25
|
+
helpers :formatter, :compat_parameters
|
26
|
+
|
27
|
+
DEFAULT_BUFFER_TYPE = "memory"
|
28
|
+
DEFAULT_FORMAT_TYPE = 'json'
|
29
|
+
|
25
30
|
config_param :host, :string, :default => 'localhost'
|
26
31
|
config_param :port, :integer, :default => 35863
|
27
32
|
config_param :timeout, :integer, :default => 30
|
28
33
|
config_param :remove_prefix, :string, :default => nil
|
29
34
|
config_param :default_category, :string, :default => 'unknown'
|
30
35
|
desc "The format of the thrift body. (default: json)"
|
31
|
-
config_param :format, :string, default:
|
36
|
+
config_param :format, :string, default: DEFAULT_FORMAT_TYPE
|
32
37
|
config_param :trim_nl, :bool, default: true
|
33
38
|
|
39
|
+
config_section :buffer do
|
40
|
+
config_set_default :@type, DEFAULT_BUFFER_TYPE
|
41
|
+
config_set_default :chunk_keys, ['tag']
|
42
|
+
end
|
43
|
+
|
44
|
+
config_section :format do
|
45
|
+
config_set_default :@type, DEFAULT_FORMAT_TYPE
|
46
|
+
end
|
47
|
+
|
34
48
|
unless method_defined?(:log)
|
35
49
|
define_method(:log) { $log }
|
36
50
|
end
|
@@ -47,11 +61,10 @@ module Fluent
|
|
47
61
|
def configure(conf)
|
48
62
|
# override default buffer_chunk_limit
|
49
63
|
conf['buffer_chunk_limit'] ||= '1m'
|
50
|
-
|
64
|
+
compat_parameters_convert(conf, :formatter)
|
51
65
|
super
|
52
66
|
|
53
|
-
@formatter =
|
54
|
-
@formatter.configure(conf)
|
67
|
+
@formatter = formatter_create
|
55
68
|
end
|
56
69
|
|
57
70
|
def start
|
@@ -77,6 +90,14 @@ module Fluent
|
|
77
90
|
[time, fr].to_msgpack
|
78
91
|
end
|
79
92
|
|
93
|
+
def formatted_to_msgpack_binary
|
94
|
+
true
|
95
|
+
end
|
96
|
+
|
97
|
+
def multi_workers_ready?
|
98
|
+
true
|
99
|
+
end
|
100
|
+
|
80
101
|
def write(chunk)
|
81
102
|
socket = Thrift::Socket.new @host, @port, @timeout
|
82
103
|
transport = Thrift::FramedTransport.new socket
|
@@ -84,7 +105,7 @@ module Fluent
|
|
84
105
|
protocol = Thrift::CompactProtocol.new transport
|
85
106
|
client = ThriftSourceProtocol::Client.new protocol
|
86
107
|
|
87
|
-
tag = chunk.
|
108
|
+
tag = chunk.metadata.tag
|
88
109
|
count = 0
|
89
110
|
header = {}
|
90
111
|
transport.open
|
@@ -1,8 +1,12 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
require 'fluent/test'
|
3
|
+
require 'fluent/test/helpers'
|
4
|
+
require 'fluent/test/driver/output'
|
3
5
|
require 'lib/fluent/plugin/out_flume'
|
4
6
|
|
5
7
|
class FlumeOutputTest < Test::Unit::TestCase
|
8
|
+
include Fluent::Test::Helpers
|
9
|
+
|
6
10
|
def setup
|
7
11
|
Fluent::Test.setup
|
8
12
|
end
|
@@ -12,8 +16,8 @@ class FlumeOutputTest < Test::Unit::TestCase
|
|
12
16
|
port 35862
|
13
17
|
]
|
14
18
|
|
15
|
-
def create_driver(conf=CONFIG
|
16
|
-
Fluent::Test::
|
19
|
+
def create_driver(conf=CONFIG)
|
20
|
+
Fluent::Test::Driver::Output.new(Fluent::Plugin::FlumeOutput) do
|
17
21
|
def write(chunk)
|
18
22
|
chunk.read
|
19
23
|
end
|
@@ -36,79 +40,82 @@ class FlumeOutputTest < Test::Unit::TestCase
|
|
36
40
|
end
|
37
41
|
|
38
42
|
def test_format
|
39
|
-
time =
|
43
|
+
time = event_time("2011-12-21 13:14:15 UTC")
|
40
44
|
|
41
45
|
d = create_driver
|
42
|
-
d.
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
d.
|
46
|
+
d.run(default_tag: 'test') do
|
47
|
+
d.feed(time, {"k11"=>"v11", "k12"=>"v12"})
|
48
|
+
d.feed(time, {"k21"=>"v21", "k22"=>"v22"})
|
49
|
+
end
|
50
|
+
assert_equal [time, {"k11"=>"v11", "k12"=>"v12"}.to_json].to_msgpack, d.formatted[0]
|
51
|
+
assert_equal [time, {"k21"=>"v21", "k22"=>"v22"}.to_json].to_msgpack, d.formatted[1]
|
47
52
|
|
48
53
|
d = create_driver(CONFIG + %[
|
49
54
|
remove_prefix test
|
50
|
-
]
|
51
|
-
assert_equal 'test.flumeplugin', d.tag
|
55
|
+
])
|
52
56
|
|
53
|
-
d.
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
d.
|
57
|
+
d.run(default_tag: 'test.flumeplugin') do
|
58
|
+
d.feed(time, {"k11"=>"v11", "k12"=>"v12"})
|
59
|
+
d.feed(time, {"k21"=>"v21", "k22"=>"v22"})
|
60
|
+
end
|
61
|
+
assert_equal [time, {"k11"=>"v11", "k12"=>"v12"}.to_json].to_msgpack, d.formatted[0]
|
62
|
+
assert_equal [time, {"k21"=>"v21", "k22"=>"v22"}.to_json].to_msgpack, d.formatted[1]
|
58
63
|
|
59
64
|
d = create_driver(CONFIG + %[
|
60
65
|
remove_prefix test
|
61
|
-
]
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
d.run
|
66
|
+
])
|
67
|
+
d.run(default_tag: 'xxx.test.flumeplugin') do
|
68
|
+
d.feed(time, {"k11"=>"v11", "k12"=>"v12"})
|
69
|
+
end
|
66
70
|
|
67
71
|
d = create_driver(CONFIG + %[
|
68
72
|
remove_prefix test
|
69
|
-
]
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
d.
|
73
|
+
])
|
74
|
+
d.run(default_tag: 'test') do
|
75
|
+
d.feed(time, {"k11"=>"v11", "k12"=>"v12"})
|
76
|
+
end
|
77
|
+
assert_equal [time, {"k11"=>"v11", "k12"=>"v12"}.to_json].to_msgpack, d.formatted[0]
|
74
78
|
|
75
79
|
d = create_driver(CONFIG + %[
|
76
80
|
remove_prefix test
|
77
|
-
]
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
d.
|
81
|
+
])
|
82
|
+
d.run(default_tag: 'test.flumeplugin') do
|
83
|
+
d.feed(time, {"k11"=>"v11", "k12"=>"v12"})
|
84
|
+
d.feed(time, {"k21"=>"v21", "k22"=>"v22"})
|
85
|
+
end
|
86
|
+
assert_equal [time, {"k11"=>"v11", "k12"=>"v12"}.to_json].to_msgpack, d.formatted[0]
|
87
|
+
assert_equal [time, {"k21"=>"v21", "k22"=>"v22"}.to_json].to_msgpack, d.formatted[1]
|
84
88
|
end
|
85
89
|
|
86
90
|
def test_write
|
87
|
-
time =
|
91
|
+
time = event_time("2011-12-21 13:14:15 UTC")
|
88
92
|
|
89
93
|
d = create_driver
|
90
|
-
d.
|
91
|
-
|
92
|
-
|
94
|
+
d.run(default_tag: 'test') do
|
95
|
+
d.feed(time, {"k11"=>"v11", "k12"=>"v12"})
|
96
|
+
d.feed(time, {"k21"=>"v21", "k22"=>"v22"})
|
97
|
+
end
|
93
98
|
|
94
99
|
d = create_driver(CONFIG + %[
|
95
100
|
remove_prefix test
|
96
|
-
]
|
97
|
-
|
98
|
-
|
101
|
+
])
|
102
|
+
d.end_if do
|
103
|
+
d.events.size >= 0
|
104
|
+
end
|
105
|
+
d.run(default_tag: 'test.flumeplugin')
|
99
106
|
|
100
107
|
d = create_driver(CONFIG + %[
|
101
108
|
remove_prefix test
|
102
|
-
]
|
103
|
-
|
104
|
-
|
105
|
-
|
109
|
+
])
|
110
|
+
d.run(default_tag: 'xxx.test.flumeplugin') do
|
111
|
+
d.feed(time, {"k11"=>"v11", "k12"=>"v12"})
|
112
|
+
end
|
106
113
|
|
107
114
|
d = create_driver(CONFIG + %[
|
108
115
|
remove_prefix test
|
109
|
-
]
|
110
|
-
|
111
|
-
|
112
|
-
|
116
|
+
])
|
117
|
+
d.run(default_tag: 'test') do
|
118
|
+
d.feed(time, {"k11"=>"v11", "k12"=>"v12"})
|
119
|
+
end
|
113
120
|
end
|
114
121
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-flume
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Muga Nishizawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -115,12 +115,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: '0'
|
116
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
117
|
requirements:
|
118
|
-
- - "
|
118
|
+
- - ">"
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
version:
|
120
|
+
version: 1.3.1
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.6.11
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Flume Input/Output plugin for Fluentd event collector
|