[Groonga-commit] droonga/fluent-plugin-droonga at 312974a [master] Rename class Proxy to Dispatcher.

Back to archive index

Daijiro MORI null+****@clear*****
Wed Nov 20 15:21:40 JST 2013


Daijiro MORI	2013-11-20 15:21:40 +0900 (Wed, 20 Nov 2013)

  New Revision: 312974ae224c9d855ff24953d18e5aff23445dcb
  https://github.com/droonga/fluent-plugin-droonga/commit/312974ae224c9d855ff24953d18e5aff23445dcb

  Message:
    Rename class Proxy to Dispatcher.

  Modified files:
    lib/droonga/adapter.rb
    lib/droonga/dispatcher.rb
    lib/droonga/executor.rb
    lib/droonga/handler.rb
    lib/droonga/worker.rb
    lib/fluent/plugin/out_droonga.rb
    test/test_adapter.rb
  Renamed files:
    lib/droonga/plugin/handler_collector.rb
      (from lib/droonga/plugin/handler_proxy.rb)

  Modified: lib/droonga/adapter.rb (+3 -3)
===================================================================
--- lib/droonga/adapter.rb    2013-11-20 15:07:39 +0900 (4e27827)
+++ lib/droonga/adapter.rb    2013-11-20 15:21:40 +0900 (668af51)
@@ -29,7 +29,7 @@ module Droonga
         "replica"=> "all",
         "post"=> true
       }]
-      post(message, "proxy")
+      post(message, "dispatcher")
     end
 
     def broadcast_all(request)
@@ -41,7 +41,7 @@ module Droonga
         "replica"=> "all",
         "post"=> true
       }]
-      post(message, "proxy")
+      post(message, "dispatcher")
     end
 
     def prefer_synchronous?(command)
@@ -150,7 +150,7 @@ module Droonga
         "body"=> request
       }
       message.push(searcher)
-      post(message, "proxy")
+      post(message, "dispatcher")
     end
   end
 end

  Modified: lib/droonga/dispatcher.rb (+26 -26)
===================================================================
--- lib/droonga/dispatcher.rb    2013-11-20 15:07:39 +0900 (136e533)
+++ lib/droonga/dispatcher.rb    2013-11-20 15:21:40 +0900 (6b328ab)
@@ -21,12 +21,12 @@ require "droonga/adapter"
 require "droonga/catalog"
 
 module Droonga
-  class Proxy
+  class Dispatcher
     attr_reader :collectors
     def initialize(worker, name)
       @engines = {}
       Droonga::catalog.get_engines(name).each do |name, options|
