summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-03-11 14:58:33 +0100
committerantirez <antirez@gmail.com>2014-03-11 15:02:41 +0100
commit07036ad45e9c8e4ea02858b17f20269703015003 (patch)
tree4ed7bc748c234561b43136d30b5953f199fad04c
parenta02424e29bb7626e01dc6381aed8e721f3ac1d69 (diff)
downloadredis-07036ad45e9c8e4ea02858b17f20269703015003.tar.gz
redis-trib: new subcommand 'call'. Exec command in all nodes.
Example: ./redis-trib.rb call 192.168.1.11:7000 config get cluster-node-timeout
-rwxr-xr-xsrc/redis-trib.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/redis-trib.rb b/src/redis-trib.rb
index 1fc73917b..bff4cab14 100755
--- a/src/redis-trib.rb
+++ b/src/redis-trib.rb
@@ -952,6 +952,23 @@ class RedisTrib
xputs ">>> New node timeout set. #{ok_count} OK, #{err_count} ERR."
end
+ def call_cluster_cmd(argv,opt)
+ cmd = argv[1..-1]
+ cmd[0] = cmd[0].upcase
+
+ # Load cluster information
+ load_cluster_info_from_node(argv[0])
+ xputs ">>> Calling #{cmd.join(" ")}"
+ @nodes.each{|n|
+ begin
+ res = n.r.send(*cmd)
+ puts "#{n}: #{res}"
+ rescue => e
+ puts "#{n}: #{e}"
+ end
+ }
+ end
+
def help_cluster_cmd(argv,opt)
show_help
exit 0
@@ -995,6 +1012,7 @@ COMMANDS={
"add-node" => ["addnode_cluster_cmd", 3, "new_host:new_port existing_host:existing_port"],
"del-node" => ["delnode_cluster_cmd", 3, "host:port node_id"],
"set-timeout" => ["set_timeout_cluster_cmd", 3, "host:port milliseconds"],
+ "call" => ["call_cluster_cmd", -3, "host:port command arg arg .. arg"],
"help" => ["help_cluster_cmd", 1, "(show this help)"]
}