YUKI Hiroshi
null+****@clear*****
Wed Jan 29 17:13:09 JST 2014
YUKI Hiroshi 2014-01-29 17:13:09 +0900 (Wed, 29 Jan 2014) New Revision: d96d8fca16e9fc41e3b7485bfe97e51f7bbb7846 https://github.com/droonga/fluent-plugin-droonga/commit/d96d8fca16e9fc41e3b7485bfe97e51f7bbb7846 Message: Move codes for error handling from distributed search plannner to the distributor Modified files: lib/droonga/plugin/distributor/distributed_search_planner.rb lib/droonga/plugin/distributor/search.rb Modified: lib/droonga/plugin/distributor/distributed_search_planner.rb (+16 -29) =================================================================== --- lib/droonga/plugin/distributor/distributed_search_planner.rb 2014-01-29 17:02:22 +0900 (089cc48) +++ lib/droonga/plugin/distributor/distributed_search_planner.rb 2014-01-29 17:13:09 +0900 (c10c7ea) @@ -17,7 +17,7 @@ module Droonga class DistributedSearchPlanner - attr_reader :messages + attr_reader :reducers, :gatherer, :searcher def initialize(search_request_message) @source_message = search_request_message @@ -27,11 +27,18 @@ module Droonga @input_names = [] @output_names = [] @output_mappers = {} - @messages = [] + + @reducers = [] + @gatherer = nil + @searcher = nil build_messages end + def messages + @reducers + [@gatherer, @searcher] + end + private UNLIMITED = -1 @@ -44,41 +51,21 @@ module Droonga transform_query(input_name, query) end - errors_reducer = { - "type" => "reduce", - "body" => { - "errors" => { - "errors_reduced" => { - "type" => "sum", - "limit" => -1, - }, - }, - }, - "inputs" => ["errors"], - "outputs" => ["errors_reduced"], - } - @messages << errors_reducer - - gatherer = { + @gatherer = { "type" => "search_gather", - "body" => @output_mappers.merge({ - "errors_reduced" => { - "output" => "errors", - }, - }), - "inputs" => @output_names + ["errors_reduced"], # XXX should be placed in the "body"? + "body" => @output_mappers, + "inputs" => @output_names, # XXX should be placed in the "body"? "post" => true, # XXX should be placed in the "body"? } - @messages << gatherer - searcher = { + + @searcher = { "type" => "broadcast", "command" => "search", # XXX should be placed in the "body"? "dataset" => @source_message["dataset"] || @request["dataset"], "body" => @request, - "outputs" => @input_names + ["errors"], # XXX should be placed in the "body"? + "outputs" => @input_names, # XXX should be placed in the "body"? "replica" => "random", # XXX should be placed in the "body"? } - @messages.push(searcher) end def ensure_unifiable! @@ -124,7 +111,7 @@ module Droonga "inputs" => [input_name], # XXX should be placed in the "body"? "outputs" => [output_name], # XXX should be placed in the "body"? } - @messages << reducer + @reducers << reducer @output_mappers[output_name] = { "output" => input_name, Modified: lib/droonga/plugin/distributor/search.rb (+7 -2) =================================================================== --- lib/droonga/plugin/distributor/search.rb 2014-01-29 17:02:22 +0900 (dadb982) +++ lib/droonga/plugin/distributor/search.rb 2014-01-29 17:13:09 +0900 (c32b528) @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# Copyright (C) 2013 Droonga Project +# Copyright (C) 2013-2014 Droonga Project # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -25,7 +25,12 @@ module Droonga command :search def search(message) planner = DistributedSearchPlanner.new(message) - distribute(planner.messages) + + #XXX This is just a temporary solution. We should handle errors by the framework itself. + planner.searcher["outputs"] << "errors" + messages = planner.messages + [reducer(message), gatherer(message)] + + distribute(messages) end end end -------------- next part -------------- HTML����������������������������...Download