fluent-plugin-droonga 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.travis.yml +7 -0
  4. data/Gemfile +40 -0
  5. data/LICENSE.txt +14 -0
  6. data/README.md +18 -0
  7. data/Rakefile +25 -0
  8. data/benchmark/benchmark.rb +123 -0
  9. data/benchmark/utils.rb +243 -0
  10. data/benchmark/watch/benchmark-notify.rb +143 -0
  11. data/benchmark/watch/benchmark-notify.sh +19 -0
  12. data/benchmark/watch/benchmark-publish.rb +120 -0
  13. data/benchmark/watch/benchmark-scan.rb +210 -0
  14. data/benchmark/watch/catalog.json +32 -0
  15. data/benchmark/watch/fluentd.conf +12 -0
  16. data/bin/grn2jsons +85 -0
  17. data/fluent-plugin-droonga.gemspec +41 -0
  18. data/lib/droonga/adapter.rb +156 -0
  19. data/lib/droonga/catalog.rb +153 -0
  20. data/lib/droonga/command_mapper.rb +45 -0
  21. data/lib/droonga/engine.rb +83 -0
  22. data/lib/droonga/executor.rb +289 -0
  23. data/lib/droonga/handler.rb +140 -0
  24. data/lib/droonga/handler_plugin.rb +35 -0
  25. data/lib/droonga/job_queue.rb +83 -0
  26. data/lib/droonga/job_queue_schema.rb +65 -0
  27. data/lib/droonga/logger.rb +34 -0
  28. data/lib/droonga/plugin.rb +41 -0
  29. data/lib/droonga/plugin/adapter/groonga/select.rb +88 -0
  30. data/lib/droonga/plugin/adapter_groonga.rb +40 -0
  31. data/lib/droonga/plugin/handler/groonga/column_create.rb +103 -0
  32. data/lib/droonga/plugin/handler/groonga/table_create.rb +100 -0
  33. data/lib/droonga/plugin/handler_add.rb +44 -0
  34. data/lib/droonga/plugin/handler_forward.rb +70 -0
  35. data/lib/droonga/plugin/handler_groonga.rb +52 -0
  36. data/lib/droonga/plugin/handler_proxy.rb +82 -0
  37. data/lib/droonga/plugin/handler_search.rb +33 -0
  38. data/lib/droonga/plugin/handler_watch.rb +102 -0
  39. data/lib/droonga/proxy.rb +371 -0
  40. data/lib/droonga/searcher.rb +415 -0
  41. data/lib/droonga/server.rb +112 -0
  42. data/lib/droonga/sweeper.rb +42 -0
  43. data/lib/droonga/watch_schema.rb +88 -0
  44. data/lib/droonga/watcher.rb +256 -0
  45. data/lib/droonga/worker.rb +51 -0
  46. data/lib/fluent/plugin/out_droonga.rb +56 -0
  47. data/lib/groonga_command_converter.rb +137 -0
  48. data/sample/cluster/catalog.json +43 -0
  49. data/sample/cluster/fluentd.conf +12 -0
  50. data/sample/fluentd.conf +8 -0
  51. data/test/fixtures/catalog.json +43 -0
  52. data/test/fixtures/document.grn +23 -0
  53. data/test/helper.rb +24 -0
  54. data/test/helper/fixture.rb +28 -0
  55. data/test/helper/sandbox.rb +73 -0
  56. data/test/helper/stub_worker.rb +27 -0
  57. data/test/helper/watch_helper.rb +35 -0
  58. data/test/plugin/adapter/groonga/test_select.rb +176 -0
  59. data/test/plugin/handler/groonga/test_column_create.rb +127 -0
  60. data/test/plugin/handler/groonga/test_table_create.rb +140 -0
  61. data/test/plugin/handler/test_handler_add.rb +135 -0
  62. data/test/plugin/handler/test_handler_groonga.rb +64 -0
  63. data/test/plugin/handler/test_handler_search.rb +512 -0
  64. data/test/plugin/handler/test_handler_watch.rb +168 -0
  65. data/test/run-test.rb +55 -0
  66. data/test/test_adapter.rb +48 -0
  67. data/test/test_catalog.rb +59 -0
  68. data/test/test_command_mapper.rb +44 -0
  69. data/test/test_groonga_command_converter.rb +242 -0
  70. data/test/test_handler.rb +53 -0
  71. data/test/test_job_queue_schema.rb +45 -0
  72. data/test/test_output.rb +99 -0
  73. data/test/test_sweeper.rb +95 -0
  74. data/test/test_watch_schema.rb +57 -0
  75. data/test/test_watcher.rb +336 -0
  76. data/test/test_worker.rb +144 -0
  77. metadata +299 -0
