Skip to content

Commit

Permalink
add an option to send indexes first
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardochimal committed May 6, 2010
1 parent 5189b2f commit c514b9e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
3 changes: 2 additions & 1 deletion lib/taps/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def serveroptparse
end

def clientoptparse(cmd)
opts={:default_chunksize => 1000, :database_url => nil, :remote_url => nil, :debug => false, :resume_filename => nil, :disable_compresion => false}
opts={:default_chunksize => 1000, :database_url => nil, :remote_url => nil, :debug => false, :resume_filename => nil, :disable_compresion => false, :indexes_first => false}
OptionParser.new do |o|
o.banner = "Usage: #{File.basename($0)} #{cmd} [OPTIONS] <local_database_url> <remote_url>"

Expand All @@ -123,6 +123,7 @@ def clientoptparse(cmd)
o.define_head "Push a database to a taps server"
end

o.on("-i", "--indexes-first", "Transfer indexes first before data") { |v| opts[:indexes_first] = true }
o.on("-r", "--resume=file", "Resume a Taps Session from a stored file") { |v| opts[:resume_filename] = v }
o.on("-c", "--chunksize=N", "Initial Chunksize") { |v| opts[:default_chunksize] = (v.to_i < 10 ? 10 : v.to_i) }
o.on("-g", "--disable-compression", "Disable Compression") { |v| opts[:disable_compression] = true }
Expand Down
24 changes: 14 additions & 10 deletions lib/taps/operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def file_prefix
"op"
end

def indexes_first?
!!opts[:indexes_first]
end

def table_filter
opts[:table_filter]
end
Expand Down Expand Up @@ -208,14 +212,14 @@ def run
verify_server

begin
pull_schema unless resuming?

unless resuming?
pull_schema
pull_indexes if indexes_first?
end
setup_signal_trap

pull_partial_data if resuming?

pull_data
pull_indexes
pull_indexes unless indexes_first?
pull_reset_sequences
close_session
rescue RestClient::Exception => e
Expand Down Expand Up @@ -375,14 +379,14 @@ def to_hash
def run
verify_server
begin
push_schema unless resuming?

unless resuming?
push_schema
push_indexes if indexes_first?
end
setup_signal_trap

push_partial_data if resuming?

push_data
push_indexes
push_indexes unless indexes_first?
push_reset_sequences
close_session
rescue RestClient::Exception => e
Expand Down

0 comments on commit c514b9e

Please sign in to comment.