Skip to content

Commit

Permalink
Distribute from outside of Planner.
Browse files Browse the repository at this point in the history
  • Loading branch information
daijiro committed Feb 7, 2014
1 parent 21139d1 commit c698154
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/droonga/dispatcher.rb
Expand Up @@ -212,7 +212,8 @@ def farm_path(route)

def process_input_message(message)
adapted_message = @adapter_runner.adapt_input(message)
@planner.process(adapted_message["type"], adapted_message)
plan = @planner.process(adapted_message["type"], adapted_message)
@planner.distribute(plan)
rescue Droonga::Pluggable::UnknownPlugin => error
raise UnknownCommand.new(error.command, message["dataset"])
end
Expand Down
4 changes: 2 additions & 2 deletions lib/droonga/planner_plugin.rb
Expand Up @@ -36,14 +36,14 @@ def scatter(message, options={})
planner.scatter
planner.key = options[:key]
planner.reduce(options[:reduce])
distribute(planner.plan)
planner.plan
end

def broadcast(message, options={})
planner = DistributedCommandPlanner.new(message)
planner.broadcast(:write => options[:write])
planner.reduce(options[:reduce])
distribute(planner.plan)
planner.plan
end

private
Expand Down
3 changes: 2 additions & 1 deletion lib/droonga/pluggable.rb
Expand Up @@ -42,9 +42,10 @@ def process(command, *arguments)
$log.trace("#{log_tag}: process: start: <#{command}>",
:plugin => plugin.class)
raise UnknownPlugin.new(command) if plugin.nil?
plugin.process(command, *arguments)
result = plugin.process(command, *arguments)
$log.trace("#{log_tag}: process: done: <#{command}>",
:plugin => plugin.class)
result
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/droonga/plugin/planner/search.rb
Expand Up @@ -25,7 +25,7 @@ class SearchPlanner < Droonga::PlannerPlugin
command :search
def search(message)
planner = DistributedSearchPlanner.new(message)
distribute(planner.plan)
planner.plan
end
end
end
2 changes: 1 addition & 1 deletion test/unit/plugin/planner/test_search.rb
Expand Up @@ -56,7 +56,7 @@ def test_distribute
},
}

@plugin.process("search", envelope)
@planner.distribute(@plugin.process("search", envelope))

message = []

Expand Down

0 comments on commit c698154

Please sign in to comment.