lib/gizzmo.rb in gizzmo-0.7.0 vs lib/gizzmo.rb in gizzmo-0.7.4

- old
+ new

@@ -7,11 +7,13 @@ require "yaml" DOC_STRINGS = { "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." + "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.", + "flush" => "Flush error queue for a given priority." } ORIGINAL_ARGV = ARGV.dup zero = File.basename($0) @@ -82,10 +84,14 @@ end, 'rebalance' => OptionParser.new do |opts| opts.banner = "Usage: #{zero} rebalance" separators(opts, DOC_STRINGS["rebalance"]) + opts.on("-w", "--write-only=CLASS") do |w| + subcommand_options.write_only_shard = w + end + opts.on("-h", "--hosts=list") do |h| subcommand_options.hosts = h end end, 'repair' => OptionParser.new do |opts| @@ -126,10 +132,13 @@ opts.on("-t", "--tables=IDS", "Show only the specified table ids (comma separated)") do |table_ids| subcommand_options.table_ids ||= [] subcommand_options.table_ids += table_ids.split(",").map { |s| s.to_i } end + opts.on("-x", "--hex", "Show base ids in hex") do + subcommand_options.hex = true + end end, 'unwrap' => OptionParser.new do |opts| opts.banner = "Usage: #{zero} unwrap SHARD_ID_TO_REMOVE [MORE SHARD_IDS]" separators(opts, DOC_STRINGS["unwrap"]) end, @@ -156,20 +165,24 @@ 'reload' => OptionParser.new do |opts| opts.banner = "Usage: #{zero} reload" separators(opts, DOC_STRINGS["reload"]) end, 'addlink' => OptionParser.new do |opts| - opts.banner = "Usage: #{zero} link PARENT_SHARD_ID CHILD_SHARD_ID WEIGHT" + opts.banner = "Usage: #{zero} addlink PARENT_SHARD_ID WEIGHT" separators(opts, DOC_STRINGS["addlink"]) end, 'unlink' => OptionParser.new do |opts| opts.banner = "Usage: #{zero} unlink PARENT_SHARD_ID CHILD_SHARD_ID" separators(opts, DOC_STRINGS["unlink"]) end, 'lookup' => OptionParser.new do |opts| - opts.banner = "Usage: #{zero} lookup TABLE_ID SOURCE_ID" + opts.banner = "Usage: #{zero} lookup [options] TABLE_ID SOURCE" separators(opts, DOC_STRINGS["lookup"]) + + opts.on("--fnv", "Use FNV1A_64 hash on source") do + subcommand_options.hash_function = :fnv + end end, 'copy' => OptionParser.new do |opts| opts.banner = "Usage: #{zero} copy SOURCE_SHARD_ID DESTINATION_SHARD_ID" separators(opts, DOC_STRINGS["copy"]) end, @@ -186,10 +199,18 @@ separators(opts, DOC_STRINGS["finish-migrate"]) end, '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 } global = OptionParser.new do |opts| opts.banner = "Usage: #{zero} [global-options] SUBCOMMAND [subcommand-options]" @@ -225,11 +246,11 @@ opts.on("-H", "--host=HOSTNAME", "HOSTNAME of remote thrift service") do |host| global_options.host = host 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| global_options.retry = r end @@ -336,6 +357,6 @@ # This is just us trying to puts into a closed stdout. For example, if you pipe into # head -1, then this script will keep running after head closes. We don't care, and # seeing the backtrace is annoying! rescue Interrupt exit 1 -end \ No newline at end of file +end