YUKI Hiroshi
null+****@clear*****
Wed Jul 23 15:00:25 JST 2014
YUKI Hiroshi 2014-07-23 15:00:25 +0900 (Wed, 23 Jul 2014) New Revision: 79df420cdcbb0c211eb646161dece6b2e09a1cbf https://github.com/droonga/droonga-engine/commit/79df420cdcbb0c211eb646161dece6b2e09a1cbf Message: Use pipeline_r to execute external commands with pipeline Modified files: bin/droonga-engine-absorb-data lib/droonga/command/serf_event_handler.rb lib/droonga/data_absorber.rb Modified: bin/droonga-engine-absorb-data (+3 -1) =================================================================== --- bin/droonga-engine-absorb-data 2014-07-23 14:46:18 +0900 (b9e9f7a) +++ bin/droonga-engine-absorb-data 2014-07-23 15:00:25 +0900 (32cec69) @@ -101,7 +101,9 @@ else :source_host => options.source_host, :destination_host => options.destination_host, :port => options.port, - :tag => options.tag) + :tag => options.tag) do |output| + puts output + end end puts "Done." Modified: lib/droonga/command/serf_event_handler.rb (+2 -10) =================================================================== --- lib/droonga/command/serf_event_handler.rb 2014-07-23 14:46:18 +0900 (3dd404a) +++ lib/droonga/command/serf_event_handler.rb 2014-07-23 15:00:25 +0900 (30360eb) @@ -158,15 +158,11 @@ module Droonga end sleep(1) # wait for restart - count = 0 DataAbsorber.absorb(:dataset => dataset_name, :source_host => source_host, :destination_host => host, :port => port, - :tag => tag) do |dump| - count += 1 - end - log("#{count} dump messages are successfully processed") + :tag => tag) sleep(1) end @@ -311,15 +307,11 @@ module Droonga log("port = #{port}") log("tag = #{tag}") - count = 0 DataAbsorber.absorb(:dataset => dataset_name, :source_host => source, :destination_host => host, :port => port, - :tag => tag) do |dump| - count += 1 - end - log("#{count} dump messages are successfully processed") + :tag => tag) end def live_nodes Modified: lib/droonga/data_absorber.rb (+5 -8) =================================================================== --- lib/droonga/data_absorber.rb 2014-07-23 14:46:18 +0900 (36adf52) +++ lib/droonga/data_absorber.rb 2014-07-23 15:00:25 +0900 (31d7aa0) @@ -39,14 +39,11 @@ module Droonga drndump_command_line = [drndump] + drndump_options client_command_line = [client] + client_options - Open3.popen3(*drndump_command_line, :pgroup => true) do |dump_in, dump_out, dump_error, dump_thread| - dump_in.close - Open3.popen3(*client_command_line, :pgroup => true) do |client_in, client_out, client_error, client_thread| - client_out.close - dump_out.each do |part| - yield part if block_given? - client_in.puts(part) - end + env = {} + Open3.pipeline_r([env, *drndump_command_line], + [env, *client_command_line]) do |last_stdout, thread| + last_stdout.each do |output| + yield output if block_given? end end end -------------- next part -------------- HTML����������������������������... Download