Permalink
Browse files

Catch connection exceptions, and display at the end

  • Loading branch information...
1 parent 2a1d892 commit 19198389f2d418cfa6ba3650bcc350cc4e1b9cd4 @stuhood stuhood committed Apr 5, 2012
Showing with 25 additions and 8 deletions.
  1. +25 −8 lib/gizzard/nameserver.rb
View
@@ -155,18 +155,35 @@ def command_log(name, create)
def validate_clients_or_raise
last_client_host = nil
last_client_hostset = nil
+ host_errors = []
# linear equality comparison for the host sets of each appserver
all_clients.map do |client|
- this_client_hostset = client.list_hostnames.inject({}) do |hostnames, hostname|
- hostnames[hostname] = true
- hostnames
- end
- if last_client_hostset != nil && this_client_hostset != last_client_hostset
- raise "App-servers #{last_client_host} and #{client.get_host} disagree on the set" +
+ begin
+ this_client_hostset = client.list_hostnames.inject({}) do |hostnames, hostname|
+ hostnames[hostname] = true
+ hostnames
+ end
+ if last_client_hostset != nil && this_client_hostset != last_client_hostset
+ err = "Disagrees with #{last_client_host} on the set" +
" of shard hosts: #{last_client_hostset.keys} vs #{this_client_hostset.keys}"
+ host_errors << [client.get_host, err]
+ else
+ last_client_host = client.get_host
+ last_client_hostset = this_client_hostset
+ end
+ rescue Exception => e
+ # record and skip the host
+ host_errors << [client.get_host, e.inspect]
+ next
+ end
+ end
+ # display errors
+ if !host_errors.empty?
+ puts "Hosts had errors:"
+ host_errors.each do |host, error|
+ puts "\t#{host}: #{error}"
end
- last_client_host = client.get_host
- last_client_hostset = this_client_hostset
+ exit 1
end
end

0 comments on commit 1919838

Please sign in to comment.