Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add back forwardings filter by table_id. more robust retry

  • Loading branch information...
commit 323f84ea3749025421ca3975a2f15f2c6c721cd4 1 parent 411cec7
@freels freels authored
Showing with 12 additions and 10 deletions.
  1. +4 −4 lib/gizzard/commands.rb
  2. +8 −6 lib/gizzard/nameserver.rb
View
8 lib/gizzard/commands.rb
@@ -41,13 +41,13 @@ def output(string)
end
end
end
-
+
class RetryProxy
def initialize(retries, object)
@inner = object
@retries_left = retries
end
-
+
def method_missing(*args)
@inner.send(*args)
rescue
@@ -63,7 +63,7 @@ def method_missing(*args)
class ShardCommand < Command
def self.make_service(global_options, log)
- RetryProxy.new global_options.retry.to_i,
+ RetryProxy.new global_options.retry.to_i,
Gizzard::Thrift::ShardManager.new(global_options.host, global_options.port, log, global_options.dry)
end
end
@@ -680,7 +680,7 @@ def self.make_service(global_options, log)
def run
puts "querying nameserver..."
table_id = (@argv.first || 0).to_i
- templates = nameserver.manifest.templates.inject({}) do |h, (t, fs)|
+ templates = nameserver.manifest(table_id).templates.inject({}) do |h, (t, fs)|
h.update t.to_config.inspect => fs
end
View
14 lib/gizzard/nameserver.rb
@@ -2,8 +2,8 @@ module Gizzard
class Nameserver
DEFAULT_PORT = 7917
- RETRIES = 3
- PARALLELISM = 20
+ RETRIES = 20
+ PARALLELISM = 10
attr_reader :hosts, :logfile, :dryrun
alias dryrun? dryrun
@@ -68,8 +68,8 @@ def method_missing(method, *args, &block)
client.respond_to?(method) ? with_retry { client.send(method, *args, &block) } : super
end
- def manifest
- Manifest.new(self)
+ def manifest(table_id=nil)
+ Manifest.new(self, table_id)
end
private
@@ -95,7 +95,7 @@ def with_retry
yield
rescue ThriftClient::Simple::ThriftException, NoMethodError
times -= 1
- (times < 0) ? raise : (sleep 0.1; retry)
+ (times < 0) ? raise : (sleep 2; retry)
end
@@ -109,9 +109,11 @@ def id; info.id; end
class Manifest
attr_reader :forwardings, :links, :shard_infos, :trees, :templates
- def initialize(nameserver)
+ def initialize(nameserver, table_id=nil)
@forwardings = nameserver.get_forwardings
+ @forwardings.reject! {|f| f.table_id != table_id } if table_id
+
@links = nameserver.get_all_links(forwardings).inject({}) do |h, link|
(h[link.up_id] ||= []) << [link.down_id, link.weight]; h
end

0 comments on commit 323f84e

Please sign in to comment.
Something went wrong with that request. Please try again.