YUKI Hiroshi
null+****@clear*****
Fri Dec 26 16:04:22 JST 2014
YUKI Hiroshi 2014-12-26 16:04:22 +0900 (Fri, 26 Dec 2014) New Revision: 2f307b62af1843f4d1fc851164064477ca95391e https://github.com/droonga/droonga-engine/commit/2f307b62af1843f4d1fc851164064477ca95391e Message: Simplify contents of the file cluster-state.json Modified files: lib/droonga/cluster_state.rb lib/droonga/serf.rb Modified: lib/droonga/cluster_state.rb (+5 -6) =================================================================== --- lib/droonga/cluster_state.rb 2014-12-26 15:42:20 +0900 (6b73cbf) +++ lib/droonga/cluster_state.rb 2014-12-26 16:04:22 +0900 (ce0ea3d) @@ -185,8 +185,8 @@ module Droonga def collect_dead_nodes nodes = [] - @state.each do |name, state| - unless state["live"] + @state.each do |name, node_state| + unless node_state["live"] nodes << name end end @@ -195,10 +195,9 @@ module Droonga def collect_nodes_by_role(role) nodes = [] - @state.each do |name, state| - if not state["foreign"] and - state["tags"]["type"] == "engine" and - state["tags"]["role"] == role + @state.each do |name, node_state| + if node_state["type"] == "engine" and + node_state["role"] == role nodes << name end end Modified: lib/droonga/serf.rb (+8 -7) =================================================================== --- lib/droonga/serf.rb 2014-12-26 15:42:20 +0900 (1f123d1) +++ lib/droonga/serf.rb 2014-12-26 16:04:22 +0900 (4dfe57c) @@ -136,21 +136,22 @@ module Droonga def current_cluster_state ensure_serf - nodes_list = {} + nodes = {} result = run_once("members", "-format", "json") result[:result] = JSON.parse(result[:result]) members = result[:result] current_cluster_id = cluster_id members["members"].each do |member| foreign = member["tags"]["cluster_id"] != current_cluster_id - nodes_list[member["name"]] = { - "live" => member["status"] == "alive", - "foreign" => foreign, - "serfAddress" => member["addr"], - "tags" => member["tags"], + next if foreign + + nodes[member["name"]] = { + "type" => member["tags"]["type"], + "role" => member["tags"]["role"], + "live" => member["status"] == "alive", } end - nodes_list + nodes end def set_tag(name, value) -------------- next part -------------- HTML����������������������������... 下載