fluent-plugin-droonga 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +7 -0
  4. data/benchmark/watch/benchmark-notify.rb +6 -6
  5. data/benchmark/watch/benchmark-notify.sh +3 -2
  6. data/bin/grn2jsons +0 -3
  7. data/doc/text/news.md +13 -0
  8. data/fluent-plugin-droonga.gemspec +1 -1
  9. data/lib/droonga/catalog/base.rb +8 -3
  10. data/lib/droonga/catalog.rb +1 -16
  11. data/lib/droonga/catalog_observer.rb +57 -0
  12. data/lib/droonga/collector.rb +1 -1
  13. data/lib/droonga/dispatcher.rb +3 -1
  14. data/lib/droonga/distributor_plugin.rb +47 -19
  15. data/lib/droonga/handler_messenger.rb +26 -2
  16. data/lib/droonga/message_processing_error.rb +6 -8
  17. data/lib/droonga/output_message.rb +17 -1
  18. data/lib/droonga/plugin/collector/basic.rb +44 -81
  19. data/lib/droonga/plugin/collector/groonga.rb +83 -0
  20. data/lib/droonga/plugin/collector/search.rb +104 -0
  21. data/lib/droonga/plugin/distributor/crud.rb +41 -0
  22. data/lib/droonga/plugin/distributor/distributed_search_planner.rb +4 -4
  23. data/lib/droonga/plugin/distributor/groonga.rb +38 -0
  24. data/lib/droonga/plugin/handler/add.rb +4 -1
  25. data/lib/droonga/plugin/handler/groonga/column_create.rb +7 -0
  26. data/lib/droonga/plugin/handler/groonga/table_remove.rb +42 -0
  27. data/lib/droonga/plugin/handler/groonga.rb +17 -2
  28. data/lib/droonga/plugin/handler/watch.rb +4 -4
  29. data/lib/droonga/plugin/input_adapter/crud.rb +27 -0
  30. data/lib/droonga/plugin/input_adapter/groonga.rb +16 -1
  31. data/lib/droonga/plugin/output_adapter/crud.rb +51 -0
  32. data/lib/droonga/plugin/output_adapter/groonga.rb +8 -1
  33. data/lib/droonga/plugin.rb +1 -1
  34. data/lib/droonga/replier.rb +7 -1
  35. data/lib/droonga/searcher.rb +168 -74
  36. data/lib/droonga/session.rb +1 -1
  37. data/lib/groonga_command_converter.rb +7 -1
  38. data/test/command/config/default/catalog.json +1 -1
  39. data/test/command/suite/add/error/invalid-integer.expected +31 -1
  40. data/test/command/suite/add/error/invalid-time.expected +31 -1
  41. data/test/command/suite/add/error/missing-key.expected +17 -1
  42. data/test/command/suite/add/error/missing-table.expected +17 -1
  43. data/test/command/suite/add/error/unknown-column.expected +31 -1
  44. data/test/command/suite/add/error/unknown-table.expected +17 -1
  45. data/test/command/suite/add/minimum.expected +1 -1
  46. data/test/command/suite/add/with-values.expected +1 -1
  47. data/test/command/suite/add/without-key.expected +1 -1
  48. data/test/command/suite/groonga/column_create/scalar.expected +2 -2
  49. data/test/command/suite/groonga/column_create/unknown-table.expected +18 -0
  50. data/test/command/suite/groonga/column_create/unknown-table.test +7 -0
  51. data/test/command/suite/groonga/column_create/vector.expected +2 -2
  52. data/test/command/suite/groonga/select/minimum.expected +1 -1
  53. data/test/command/suite/groonga/table_create/array.expected +1 -1
  54. data/test/command/suite/groonga/table_create/hash.expected +1 -1
  55. data/test/command/suite/groonga/table_remove/success.expected +17 -0
  56. data/test/command/suite/groonga/table_remove/success.test +8 -0
  57. data/test/command/suite/groonga/table_remove/unknown-table.expected +18 -0
  58. data/test/command/suite/groonga/table_remove/unknown-table.test +7 -0
  59. data/test/command/suite/message/error/missing-dataset.expected +1 -1
  60. data/test/command/suite/message/error/unknown-command.expected +1 -1
  61. data/test/command/suite/message/error/unknown-dataset.expected +1 -1
  62. data/test/command/suite/search/attributes/array.expected +1 -1
  63. data/test/command/suite/search/attributes/hash.expected +1 -1
  64. data/test/command/suite/search/complex.expected +1 -1
  65. data/test/command/suite/search/condition/nested.expected +1 -1
  66. data/test/command/suite/search/condition/query.expected +1 -1
  67. data/test/command/suite/search/condition/script.expected +1 -1
  68. data/test/command/suite/search/error/cyclic-source.expected +1 -1
  69. data/test/command/suite/search/error/deeply-cyclic-source.expected +1 -1
  70. data/test/command/suite/search/error/missing-source-parameter.expected +1 -1
  71. data/test/command/suite/search/error/unknown-source.expected +1 -1
  72. data/test/command/suite/search/group/count.expected +1 -1
  73. data/test/command/suite/search/group/limit.expected +1 -1
  74. data/test/command/suite/search/group/string.expected +1 -1
  75. data/test/command/suite/search/multiple/chained.expected +1 -1
  76. data/test/command/suite/search/multiple/parallel.expected +1 -1
  77. data/test/command/suite/search/range/only-output.expected +1 -1
  78. data/test/command/suite/search/range/only-sort.expected +1 -1
  79. data/test/command/suite/search/range/sort-and-output.expected +1 -1
  80. data/test/command/suite/search/range/too-large-output-offset.expected +1 -1
  81. data/test/command/suite/search/range/too-large-sort-offset.expected +1 -1
  82. data/test/command/suite/search/response/records/value/time.expected +1 -1
  83. data/test/command/suite/search/simple.expected +1 -1
  84. data/test/command/suite/search/sort/default-offset-limit.expected +1 -1
  85. data/test/command/suite/search/sort/invisible-column.expected +1 -1
  86. data/test/command/suite/watch/subscribe.expected +1 -1
  87. data/test/command/suite/watch/unsubscribe.expected +1 -1
  88. data/test/performance/run-test.rb +56 -0
  89. data/{benchmark → test/performance}/watch/catalog.json +0 -0
  90. data/test/performance/watch/feed.json +9 -0
  91. data/{benchmark → test/performance}/watch/fluentd.conf +0 -0
  92. data/test/performance/watch/subscribe.json +3 -0
  93. data/test/unit/catalog/test_version1.rb +34 -0
  94. data/test/unit/plugin/collector/test_basic.rb +300 -479
  95. data/test/unit/plugin/collector/test_search.rb +814 -0
  96. data/test/unit/plugin/distributor/test_search.rb +4 -4
  97. data/test/unit/plugin/distributor/test_search_planner.rb +260 -260
  98. data/test/unit/plugin/handler/groonga/test_column_create.rb +15 -1
  99. data/test/unit/plugin/handler/groonga/test_table_create.rb +6 -2
  100. data/test/unit/plugin/handler/groonga/test_table_remove.rb +58 -0
  101. data/test/unit/plugin/handler/test_add.rb +3 -1
  102. data/test/unit/plugin/handler/test_groonga.rb +24 -0
  103. data/test/unit/plugin/handler/test_search.rb +294 -0
  104. data/test/unit/plugin/handler/test_watch.rb +1 -1
  105. data/test/unit/plugin/{adapter → input_adapter}/groonga/test_select.rb +5 -37
  106. data/test/unit/plugin/output_adapter/groonga/test_select.rb +55 -0
  107. metadata +38 -6
