gizzmo 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.6.0
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{gizzmo}
8
- s.version = "0.5.0"
8
+ s.version = "0.6.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kyle Maxwell"]
@@ -229,6 +229,28 @@ module Gizzard
229
229
  end
230
230
  end
231
231
  end
232
+
233
+ class RepairCommand < ShardCommand
234
+ def run
235
+ args = @argv.dup.map{|a| a.split(/\s+/)}.flatten
236
+ pairs = []
237
+ loop do
238
+ a = args.shift
239
+ b = args.shift
240
+ break unless a && b
241
+ pairs << [a, b]
242
+ end
243
+ pairs.each do |master, slave|
244
+ puts "#{master} #{slave}"
245
+ mprefixes = service.shards_for_hostname(master).map{|s| s.id.table_prefix}
246
+ sprefixes = service.shards_for_hostname(slave).map{|s| s.id.table_prefix}
247
+ delta = mprefixes - sprefixes
248
+ delta.each do |prefix|
249
+ puts "gizzmo copy #{master}/#{prefix} #{slave}/#{prefix}"
250
+ end
251
+ end
252
+ end
253
+ end
232
254
 
233
255
  class WrapCommand < ShardCommand
234
256
  def self.derive_wrapper_shard_id(shard_info, wrapping_class_name)
@@ -267,12 +289,18 @@ module Gizzard
267
289
  end
268
290
 
269
291
  def run
292
+ puts command_options.inspect
293
+ additional_hosts = (command_options.hosts || "").split(/[\s,]+/)
270
294
  ids = @argv.map{|arg| ShardId.new(*arg.split("/")) rescue nil }.compact
271
295
  by_host = ids.inject({}) do |memo, id|
272
296
  memo[id.hostname] ||= NamedArray.new(id.hostname)
273
297
  memo[id.hostname] << id
274
298
  memo
275
299
  end
300
+
301
+ additional_hosts.each do |host|
302
+ by_host[host] ||= NamedArray.new(host)
303
+ end
276
304
 
277
305
  sets = by_host.values
278
306
 
@@ -284,6 +312,7 @@ module Gizzard
284
312
  end while longest.length > shortest.length + 1
285
313
 
286
314
  shard_info = nil
315
+ puts sets.map{|l|l.length}.inspect
287
316
  sets.each do |set|
288
317
  host = set.name
289
318
  set.each do |id|
@@ -291,9 +320,8 @@ module Gizzard
291
320
  shard_info ||= service.get_shard(id)
292
321
  old = id.to_unix
293
322
  id.hostname = host
294
- puts "gizzmo create #{shard_info.class_name} -s '#{shard_info.source_type}' -d '#{shard_info.destination_type}' #{old}"
323
+ puts "gizzmo create #{shard_info.class_name} -s '#{shard_info.source_type}' -d '#{shard_info.destination_type}' #{id.to_unix}"
295
324
  puts "gizzmo copy #{old} #{id.to_unix}"
296
- puts "gizzmo delete #{old}"
297
325
  end
298
326
  end
299
327
  end
@@ -81,8 +81,16 @@ subcommands = {
81
81
  separators(opts, DOC_STRINGS["report"])
82
82
  end,
83
83
  'rebalance' => OptionParser.new do |opts|
84
- opts.banner = "Usage: #{zero} rebalance RUBY_REGEX"
84
+ opts.banner = "Usage: #{zero} rebalance"
85
85
  separators(opts, DOC_STRINGS["rebalance"])
86
+
87
+ opts.on("-h", "--hosts=list") do |h|
88
+ subcommand_options.hosts = h
89
+ end
90
+ end,
91
+ 'repair' => OptionParser.new do |opts|
92
+ opts.banner = "Usage: #{zero} repair MASTER SLAVE [MASTER SLAVE...]"
93
+ separators(opts, DOC_STRINGS["repair"])
86
94
  end,
87
95
  'pair' => OptionParser.new do |opts|
88
96
  opts.banner = "Usage: #{zero} pair"
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 5
7
+ - 6
8
8
  - 0
9
- version: 0.5.0
9
+ version: 0.6.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kyle Maxwell