fluent-plugin-droonga 0.9.9 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dir-locals.el +3 -0
- data/.travis.yml +6 -2
- data/README.md +6 -7
- data/Rakefile +23 -6
- data/fluent-plugin-droonga.gemspec +2 -2
- data/lib/droonga/adapter.rb +12 -3
- data/lib/droonga/adapter_runner.rb +28 -23
- data/lib/droonga/catalog/base.rb +7 -111
- data/lib/droonga/catalog/dataset.rb +13 -25
- data/lib/droonga/catalog/errors.rb +94 -0
- data/lib/droonga/catalog/schema.rb +277 -0
- data/lib/droonga/catalog/version1.rb +404 -0
- data/lib/droonga/catalog/version2.rb +160 -0
- data/lib/droonga/catalog_loader.rb +27 -4
- data/lib/droonga/catalog_observer.rb +44 -6
- data/lib/droonga/collector.rb +12 -10
- data/lib/droonga/{handler_plugin.rb → collector_message.rb} +47 -20
- data/lib/droonga/collector_runner.rb +64 -0
- data/lib/droonga/collectors.rb +18 -0
- data/lib/droonga/{catalog.rb → collectors/add.rb} +9 -7
- data/lib/droonga/{command_repository.rb → collectors/and.rb} +7 -14
- data/lib/droonga/collectors/sum.rb +26 -0
- data/lib/droonga/dispatcher.rb +74 -41
- data/lib/droonga/distributed_command_planner.rb +2 -2
- data/lib/droonga/engine.rb +13 -5
- data/lib/droonga/{message_processing_error.rb → error.rb} +33 -12
- data/lib/droonga/{plugin/planner/search.rb → error_messages.rb} +12 -10
- data/lib/droonga/farm.rb +15 -14
- data/lib/droonga/fluent_message_sender.rb +15 -11
- data/lib/droonga/forwarder.rb +22 -18
- data/lib/droonga/handler.rb +8 -2
- data/lib/droonga/handler_runner.rb +47 -26
- data/lib/droonga/input_message.rb +6 -6
- data/lib/droonga/{command.rb → loggable.rb} +7 -14
- data/lib/droonga/logger.rb +56 -15
- data/lib/droonga/message_matcher.rb +12 -7
- data/lib/droonga/message_pusher.rb +8 -4
- data/lib/droonga/message_receiver.rb +11 -9
- data/lib/droonga/output_message.rb +2 -0
- data/lib/droonga/planner.rb +21 -10
- data/lib/droonga/plugin.rb +15 -0
- data/lib/droonga/plugin/metadata/{adapter_message.rb → adapter_input_message.rb} +6 -14
- data/lib/droonga/plugin/metadata/adapter_output_message.rb +39 -0
- data/lib/droonga/plugin/metadata/collector_message.rb +39 -0
- data/lib/droonga/plugin/metadata/input_message.rb +15 -0
- data/lib/droonga/plugin_loader.rb +33 -25
- data/lib/droonga/plugin_registry.rb +9 -1
- data/lib/droonga/plugins/basic.rb +54 -0
- data/lib/droonga/plugins/crud.rb +36 -15
- data/lib/droonga/plugins/error.rb +5 -4
- data/lib/droonga/plugins/groonga.rb +9 -6
- data/lib/droonga/plugins/groonga/column_create.rb +10 -5
- data/lib/droonga/plugins/groonga/generic_command.rb +2 -8
- data/lib/droonga/plugins/groonga/generic_response.rb +2 -2
- data/lib/droonga/plugins/groonga/select.rb +2 -2
- data/lib/droonga/plugins/groonga/table_create.rb +9 -4
- data/lib/droonga/plugins/groonga/table_remove.rb +10 -5
- data/lib/droonga/plugins/search.rb +106 -5
- data/lib/droonga/plugins/search/distributed_search_planner.rb +398 -0
- data/lib/droonga/plugins/watch.rb +41 -20
- data/lib/droonga/processor.rb +12 -9
- data/lib/droonga/{plugin/collector/basic.rb → reducer.rb} +36 -50
- data/lib/droonga/replier.rb +7 -4
- data/lib/droonga/searcher.rb +40 -37
- data/lib/droonga/server.rb +8 -6
- data/lib/droonga/session.rb +17 -7
- data/lib/droonga/single_step.rb +53 -0
- data/lib/droonga/{plugin/planner/watch.rb → single_step_definition.rb} +27 -26
- data/lib/droonga/{partition.rb → slice.rb} +23 -12
- data/lib/droonga/status_code.rb +25 -0
- data/lib/droonga/step_runner.rb +63 -0
- data/lib/droonga/watch_schema.rb +7 -3
- data/lib/droonga/watcher.rb +4 -4
- data/lib/droonga/worker.rb +6 -6
- data/lib/fluent/plugin/out_droonga.rb +27 -2
- data/sample/cluster/catalog.json +33 -32
- data/test/command/config/default/catalog.json +72 -45
- data/test/command/config/version1/catalog.json +68 -0
- data/test/command/config/version1/fluentd.conf +11 -0
- data/test/command/suite/message/error/missing-dataset.expected +1 -1
- data/test/command/suite/message/error/unknown-dataset.expected +1 -1
- data/test/command/suite/message/error/unknown-type.expected +13 -0
- data/test/command/suite/message/error/{unknown-command.test → unknown-type.test} +1 -1
- data/test/command/suite/search/error/missing-source-parameter.expected +1 -1
- data/test/command/suite/search/error/unknown-source.expected +15 -3
- data/test/command/suite/watch/subscribe.expected +1 -3
- data/test/command/suite/watch/unsubscribe.expected +1 -3
- data/test/performance/watch/catalog.json +1 -0
- data/test/unit/catalog/test_dataset.rb +16 -358
- data/test/unit/catalog/test_schema.rb +285 -0
- data/test/unit/catalog/test_version1.rb +222 -28
- data/test/unit/catalog/test_version2.rb +155 -0
- data/test/unit/fixtures/catalog/version2.json +62 -0
- data/test/unit/helper/distributed_search_planner_helper.rb +2 -2
- data/test/unit/plugins/crud/test_add.rb +13 -13
- data/test/unit/plugins/groonga/test_column_create.rb +14 -11
- data/test/unit/plugins/groonga/test_table_create.rb +4 -9
- data/test/unit/plugins/groonga/test_table_remove.rb +4 -9
- data/test/unit/{plugin/planner/search_planner → plugins/search/planner}/test_basic.rb +0 -0
- data/test/unit/{plugin/planner/search_planner → plugins/search/planner}/test_group_by.rb +0 -0
- data/test/unit/{plugin/planner/search_planner → plugins/search/planner}/test_output.rb +0 -0
- data/test/unit/{plugin/planner/search_planner → plugins/search/planner}/test_sort_by.rb +0 -0
- data/test/unit/{plugin/collector/test_search.rb → plugins/search/test_collector.rb} +40 -39
- data/test/unit/plugins/{test_search.rb → search/test_handler.rb} +6 -5
- data/test/unit/{plugin/planner/test_search.rb → plugins/search/test_planner.rb} +3 -3
- data/test/unit/{plugin/collector → plugins}/test_basic.rb +68 -50
- data/test/unit/plugins/test_groonga.rb +2 -15
- data/test/unit/plugins/test_watch.rb +25 -22
- data/test/unit/test_message_matcher.rb +29 -6
- data/test/unit/test_output.rb +4 -0
- metadata +58 -50
- data/lib/droonga/collector_plugin.rb +0 -50
- data/lib/droonga/legacy_pluggable.rb +0 -66
- data/lib/droonga/legacy_plugin.rb +0 -57
- data/lib/droonga/legacy_plugin_repository.rb +0 -54
- data/lib/droonga/planner_plugin.rb +0 -54
- data/lib/droonga/plugin/collector/search.rb +0 -98
- data/lib/droonga/plugin/planner/crud.rb +0 -49
- data/lib/droonga/plugin/planner/distributed_search_planner.rb +0 -393
- data/lib/droonga/plugin/planner/groonga.rb +0 -54
- data/lib/droonga/plugin_registerable.rb +0 -75
- data/test/command/suite/message/error/unknown-command.expected +0 -13
- data/test/unit/test_command_repository.rb +0 -39
- data/test/unit/test_legacy_plugin.rb +0 -50
- data/test/unit/test_legacy_plugin_repository.rb +0 -89
data/lib/droonga/processor.rb
CHANGED
@@ -13,10 +13,13 @@
|
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
14
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
15
15
|
|
16
|
+
require "droonga/loggable"
|
16
17
|
require "droonga/handler_runner"
|
17
18
|
|
18
19
|
module Droonga
|
19
20
|
class Processor
|
21
|
+
include Loggable
|
22
|
+
|
20
23
|
def initialize(loop, message_pusher, options={})
|
21
24
|
@loop = loop
|
22
25
|
@message_pusher = message_pusher
|
@@ -30,26 +33,26 @@ module Droonga
|
|
30
33
|
end
|
31
34
|
|
32
35
|
def shutdown
|
33
|
-
|
36
|
+
logger.trace("shutdown: start")
|
34
37
|
@handler_runner.shutdown
|
35
|
-
|
38
|
+
logger.trace("shutdown: done")
|
36
39
|
end
|
37
40
|
|
38
41
|
def process(message)
|
39
|
-
|
40
|
-
|
41
|
-
if @handler_runner.processable?(
|
42
|
-
|
43
|
-
synchronous = @handler_runner.prefer_synchronous?(
|
42
|
+
logger.trace("process: start")
|
43
|
+
type = message["type"]
|
44
|
+
if @handler_runner.processable?(type)
|
45
|
+
logger.trace("process: handlable: #{type}")
|
46
|
+
synchronous = @handler_runner.prefer_synchronous?(type)
|
44
47
|
if @n_workers.zero? or synchronous
|
45
48
|
@handler_runner.process(message)
|
46
49
|
else
|
47
50
|
@message_pusher.push(message)
|
48
51
|
end
|
49
52
|
else
|
50
|
-
|
53
|
+
logger.trace("process: ignore #{type}")
|
51
54
|
end
|
52
|
-
|
55
|
+
logger.trace("process: done")
|
53
56
|
end
|
54
57
|
|
55
58
|
private
|
@@ -1,6 +1,4 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# Copyright (C) 2013 Droonga Project
|
1
|
+
# Copyright (C) 2014 Droonga Project
|
4
2
|
#
|
5
3
|
# This library is free software; you can redistribute it and/or
|
6
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -15,82 +13,70 @@
|
|
15
13
|
# License along with this library; if not, write to the Free Software
|
16
14
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
15
|
|
18
|
-
require "droonga/collector_plugin"
|
19
|
-
|
20
16
|
module Droonga
|
21
|
-
class
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
class Reducer
|
18
|
+
class << self
|
19
|
+
# TODO: This is right location?
|
20
|
+
def apply_range(items, range)
|
21
|
+
if items and items.is_a?(Array)
|
22
|
+
offset = range["offset"] || 0
|
23
|
+
unless offset.zero?
|
24
|
+
items = items[offset..-1] || []
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
limit = range["limit"] || 0
|
28
|
+
unless limit == UNLIMITED
|
29
|
+
items = items[0...limit]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
items
|
31
33
|
end
|
32
|
-
emit(output, result)
|
33
34
|
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
36
|
+
# XXX: We has ULIMITED defined
|
37
|
+
# lib/droonga/plugins/search/distributed_search_planner.rb. We
|
38
|
+
# should unify it.
|
39
|
+
UNLIMITED = -1
|
40
|
+
|
41
|
+
def initialize(deal)
|
42
|
+
@deal = deal # TODO: deal is good name?
|
43
43
|
end
|
44
44
|
|
45
|
-
def reduce(
|
46
|
-
if left_value.nil?
|
45
|
+
def reduce(left_value, right_value)
|
46
|
+
if left_value.nil? or right_value.nil?
|
47
47
|
return right_value || left_value
|
48
48
|
end
|
49
49
|
|
50
50
|
reduced_value = nil
|
51
51
|
|
52
|
-
case deal["type"]
|
52
|
+
case @deal["type"]
|
53
53
|
when "and"
|
54
|
-
reduced_value = left_value
|
54
|
+
reduced_value = (left_value and right_value)
|
55
55
|
when "or"
|
56
|
-
reduced_value = left_value
|
56
|
+
reduced_value = (left_value or right_value)
|
57
57
|
when "sum"
|
58
58
|
reduced_value = sum(left_value, right_value)
|
59
|
-
reduced_value =
|
60
|
-
|
59
|
+
reduced_value = self.class.apply_range(reduced_value,
|
60
|
+
"limit" => @deal["limit"])
|
61
61
|
when "average"
|
62
62
|
reduced_value = (left_value.to_f + right_value.to_f) / 2
|
63
63
|
when "sort"
|
64
64
|
reduced_value = merge(left_value,
|
65
65
|
right_value,
|
66
|
-
:operators => deal["operators"],
|
67
|
-
:key_column => deal["key_column"])
|
68
|
-
reduced_value =
|
69
|
-
|
66
|
+
:operators => @deal["operators"],
|
67
|
+
:key_column => @deal["key_column"])
|
68
|
+
reduced_value = self.class.apply_range(reduced_value,
|
69
|
+
"limit" => @deal["limit"])
|
70
70
|
end
|
71
71
|
|
72
72
|
reduced_value
|
73
73
|
end
|
74
74
|
|
75
|
-
|
76
|
-
if items && items.is_a?(Array)
|
77
|
-
offset = output["offset"] || 0
|
78
|
-
unless offset.zero?
|
79
|
-
items = items[offset..-1] || []
|
80
|
-
end
|
81
|
-
|
82
|
-
limit = output["limit"] || 0
|
83
|
-
unless limit == UNLIMITED
|
84
|
-
items = items[0...limit]
|
85
|
-
end
|
86
|
-
end
|
87
|
-
items
|
88
|
-
end
|
89
|
-
|
75
|
+
private
|
90
76
|
def sum(x, y)
|
91
77
|
return x || y if x.nil? or y.nil?
|
92
78
|
|
93
|
-
if x.is_a?(Hash)
|
79
|
+
if x.is_a?(Hash) and y.is_a?(Hash)
|
94
80
|
x.merge(y)
|
95
81
|
else
|
96
82
|
x + y
|
data/lib/droonga/replier.rb
CHANGED
@@ -13,20 +13,23 @@
|
|
13
13
|
# License along with this library; if not, write to the Free Software
|
14
14
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
15
15
|
|
16
|
+
require "droonga/loggable"
|
17
|
+
require "droonga/status_code"
|
18
|
+
|
16
19
|
module Droonga
|
17
20
|
class Replier
|
18
|
-
|
21
|
+
include Loggable
|
19
22
|
|
20
23
|
def initialize(forwarder)
|
21
24
|
@forwarder = forwarder
|
22
25
|
end
|
23
26
|
|
24
27
|
def reply(message)
|
25
|
-
|
28
|
+
logger.trace("reply: start")
|
26
29
|
destination = message["replyTo"]
|
27
30
|
reply_message = {
|
28
31
|
"inReplyTo" => message["id"],
|
29
|
-
"statusCode" => message["statusCode"] ||
|
32
|
+
"statusCode" => message["statusCode"] || StatusCode::OK,
|
30
33
|
"type" => destination["type"],
|
31
34
|
"body" => message["body"],
|
32
35
|
}
|
@@ -35,7 +38,7 @@ module Droonga
|
|
35
38
|
reply_message["errors"] = errors unless errors.empty?
|
36
39
|
end
|
37
40
|
@forwarder.forward(reply_message, destination)
|
38
|
-
|
41
|
+
logger.trace("reply: done")
|
39
42
|
end
|
40
43
|
|
41
44
|
private
|
data/lib/droonga/searcher.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
#
|
3
1
|
# Copyright (C) 2013-2014 Droonga Project
|
4
2
|
#
|
5
3
|
# This library is free software; you can redistribute it and/or
|
@@ -19,34 +17,37 @@ require "English"
|
|
19
17
|
require "tsort"
|
20
18
|
require "groonga"
|
21
19
|
|
20
|
+
require "droonga/loggable"
|
22
21
|
require "droonga/time_formatter"
|
23
|
-
require "droonga/
|
22
|
+
require "droonga/error_messages"
|
24
23
|
|
25
24
|
module Droonga
|
26
25
|
class Searcher
|
27
|
-
|
26
|
+
include Loggable
|
27
|
+
|
28
|
+
class NoQuery < ErrorMessages::BadRequest
|
28
29
|
def initialize
|
29
30
|
super("You must specify one or more query.")
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
33
|
-
class MissingSourceParameter < BadRequest
|
34
|
+
class MissingSourceParameter < ErrorMessages::BadRequest
|
34
35
|
def initialize(query, queries)
|
35
|
-
super("
|
36
|
+
super("[#{query}] No source is specified. " +
|
36
37
|
"Query must have a valid source.",
|
37
38
|
queries)
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
41
|
-
class UnknownSource < NotFound
|
42
|
+
class UnknownSource < ErrorMessages::NotFound
|
42
43
|
def initialize(source, queries)
|
43
|
-
super("
|
44
|
+
super("Source not found: <#{source}> " +
|
44
45
|
"It must be a name of an existing table or another query.",
|
45
46
|
queries)
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
49
|
-
class CyclicSource < BadRequest
|
50
|
+
class CyclicSource < ErrorMessages::BadRequest
|
50
51
|
def initialize(queries)
|
51
52
|
super("There is cyclic reference of sources.",
|
52
53
|
queries)
|
@@ -59,40 +60,40 @@ module Droonga
|
|
59
60
|
|
60
61
|
def search(queries)
|
61
62
|
outputs = nil
|
62
|
-
|
63
|
+
logger.trace("search: start", :queries => queries)
|
63
64
|
@context.push_memory_pool do
|
64
65
|
outputs = process_queries(queries)
|
65
66
|
end
|
66
|
-
|
67
|
+
logger.trace("search: done")
|
67
68
|
return outputs
|
68
69
|
end
|
69
70
|
|
70
71
|
private
|
71
72
|
def process_queries(queries)
|
72
|
-
|
73
|
-
if queries.nil?
|
73
|
+
logger.trace("process_queries: start")
|
74
|
+
if queries.nil? or queries.empty?
|
74
75
|
raise NoQuery.new
|
75
76
|
end
|
76
|
-
|
77
|
+
logger.trace("process_queries: sort: start")
|
77
78
|
sorted_queries = QuerySorter.sort(queries)
|
78
|
-
|
79
|
+
logger.trace("process_queries: sort: done")
|
79
80
|
outputs = {}
|
80
81
|
results = {}
|
81
82
|
sorted_queries.each do |name|
|
82
83
|
if queries[name]
|
83
|
-
|
84
|
-
|
84
|
+
logger.trace("process_queries: search: start",
|
85
|
+
:name => name)
|
85
86
|
search_request = SearchRequest.new(@context, queries[name], results)
|
86
87
|
search_result = QuerySearcher.search(search_request)
|
87
88
|
results[name] = search_result.records
|
88
|
-
|
89
|
-
:name => name)
|
90
|
-
if search_request.need_output?
|
91
|
-
$log.trace("#{log_tag}: process_queries: format: start",
|
89
|
+
logger.trace("process_queries: search: done",
|
92
90
|
:name => name)
|
91
|
+
if search_request.need_output?
|
92
|
+
logger.trace("process_queries: format: start",
|
93
|
+
:name => name)
|
93
94
|
outputs[name] = ResultFormatter.format(search_request, search_result)
|
94
|
-
|
95
|
-
|
95
|
+
logger.trace("process_queries: format: done",
|
96
|
+
:name => name)
|
96
97
|
end
|
97
98
|
elsif @context[name]
|
98
99
|
results[name] = @context[name]
|
@@ -100,7 +101,7 @@ module Droonga
|
|
100
101
|
raise UnknownSource.new(name, queries)
|
101
102
|
end
|
102
103
|
end
|
103
|
-
|
104
|
+
logger.trace("process_queries: done")
|
104
105
|
return outputs
|
105
106
|
end
|
106
107
|
|
@@ -192,6 +193,8 @@ module Droonga
|
|
192
193
|
end
|
193
194
|
|
194
195
|
class QuerySearcher
|
196
|
+
include Loggable
|
197
|
+
|
195
198
|
OPERATOR_CONVERSION_TABLE = {
|
196
199
|
"||" => Groonga::Operator::OR,
|
197
200
|
"&&" => Groonga::Operator::AND,
|
@@ -292,7 +295,7 @@ module Droonga
|
|
292
295
|
end
|
293
296
|
|
294
297
|
def search_query!
|
295
|
-
|
298
|
+
logger.trace("search_query: start")
|
296
299
|
|
297
300
|
@result.start_time = Time.now
|
298
301
|
|
@@ -309,7 +312,7 @@ module Droonga
|
|
309
312
|
sort_by = @request.query["sortBy"]
|
310
313
|
apply_sort_by!(sort_by) if sort_by
|
311
314
|
|
312
|
-
|
315
|
+
logger.trace("search_query: done")
|
313
316
|
@result.records = @records
|
314
317
|
@result.end_time = Time.now
|
315
318
|
end
|
@@ -318,16 +321,16 @@ module Droonga
|
|
318
321
|
expression = Groonga::Expression.new(context: @request.context)
|
319
322
|
expression.define_variable(:domain => @records)
|
320
323
|
parse_condition(@records, expression, condition)
|
321
|
-
|
322
|
-
|
324
|
+
logger.trace("search_query: select: start",
|
325
|
+
:condition => condition)
|
323
326
|
@records = @records.select(expression)
|
324
|
-
|
327
|
+
logger.trace("search_query: select: done")
|
325
328
|
@result.condition = expression
|
326
329
|
end
|
327
330
|
|
328
331
|
def apply_group_by!(group_by)
|
329
|
-
|
330
|
-
|
332
|
+
logger.trace("search_query: group: start",
|
333
|
+
:by => group_by)
|
331
334
|
case group_by
|
332
335
|
when String
|
333
336
|
@records = @records.group(group_by)
|
@@ -338,13 +341,13 @@ module Droonga
|
|
338
341
|
else
|
339
342
|
raise '"groupBy" parameter must be a Hash or a String'
|
340
343
|
end
|
341
|
-
|
342
|
-
|
344
|
+
logger.trace("search_query: group: done",
|
345
|
+
:by => group_by)
|
343
346
|
end
|
344
347
|
|
345
348
|
def apply_sort_by!(sort_by)
|
346
|
-
|
347
|
-
|
349
|
+
logger.trace("search_query: sort: start",
|
350
|
+
:by => sort_by)
|
348
351
|
case sort_by
|
349
352
|
when Array
|
350
353
|
keys = parse_order_keys(sort_by)
|
@@ -358,8 +361,8 @@ module Droonga
|
|
358
361
|
raise '"sortBy" parameter must be a Hash or an Array'
|
359
362
|
end
|
360
363
|
@records = @records.sort(keys, :offset => offset, :limit => limit)
|
361
|
-
|
362
|
-
|
364
|
+
logger.trace("search_query: sort: done",
|
365
|
+
:by => sort_by)
|
363
366
|
end
|
364
367
|
|
365
368
|
def log_tag
|
data/lib/droonga/server.rb
CHANGED
@@ -15,22 +15,24 @@
|
|
15
15
|
# License along with this library; if not, write to the Free Software
|
16
16
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
17
|
|
18
|
+
require "droonga/logger"
|
19
|
+
|
18
20
|
module Droonga
|
19
21
|
module Server
|
20
22
|
def before_run
|
21
|
-
|
22
|
-
|
23
|
+
Droonga.logger.trace("#{log_tag}: before_run: start")
|
24
|
+
Droonga.logger.trace("#{log_tag}: before_run: done")
|
23
25
|
end
|
24
26
|
|
25
27
|
def after_run
|
26
|
-
|
27
|
-
|
28
|
+
Droonga.logger.trace("#{log_tag}: after_run: start")
|
29
|
+
Droonga.logger.trace("#{log_tag}: after_run: done")
|
28
30
|
end
|
29
31
|
|
30
32
|
def stop(stop_graceful)
|
31
|
-
|
33
|
+
Droonga.logger.trace("#{log_tag}: stop: start")
|
32
34
|
super(stop_graceful)
|
33
|
-
|
35
|
+
Droonga.logger.trace("#{log_tag}: stop: done")
|
34
36
|
end
|
35
37
|
|
36
38
|
private
|
data/lib/droonga/session.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013 Droonga Project
|
1
|
+
# Copyright (C) 2013-2014 Droonga Project
|
2
2
|
#
|
3
3
|
# This library is free software; you can redistribute it and/or
|
4
4
|
# modify it under the terms of the GNU Lesser General Public
|
@@ -15,10 +15,10 @@
|
|
15
15
|
|
16
16
|
module Droonga
|
17
17
|
class Session
|
18
|
-
def initialize(id, dispatcher,
|
18
|
+
def initialize(id, dispatcher, collector_runner, tasks, inputs)
|
19
19
|
@id = id
|
20
20
|
@dispatcher = dispatcher
|
21
|
-
@
|
21
|
+
@collector_runner = collector_runner
|
22
22
|
@tasks = tasks
|
23
23
|
@n_dones = 0
|
24
24
|
@inputs = inputs
|
@@ -49,20 +49,30 @@ module Droonga
|
|
49
49
|
tasks.each do |task|
|
50
50
|
task["n_of_inputs"] += 1
|
51
51
|
step = task["step"]
|
52
|
-
|
53
|
-
command = "collector_" + type
|
52
|
+
command = step["type"]
|
54
53
|
n_of_expects = step["n_of_expects"]
|
55
54
|
message = {
|
56
55
|
"task"=>task,
|
57
56
|
"name"=>name,
|
58
57
|
"value"=>value
|
59
58
|
}
|
60
|
-
@
|
59
|
+
@collector_runner.collect(message)
|
61
60
|
return if task["n_of_inputs"] < n_of_expects
|
62
61
|
#the task is done
|
63
62
|
result = task["values"]
|
64
63
|
post = step["post"]
|
65
|
-
|
64
|
+
if post
|
65
|
+
# XXX: It is just a workaround.
|
66
|
+
# Remove me when super step is introduced.
|
67
|
+
if result["errors"]
|
68
|
+
reply_body = result
|
69
|
+
elsif command == "search_gather"
|
70
|
+
reply_body = result
|
71
|
+
else
|
72
|
+
reply_body = result["result"]
|
73
|
+
end
|
74
|
+
@dispatcher.reply("body" => reply_body)
|
75
|
+
end
|
66
76
|
step["descendants"].each do |name, routes|
|
67
77
|
message = {
|
68
78
|
"id" => @id,
|