[ https://issues.apache.org/jira/browse/THRIFT-1312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13095471#comment-13095471 ]
Bryan Duxbury commented on THRIFT-1312: --------------------------------------- When I run "rake spec", I get: {code} /Users/bryanduxbury/projects/thrift/thrift-trunk/lib/rb/spec/spec_helper.rb:54: warning: already initialized constant COMPACT_PROTOCOL_TEST_STRUCT ./spec/thrift/server/mutexable_thread_pool_server_spec.rb:3: uninitialized constant Thrift::MutexableThreadPoolServer (NameError) from /Users/bryanduxbury/.rvm/gems/ruby-1.8.7-p330/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:15:in `load' from /Users/bryanduxbury/.rvm/gems/ruby-1.8.7-p330/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:15:in `load_files' from /Users/bryanduxbury/.rvm/gems/ruby-1.8.7-p330/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:14:in `each' from /Users/bryanduxbury/.rvm/gems/ruby-1.8.7-p330/gems/rspec-1.3.2/lib/spec/runner/example_group_runner.rb:14:in `load_files' from /Users/bryanduxbury/.rvm/gems/ruby-1.8.7-p330/gems/rspec-1.3.2/lib/spec/runner/options.rb:134:in `run_examples' from /Users/bryanduxbury/.rvm/gems/ruby-1.8.7-p330/gems/rspec-1.3.2/lib/spec/runner/command_line.rb:9:in `run' from /Users/bryanduxbury/.rvm/gems/ruby-1.8.7-p330/gems/rspec-1.3.2/bin/spec:5 rake aborted! {code} > Add MutexableThreadPoolServer and ProcessPoolServer > --------------------------------------------------- > > Key: THRIFT-1312 > URL: https://issues.apache.org/jira/browse/THRIFT-1312 > Project: Thrift > Issue Type: New Feature > Components: Ruby - Library > Affects Versions: 0.7 > Reporter: Scott Gonyea > Fix For: 0.8 > > Attachments: thrift-1312.patch, thrift-1312.patch > > > Hi, this feature request adds the verbosely-named "MutexableThreadPoolServer" > and "ProcessPoolServer" to the Thrift Ruby Library. > The MutexableThreadPoolServer (MTPServer) contains a thorough set of tests, > as well as an example file that demonstrates its use. > Below is a lengthy description of how we make use of the MTPServer. But > before getting into that, you can find the code here, or in the included > patch. > https://github.com/sgonyea/thrift/tree/mtps/lib/rb > This draws very heavily from the ThreadPoolServer, except that it introduces > the use of Mutexes as one way to stop the server from spawning threads. > Further, it offers a #stop_threads method, that will check the state of each > thread and release control once all threads have finished serving requests to > clients. > Internally, this MTPServer is used in conjunction with HAProxy to shut down > and start up, cleanly, and to avoid all sorts of crazy race conditions that > often arise when serving over a raw socket. > When the MTPServer is started, it will fill the ThreadPool with N threads. > Once done, it is ready to receive requests and will yield to a callback if > one is supplied. In this callback, we call out to HAProxy and signal that we > are ready to begin accepting connections from API clients. > The parent application can be setup to trap any signals, as we do, and to > then lock the mutex (to prevent new threads from pooling). It then calls > @server.stop_threads. It also spins off another thread that will hard shut > down the server if Threads continue past an arbitrary amount of time. > The other benefit in using HAProxy is that it will close connections from > clients, if they are idle for some period of time. This prevents another > common issue, where a client remains connected and causes our Thread to > block, until the sun explodes. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira