[Groonga-commit] droonga/droonga-engine at 464c89d [master] Set cluster id as a serf tag

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Jun 26 15:26:06 JST 2014


YUKI Hiroshi	2014-06-26 15:26:06 +0900 (Thu, 26 Jun 2014)

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

  Message:
    Set cluster id as a serf tag

  Modified files:
    lib/droonga/engine.rb
    lib/droonga/engine_state.rb

  Modified: lib/droonga/engine.rb (+4 -0)
===================================================================
--- lib/droonga/engine.rb    2014-06-26 14:48:26 +0900 (ea4b875)
+++ lib/droonga/engine.rb    2014-06-26 15:26:06 +0900 (aea4753)
@@ -33,6 +33,10 @@ module Droonga
       @state = EngineState.new(loop, name, internal_name)
       @catalog = load_catalog
       @state.catalog = @catalog
+
+      serf = Serf.new(loop, name)
+      serf.set_tag("cluster_id", @state.cluster_id)
+
       @dispatcher = create_dispatcher
       @nodes_status_observer = FileObserver.new(loop, Path.nodes_status)
       @nodes_status_observer.on_change = lambda do

  Modified: lib/droonga/engine_state.rb (+9 -0)
===================================================================
--- lib/droonga/engine_state.rb    2014-06-26 14:48:26 +0900 (39d92ce)
+++ lib/droonga/engine_state.rb    2014-06-26 15:26:06 +0900 (420add9)
@@ -16,6 +16,7 @@
 require "English"
 
 require "coolio"
+require "digest/sha1"
 
 require "droonga/loggable"
 require "droonga/event_loop"
@@ -116,6 +117,10 @@ module Droonga
       @nodes_status = new_status
     end
 
+    def cluster_id
+      @cluster_id ||= prepare_cluster_id
+    end
+
     private
     def prepare_live_nodes
       @nodes_status.keys.select do |key|
@@ -123,6 +128,10 @@ module Droonga
       end
     end
 
+    def prepare_cluster_id
+      Digest::SHA1.hexdigest(all_nodes.join("\n"))
+    end
+
     def log_tag
       "engine_state"
     end
-------------- next part --------------
HTML����������������������������...
Download 



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