[Groonga-commit] droonga/fluent-plugin-droonga at 801e2d5 [master] Rename 'component' to 'step'.

Back to archive index

Daijiro MORI null+****@clear*****
Fri Feb 7 13:36:34 JST 2014


Daijiro MORI	2014-02-07 13:36:34 +0900 (Fri, 07 Feb 2014)

  New Revision: 801e2d53a9b8e09346dceebe4038498d18bd4010
  https://github.com/droonga/fluent-plugin-droonga/commit/801e2d53a9b8e09346dceebe4038498d18bd4010

  Message:
    Rename 'component' to 'step'.

  Modified files:
    lib/droonga/collector_plugin.rb
    lib/droonga/dispatcher.rb
    lib/droonga/distribution_planner.rb
    lib/droonga/handler_message.rb
    lib/droonga/session.rb
    lib/droonga/test/stub_handler_message.rb
    test/unit/plugin/collector/test_basic.rb
    test/unit/plugin/collector/test_search.rb

  Modified: lib/droonga/collector_plugin.rb (+5 -5)
===================================================================
--- lib/droonga/collector_plugin.rb    2014-02-07 13:10:28 +0900 (fc8f074)
+++ lib/droonga/collector_plugin.rb    2014-02-07 13:36:34 +0900 (b94db6d)
@@ -21,7 +21,7 @@ module Droonga
   class CollectorPlugin < LegacyPlugin
     extend PluginRegisterable
 
-    attr_reader :task, :input_name, :component, :output_values, :body, :output_names
+    attr_reader :task, :input_name, :step, :output_values, :body, :output_names
     def initialize
       super()
     end
@@ -30,11 +30,11 @@ module Droonga
       return false unless message.is_a? Hash
       @task = message["task"]
       return false unles****@task*****_a? Hash
-      @component = @task["component"]
-      return false unles****@compo*****_a? Hash
+      @step = @task["step"]
+      return false unles****@step*****_a? Hash
       @output_values = @task["values"]
-      @body = @component["body"]
-      @output_names = @component["outputs"]
+      @body = @step["body"]
+      @output_names = @step["outputs"]
       @id = message["id"]
       @value = message["value"]
       @input_name = message["name"]

  Modified: lib/droonga/dispatcher.rb (+30 -30)
===================================================================
--- lib/droonga/dispatcher.rb    2014-02-07 13:10:28 +0900 (91f6593)
+++ lib/droonga/dispatcher.rb    2014-02-07 13:36:34 +0900 (5fdcaf3)
@@ -130,9 +130,9 @@ module Droonga
       if session
         session.receive(message["input"], message["value"])
       else
-        components = message["components"]
-        if components
-          session_planner = SessionPlanner.new(self, components)
+        steps = message["steps"]
+        if steps
+          session_planner = SessionPlanner.new(self, steps)
           session = session_planner.create_session(id, @collector)
           @sessions[id] = session
         else
@@ -153,23 +153,23 @@ module Droonga
       end
     end
 
-    def dispatch_components(components)
+    def dispatch_steps(steps)
       id = generate_id
       destinations = {}
-      components.each do |component|
-        dataset = component["dataset"]
+      steps.each do |step|
+        dataset = step["dataset"]
         if dataset
-          routes = Droonga.catalog.get_routes(dataset, component)
-          component["routes"] = routes
+          routes = Droonga.catalog.get_routes(dataset, step)
+          step["routes"] = routes
         else
-          component["routes"] ||= [id]
+          step["routes"] ||= [id]
         end
-        routes = component["routes"]
+        routes = step["routes"]
         routes.each do |route|
           destinations[farm_path(route)] = true
         end
       end
-      dispatch_message = { "id" => id, "components" => components }
+      dispatch_message = { "id" => id, "steps" => steps }
       destinations.each_key do |destination|
         dispatch(dispatch_message, destination)
       end
@@ -178,10 +178,10 @@ module Droonga
     def process_local_message(local_message)
       task = local_message["task"]
       partition_name = task["route"]
-      component = task["component"]
-      command = component["command"]
+      step = task["step"]
+      command = step["command"]
       descendants = {}
-      component["descendants"].each do |name, routes|
+      step["descendants"].each do |name, routes|
         descendants[name] = routes.collect do |route|
           farm_path(route)
         end
@@ -229,28 +229,28 @@ module Droonga
     end
 
     class SessionPlanner
-      attr_reader :components
+      attr_reader :steps
 
