YUKI Hiroshi
null+****@clear*****
Thu Jul 17 19:41:52 JST 2014
YUKI Hiroshi 2014-07-17 19:41:52 +0900 (Thu, 17 Jul 2014) New Revision: 1a7a643766b834107f460f416dd99149efbc66ea https://github.com/droonga/droonga-engine/commit/1a7a643766b834107f460f416dd99149efbc66ea Message: Receive results of serf commands as JSON Modified files: bin/droonga-engine-absorb-data bin/droonga-engine-join bin/droonga-engine-unjoin lib/droonga/command/serf_event_handler.rb lib/droonga/serf.rb Modified: bin/droonga-engine-absorb-data (+1 -1) =================================================================== --- bin/droonga-engine-absorb-data 2014-07-17 19:39:57 +0900 (46e96b0) +++ bin/droonga-engine-absorb-data 2014-07-17 19:41:52 +0900 (78b95f9) @@ -77,7 +77,7 @@ result = Droonga::Serf.send_query(destination_node, "absorb_data", "port" => options.port, "tag" => options.tag, "dataset" => options.dataset) -puts result[:output] +puts result[:result] puts result[:error] unless result[:error].empty? puts "Done." Modified: bin/droonga-engine-join (+1 -1) =================================================================== --- bin/droonga-engine-join 2014-07-17 19:39:57 +0900 (46d8726) +++ bin/droonga-engine-join 2014-07-17 19:41:52 +0900 (5c407f4) @@ -118,7 +118,7 @@ result = Droonga::Serf.send_query(options.joining_node, "join", "type" => "replica", "source" => options.source_node, "copy" => options.copy) -puts result[:output] +puts result[:result] puts result[:error] unless result[:error].empty? puts "Done." Modified: bin/droonga-engine-unjoin (+1 -1) =================================================================== --- bin/droonga-engine-unjoin 2014-07-17 19:39:57 +0900 (4872ffc) +++ bin/droonga-engine-unjoin 2014-07-17 19:41:52 +0900 (9ee4c2e) @@ -84,7 +84,7 @@ puts "Unjoining replica from the cluster..." result = Droonga::Serf.send_query(options.remaining_node, "remove_replicas", "dataset" => options.dataset, "hosts" => [options.replica_remove_host]) -puts result[:output] +puts result[:result] puts result[:error] unless result[:error].empty? puts "Done." Modified: lib/droonga/command/serf_event_handler.rb (+6 -6) =================================================================== --- lib/droonga/command/serf_event_handler.rb 2014-07-17 19:39:57 +0900 (be11743) +++ lib/droonga/command/serf_event_handler.rb 2014-07-17 19:41:52 +0900 (c4b67c3) @@ -312,12 +312,12 @@ module Droonga def live_nodes nodes = {} - members = `#{@serf} members -rpc-addr #{@serf_rpc_address}` - members.each_line do |member| - name, address, status, = member.strip.split(/\s+/) - if status == "alive" - nodes[name] = { - "serfAddress" => address, + raw_members = `#{@serf} members -rpc-addr #{@serf_rpc_address} -format json` + members = JSON.parse(raw_members) + members["members"].each_line do |member| + if member["status"] == "alive" + nodes[member["name"]] = { + "serfAddress" => member["addr"], } end end Modified: lib/droonga/serf.rb (+3 -1) =================================================================== --- lib/droonga/serf.rb 2014-07-17 19:39:57 +0900 (1ab3643) +++ lib/droonga/serf.rb 2014-07-17 19:41:52 +0900 (819faac) @@ -141,6 +141,7 @@ module Droonga def run(command, *options) process = SerfProcess.new(@loop, @serf, command, "-rpc-addr", rpc_address, + "-format", "json", *options) process.start process @@ -149,6 +150,7 @@ module Droonga def run_once(command, *options) process = SerfProcess.new(@loop, @serf, command, "-rpc-addr", rpc_address, + "-format", "json", *options) process.run_once end @@ -243,7 +245,7 @@ module Droonga def run_once stdout, stderror, status = Open3.capture3(@serf, @command, *@options) { - :output => stdout, + :result => JSON.parse(stdout), :error => stderror, :status => status, } -------------- next part -------------- HTML����������������������������...Download