@@ -0,0 +1,144 @@
1
+ # Copyright (C) 2013 droonga project
2
+ #
3
+ # This library is free software; you can redistribute it and/or
4
+ # modify it under the terms of the GNU Lesser General Public
5
+ # License version 2.1 as published by the Free Software Foundation.
6
+ #
7
+ # This library is distributed in the hope that it will be useful,
8
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
9
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10
+ # Lesser General Public License for more details.
11
+ #
12
+ # You should have received a copy of the GNU Lesser General Public
13
+ # License along with this library; if not, write to the Free Software
14
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
+
16
+ require "helper"
17
+
18
+ require "droonga/worker"
19
+
20
+ class WorkerTest < Test::Unit::TestCase
21
+ def setup
22
+ setup_database
23
+ setup_handlers
24
+ setup_worker
25
+ setup_output_receiver
26
+ end
27
+
28
+ def teardown
29
+ teardown_worker
30
+ teardown_output_receiver
31
+ end
32
+
33
+ private
34
+ def setup_database
35
+ restore(fixture_data("document.grn"))
36
+ end
37
+
38
+ def setup_handlers
39
+ ["search"].each do |handler_name|
40
+ plugin = Droonga::Plugin.new("handler", handler_name)
41
+ plugin.load
42
+ end
43
+ end
44
+
45
+ def setup_worker
46
+ @worker = Droonga::Worker.new(:database => @database_path.to_s,
47
+ :queue_name => "DroongaQueue",
48
+ :pool_size => 0)
49
+ @worker.add_handler("search")
50
+ end
51
+
52
+ def teardown_worker
53
+ @worker.shutdown
54
+ @worker = nil
55
+ end
56
+
57
+ def setup_output_receiver
58
+ @output_receiver_host = "127.0.0.1"
59
+ @output_receiver_port = 2929
60
+ @output_receiver = TCPServer.new(@output_receiver_host,
61
+ @output_receiver_port)
62
+ end
63
+
64
+ def teardown_output_receiver
65
+ @output_receiver.close
66
+ @output_receiver = nil
67
+ end
68
+
69
+ class SearchTest < self
70
+ def test_minimum
71
+ request = {
72
+ "type" => "search",
73
+ "id" => request_id,
74
+ "replyTo" => reply_to,
75
+ "body" => {
76
+ "queries" => {
77
+ "sections" => {
78
+ "source" => "Sections",
79
+ "output" => {
80
+ "elements" => [
81
+ "count",
82
+ ],
83
+ },
84
+ },
85
+ },
86
+ },
87
+ }
88
+ expected = {
89
+ "inReplyTo" => request_id,
90
+ "type" => "search.result",
91
+ "statusCode" => 200,
92
+ "body" => {
93
+ "sections" => {
94
+ "count" => 9,
95
+ },
96
+ },
97
+ }
98
+ @worker.dispatch("", 0, request)
99
+ actual = receive_response
100
+ assert_equal(expected, normalize_result_set(actual))
101
+ end
102
+
103
+ private
104
+ def start_time
105
+ "2013-01-31T14:34:47+09:00"
106
+ end
107
+
108
+ def elapsed_time
109
+ 0.01
110
+ end
111
+
112
+ def reply_to
113
+ "#{@output_receiver_host}:#{@output_receiver_port}/droonga.message"
114
+ end
115
+
116
+ def request_id
117
+ "request-id"
118
+ end
119
+
120
+ def normalize_result_set(result_set)
121
+ normalized_result_set = copy_deeply(result_set)
122
+ normalized_result_set["body"].each do |name, result|
123
+ result["startTime"] = start_time if result["startTime"]
124
+ result["elapsedTime"] = elapsed_time if result["elapsedTime"]
125
+ end
126
+ normalized_result_set
127
+ end
128
+
129
+ ENOUGH_RESPONSE_DATA_SIZE = 4096 * 4
130
+ def receive_response
131
+ readables, = IO.select([@output_receiver], [], [], 0)
132
+ assert_not_empty(readables, "not replied")
133
+
134
+ response_socket = @output_receiver.accept
135
+ response_data = response_socket.read_nonblock(ENOUGH_RESPONSE_DATA_SIZE)
136
+ tag, time, response = MessagePack.unpack(response_data)
137
+ response
138
+ end
139
+
140
+ def copy_deeply(object)
141
+ Marshal.load(Marshal.dump(object))
142
+ end
143
+ end
144
+ end
metadata ADDED
@@ -0,0 +1,299 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-droonga
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Droonga Project
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fluentd
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rroonga
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 3.0.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 3.0.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: groonga-command-parser
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: fluent-logger
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: serverengine
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: bundler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: droonga-client
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: test-unit
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: test-unit-notify
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: test-unit-rr
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description: Droonga(distributed groonga) plugin for Fluent event collector
168
+ email:
169
+ - droonga@groonga.org
170
+ executables:
171
+ - grn2jsons
172
+ extensions: []
173
+ extra_rdoc_files: []
174
+ files:
175
+ - ".gitignore"
176
+ - ".travis.yml"
177
+ - Gemfile
178
+ - LICENSE.txt
179
+ - README.md
180
+ - Rakefile
181
+ - benchmark/benchmark.rb
182
+ - benchmark/utils.rb
183
+ - benchmark/watch/benchmark-notify.rb
184
+ - benchmark/watch/benchmark-notify.sh
185
+ - benchmark/watch/benchmark-publish.rb
186
+ - benchmark/watch/benchmark-scan.rb
187
+ - benchmark/watch/catalog.json
188
+ - benchmark/watch/fluentd.conf
189
+ - bin/grn2jsons
190
+ - fluent-plugin-droonga.gemspec
191
+ - lib/droonga/adapter.rb
192
+ - lib/droonga/catalog.rb
193
+ - lib/droonga/command_mapper.rb
194
+ - lib/droonga/engine.rb
195
+ - lib/droonga/executor.rb
196
+ - lib/droonga/handler.rb
197
+ - lib/droonga/handler_plugin.rb
198
+ - lib/droonga/job_queue.rb
199
+ - lib/droonga/job_queue_schema.rb
200
+ - lib/droonga/logger.rb
201
+ - lib/droonga/plugin.rb
202
+ - lib/droonga/plugin/adapter/groonga/select.rb
203
+ - lib/droonga/plugin/adapter_groonga.rb
204
+ - lib/droonga/plugin/handler/groonga/column_create.rb
205
+ - lib/droonga/plugin/handler/groonga/table_create.rb
206
+ - lib/droonga/plugin/handler_add.rb
207
+ - lib/droonga/plugin/handler_forward.rb
208
+ - lib/droonga/plugin/handler_groonga.rb
209
+ - lib/droonga/plugin/handler_proxy.rb
210
+ - lib/droonga/plugin/handler_search.rb
211
+ - lib/droonga/plugin/handler_watch.rb
212
+ - lib/droonga/proxy.rb
213
+ - lib/droonga/searcher.rb
214
+ - lib/droonga/server.rb
215
+ - lib/droonga/sweeper.rb
216
+ - lib/droonga/watch_schema.rb
217
+ - lib/droonga/watcher.rb
218
+ - lib/droonga/worker.rb
219
+ - lib/fluent/plugin/out_droonga.rb
220
+ - lib/groonga_command_converter.rb
221
+ - sample/cluster/catalog.json
222
+ - sample/cluster/fluentd.conf
223
+ - sample/fluentd.conf
224
+ - test/fixtures/catalog.json
225
+ - test/fixtures/document.grn
226
+ - test/helper.rb
227
+ - test/helper/fixture.rb
228
+ - test/helper/sandbox.rb
229
+ - test/helper/stub_worker.rb
230
+ - test/helper/watch_helper.rb
231
+ - test/plugin/adapter/groonga/test_select.rb
232
+ - test/plugin/handler/groonga/test_column_create.rb
233
+ - test/plugin/handler/groonga/test_table_create.rb
234
+ - test/plugin/handler/test_handler_add.rb
235
+ - test/plugin/handler/test_handler_groonga.rb
236
+ - test/plugin/handler/test_handler_search.rb
237
+ - test/plugin/handler/test_handler_watch.rb
238
+ - test/run-test.rb
239
+ - test/test_adapter.rb
240
+ - test/test_catalog.rb
241
+ - test/test_command_mapper.rb
242
+ - test/test_groonga_command_converter.rb
243
+ - test/test_handler.rb
244
+ - test/test_job_queue_schema.rb
245
+ - test/test_output.rb
246
+ - test/test_sweeper.rb
247
+ - test/test_watch_schema.rb
248
+ - test/test_watcher.rb
249
+ - test/test_worker.rb
250
+ homepage: https://github.com/droonga/fluent-plugin-droonga
251
+ licenses: []
252
+ metadata: {}
253
+ post_install_message:
254
+ rdoc_options: []
255
+ require_paths:
256
+ - lib
257
+ required_ruby_version: !ruby/object:Gem::Requirement
258
+ requirements:
259
+ - - ">="
260
+ - !ruby/object:Gem::Version
261
+ version: '0'
262
+ required_rubygems_version: !ruby/object:Gem::Requirement
263
+ requirements:
264
+ - - ">="
265
+ - !ruby/object:Gem::Version
266
+ version: '0'
267
+ requirements: []
268
+ rubyforge_project:
269
+ rubygems_version: 2.0.3
270
+ signing_key:
271
+ specification_version: 4
272
+ summary: Droonga(distributed groonga) plugin for Fluent event collector
273
+ test_files:
274
+ - test/fixtures/catalog.json
275
+ - test/fixtures/document.grn
276
+ - test/helper.rb
277
+ - test/helper/fixture.rb
278
+ - test/helper/sandbox.rb
279
+ - test/helper/stub_worker.rb
280
+ - test/helper/watch_helper.rb
281
+ - test/plugin/adapter/groonga/test_select.rb
282
+ - test/plugin/handler/groonga/test_column_create.rb
283
+ - test/plugin/handler/groonga/test_table_create.rb
284
+ - test/plugin/handler/test_handler_add.rb
285
+ - test/plugin/handler/test_handler_groonga.rb
286
+ - test/plugin/handler/test_handler_search.rb
287
+ - test/plugin/handler/test_handler_watch.rb
288
+ - test/run-test.rb
289
+ - test/test_adapter.rb
290
+ - test/test_catalog.rb
291
+ - test/test_command_mapper.rb
292
+ - test/test_groonga_command_converter.rb
293
+ - test/test_handler.rb
294
+ - test/test_job_queue_schema.rb
295
+ - test/test_output.rb
296
+ - test/test_sweeper.rb
297
+ - test/test_watch_schema.rb
298
+ - test/test_watcher.rb
299
+ - test/test_worker.rb