YUKI Hiroshi
null+****@clear*****
Thu Jan 15 17:29:04 JST 2015
YUKI Hiroshi 2015-01-15 17:29:04 +0900 (Thu, 15 Jan 2015) New Revision: 755b0a3182a56a2bea9ee9998cdcce150db6f0e2 https://github.com/droonga/droonga-engine/commit/755b0a3182a56a2bea9ee9998cdcce150db6f0e2 Message: Split methods for joining steps Modified files: lib/droonga/command/remote.rb Modified: lib/droonga/command/remote.rb (+20 -22) =================================================================== --- lib/droonga/command/remote.rb 2015-01-15 17:24:45 +0900 (329d3ef) +++ lib/droonga/command/remote.rb 2015-01-15 17:29:04 +0900 (8e56db5) @@ -188,27 +188,13 @@ module Droonga @catalog = fetch_catalog - other_hosts = replica_hosts - log("other_hosts = #{other_hosts}") - return if other_hosts.empty? + @other_hosts = replica_hosts + log("other_hosts = #{@other_hosts}") + return if @other_hosts.empty? @serf.role = NodeMetadata::Role::ABSORB_DESTINATION - # restart self with the fetched catalog. - SafeFileWriter.write(Path.catalog) do |output, file| - output.puts(JSON.pretty_generate(@catalog)) - @service_installation.ensure_correct_file_permission(file) - end - - log("joining to the cluster: update myself") - - CatalogModifier.modify do |modifier, file| - modifier.datasets[dataset_name].replicas.hosts += other_hosts - modifier.datasets[dataset_name].replicas.hosts.uniq! - @service_installation.ensure_correct_file_permission(file) - end - - @serf.join(*other_hosts) + join_to_cluster absorb_data if should_absorb_data? @@ -232,14 +218,26 @@ module Droonga fetcher.fetch(:dataset => dataset_name) end - def absorb_data - log("starting to copy data from #{source_host}") + def join_to_cluster + # restart self with the fetched catalog. + SafeFileWriter.write(Path.catalog) do |output, file| + output.puts(JSON.pretty_generate(@catalog)) + @service_installation.ensure_correct_file_permission(file) + end + + log("joining to the cluster: update myself") CatalogModifier.modify do |modifier, file| - modifier.datasets[dataset_name].replicas.hosts = [host] + modifier.datasets[dataset_name].replicas.hosts += @other_hosts + modifier.datasets[dataset_name].replicas.hosts.uniq! @service_installation.ensure_correct_file_permission(file) end - sleep(5) #TODO: wait for restart. this should be done more safely, to avoid starting of absorbing with old catalog.json. + + @serf.join(*@other_hosts) + end + + def absorb_data + log("starting to copy data from #{source_host}") metadata = NodeMetadata.new metadata.set(:absorbing, true) -------------- next part -------------- HTML����������������������������... 下载