[Groonga-commit] droonga/droonga-engine at 9931a2d [master] Forward "read" messages always even if roles of nodes are different

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Apr 2 12:13:58 JST 2015


YUKI Hiroshi	2015-04-02 12:13:58 +0900 (Thu, 02 Apr 2015)

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

  Message:
    Forward "read" messages always even if roles of nodes are different

  Modified files:
    lib/droonga/dispatcher.rb
    lib/droonga/engine_node.rb

  Modified: lib/droonga/dispatcher.rb (+1 -0)
===================================================================
--- lib/droonga/dispatcher.rb    2015-04-02 11:37:22 +0900 (9a53b61)
+++ lib/droonga/dispatcher.rb    2015-04-02 12:13:58 +0900 (104e20d)
@@ -212,6 +212,7 @@ module Droonga
         dataset =****@catal*****(step["dataset"])
         if dataset
           if write_step?(step)
+            step["write"] = true
             target_nodes =****@clust*****_nodes
             if target_nodes.empty?
               logger.error("there is no node to dispath a write step!",

  Modified: lib/droonga/engine_node.rb (+22 -2)
===================================================================
--- lib/droonga/engine_node.rb    2015-04-02 11:37:22 +0900 (58e0af5)
+++ lib/droonga/engine_node.rb    2015-04-02 12:13:58 +0900 (9c8b8f8)
@@ -55,9 +55,21 @@ module Droonga
     end
 
     def forward(message, destination)
-      if not really_writable?
+      if read_message?(message)
+        # A node can receive read messages for other nodes,
+        # while changing its role. They must not be buffered.
+        output(message, destination)
+        return
+      end
+
+      unless really_writable?
+        # The target node is not ready. We should send the message later.
         @buffer.add(message, destination)
-      elsif****@buffe*****?
+        return
+      end
+
+      # The target node is ready.
+      if****@buffe*****?
         output(message, destination)
       else
         @buffer.add(message, destination)
@@ -170,6 +182,14 @@ module Droonga
       @sender_node_metadata.role
     end
 
+    def read_message?(message)
+      steps = message["body"]["steps"]
+      return false unless steps
+      steps.all? do |step|
+        not step["write"]
+      end
+    end
+
     def output(message, destination)
       command = destination["type"]
       receiver = destination["to"]
-------------- next part --------------
HTML����������������������������...
Download 



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