fluent-plugin-flume 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +1 -0
- data/ChangeLog +1 -0
- data/README.rdoc +105 -0
- data/Rakefile +57 -0
- data/VERSION +1 -0
- data/bin/fluent-flume-remote +28 -0
- data/fluent-plugin-flume.gemspec +56 -0
- data/lib/fluent/plugin/in_flume.rb +164 -0
- data/lib/fluent/plugin/out_flume.rb +96 -0
- data/lib/fluent/plugin/thrift/flume.thrift +72 -0
- data/lib/fluent/plugin/thrift/flume.thrift.orig +72 -0
- data/lib/fluent/plugin/thrift/flume_constants.rb +8 -0
- data/lib/fluent/plugin/thrift/flume_types.rb +71 -0
- data/lib/fluent/plugin/thrift/thrift_flume_event_server.rb +220 -0
- data/test/plugin/test_in_flume.rb +209 -0
- data/test/plugin/test_out_flume.rb +177 -0
- metadata +87 -0
@@ -0,0 +1,177 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'fluent/test'
|
3
|
+
require 'lib/fluent/plugin/out_flume'
|
4
|
+
|
5
|
+
class FlumeOutputTest < Test::Unit::TestCase
|
6
|
+
CONFIG = %[
|
7
|
+
host 127.0.0.1
|
8
|
+
port 35862
|
9
|
+
]
|
10
|
+
|
11
|
+
def create_driver(conf=CONFIG, tag='test')
|
12
|
+
Fluent::Test::BufferedOutputTestDriver.new(Fluent::FlumeOutput, tag).configure(conf)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_configure
|
16
|
+
d = create_driver('')
|
17
|
+
|
18
|
+
assert_equal 'localhost', d.instance.host
|
19
|
+
assert_equal 35863, d.instance.port
|
20
|
+
assert_equal 30, d.instance.timeout
|
21
|
+
assert_equal 'unknown', d.instance.default_category
|
22
|
+
assert_nil d.instance.remove_prefix
|
23
|
+
|
24
|
+
d = create_driver
|
25
|
+
|
26
|
+
assert_equal '127.0.0.1', d.instance.host
|
27
|
+
assert_equal 35862, d.instance.port
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_format
|
31
|
+
time = Time.parse("2011-12-21 13:14:15 UTC").to_i
|
32
|
+
|
33
|
+
d = create_driver
|
34
|
+
d.emit({"k11"=>"v11", "k12"=>"v12"}, time)
|
35
|
+
d.emit({"k21"=>"v21", "k22"=>"v22"}, time)
|
36
|
+
d.expect_format [d.tag, time, {"k11"=>"v11", "k12"=>"v12"}].to_msgpack
|
37
|
+
d.expect_format [d.tag, time, {"k21"=>"v21", "k22"=>"v22"}].to_msgpack
|
38
|
+
d.run
|
39
|
+
|
40
|
+
d = create_driver(CONFIG + %[
|
41
|
+
remove_prefix test
|
42
|
+
], 'test.flumeplugin')
|
43
|
+
assert_equal 'test.flumeplugin', d.tag
|
44
|
+
|
45
|
+
d.emit({"k11"=>"v11", "k12"=>"v12"}, time)
|
46
|
+
d.emit({"k21"=>"v21", "k22"=>"v22"}, time)
|
47
|
+
d.expect_format ['flumeplugin', time, {"k11"=>"v11", "k12"=>"v12"}].to_msgpack
|
48
|
+
d.expect_format ['flumeplugin', time, {"k21"=>"v21", "k22"=>"v22"}].to_msgpack
|
49
|
+
d.run
|
50
|
+
|
51
|
+
d = create_driver(CONFIG + %[
|
52
|
+
remove_prefix test
|
53
|
+
], 'xxx.test.flumeplugin')
|
54
|
+
assert_equal 'xxx.test.flumeplugin', d.tag
|
55
|
+
d.emit({"k11"=>"v11", "k12"=>"v12"}, time)
|
56
|
+
d.expect_format ['xxx.test.flumeplugin', time, {"k11"=>"v11", "k12"=>"v12"}].to_msgpack
|
57
|
+
d.run
|
58
|
+
|
59
|
+
d = create_driver(CONFIG + %[
|
60
|
+
remove_prefix test
|
61
|
+
], 'test')
|
62
|
+
assert_equal 'test', d.tag
|
63
|
+
d.emit({"k11"=>"v11", "k12"=>"v12"}, time)
|
64
|
+
d.expect_format ['unknown', time, {"k11"=>"v11", "k12"=>"v12"}].to_msgpack
|
65
|
+
d.run
|
66
|
+
|
67
|
+
d = create_driver(CONFIG + %[
|
68
|
+
remove_prefix test
|
69
|
+
], 'test.flumeplugin')
|
70
|
+
assert_equal 'test.flumeplugin', d.tag
|
71
|
+
d.emit({"k11"=>"v11", "k12"=>"v12"}, time)
|
72
|
+
d.emit({"k21"=>"v21", "k22"=>"v22"}, time)
|
73
|
+
d.expect_format ['flumeplugin', time, {"k11"=>"v11", "k12"=>"v12"}].to_msgpack
|
74
|
+
d.expect_format ['flumeplugin', time, {"k21"=>"v21", "k22"=>"v22"}].to_msgpack
|
75
|
+
d.run
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_write
|
79
|
+
time = Time.parse("2011-12-21 13:14:15 UTC").to_i
|
80
|
+
|
81
|
+
d = create_driver
|
82
|
+
d.emit({"k11"=>"v11", "k12"=>"v12"}, time)
|
83
|
+
d.emit({"k21"=>"v21", "k22"=>"v22"}, time)
|
84
|
+
d.run
|
85
|
+
assert_equal [
|
86
|
+
[d.tag, time, {"k11"=>"v11", "k12"=>"v12"}.to_json.to_s],
|
87
|
+
[d.tag, time, {"k21"=>"v21", "k22"=>"v22"}.to_json.to_s],
|
88
|
+
], $handler.last
|
89
|
+
$handler.last_clear
|
90
|
+
|
91
|
+
d = create_driver(CONFIG + %[
|
92
|
+
remove_prefix test
|
93
|
+
], 'test.flumeplugin')
|
94
|
+
assert_equal 'test.flumeplugin', d.tag
|
95
|
+
d.emit({"k11"=>"v11", "k12"=>"v12"}, time)
|
96
|
+
d.emit({"k21"=>"v21", "k22"=>"v22"}, time)
|
97
|
+
d.run
|
98
|
+
assert_equal [
|
99
|
+
['flumeplugin', time, {"k11"=>"v11", "k12"=>"v12"}.to_json.to_s],
|
100
|
+
['flumeplugin', time, {"k21"=>"v21", "k22"=>"v22"}.to_json.to_s],
|
101
|
+
], $handler.last
|
102
|
+
$handler.last_clear
|
103
|
+
|
104
|
+
d = create_driver(CONFIG + %[
|
105
|
+
remove_prefix test
|
106
|
+
], 'xxx.test.flumeplugin')
|
107
|
+
assert_equal 'xxx.test.flumeplugin', d.tag
|
108
|
+
d.emit({"k11"=>"v11", "k12"=>"v12"}, time)
|
109
|
+
d.run
|
110
|
+
assert_equal [
|
111
|
+
['xxx.test.flumeplugin', time, {"k11"=>"v11", "k12"=>"v12"}.to_json.to_s],
|
112
|
+
], $handler.last
|
113
|
+
$handler.last_clear
|
114
|
+
|
115
|
+
d = create_driver(CONFIG + %[
|
116
|
+
remove_prefix test
|
117
|
+
], 'test')
|
118
|
+
assert_equal 'test', d.tag
|
119
|
+
d.emit({"k11"=>"v11", "k12"=>"v12"}, time)
|
120
|
+
d.run
|
121
|
+
assert_equal [
|
122
|
+
[d.instance.default_category, time, {"k11"=>"v11", "k12"=>"v12"}.to_json.to_s],
|
123
|
+
], $handler.last
|
124
|
+
$handler.last_clear
|
125
|
+
end
|
126
|
+
|
127
|
+
def setup
|
128
|
+
Fluent::Test.setup
|
129
|
+
Fluent::FlumeOutput.new
|
130
|
+
$handler = TestFlumeServerHandler.new
|
131
|
+
@dummy_server_thread = Thread.new do
|
132
|
+
begin
|
133
|
+
transport = Thrift::ServerSocket.new '127.0.0.1', 35862
|
134
|
+
processor = ThriftFlumeEventServer::Processor.new $handler
|
135
|
+
transport_factory = Thrift::BufferedTransportFactory.new
|
136
|
+
protocol_factory = Thrift::BinaryProtocolFactory.new
|
137
|
+
protocol_factory.instance_eval {|obj|
|
138
|
+
def get_protocol(trans) # override
|
139
|
+
Thrift::BinaryProtocol.new(trans, strict_read=false, strict_write=false)
|
140
|
+
end
|
141
|
+
}
|
142
|
+
server = Thrift::SimpleServer.new processor, transport, transport_factory, protocol_factory
|
143
|
+
server.serve
|
144
|
+
ensure
|
145
|
+
#transport.close unless transport.closed?
|
146
|
+
transport.close if transport
|
147
|
+
end
|
148
|
+
end
|
149
|
+
sleep 0.1 # boo...
|
150
|
+
end
|
151
|
+
|
152
|
+
def teardown
|
153
|
+
@dummy_server_thread.kill
|
154
|
+
@dummy_server_thread.join
|
155
|
+
end
|
156
|
+
|
157
|
+
class TestFlumeServerHandler
|
158
|
+
attr :last
|
159
|
+
def initialize
|
160
|
+
@last = []
|
161
|
+
end
|
162
|
+
def append(evt)
|
163
|
+
@last << [evt.fieldss['category'], evt.timestamp, evt.body]
|
164
|
+
end
|
165
|
+
def rawAppend(evt)
|
166
|
+
end
|
167
|
+
def ackedAppend(evt)
|
168
|
+
EventStatus::OK
|
169
|
+
end
|
170
|
+
def close
|
171
|
+
end
|
172
|
+
def last_clear
|
173
|
+
@last.clear
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-flume
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Muga Nishizawa
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-02 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fluentd
|
16
|
+
requirement: &2151808400 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.10.16
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2151808400
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: thrift
|
27
|
+
requirement: &2151805100 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.6.0
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2151805100
|
36
|
+
description:
|
37
|
+
email: muga.nishizawa@gmail.com
|
38
|
+
executables:
|
39
|
+
- fluent-flume-remote
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files:
|
42
|
+
- ChangeLog
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- AUTHORS
|
46
|
+
- Rakefile
|
47
|
+
- VERSION
|
48
|
+
- bin/fluent-flume-remote
|
49
|
+
- fluent-plugin-flume.gemspec
|
50
|
+
- lib/fluent/plugin/in_flume.rb
|
51
|
+
- lib/fluent/plugin/out_flume.rb
|
52
|
+
- lib/fluent/plugin/thrift/flume.thrift
|
53
|
+
- lib/fluent/plugin/thrift/flume.thrift.orig
|
54
|
+
- lib/fluent/plugin/thrift/flume_constants.rb
|
55
|
+
- lib/fluent/plugin/thrift/flume_types.rb
|
56
|
+
- lib/fluent/plugin/thrift/thrift_flume_event_server.rb
|
57
|
+
- test/plugin/test_in_flume.rb
|
58
|
+
- test/plugin/test_out_flume.rb
|
59
|
+
- ChangeLog
|
60
|
+
- README.rdoc
|
61
|
+
homepage: https://github.com/muga/fluent-plugin-flume
|
62
|
+
licenses: []
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.8.15
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: Flume Input/Output plugin for Fluentd event collector
|
85
|
+
test_files:
|
86
|
+
- test/plugin/test_in_flume.rb
|
87
|
+
- test/plugin/test_out_flume.rb
|