@@ -0,0 +1,17 @@
1
+ [
2
+ "droonga.message",
3
+ 0,
4
+ {
5
+ "inReplyTo": "request-id",
6
+ "statusCode": 200,
7
+ "type": "table_remove.result",
8
+ "body": [
9
+ [
10
+ 0,
11
+ 0.0,
12
+ 0.0
13
+ ],
14
+ true
15
+ ]
16
+ }
17
+ ]
@@ -0,0 +1,8 @@
1
+ #@include fixture/user-table.jsons
2
+ {
3
+ "type": "table_remove",
4
+ "dataset": "Droonga",
5
+ "body": {
6
+ "name" : "User"
7
+ }
8
+ }
@@ -0,0 +1,18 @@
1
+ [
2
+ "droonga.message",
3
+ 0,
4
+ {
5
+ "inReplyTo": "request-id",
6
+ "statusCode": 200,
7
+ "type": "table_remove.result",
8
+ "body": [
9
+ [
10
+ -22,
11
+ 0.0,
12
+ 0.0,
13
+ "table not found"
14
+ ],
15
+ false
16
+ ]
17
+ }
18
+ ]
@@ -0,0 +1,7 @@
1
+ {
2
+ "type": "table_remove",
3
+ "dataset": "Droonga",
4
+ "body": {
5
+ "name" : "Unknown"
6
+ }
7
+ }
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 400,
7
7
  "type": "add.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 400,
