[Groonga-commit] droonga/droonga-engine at d10b736 [master] Build and dispatch one way message for dead nodes

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Jun 26 19:40:57 JST 2014


YUKI Hiroshi	2014-06-26 19:40:57 +0900 (Thu, 26 Jun 2014)

  New Revision: d10b73635757282894b123c2d686068ad82acff5
  https://github.com/droonga/droonga-engine/commit/d10b73635757282894b123c2d686068ad82acff5

  Message:
    Build and dispatch one way message for dead nodes

  Modified files:
    lib/droonga/dispatcher.rb

  Modified: lib/droonga/dispatcher.rb (+23 -0)
===================================================================
--- lib/droonga/dispatcher.rb    2014-06-26 19:40:02 +0900 (235bb20)
+++ lib/droonga/dispatcher.rb    2014-06-26 19:40:57 +0900 (db1bb38)
@@ -170,19 +170,40 @@ module Droonga
 
     def dispatch_steps(steps)
       id = @engine_state.generate_id
+
+      one_way_steps = []
+      have_dead_nodes = not @engine_state.dead_nodes.empty?
+
       steps.each do |step|
         dataset =****@catal*****(step["dataset"])
         if dataset
+          if have_dead_nodes and write_step?(step)
+            routes = dataset.get_routes(step, @engine_state.dead_nodes)
+            unless routes.empty?
+              one_way_step = Marshal.load(Marshal.dump(step))
+              one_way_step["routes"] = routes
+              one_way_steps << one_way_step
+            end
+          end
           routes = dataset.get_routes(step, @engine_state.live_nodes)
           step["routes"] = routes
         else
           step["routes"] ||= [id]
         end
       end
+
       dispatch_message = { "id" => id, "steps" => steps }
       get_destinations(steps).each do |destination|
         dispatch(dispatch_message, destination)
       end
+
+      unless one_way_steps.empty?
+        dispatch_message = { "id" => @engine_state.generate_id,
+                             "steps" => one_way_steps }
+        get_destinations(one_way_steps).each do |destination|
+          dispatch(dispatch_message, destination)
+        end
+      end
     end
 
     def get_destinations(steps)
@@ -217,6 +238,8 @@ module Droonga
     end
 
     def write_step?(step)
+      return false unless step["dataset"]
+
       step_runner = @step_runners[step["dataset"]]
       return false unless step_runner
 
-------------- next part --------------
HTML����������������������������...
Download 



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