Navigation Menu

Skip to content

Commit

Permalink
Detect the emptyness of the destination node correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 17, 2015
1 parent dcd33c0 commit 53b4945
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions lib/droonga/data_absorber_client.rb
Expand Up @@ -127,7 +127,7 @@ def source_node_suspendable?
end

def empty_destination?
source_table_names.empty?
table_names_in_destination_node.empty?
end

private
Expand Down Expand Up @@ -158,32 +158,17 @@ def destination_client_options
}.merge(@client_options)
end

def create_destination_client
Droonga::Client.new(destination_client_options)
def create_destination_client(options={})
Droonga::Client.new(destination_client_options.merge(options))
end

def source_client_options
{
:host => @source_host,
:port => @source_port,
:tag => @source_tag,
:dataset => @source_dataset,
:protocol => :droonga,
:receiver_host => @receiver_host,
:receiver_port => @receiver_port,
}
end

def create_source_client
Droonga::Client.new(source_client_options)
end

def source_table_names
@source_table_names ||= get_source_table_names
def table_names_in_destination_node
@table_names_in_destination_node ||= get_table_names_in_destination_node
end

def get_source_table_names
client = create_source_client
def get_table_names_in_destination_node
client = create_destination_client(:backend => :thread,
:loop => nil)
response = client.request("dataset" => @source_dataset,
"type" => "table_list")

Expand Down

0 comments on commit 53b4945

Please sign in to comment.