-      def initialize(dispatcher, components)
+      def initialize(dispatcher, steps)
         @dispatcher = dispatcher
-        @components = components
+        @steps = steps
       end
 
       def create_session(id, collector)
         resolve_descendants
         tasks = []
         inputs = {}
-        @components.each do |component|
-          component["routes"].each do |route|
+        @steps.each do |step|
+          step["routes"].each do |route|
             next unles****@dispa*****?(route)
             task = {
               "route" => route,
-              "component" => component,
+              "step" => step,
               "n_of_inputs" => 0,
               "values" => {}
             }
             tasks << task
-            (component["inputs"] || [nil]).each do |input|
+            (step["inputs"] || [nil]).each do |input|
               inputs[input] ||= []
               inputs[input] << task
             end
@@ -261,24 +261,24 @@ module Droonga
 
       def resolve_descendants
         @descendants = {}
-        @components.size.times do |index|
-          component = @components[index]
-          (component["inputs"] || []).each do |input|
+        @steps.size.times do |index|
+          step = @steps[index]
+          (step["inputs"] || []).each do |input|
             @descendants[input] ||= []
             @descendants[input] << index
           end
-          component["n_of_expects"] = 0
+          step["n_of_expects"] = 0
         end
-        @components.each do |component|
+        @steps.each do |step|
           descendants = {}
-          (component["outputs"] || []).each do |output|
+          (step["outputs"] || []).each do |output|
             descendants[output] = []
             @descendants[output].each do |index|
-              @components[index]["n_of_expects"] += component["routes"].size
-              descendants[output].concat(@components[index]["routes"])
+              @steps[index]["n_of_expects"] += step["routes"].size
+              descendants[output].concat(@steps[index]["routes"])
             end
           end
-          component["descendants"] = descendants
+          step["descendants"] = descendants
         end
       end
     end

  Modified: lib/droonga/distribution_planner.rb (+18 -18)
===================================================================
--- lib/droonga/distribution_planner.rb    2014-02-07 13:10:28 +0900 (e5cfad2)
+++ lib/droonga/distribution_planner.rb    2014-02-07 13:36:34 +0900 (430d488)
@@ -27,41 +27,41 @@ module Droonga
       end
     end
 
-    class CyclicComponentsError < StandardError
-      attr_reader :components
-      def initialize(components)
-        @components = components
-        super("cyclic components found: <#{components}>")
+    class CyclicStepsError < StandardError
+      attr_reader :steps
+      def initialize(steps)
+        @steps = steps
+        super("cyclic steps found: <#{steps}>")
       end
     end
 
     include TSort
 
-    def initialize(dispatcher, components)
+    def initialize(dispatcher, steps)
       @dispatcher = dispatcher
-      @components = components
+      @steps = steps
     end
 
     def distribute
-      planned_components = plan
-      @dispatcher.dispatch_components(planned_components)
+      planned_steps = plan
+      @dispatcher.dispatch_steps(planned_steps)
     end
 
     def plan
       @dependency = {}
-      @components.each do |component|
-        @dependency[component] = component["inputs"]
-        next unless component["outputs"]
-        component["outputs"].each do |output|
-          @dependency[output] = [component]
+      @steps.each do |step|
+        @dependency[step] = step["inputs"]
+        next unless step["outputs"]
+        step["outputs"].each do |output|
+          @dependency[output] = [step]
         end
       end
-      components = []
+      steps = []
       each_strongly_connected_component do |cs|
-        raise CyclicComponentsError.new(cs) if cs.size > 1
-        components.concat(cs) unless cs.first.is_a? String
+        raise CyclicStepsError.new(cs) if cs.size > 1
+        steps.concat(cs) unless cs.first.is_a? String
       end
-      components
+      steps
     end
 
     private

  Modified: lib/droonga/handler_message.rb (+5 -5)
===================================================================
--- lib/droonga/handler_message.rb    2014-02-07 13:10:28 +0900 (005bf6d)
+++ lib/droonga/handler_message.rb    2014-02-07 13:36:34 +0900 (188ee4b)
@@ -25,8 +25,8 @@ module Droonga
         raise "<task> value isn't object: <#{@raw.inspect}>"
       end
 
-      unless component.is_a?(Hash)
-        raise "<task/component> value isn't object: <#{@raw.inspect}>"
+      unless step.is_a?(Hash)
+        raise "<task/step> value isn't object: <#{@raw.inspect}>"
       end
     end
 
