Skip to content

Commit

Permalink
Accept "--records-per-second" option for droonga-engine-absorb-data a…
Browse files Browse the repository at this point in the history
…nd droonga-engine-join
  • Loading branch information
piroor committed Nov 27, 2014
1 parent ae14394 commit c7d2e03
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
11 changes: 10 additions & 1 deletion bin/droonga-engine-absorb-data
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class AbsorbDataCommand
options.tag = Droonga::CatalogGenerator::DEFAULT_TAG
options.dataset = Droonga::CatalogGenerator::DEFAULT_DATASET
options.remote = true
options.messages_per_second = Droonga::DataAbsorber::DEFAULT_MESSAGES_PER_SECOND
parser = OptionParser.new
parser.version = Droonga::Engine::VERSION

Expand Down Expand Up @@ -93,6 +94,12 @@ class AbsorbDataCommand
"(#{options.dataset})") do |dataset|
options.dataset = dataset
end
parser.on("--records-per-second=N", Integer,
"Maximum number of records per second to be absorbed.",
"'#{Droonga::Client::RateLimiter::NO_LIMIT}' means no limit.",
"(#{options.messages_per_second})") do |n|
options.messages_per_second = n
end

parser.parse!(ARGV)
@options = options
Expand Down Expand Up @@ -134,6 +141,7 @@ class AbsorbDataCommand
:destination_host => @options.destination_host,
:port => @options.port,
:tag => @options.tag,
:messages_per_second => @options.messages_per_second,
}
Droonga::DataAbsorber.new(absorber_options)
end
Expand All @@ -145,7 +153,8 @@ class AbsorbDataCommand
"source" => @options.source_host,
"port" => @options.port,
"tag" => @options.tag,
"dataset" => @options.dataset)
"dataset" => @options.dataset,
"messages_per_second" => @options.messages_per_second)
last_progress = ""
while true
sleep(3)
Expand Down
6 changes: 6 additions & 0 deletions bin/droonga-engine-join
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ class JoinCommand
option.on(:tag=,
"Tag name of the soruce cluster to be connected.",
:default => Droonga::CatalogGenerator::DEFAULT_TAG)
option.on("records-per-second=",
:as => Integer,
"Maximum number of records per second to be copied. " +
"'#{Droonga::Client::RateLimiter::NO_LIMIT}' means no limit.",
:default => Droonga::DataAbsorber::DEFAULT_MESSAGES_PER_SECOND)
end
@options = options
rescue Slop::MissingOptionError => error
Expand Down Expand Up @@ -98,6 +103,7 @@ class JoinCommand
:destination_host => @options[:host],
:port => @options[:port],
:tag => @options[:tag],
:messages_per_second => @options["records-per-second"],
}
Droonga::DataAbsorber.new(absorber_options)
end
Expand Down
12 changes: 11 additions & 1 deletion lib/droonga/command/remote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ def dataset_name
@params["dataset"]
end

def messages_per_second
@params["messages_per_second"]
end

def valid_params?
have_required_params? and
valid_node?(source_node) and
Expand Down Expand Up @@ -227,7 +231,8 @@ def absorb_data
:source_host => source_host,
:destination_host => joining_host,
:port => port,
:tag => tag)
:tag => tag,
:messages_per_second => messages_per_second)
status.delete(:absorbing)
sleep(1)
end
Expand Down Expand Up @@ -265,6 +270,7 @@ def process
:destination_host => host,
:port => port,
:tag => tag,
:messages_per_second => messages_per_second,
:client => "droonga-send")
status.delete(:absorbing)
end
Expand All @@ -285,6 +291,10 @@ def port
def tag
@tag ||= @params["tag"]
end

def messages_per_second
@messages_per_second ||= @params["messages_per_second"]
end
end

class ModifyReplicasBase < Base
Expand Down

0 comments on commit c7d2e03

Please sign in to comment.