7
7
  "type": "unknown-command.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 404,
7
7
  "type": "add.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 400,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 400,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 400,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 404,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "search.result",
8
8
  "body": {
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "watch.subscribe.result",
8
8
  "body": [
@@ -2,7 +2,7 @@
2
2
  "droonga.message",
3
3
  0,
4
4
  {
5
- "inReplyTo": null,
5
+ "inReplyTo": "request-id",
6
6
  "statusCode": 200,
7
7
  "type": "watch.unsubscribe.result",
8
8
  "body": [
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Copyright (C) 2014 Droonga Project
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License version 2.1 as published by the Free Software Foundation.
8
+ #
9
+ # This library is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
+ # Lesser General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU Lesser General Public
15
+ # License along with this library; if not, write to the Free Software
16
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
+
18
+ require "rbconfig"
19
+ require "fileutils"
20
+
21
+ def run(*command_line)
22
+ command_line = command_line.collect do |argument|
23
+ argument.to_s
24
+ end
25
+ return if system(*command_line)
26
+ puts("failed to run: #{command_line.join(' ')}")
27
+ exit(false)
28
+ end
29
+
30
+ base_dir = File.dirname(__FILE__)
31
+ lib_dir = File.expand_path(File.join(base_dir, "..", "..", "lib"))
32
+
33
+ drnbench_options = []
34
+ drnbench_options.concat(["--start-n-subscribers", 10])
35
+ drnbench_options.concat(["--n-publishings", 10])
36
+ drnbench_options.concat(["--n-steps", 9])
37
+ drnbench_options.concat(["--timeout", 5])
38
+ drnbench_options.concat(["--subscribe-request-file",
39
+ File.join(base_dir, "watch", "subscribe.json")])
40
+ drnbench_options.concat(["--feed-file",
41
+ File.join(base_dir, "watch", "feed.json")])
42
+
43
+ protocol_adapter_dir = File.join(base_dir, "..", "..", "..", "express-droonga")
44
+ if File.exist?(protocol_adapter_dir)
45
+ drnbench_options.concat(["--protocol-adapter-application-dir", protocol_adapter_dir])
46
+ drnbench_options.concat(["--protocol-adapter-port", 13000])
47
+ end
48
+
49
+ drnbench_options.concat(["--engine-config-path",
50
+ File.join(base_dir, "watch")])
51
+ drnbench_options.concat(["--fluentd-options", "-I#{lib_dir}"])
52
+ drnbench_options.concat(ARGV)
53
+
54
+ drnbench_publish_subscribe = Gem.bin_path("drnbench",
55
+ "drnbench-publish-subscribe")
56
+ run(drnbench_publish_subscribe, *drnbench_options)
File without changes
@@ -0,0 +1,9 @@
1
+ {
2
+ "type": "watch.feed",
3
+ "dataset": "Watch",
4
+ "body": {
5
+ "targets": {
6
+ "body": "a content including the keyword"
7
+ }
8
+ }
9
+ }
File without changes
@@ -0,0 +1,3 @@
1
+ {
2
+ "path": "/droonga-streaming/watch?condition=keyword"
3
+ }
@@ -64,4 +64,38 @@ class CatalogTest < Test::Unit::TestCase
64
64
  def base_path
65
65
  File.dirname(catalog_path)
66
66
  end
67
+
68
+ class DataSetTest < self
69
+ class RingTest < self
70
+ class TotalWeightTest < self
71
+ def setup
72
+ end
73
+
74
+ def test_three_zones
75
+ dataset = {
76
+ "ring" => {
77
+ "zone1" => {
78
+ "weight" => 10,
79
+ },
80
+ "zone2" => {
81
+ "weight" => 20,
82
+ },
83
+ "zone3" => {
84
+ "weight" => 30,
85
+ },
86
+ }
87
+ }
88
+ assert_equal(10 + 20 + 30,
89
+ total_weight(dataset))
90
+ end
91
+
92
+ private
93
+ def total_weight(dataset)
94
+ catalog = Droonga::Catalog::Version1.new({"datasets" => []},
95
+ "base-path")
96
+ catalog.send(:compute_total_weight, dataset)
97
+ end
98
+ end
99
+ end
100
+ end
67
101
  end