Permalink
Browse files

Reuse connections, and bump the number of server threads, in order to…

… avoid proper cleanup for now.
  • Loading branch information...
1 parent 16fb071 commit e0c01e81ee0dbfa01364123b5e68ce3d14a7c674 @stuhood stuhood committed May 9, 2012
@@ -303,7 +303,7 @@ def with_retry(opname, min_backoff_secs)
times ||= @retries
yield
rescue Exception => e
- STDERR.puts "\nException for #{opname}: #{e.class}: #{e.description rescue "(no description)"}"
+ STDERR.puts "\nException for #{opname}: #{e.to_s}: #{e.description rescue "(no description)"}"
STDERR.puts "Retrying #{times} more time#{'s' if times > 1}..." if times > 0
times -= 1
sleep_time = [min_backoff_secs, MAX_BACKOFF_SECS / [times, 1].max].max
@@ -321,11 +321,18 @@ def _proxy(method_name, *args)
cls = self.class.ancestors.find { |cls| cls.respond_to?(:_arg_structs) and cls._arg_structs[method_name.to_sym] }
arg_class, rv_class = cls._arg_structs[method_name.to_sym]
arg_struct = arg_class.new(*args)
- sock = TCPSocket.new(@host, @port)
- sock.write(ThriftClient::Simple.pack_request(method_name, arg_struct, @framed))
- rv = ThriftClient::Simple.read_response(sock, rv_class, @framed)
- sock.close
- rv[2]
+ @sock ||= TCPSocket.new(@host, @port)
+ begin
+ packed = ThriftClient::Simple.pack_request(method_name, arg_struct, @framed)
+ wrote = @sock.write(packed)
+ rv = ThriftClient::Simple.read_response(@sock, rv_class, @framed)
+ rv[2]
+ rescue Exception => e
+ # attempt to close the socket and nil it, then re-raise the original exception
+ begin; @sock.close; rescue; end
+ @sock = nil
+ raise e
+ end
end
# convenience. robey is lazy.
@@ -80,6 +80,7 @@ package object config {
nameServerReplicas = testNameServerReplicas(name)
jobInjector.port = iPort
manager.port = mPort
+ manager.threadPool.minThreads = 10
val server = new TestTHsHaServer { val name = "TestGizzardService"; val port = sPort }
val databaseConnection = new TestDBConnection { val database = "gizzard_test_" + name }

0 comments on commit e0c01e8

Please sign in to comment.