YUKI Hiroshi
null+****@clear*****
Thu Dec 25 16:41:16 JST 2014
YUKI Hiroshi 2014-12-25 16:41:16 +0900 (Thu, 25 Dec 2014) New Revision: ed7e217d95b42f86b20f79fcda428ce352f4c16d https://github.com/droonga/droonga-engine/commit/ed7e217d95b42f86b20f79fcda428ce352f4c16d Message: Handle changes of live nodes list correctly Conflicts: lib/droonga/engine_state.rb Modified files: lib/droonga/cluster_state.rb lib/droonga/engine.rb lib/droonga/engine_state.rb Modified: lib/droonga/cluster_state.rb (+15 -0) =================================================================== --- lib/droonga/cluster_state.rb 2014-12-25 16:33:20 +0900 (2ca555c) +++ lib/droonga/cluster_state.rb 2014-12-25 16:41:16 +0900 (2dd734d) @@ -21,10 +21,12 @@ module Droonga include Loggable attr_accessor :catalog + attr_writer :on_change def initialize @catalog = nil @live_nodes_list = nil + @on_change = nil end def all_nodes @@ -80,6 +82,19 @@ module Droonga same_role_nodes - dead_nodes end + def live_nodes_list=(new_nodes_list) + old_live_nodes_list = @live_nodes_list + @live_nodes_list = new_nodes_list + unless old_live_nodes_list == new_nodes_list + on_change + end + @live_nodes_list + end + + def on_change + @on_change.call if @on_change + end + private def node_metadata @node_metadata ||= NodeMetadata.new Modified: lib/droonga/engine.rb (+2 -2) =================================================================== --- lib/droonga/engine.rb 2014-12-25 16:33:20 +0900 (308e343) +++ lib/droonga/engine.rb 2014-12-25 16:41:16 +0900 (9d6872b) @@ -33,13 +33,13 @@ module Droonga attr_writer :on_ready def initialize(loop, name, internal_name) @state = EngineState.new(loop, name, internal_name) - @state.live_nodes_list = load_live_nodes_list + @state.cluster.live_nodes_list = load_live_nodes_list @catalog = load_catalog @state.catalog = @catalog @dispatcher = create_dispatcher @live_nodes_list_observer = FileObserver.new(loop, Path.live_nodes_list) @live_nodes_list_observer.on_change = lambda do - @state.live_nodes_list = load_live_nodes_list + @state.cluster.live_nodes_list = load_live_nodes_list end @node_metadata_observer = FileObserver.new(loop, Path.node_metadata) @node_metadata_observer.on_change = lambda do Modified: lib/droonga/engine_state.rb (+3 -0) =================================================================== --- lib/droonga/engine_state.rb 2014-12-25 16:33:20 +0900 (aeaae14) +++ lib/droonga/engine_state.rb 2014-12-25 16:41:16 +0900 (1d598e0) @@ -46,6 +46,9 @@ module Droonga @cluster = ClusterState.new @forwarder = BufferedForwarder.new(@loop, :cluster_state => @cluster) + @cluster.on_change = lambda do + @forwarder.resume + end @replier = Replier.new(@forwarder) @on_ready = nil @on_finish = nil -------------- next part -------------- HTML����������������������������... 다운로드