Navigation Menu

Skip to content

Commit

Permalink
Join to the cluster before absorb
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Jan 15, 2015
1 parent 929edbf commit 1c91d34
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 0 additions & 8 deletions bin/droonga-engine-join
Expand Up @@ -152,10 +152,6 @@ class JoinCommand
"node" => source_node,
"role" => Droonga::NodeMetadata::Role::ABSORB_SOURCE)
end
run_remote_command(joining_node, "change_role",
"node" => joining_node,
"role" => Droonga::NodeMetadata::Role::ABSORB_DESTINATION)
@node_role_changed = true
end

def reset_node_role
Expand All @@ -164,10 +160,6 @@ class JoinCommand
"node" => source_node,
"role" => nil)
end
run_remote_command(joining_node, "change_role",
"node" => joining_node,
"role" => nil)
@node_role_changed = false
end

def do_join
Expand Down
8 changes: 6 additions & 2 deletions lib/droonga/command/remote.rb
Expand Up @@ -192,14 +192,14 @@ def join_as_replica
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

absorb_data if should_absorb_data?

log("joining to the cluster: update myself")

CatalogModifier.modify do |modifier, file|
Expand All @@ -209,6 +209,10 @@ def join_as_replica
end

@serf.join(*other_hosts)

absorb_data if should_absorb_data?

@serf.role = nil
end

def replica_hosts
Expand Down

0 comments on commit 1c91d34

Please sign in to comment.