Navigation Menu

Skip to content

Commit

Permalink
Add validation of absorb options
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 15, 2015
1 parent 188fe47 commit 6d3cbe5
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/droonga/data_absorber_client.rb
Expand Up @@ -24,6 +24,12 @@ module Droonga
class DataAbsorberClient
include Loggable

class DestinationEqualsToSource < StandardError
def initialize(params)
super("The source and the destination are same", params)
end
end

DEFAULT_MESSAGES_PER_SECOND = 100
DEFAULT_PROGRESS_INTERVAL_SECONDS = 3

Expand Down Expand Up @@ -57,6 +63,8 @@ def initialize(params)
@client_options = @params[:client_options] || {}

@error_message = nil

validate_params
end

def run
Expand Down Expand Up @@ -119,6 +127,22 @@ def source_node_suspendable?
end

private
def validate_params
source_node_name = NodeName.new(:host => @source_host,
:port => @source_port,
:tag => @source_tag)
destination_node_name = NodeName.new(:host => @host,
:port => @port,
:tag => @tag)
if source_node_name == destination_node_name and
@source_dataset == @dataset
raise DestinationEqualsToSource.new(:host => @host,
:port => @port,
:tag => @tag,
:dataset => @dataset)
end
end

def source_replica_hosts
@source_replica_hosts ||= get_source_replica_hosts
end
Expand Down

0 comments on commit 6d3cbe5

Please sign in to comment.