-        engine = Droonga::Engine.new(options.merge(:proxy => false,
+        engine = Droonga::Engine.new(options.merge(:standalone => true,
                                                    :with_server => false))
         engine.start
         @engines[name] = engine
@@ -36,7 +36,7 @@ module Droonga
       @collectors = {}
       @current_id = 0
       @local = Regexp.new("^#{@name}")
-      plugins = ["proxy"] + (Droonga::catalog.option("plugins")||[]) + ["adapter"]
+      plugins = ["collector"] + (Droonga::catalog.option("plugins")||[]) + ["adapter"]
       plugins.each do |plugin|
         @worker.add_handler(plugin)
       end
@@ -87,7 +87,7 @@ module Droonga
       if local?(destination)
         handle_internal_message(message)
       else
-        post(message, "to"=>farm_path(destination), "type"=>"proxy")
+        post(message, "to"=>farm_path(destination), "type"=>"dispatcher")
       end
     end
 
@@ -141,8 +141,8 @@ module Droonga
       end
 
       include TSort
-      def initialize(proxy, components)
-        @proxy = proxy
+      def initialize(dispatcher, components)
+        @dispatcher = dispatcher
         @components = components
       end
 
@@ -175,7 +175,7 @@ module Droonga
               local
             end
           routes.each do |route|
-            destinations[@proxy.farm_path(route)] += 1
+            destinations[@dispatcher.farm_path(route)] += 1
           end
           component["routes"] = routes
         end
@@ -188,7 +188,7 @@ module Droonga
         inputs = {}
         @components.each do |component|
           component["routes"].each do |route|
-            next unles****@proxy*****?(route)
+            next unles****@dispa*****?(route)
             task = {
               "route" => route,
               "component" => component,
@@ -202,8 +202,8 @@ module Droonga
             end
           end
         end
-        collector = Collector.new(id, @proxy, @components, tasks, inputs)
-        @proxy.collectors[id] = collector
+        collector = Collector.new(id, @dispatcher, @components, tasks, inputs)
+        @dispatcher.collectors[id] = collector
         return collector
       end
 
@@ -252,9 +252,9 @@ module Droonga
     end
 
     class Collector
-      def initialize(id, proxy, components, tasks, inputs)
+      def initialize(id, dispatcher, components, tasks, inputs)
         @id = id
-        @proxy = proxy
+        @dispatcher = dispatcher
         @components = components
         @tasks = tasks
         @n_dones = 0
@@ -271,7 +271,7 @@ module Droonga
           task["n_of_inputs"] += 1 if name
           component = task["component"]
           type = component["type"]
-          command = component["command"] || ("proxy_" + type)
+          command = component["command"] || ("collector_" + type)
           n_of_expects = component["n_of_expects"]
           synchronous = nil
           if command
@@ -288,21 +288,21 @@ module Droonga
               component["descendants"].each do |name, indices|
                 descendants[name] = indices.collect do |index|
                   @components[index]["routes"].map do |route|
-                    @proxy.farm_path(route)
+                    @dispatcher.farm_path(route)
                   end
                 end
               end
               message["descendants"] = descendants
               message["id"] = @id
             end
-            @proxy.deliver(@id, task["route"], message, command, synchronous)
+            @dispatcher.deliver(@id, task["route"], message, command, synchronous)
           end
           return if task["n_of_inputs"] < n_of_expects
           #the task is done
           if synchronous
             result = task["values"]
             post = component["post"]
-            @proxy.post(result, post) if post
+            @dispatcher.post(result, post) if post
             component["descendants"].each do |name, indices|
               message = {
                 "id" => @id,
@@ -311,32 +311,32 @@ module Droonga
               }
               indices.each do |index|
                 @components[index]["routes"].each do |route|
-                  @proxy.dispatch(message, route)
+                  @dispatcher.dispatch(message, route)
                 end
               end
             end
           end
           @n_dones += 1
-          @proxy.collectors.delete(@id) if @n_dones ==****@tasks*****
+          @dispatcher.collectors.delete(@id) if @n_dones ==****@tasks*****
         end
       end
     end
   end
 
-  class ProxyMessageHandler < Droonga::Handler
-    Droonga::HandlerPlugin.register("proxy_message", self)
+  class DispatcherMessageHandler < Droonga::Handler
+    Droonga::HandlerPlugin.register("dispatcher_message", self)
     def initialize(*arguments)
       super
-      @proxy = Droonga::Proxy.new(@worker, @worker.name)
+      @dispatcher = Droonga::Dispatcher.new(@worker, @worker.name)
     end
 
     def shutdown
-      @proxy.shutdown
+      @dispatcher.shutdown
     end
 
-    command :proxy
-    def proxy(request, *arguments)
-      @proxy.handle(request, arguments)
+    command :dispatcher
+    def dispatcher(request, *arguments)
+      @dispatcher.handle(request, arguments)
     end
 
     def prefer_synchronous?(command)
@@ -344,7 +344,7 @@ module Droonga
     end
   end
 
-  class ProxyHandler < Droonga::Handler
+  class CollectorHandler < Droonga::Handler
     attr_reader :task, :input_name, :component, :output_values, :body, :output_names
     def handle(command, request, *arguments)
       return false unless request.is_a? Hash

  Modified: lib/droonga/executor.rb (+1 -1)
===================================================================
--- lib/droonga/executor.rb    2013-11-20 15:07:39 +0900 (2916288)
+++ lib/droonga/executor.rb    2013-11-20 15:21:40 +0900 (130b750)
@@ -242,7 +242,7 @@ module Droonga
       @handler_names.each do |handler_name|
         add_handler(handler_name)
       end
-      add_handler("proxy_message") if @options[:proxy]
+      add_handler("dispatcher_message") unless @options[:standalone]
     end
 
     def find_handler(command)

  Modified: lib/droonga/handler.rb (+1 -1)
===================================================================
--- lib/droonga/handler.rb    2013-11-20 15:07:39 +0900 (9abde79)
+++ lib/droonga/handler.rb    2013-11-20 15:21:40 +0900 (ec9b74c)
@@ -131,7 +131,7 @@ module Droonga
         }
         dests.each do |routes|
           routes.each do |route|
-            post(message, "to"=>route, "type"=>"proxy")
+            post(message, "to"=>route, "type"=>"dispatcher")
           end
         end
       end

  Renamed: lib/droonga/plugin/handler_collector.rb (+6 -6) 89%
===================================================================
--- lib/droonga/plugin/handler_proxy.rb    2013-11-20 15:07:39 +0900 (92cb85d)
+++ lib/droonga/plugin/handler_collector.rb    2013-11-20 15:21:40 +0900 (e8993f8)
@@ -19,17 +19,17 @@ require "droonga/handler"
 require "droonga/searcher"
 
 module Droonga
-  class BasicProxyHandler < Droonga::ProxyHandler
-    Droonga::HandlerPlugin.register("proxy", self)
+  class BasicCollectorHandler < Droonga::CollectorHandler
+    Droonga::HandlerPlugin.register("collector", self)
 
-    command :proxy_gather
-    def proxy_gather(request)
+    command :collector_gather
+    def collector_gather(request)
       output = body ? body[input_name] : input_name
       emit(request, output)
     end
 
-    command :proxy_reduce
-    def proxy_reduce(request)
+    command :collector_reduce
+    def collector_reduce(request)
       return unless request
       body[input_name].each do |output, elements|
         value = request

  Modified: lib/droonga/worker.rb (+1 -1)
===================================================================
--- lib/droonga/worker.rb    2013-11-20 15:07:39 +0900 (6c1c360)
+++ lib/droonga/worker.rb    2013-11-20 15:21:40 +0900 (c2261b1)
@@ -22,7 +22,7 @@ module Droonga
     attr_reader :context, :envelope, :name
 
     def initialize
-      @executor = Executor.new(config.merge(:proxy => false))
+      @executor = Executor.new(config.merge(:standalone => true))
     end
 
     def run

  Modified: lib/fluent/plugin/out_droonga.rb (+1 -1)
===================================================================
--- lib/fluent/plugin/out_droonga.rb    2013-11-20 15:07:39 +0900 (b0d914e)
+++ lib/fluent/plugin/out_droonga.rb    2013-11-20 15:21:40 +0900 (0551c69)
@@ -37,7 +37,7 @@ module Fluent
                                     :n_workers => @n_workers,
                                     :handlers => @handlers,
                                     :name => @name,
-                                    :proxy => @proxy)
+                                    :standalone => !@proxy)
       @engine.start
     end
 

  Modified: test/test_adapter.rb (+4 -4)
===================================================================
--- test/test_adapter.rb    2013-11-20 15:07:39 +0900 (00d256f)
+++ test/test_adapter.rb    2013-11-20 15:21:40 +0900 (825ea35)
@@ -28,20 +28,20 @@ class AdapterTest < Test::Unit::TestCase
     end
 
     def setup
-      @proxy = Object.new
-      @groonga_adapter = GroongaAdapter.new(@proxy)
+      @dispatcher = Object.new
+      @groonga_adapter = GroongaAdapter.new(@dispatcher)
     end
 
     def test_called
       request = nil
-      stub(@proxy).post
+      stub(@dispatcher).post
       assert_equal(:selected, @groonga_adapter.adapt(:select, request))
     end
 
     def test_post
       request = nil
       response = nil
-      mock(@proxy).post(:search).yields(response)
+      mock(@dispatcher).post(:search).yields(response)
       @groonga_adapter.adapt(:select, request)
     end
   end
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index