Navigation Menu

Skip to content

Commit

Permalink
Output more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Jun 28, 2014
1 parent 9856832 commit 45909e3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/droonga/command/serf_event_handler.rb
Expand Up @@ -117,7 +117,13 @@ def join_as_replica
port = dataset.port
other_hosts = dataset.hosts

puts "dataset = #{dataset_name}"
puts "port = #{port}"
puts "tag = #{tag}"

if @payload["copy"]
puts "starting to copy data from #{source}"

modify_catalog do |modifier|
modifier.datasets[dataset].replicas.hosts = [host]
end
Expand All @@ -131,12 +137,16 @@ def join_as_replica
sleep(1)
end

puts "joining to the cluster: update myself"

modify_catalog do |modifier|
modifier.datasets[dataset].replicas.hosts += other_hosts
modifier.datasets[dataset].replicas.hosts.uniq!
end
sleep(1) # wait for restart

puts "joining to the cluster: update others"

source_node = "#{source}:#{port}/#{tag}"
Serf.send_query(source_node, "add_replicas",
"dataset" => dataset,
Expand All @@ -150,6 +160,8 @@ def set_replicas
hosts = given_hosts
return unless hosts

puts "new replicas: #{hosts.join(",")}"

modify_catalog do |modifier|
modifier.datasets[dataset].replicas.hosts = hosts
end
Expand All @@ -162,6 +174,8 @@ def add_replicas
hosts = given_hosts
return unless hosts

puts "adding replicas: #{hosts.join(",")}"

modify_catalog do |modifier|
modifier.datasets[dataset].replicas.hosts += hosts
modifier.datasets[dataset].replicas.hosts.uniq!
Expand All @@ -175,6 +189,8 @@ def remove_replica
hosts = given_hosts
return unless hosts

puts "removing replicas: #{hosts.join(",")}"

modify_catalog do |modifier|
modifier.datasets[dataset].replicas.hosts -= hosts
end
Expand Down

0 comments on commit 45909e3

Please sign in to comment.