Permalink
Browse files

Add a flush command to gizzmo.

  • Loading branch information...
1 parent d1b3a2d commit b3d8b7f93b4878a5e1bc9a31c023aedc4204484c Ed Ceaser committed Sep 9, 2010
Showing with 31 additions and 7 deletions.
  1. +1 −1 VERSION
  2. +2 −2 gizzmo.gemspec
  3. +12 −0 lib/gizzard/commands.rb
  4. +12 −3 lib/gizzmo.rb
  5. +4 −1 test/test.sh
View
@@ -1 +1 @@
-0.7.2
+0.7.3
View
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = %q{gizzmo}
- s.version = "0.7.2"
+ s.version = "0.7.3"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Kyle Maxwell"]
- s.date = %q{2010-09-02}
+ s.date = %q{2010-09-08}
s.default_executable = %q{gizzmo}
s.description = %q{Gizzmo is a command-line client for managing gizzard clusters.}
s.email = %q{kmaxwell@twitter.com}
View
@@ -527,4 +527,16 @@ def run
STDERR.print "\n"
end
end
+
+ class FlushCommand < JobCommand
+ def run
+ args = @argv[0]
+ help!("Requires --all, or a job priority id.") unless args || command_options.flush_all
+ if command_options.flush_all
+ service.retry_errors()
+ else
+ service.retry_errors_for(args.to_i)
+ end
+ end
+ end
end
View
@@ -10,7 +10,8 @@ class HelpNeededError < RuntimeError; end
"create" => "Create shard(s) of a given Java/Scala class. If you don't know the list of available classes, you can just try a bogus class, and the exception will include a list of valid classes.",
"wrap" => "Wrapping creates a new (virtual, e.g. blocking, replicating, etc.) shard, and relinks SHARD_ID_TO_WRAP's parent links to run through the new shard.",
"inject" => "Inject jobs (as literal json) into the server. Jobs can be linefeed-terminated from stdin, or passed as arguments. Priority is server-defined, but typically lower numbers (like 1) are lower priority.",
- "lookup" => "Lookup the shard id that holds the record for a given table / source_id."
+ "lookup" => "Lookup the shard id that holds the record for a given table / source_id.",
+ "flush" => "Flush error queue for a given priority."
}
ORIGINAL_ARGV = ARGV.dup
@@ -196,6 +197,14 @@ def separators(opts, string)
'inject' => OptionParser.new do |opts|
opts.banner = "Usage: #{zero} inject PRIORITY JOBS..."
separators(opts, DOC_STRINGS["inject"])
+ end,
+ 'flush' => OptionParser.new do |opts|
+ opts.banner = "Usage: #{zero} flush --all|PRIORITY"
+ separators(opts, DOC_STRINGS["flush"])
+
+ opts.on("--all", "Flush all error queues.") do
+ subcommand_options.flush_all = true
+ end
end
}
@@ -235,7 +244,7 @@ def separators(opts, string)
end
opts.on("-P", "--port=PORT", "PORT of remote thrift service") do |port|
- global_options.port = port
+ global_options.port = port.to_i
end
opts.on("-r", "--retry=TIMES", "TIMES to retry the command") do |r|
@@ -346,4 +355,4 @@ def process_nested_parsers(global, subcommands)
# seeing the backtrace is annoying!
rescue Interrupt
exit 1
-end
+end
View
@@ -73,4 +73,7 @@ do
g addlink "localhost/table_deep_repl_$last" "localhost/table_deep_repl_$i" 2
done
-g subtree localhost/table_deep_repl_5 | expect deep.txt
+g subtree localhost/table_deep_repl_5 | expect deep.txt
+
+g flush --all
+g flush 1

0 comments on commit b3d8b7f

Please sign in to comment.