@@ -42,12 +42,12 @@ module Droonga
       @task ||= body["task"]
     end
 
-    def component
-      @component ||= task["component"]
+    def step
+      @step ||= task["step"]
     end
 
     def request
-      @request ||= component["body"]
+      @request ||= step["body"]
     end
 
     def id

  Modified: lib/droonga/session.rb (+5 -5)
===================================================================
--- lib/droonga/session.rb    2014-02-07 13:10:28 +0900 (aff2225)
+++ lib/droonga/session.rb    2014-02-07 13:36:34 +0900 (f84870a)
@@ -48,10 +48,10 @@ module Droonga
       end
       tasks.each do |task|
         task["n_of_inputs"] += 1
-        component = task["component"]
-        type = component["type"]
+        step = task["step"]
+        type = step["type"]
         command = "collector_" + type
-        n_of_expects = component["n_of_expects"]
+        n_of_expects = step["n_of_expects"]
         message = {
           "task"=>task,
           "name"=>name,
@@ -61,9 +61,9 @@ module Droonga
         return if task["n_of_inputs"] < n_of_expects
         #the task is done
         result = task["values"]
-        post = component["post"]
+        post = step["post"]
         @dispatcher.reply("body" => result) if post
-        component["descendants"].each do |name, routes|
+        step["descendants"].each do |name, routes|
           message = {
             "id" => @id,
             "input" => name,

  Modified: lib/droonga/test/stub_handler_message.rb (+1 -1)
===================================================================
--- lib/droonga/test/stub_handler_message.rb    2014-02-07 13:10:28 +0900 (57f1887)
+++ lib/droonga/test/stub_handler_message.rb    2014-02-07 13:36:34 +0900 (c30b7b3)
@@ -22,7 +22,7 @@ module Droonga
         raw = {
           "body" => {
             "task" => {
-              "component" => {
+              "step" => {
                 "body" => request,
               },
             },

  Modified: test/unit/plugin/collector/test_basic.rb (+2 -2)
===================================================================
--- test/unit/plugin/collector/test_basic.rb    2014-02-07 13:10:28 +0900 (077d0b3)
+++ test/unit/plugin/collector/test_basic.rb    2014-02-07 13:36:34 +0900 (a22bf81)
@@ -59,7 +59,7 @@ class BasicCollectorTest < Test::Unit::TestCase
       request = {
         "task" => {
           "values" => nil,
-          "component" => {
+          "step" => {
             "body" => nil,
             "outputs" => nil,
           },
@@ -81,7 +81,7 @@ class BasicCollectorTest < Test::Unit::TestCase
           "values" => {
             output_name => [0, 1, 2],
           },
-          "component" => {
+          "step" => {
             "body" => {
               input_name => {
                 output_name => {

  Modified: test/unit/plugin/collector/test_search.rb (+6 -6)
===================================================================
--- test/unit/plugin/collector/test_search.rb    2014-02-07 13:10:28 +0900 (1b134f7)
+++ test/unit/plugin/collector/test_search.rb    2014-02-07 13:36:34 +0900 (92117a3)
@@ -308,7 +308,7 @@ class SearchCollectorTest < Test::Unit::TestCase
       request = {
         "task" => {
           "values" => nil,
-          "component" => {
+          "step" => {
             "body" => nil,
             "outputs" => nil,
           },
@@ -346,7 +346,7 @@ class SearchCollectorTest < Test::Unit::TestCase
               ],
             },
           },
-          "component" => {
+          "step" => {
             "body" => {
               input_name => {
                 output_name => {
@@ -431,7 +431,7 @@ class SearchCollectorTest < Test::Unit::TestCase
               ],
             },
           },
-          "component" => {
+          "step" => {
             "body" => {
               input_name => {
                 output_name => {
@@ -511,7 +511,7 @@ class SearchCollectorTest < Test::Unit::TestCase
               ],
             },
           },
-          "component" => {
+          "step" => {
             "body" => {
               input_name => {
                 output_name => {
@@ -595,7 +595,7 @@ class SearchCollectorTest < Test::Unit::TestCase
               ],
             },
           },
-          "component" => {
+          "step" => {
             "body" => {
               input_name => {
                 output_name => {
@@ -696,7 +696,7 @@ class SearchCollectorTest < Test::Unit::TestCase
               ],
             },
           },
-          "component" => {
+          "step" => {
             "body" => {
               input_name => {
                 output_name => {
-------------- next part --------------
HTML����������������������������...
다운로드 



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