[Groonga-commit] droonga/droonga-engine at 895c40f [master] Reassign state of nodes

Back to archive index

YUKI Hiroshi null+****@clear*****
Tue Dec 16 16:50:03 JST 2014


YUKI Hiroshi	2014-12-16 16:50:03 +0900 (Tue, 16 Dec 2014)

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

  Message:
    Reassign state of nodes
    
    old       => new
    active    => active
    suspended => inactive
    inactive  => dead
    
    And, some new states are introduced internally.
    
     * readable: nodes which can return results.
     * unreadable: nodes which cannot return results. dead or suspended.
     * writable: nodes should receive write-messages, even if they are dead or suspended.

  Modified files:
    lib/droonga/dispatcher.rb
    lib/droonga/engine_state.rb
    lib/droonga/live_nodes_list.rb
    lib/droonga/plugins/system.rb
    test/unit/plugins/system/test_status.rb

  Modified: lib/droonga/dispatcher.rb (+2 -2)
===================================================================
--- lib/droonga/dispatcher.rb    2014-12-13 14:24:04 +0900 (f774a0f)
+++ lib/droonga/dispatcher.rb    2014-12-16 16:50:03 +0900 (7008e71)
@@ -193,9 +193,9 @@ module Droonga
         dataset =****@catal*****(step["dataset"])
         if dataset
           if write_step?(step)
-            target_nodes = @engine_state.live_nodes
+            target_nodes = @engine_state.writable_nodes
           else
-            target_nodes = @engine_state.active_nodes
+            target_nodes = @engine_state.readable_nodes
           end
           routes = dataset.compute_routes(step, target_nodes)
           step["routes"] = routes

  Modified: lib/droonga/engine_state.rb (+15 -29)
===================================================================
--- lib/droonga/engine_state.rb    2014-12-13 14:24:04 +0900 (1ec2eb9)
+++ lib/droonga/engine_state.rb    2014-12-16 16:50:03 +0900 (9d9c38e)
@@ -108,22 +108,6 @@ module Droonga
       @catalog.all_nodes
     end
 
-    # nodes who provide the service actually
-    #  * read-only messages  : deliver
-    #  * read-write messages : deliver
-    #  * responses           : returned
-    def active_nodes
-      all_nodes - dead_nodes - suspended_nodes
-    end
-
-    # nodes in the cluster
-    #  * read-only messages  : deliver
-    #  * read-write messages : deliver
-    #  * responses           : undetermined
-    def live_nodes
-      all_nodes - dead_nodes
-    end
-
     def dead_nodes
       if @live_nodes_list
         @live_nodes_list.dead_nodes
@@ -132,17 +116,12 @@ module Droonga
       end
     end
 
-    # nodes who temporary suspended
-    # (going to join to the cluster, etc,)
-    #  * read-only messages  : don't deliver
-    #  * read-write messages : deliver
-    #  * responses           : not returned
-    def suspended_nodes
-      if @live_nodes_list
-        @live_nodes_list.suspended_nodes
-      else
-        []
-      end
+    def readable_nodes
+      all_nodes - unreadable_nodes
+    end
+
+    def writable_nodes
+      all_nodes
     end
 
     def live_nodes_list=(new_nodes_list)
@@ -156,8 +135,7 @@ module Droonga
 
     def remove_inactive_routes(routes)
       routes.reject do |route|
-        node = farm_path(route)
-        dead_nodes.include?(node) or suspended_nodes.include?(node)
+        unreadable_nodes.include?(farm_path(route))
       end
     end
 
@@ -166,6 +144,14 @@ module Droonga
     end
 
     private
+    def unreadable_nodes
+      if @live_nodes_list
+        @live_nodes_list.unreadable_nodes
+      else
+        []
+      end
+    end
+
     def log_tag
       "engine_state"
     end

  Modified: lib/droonga/live_nodes_list.rb (+4 -0)
===================================================================
--- lib/droonga/live_nodes_list.rb    2014-12-13 14:24:04 +0900 (60258ef)
+++ lib/droonga/live_nodes_list.rb    2014-12-16 16:50:03 +0900 (2cd1fdf)
@@ -31,6 +31,10 @@ module Droonga
       @suspended_nodes ||= collect_suspended_nodes
     end
 
+    def unreadable_nodes
+      @unreadable_nodes ||= dead_nodes + suspended_nodes
+    end
+
     def ==(nodes_list)
       nodes_list.is_a?(self.class) and
         nodes_list.all_nodes == all_nodes and

  Modified: lib/droonga/plugins/system.rb (+5 -5)
===================================================================
--- lib/droonga/plugins/system.rb    2014-12-13 14:24:04 +0900 (d6b56a5)
+++ lib/droonga/plugins/system.rb    2014-12-16 16:50:03 +0900 (8d2af51)
@@ -26,14 +26,14 @@ module Droonga
 
         def handle(message)
           engine_state =****@messe*****_state
-          active_nodes = engine_state.active_nodes
-          suspended_nodes = engine_state.suspended_nodes
+          readable_nodes = engine_state.readable_nodes
+          dead_nodes = engine_state.dead_nodes
           nodes = {}
           engine_state.all_nodes.collect do |identifier|
-            if active_nodes.include?(identifier)
+            if readable_nodes.include?(identifier)
               status = "active"
-            elsif suspended_nodes.include?(identifier)
-              status = "suspended"
+            elsif dead_nodes.include?(identifier)
+              status = "dead"
             else
               status = "inactive"
             end

  Modified: test/unit/plugins/system/test_status.rb (+3 -9)
===================================================================
--- test/unit/plugins/system/test_status.rb    2014-12-13 14:24:04 +0900 (eb652fd)
+++ test/unit/plugins/system/test_status.rb    2014-12-16 16:50:03 +0900 (9a4d7a4)
@@ -54,18 +54,12 @@ class SystemStatusHandlerTest < Test::Unit::TestCase
       ]
     end
 
-    def active_nodes
+    def readable_nodes
       [
         "127.0.0.1:10031/droonga",
       ]
     end
 
-    def suspended_nodes
-      [
-        "127.0.0.1:10032/droonga",
-      ]
-    end
-
     def dead_nodes
       [
         "127.0.0.1:10033/droonga",
@@ -83,10 +77,10 @@ class SystemStatusHandlerTest < Test::Unit::TestCase
           "status" => "active",
         },
         "127.0.0.1:10032/droonga" => {
-          "status" => "suspended",
+          "status" => "inactive",
         },
         "127.0.0.1:10033/droonga" => {
-          "status" => "inactive",
+          "status" => "dead",
         },
       },
     }
-------------- next part --------------
HTML����������������������������...
다운로드 



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