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: 28ae9197936e396ebc030a5bce442a3d6a384595 https://github.com/droonga/droonga-engine/commit/28ae9197936e396ebc030a5bce442a3d6a384595 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 (ed79a41) +++ lib/droonga/cluster_state.rb 2014-12-26 16:04:22 +0900 (ef4b9bb) @@ -173,8 +173,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 @@ -183,10 +183,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����������������������������... Descargar