Skip to content

Commit

Permalink
Merge pull request #2810 from dwlt/add-copy-replace-parameters-to-red…
Browse files Browse the repository at this point in the history
…is-trib-import

Add copy & replace parameters to redis-trib import
  • Loading branch information
antirez committed Oct 15, 2015
2 parents 6ed12bd + 8a85ad2 commit bdcb145
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/redis-trib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,9 @@ def call_cluster_cmd(argv,opt)
def import_cluster_cmd(argv,opt)
source_addr = opt['from']
xputs ">>> Importing data from #{source_addr} to cluster #{argv[1]}"

use_copy = opt['copy']
use_replace = opt['replace']

# Check the existing cluster.
load_cluster_info_from_node(argv[0])
check_cluster
Expand Down Expand Up @@ -1184,7 +1186,10 @@ def import_cluster_cmd(argv,opt)
print "Migrating #{k} to #{target}: "
STDOUT.flush
begin
source.client.call(["migrate",target.info[:host],target.info[:port],k,0,15000])
cmd = ["migrate",target.info[:host],target.info[:port],k,0,15000]
cmd << :copy if use_copy
cmd << :replace if use_replace
source.client.call(cmd)
rescue => e
puts e
else
Expand Down Expand Up @@ -1344,7 +1349,7 @@ def key_to_slot(key)
ALLOWED_OPTIONS={
"create" => {"replicas" => true},
"add-node" => {"slave" => false, "master-id" => true},
"import" => {"from" => :required},
"import" => {"from" => :required, "copy" => false, "replace" => false},
"reshard" => {"from" => true, "to" => true, "slots" => true, "yes" => false}
}
Expand Down

0 comments on commit bdcb145

Please sign in to comment.