summaryrefslogtreecommitdiff
path: root/src/redis-trib.rb
diff options
context:
space:
mode:
authordaniele <daniele.mazzini@gmail.com>2015-12-06 22:47:57 +0100
committerantirez <antirez@gmail.com>2015-12-11 10:59:08 +0100
commit3d254e05f40ec1a9db94bc7c43262b24f6197a9f (patch)
treee24c7b740835904d7ebdf1877e79c672a0824812 /src/redis-trib.rb
parentadc2fe69934fae596aee29c49db6acdc203a62d9 (diff)
downloadredis-3d254e05f40ec1a9db94bc7c43262b24f6197a9f.tar.gz
redis-trib.rb: --timeout XXXXX option added to fix and reshard commands. Defaults to 15000 milliseconds
Diffstat (limited to 'src/redis-trib.rb')
-rwxr-xr-xsrc/redis-trib.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/redis-trib.rb b/src/redis-trib.rb
index 068e60d4e..b24c20343 100755
--- a/src/redis-trib.rb
+++ b/src/redis-trib.rb
@@ -288,6 +288,7 @@ class RedisTrib
@nodes = []
@fix = false
@errors = []
+ @timeout = 15000
end
def check_arity(req_args, num_args)
@@ -819,11 +820,11 @@ class RedisTrib
break if keys.length == 0
keys.each{|key|
begin
- source.r.client.call(["migrate",target.info[:host],target.info[:port],key,0,15000])
+ source.r.client.call(["migrate",target.info[:host],target.info[:port],key,0,@timeout])
rescue => e
if o[:fix] && e.to_s =~ /BUSYKEY/
xputs "*** Target key #{key} exists. Replacing it for FIX."
- source.r.client.call(["migrate",target.info[:host],target.info[:port],key,0,15000,:replace])
+ source.r.client.call(["migrate",target.info[:host],target.info[:port],key,0,@timeout,:replace])
else
puts ""
xputs "[ERR] #{e}"
@@ -853,6 +854,8 @@ class RedisTrib
def fix_cluster_cmd(argv,opt)
@fix = true
+ @timeout = opt['timeout'].to_i if opt['timeout']
+
load_cluster_info_from_node(argv[0])
check_cluster
end
@@ -865,6 +868,8 @@ class RedisTrib
exit 1
end
+ @timeout = opt['timeout'].to_i if opt['timeout'].to_i
+
# Get number of slots
if opt['slots']
numslots = opt['slots'].to_i
@@ -1186,7 +1191,7 @@ class RedisTrib
print "Migrating #{k} to #{target}: "
STDOUT.flush
begin
- cmd = ["migrate",target.info[:host],target.info[:port],k,0,15000]
+ cmd = ["migrate",target.info[:host],target.info[:port],k,0,@timeout]
cmd << :copy if use_copy
cmd << :replace if use_replace
source.client.call(cmd)
@@ -1350,7 +1355,8 @@ ALLOWED_OPTIONS={
"create" => {"replicas" => true},
"add-node" => {"slave" => false, "master-id" => true},
"import" => {"from" => :required, "copy" => false, "replace" => false},
- "reshard" => {"from" => true, "to" => true, "slots" => true, "yes" => false}
+ "reshard" => {"from" => true, "to" => true, "slots" => true, "yes" => false, "timeout" => 15000},
+ "fix" => {"timeout" => 15000},
}
def show_help