You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by kc...@apache.org on 2008/06/18 03:18:47 UTC
svn commit: r669021 - in /incubator/thrift/trunk/lib/rb/benchmark:
fairness.rb thin_server.rb
Author: kclark
Date: Tue Jun 17 18:18:47 2008
New Revision: 669021
URL: http://svn.apache.org/viewvc?rev=669021&view=rev
Log:
rb: Tweak the benchmark to allow running the server in a separate process
Add a thin server library that can be run by hand
Added:
incubator/thrift/trunk/lib/rb/benchmark/thin_server.rb
Modified:
incubator/thrift/trunk/lib/rb/benchmark/fairness.rb
Modified: incubator/thrift/trunk/lib/rb/benchmark/fairness.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/benchmark/fairness.rb?rev=669021&r1=669020&r2=669021&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/benchmark/fairness.rb (original)
+++ incubator/thrift/trunk/lib/rb/benchmark/fairness.rb Tue Jun 17 18:18:47 2008
@@ -31,6 +31,7 @@
end
def self.start_server(serverClass, trans = nil)
+ return if serverClass == Object
handler = BenchmarkHandler.new
processor = ThriftBenchmark::BenchmarkService::Processor.new(handler)
transport = trans || ServerSocket.new(HOST, PORT)
@@ -49,6 +50,7 @@
end
def self.shutdown
+ return if @server.nil?
if @server.respond_to? :shutdown
@server.shutdown
else
Added: incubator/thrift/trunk/lib/rb/benchmark/thin_server.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/benchmark/thin_server.rb?rev=669021&view=auto
==============================================================================
--- incubator/thrift/trunk/lib/rb/benchmark/thin_server.rb (added)
+++ incubator/thrift/trunk/lib/rb/benchmark/thin_server.rb Tue Jun 17 18:18:47 2008
@@ -0,0 +1,25 @@
+$:.unshift File.dirname(__FILE__) + '/../lib'
+require 'thrift'
+require 'thrift/server/nonblockingserver'
+$:.unshift File.dirname(__FILE__) + "/gen-rb"
+require 'BenchmarkService'
+HOST = 'localhost'
+PORT = 42587
+
+class BenchmarkHandler
+ # 1-based index into the fibonacci sequence
+ def fibonacci(n)
+ seq = [1, 1]
+ 3.upto(n) do
+ seq << seq[-1] + seq[-2]
+ end
+ seq[n-1] # n is 1-based
+ end
+end
+
+handler = BenchmarkHandler.new
+processor = ThriftBenchmark::BenchmarkService::Processor.new(handler)
+transport = Thrift::ServerSocket.new(HOST, PORT)
+transportFactory = Thrift::FramedTransportFactory.new
+Thrift::NonblockingServer.new(processor, transport, transportFactory).serve
+