YUKI Hiroshi
null+****@clear*****
Thu Jul 17 18:26:33 JST 2014
YUKI Hiroshi 2014-07-17 18:26:33 +0900 (Thu, 17 Jul 2014) New Revision: fe2c776e0fe817b0d7ba9afab39b2b89229da547 https://github.com/droonga/droonga-engine/commit/fe2c776e0fe817b0d7ba9afab39b2b89229da547 Message: Output result of remote commands Modified files: bin/droonga-engine-absorb-data bin/droonga-engine-join bin/droonga-engine-unjoin lib/droonga/command/serf_event_handler.rb Modified: bin/droonga-engine-absorb-data (+8 -6) =================================================================== --- bin/droonga-engine-absorb-data 2014-07-17 18:04:13 +0900 (8258a35) +++ bin/droonga-engine-absorb-data 2014-07-17 18:26:33 +0900 (46e96b0) @@ -71,12 +71,14 @@ end destination_node = "#{options.destination_host}:#{options.port}/#{options.tag}" puts "Absorbing data..." -Droonga::Serf.send_query(destination_node, "absorb_data", - "node" => destination_node, - "source" => options.source_host, - "port" => options.port, - "tag" => options.tag, - "dataset" => options.dataset) +result = Droonga::Serf.send_query(destination_node, "absorb_data", + "node" => destination_node, + "source" => options.source_host, + "port" => options.port, + "tag" => options.tag, + "dataset" => options.dataset) +puts result[:output] +puts result[:error] unless result[:error].empty? puts "Done." exit(true) Modified: bin/droonga-engine-join (+7 -6) =================================================================== --- bin/droonga-engine-join 2014-07-17 18:04:13 +0900 (9116b36) +++ bin/droonga-engine-join 2014-07-17 18:26:33 +0900 (46d8726) @@ -113,12 +113,13 @@ options.joining_node = "#{options.joining_host}:#{options.port}/#{options.tag}" options.source_node = "#{options.replica_source_host}:#{options.port}/#{options.tag}" puts "Joining new replica to the cluster..." -Droonga::Serf.send_query(options.joining_node, "join", - "node" => options.joining_node, - "type" => "replica", - "source" => options.source_node, - "copy" => options.copy) - +result = Droonga::Serf.send_query(options.joining_node, "join", + "node" => options.joining_node, + "type" => "replica", + "source" => options.source_node, + "copy" => options.copy) +puts result[:output] +puts result[:error] unless result[:error].empty? puts "Done." exit(true) Modified: bin/droonga-engine-unjoin (+5 -3) =================================================================== --- bin/droonga-engine-unjoin 2014-07-17 18:04:13 +0900 (b4923ce) +++ bin/droonga-engine-unjoin 2014-07-17 18:26:33 +0900 (4872ffc) @@ -81,9 +81,11 @@ options.remaining_node = "#{remaining_host}:#{options.port}/#{options.tag}" puts "Unjoining replica from the cluster..." -Droonga::Serf.send_query(options.remaining_node, "remove_replicas", - "dataset" => options.dataset, - "hosts" => [options.replica_remove_host]) +result = Droonga::Serf.send_query(options.remaining_node, "remove_replicas", + "dataset" => options.dataset, + "hosts" => [options.replica_remove_host]) +puts result[:output] +puts result[:error] unless result[:error].empty? puts "Done." Modified: lib/droonga/command/serf_event_handler.rb (+17 -9) =================================================================== --- lib/droonga/command/serf_event_handler.rb 2014-07-17 18:04:13 +0900 (57812c4) +++ lib/droonga/command/serf_event_handler.rb 2014-07-17 18:26:33 +0900 (c7a8902) @@ -162,18 +162,18 @@ module Droonga puts "joining to the cluster: update others" source_node = "#{source_host}:#{port}/#{tag}" - Serf.send_query(source_node, "add_replicas", - "dataset" => dataset_name, - "hosts" => [host]) + run_remote_command(source_node, "add_replicas", + "dataset" => dataset_name, + "hosts" => [host]) end def fetch_catalog(source_node) source_host = source_node.split(":").first port = 10032 + rand(10000) - Serf.send_query(source_node, "publish_catalog", - "node" => source_node, - "port" => port) + run_remote_command(source_node, "publish_catalog", + "node" => source_node, + "port" => port) sleep(3) # wait until the HTTP server becomes ready url = "http://#{source_host}:#{port}" @@ -184,9 +184,9 @@ module Droonga response = connection.get("/catalog.json") catalog = response.body - Serf.send_query(source_node, "unpublish_catalog", - "node" => source_node, - "port" => port) + run_remote_command(source_node, "unpublish_catalog", + "node" => source_node, + "port" => port) JSON.parse(catalog) end @@ -333,6 +333,14 @@ module Droonga status[key] = value SafeFileWriter.write(Serf.status_file, JSON.pretty_generate(status)) end + + def run_remote_command(node, command, options={}) + puts "remote command: #{command} on #{node}" + result = Serf.send_query(node, command, options) + puts result[:output] + puts result[:error] unless result[:error].empty? + result + end end end end -------------- next part -------------- HTML����������������������������... 下载