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
40377fa5
Commit
40377fa5
authored
Jan 24, 2014
by
antirez
Browse files
Cluster: redis-trib set-timeout implemented.
parent
0f9422d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/redis-trib.rb
View file @
40377fa5
...
@@ -912,6 +912,34 @@ class RedisTrib
...
@@ -912,6 +912,34 @@ class RedisTrib
node
.
r
.
shutdown
node
.
r
.
shutdown
end
end
def
set_timeout_cluster_cmd
(
argv
,
opt
)
timeout
=
argv
[
1
].
to_i
if
timeout
<
100
puts
"Setting a node timeout of less than 100 milliseconds is a bad idea."
exit
1
end
# Load cluster information
load_cluster_info_from_node
(
argv
[
0
])
ok_count
=
0
err_count
=
0
# Send CLUSTER FORGET to all the nodes but the node to remove
xputs
">>> Reconfiguring node timeout in every cluster node..."
@nodes
.
each
{
|
n
|
begin
n
.
r
.
config
(
"set"
,
"cluster-node-timeout"
,
timeout
)
n
.
r
.
config
(
"rewrite"
)
ok_count
+=
1
xputs
"*** New timeout set for
#{
n
}
"
rescue
=>
e
puts
"ERR setting node-timeot for
#{
n
}
:
#{
e
}
"
err_count
+=
1
end
}
xputs
">>> New node timeout set.
#{
ok_count
}
OK,
#{
err_count
}
ERR."
end
def
help_cluster_cmd
(
argv
,
opt
)
def
help_cluster_cmd
(
argv
,
opt
)
show_help
show_help
exit
0
exit
0
...
@@ -952,8 +980,9 @@ COMMANDS={
...
@@ -952,8 +980,9 @@ COMMANDS={
"check"
=>
[
"check_cluster_cmd"
,
2
,
"host:port"
],
"check"
=>
[
"check_cluster_cmd"
,
2
,
"host:port"
],
"fix"
=>
[
"fix_cluster_cmd"
,
2
,
"host:port"
],
"fix"
=>
[
"fix_cluster_cmd"
,
2
,
"host:port"
],
"reshard"
=>
[
"reshard_cluster_cmd"
,
2
,
"host:port"
],
"reshard"
=>
[
"reshard_cluster_cmd"
,
2
,
"host:port"
],
"addnode"
=>
[
"addnode_cluster_cmd"
,
3
,
"new_host:new_port existing_host:existing_port"
],
"add-node"
=>
[
"addnode_cluster_cmd"
,
3
,
"new_host:new_port existing_host:existing_port"
],
"delnode"
=>
[
"delnode_cluster_cmd"
,
3
,
"host:port node_id"
],
"del-node"
=>
[
"delnode_cluster_cmd"
,
3
,
"host:port node_id"
],
"set-timeout"
=>
[
"set_timeout_cluster_cmd"
,
3
,
"host:port milliseconds"
],
"help"
=>
[
"help_cluster_cmd"
,
1
,
"(show this help)"
]
"help"
=>
[
"help_cluster_cmd"
,
1
,
"(show this help)"
]
}
}
...
@@ -966,14 +995,14 @@ def show_help
...
@@ -966,14 +995,14 @@ def show_help
puts
"Usage: redis-trib <command> <options> <arguments ...>
\n\n
"
puts
"Usage: redis-trib <command> <options> <arguments ...>
\n\n
"
COMMANDS
.
each
{
|
k
,
v
|
COMMANDS
.
each
{
|
k
,
v
|
o
=
""
o
=
""
puts
"
#{
k
.
ljust
(
1
0
)
}
#{
v
[
2
]
}
"
puts
"
#{
k
.
ljust
(
1
5
)
}
#{
v
[
2
]
}
"
if
ALLOWED_OPTIONS
[
k
]
if
ALLOWED_OPTIONS
[
k
]
ALLOWED_OPTIONS
[
k
].
each
{
|
optname
,
has_arg
|
ALLOWED_OPTIONS
[
k
].
each
{
|
optname
,
has_arg
|
puts
" --
#{
optname
}
"
+
(
has_arg
?
" <arg>"
:
""
)
puts
"
--
#{
optname
}
"
+
(
has_arg
?
" <arg>"
:
""
)
}
}
end
end
}
}
puts
"
\n
For check, fix, reshard, delnode, you can specify
host:
port of any working node.
\n
"
puts
"
\n
For check, fix, reshard, del
-
node,
set-timeout
you can specify
the host and
port of any working node
in the cluster
.
\n
"
end
end
# Sanity check
# Sanity check
...
...
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