Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
71bf5604
Commit
71bf5604
authored
Dec 11, 2015
by
Salvatore Sanfilippo
Browse files
Merge pull request #2918 from danmaz74/3.0
redis-trib.rb: --timeout XXXXX option added to fix and reshard
parents
bf09e58d
47bd2a09
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/redis-trib.rb
View file @
71bf5604
...
@@ -288,6 +288,7 @@ class RedisTrib
...
@@ -288,6 +288,7 @@ class RedisTrib
@nodes
=
[]
@nodes
=
[]
@fix
=
false
@fix
=
false
@errors
=
[]
@errors
=
[]
@timeout
=
15000
end
end
def
check_arity
(
req_args
,
num_args
)
def
check_arity
(
req_args
,
num_args
)
...
@@ -819,11 +820,11 @@ class RedisTrib
...
@@ -819,11 +820,11 @@ class RedisTrib
break
if
keys
.
length
==
0
break
if
keys
.
length
==
0
keys
.
each
{
|
key
|
keys
.
each
{
|
key
|
begin
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
rescue
=>
e
if
o
[
:fix
]
&&
e
.
to_s
=~
/BUSYKEY/
if
o
[
:fix
]
&&
e
.
to_s
=~
/BUSYKEY/
xputs
"*** Target key
#{
key
}
exists. Replacing it for FIX."
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
else
puts
""
puts
""
xputs
"[ERR]
#{
e
}
"
xputs
"[ERR]
#{
e
}
"
...
@@ -853,6 +854,8 @@ class RedisTrib
...
@@ -853,6 +854,8 @@ class RedisTrib
def
fix_cluster_cmd
(
argv
,
opt
)
def
fix_cluster_cmd
(
argv
,
opt
)
@fix
=
true
@fix
=
true
@timeout
=
opt
[
'timeout'
].
to_i
if
opt
[
'timeout'
]
load_cluster_info_from_node
(
argv
[
0
])
load_cluster_info_from_node
(
argv
[
0
])
check_cluster
check_cluster
end
end
...
@@ -865,6 +868,8 @@ class RedisTrib
...
@@ -865,6 +868,8 @@ class RedisTrib
exit
1
exit
1
end
end
@timeout
=
opt
[
'timeout'
].
to_i
if
opt
[
'timeout'
].
to_i
# Get number of slots
# Get number of slots
if
opt
[
'slots'
]
if
opt
[
'slots'
]
numslots
=
opt
[
'slots'
].
to_i
numslots
=
opt
[
'slots'
].
to_i
...
@@ -1186,7 +1191,7 @@ class RedisTrib
...
@@ -1186,7 +1191,7 @@ class RedisTrib
print
"Migrating
#{
k
}
to
#{
target
}
: "
print
"Migrating
#{
k
}
to
#{
target
}
: "
STDOUT
.
flush
STDOUT
.
flush
begin
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
<<
:copy
if
use_copy
cmd
<<
:replace
if
use_replace
cmd
<<
:replace
if
use_replace
source
.
client
.
call
(
cmd
)
source
.
client
.
call
(
cmd
)
...
@@ -1350,7 +1355,8 @@ ALLOWED_OPTIONS={
...
@@ -1350,7 +1355,8 @@ ALLOWED_OPTIONS={
"create"
=>
{
"replicas"
=>
true
},
"create"
=>
{
"replicas"
=>
true
},
"add-node"
=>
{
"slave"
=>
false
,
"master-id"
=>
true
},
"add-node"
=>
{
"slave"
=>
false
,
"master-id"
=>
true
},
"import"
=>
{
"from"
=>
:required
,
"copy"
=>
false
,
"replace"
=>
false
},
"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
def
show_help
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment