David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
Mark Slee | 9f0c651 | 2007-02-28 23:58:26 +0000 | [diff] [blame] | 19 | |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 20 | #ifndef _THRIFT_SERVER_TSERVER_H_ |
| 21 | #define _THRIFT_SERVER_TSERVER_H_ 1 |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 22 | |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 23 | #include <TProcessor.h> |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 24 | #include <transport/TServerTransport.h> |
Mark Slee | 4af6ed7 | 2006-10-25 19:02:49 +0000 | [diff] [blame] | 25 | #include <protocol/TBinaryProtocol.h> |
Marc Slemko | 3ea0033 | 2006-08-17 01:11:13 +0000 | [diff] [blame] | 26 | #include <concurrency/Thread.h> |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 27 | |
| 28 | #include <boost/shared_ptr.hpp> |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 29 | |
T Jake Luciani | b5e6221 | 2009-01-31 22:36:20 +0000 | [diff] [blame] | 30 | namespace apache { namespace thrift { namespace server { |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 31 | |
T Jake Luciani | b5e6221 | 2009-01-31 22:36:20 +0000 | [diff] [blame] | 32 | using apache::thrift::TProcessor; |
| 33 | using apache::thrift::protocol::TBinaryProtocolFactory; |
| 34 | using apache::thrift::protocol::TProtocol; |
| 35 | using apache::thrift::protocol::TProtocolFactory; |
| 36 | using apache::thrift::transport::TServerTransport; |
| 37 | using apache::thrift::transport::TTransport; |
| 38 | using apache::thrift::transport::TTransportFactory; |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 39 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 40 | /** |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 41 | * Virtual interface class that can handle events from the server core. To |
| 42 | * use this you should subclass it and implement the methods that you care |
| 43 | * about. Your subclass can also store local data that you may care about, |
| 44 | * such as additional "arguments" to these methods (stored in the object |
| 45 | * instance's state). |
| 46 | */ |
| 47 | class TServerEventHandler { |
| 48 | public: |
| 49 | |
| 50 | virtual ~TServerEventHandler() {} |
| 51 | |
| 52 | /** |
| 53 | * Called before the server begins. |
| 54 | */ |
| 55 | virtual void preServe() {} |
| 56 | |
| 57 | /** |
| 58 | * Called when a new client has connected and is about to being processing. |
| 59 | */ |
David Reiss | 2324871 | 2010-10-06 17:10:08 +0000 | [diff] [blame] | 60 | virtual void* createContext(boost::shared_ptr<TProtocol> input, |
| 61 | boost::shared_ptr<TProtocol> output) { |
| 62 | (void)input; |
| 63 | (void)output; |
| 64 | return NULL; |
| 65 | } |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 66 | |
| 67 | /** |
David Reiss | 2324871 | 2010-10-06 17:10:08 +0000 | [diff] [blame] | 68 | * Called when a client has finished request-handling to delete server |
| 69 | * context. |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 70 | */ |
David Reiss | 2324871 | 2010-10-06 17:10:08 +0000 | [diff] [blame] | 71 | virtual void deleteContext(void* serverContext, |
| 72 | boost::shared_ptr<TProtocol>input, |
| 73 | boost::shared_ptr<TProtocol>output) { |
| 74 | (void)serverContext; |
| 75 | (void)input; |
| 76 | (void)output; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Called when a client is about to call the processor. |
| 81 | */ |
| 82 | virtual void processContext(void* serverContext, |
| 83 | boost::shared_ptr<TTransport> transport) { |
| 84 | (void)serverContext; |
| 85 | (void)transport; |
| 86 | } |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 87 | |
| 88 | protected: |
| 89 | |
| 90 | /** |
| 91 | * Prevent direct instantiation. |
| 92 | */ |
| 93 | TServerEventHandler() {} |
| 94 | |
| 95 | }; |
| 96 | |
| 97 | /** |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 98 | * Thrift server. |
| 99 | * |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 100 | */ |
Aditya Agarwal | d622e96 | 2006-10-11 02:42:49 +0000 | [diff] [blame] | 101 | class TServer : public concurrency::Runnable { |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 102 | public: |
| 103 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 104 | virtual ~TServer() {} |
Mark Slee | 4af6ed7 | 2006-10-25 19:02:49 +0000 | [diff] [blame] | 105 | |
Mark Slee | 794993d | 2006-09-20 01:56:10 +0000 | [diff] [blame] | 106 | virtual void serve() = 0; |
Aditya Agarwal | d622e96 | 2006-10-11 02:42:49 +0000 | [diff] [blame] | 107 | |
Mark Slee | 6e3f637 | 2007-03-01 22:05:46 +0000 | [diff] [blame] | 108 | virtual void stop() {} |
| 109 | |
Aditya Agarwal | d622e96 | 2006-10-11 02:42:49 +0000 | [diff] [blame] | 110 | // Allows running the server as a Runnable thread |
Mark Slee | 4af6ed7 | 2006-10-25 19:02:49 +0000 | [diff] [blame] | 111 | virtual void run() { |
| 112 | serve(); |
| 113 | } |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 114 | |
Bryan Duxbury | 6dd9cd0 | 2011-09-01 18:06:20 +0000 | [diff] [blame] | 115 | boost::shared_ptr<TProcessorFactory> getProcessorFactory() { |
| 116 | return processorFactory_; |
Mark Slee | 2f6404d | 2006-10-10 01:37:40 +0000 | [diff] [blame] | 117 | } |
Aditya Agarwal | 1ea9052 | 2007-01-19 02:02:12 +0000 | [diff] [blame] | 118 | |
Mark Slee | 5ea15f9 | 2007-03-05 22:55:59 +0000 | [diff] [blame] | 119 | boost::shared_ptr<TServerTransport> getServerTransport() { |
Aditya Agarwal | 1ea9052 | 2007-01-19 02:02:12 +0000 | [diff] [blame] | 120 | return serverTransport_; |
| 121 | } |
| 122 | |
Mark Slee | 5ea15f9 | 2007-03-05 22:55:59 +0000 | [diff] [blame] | 123 | boost::shared_ptr<TTransportFactory> getInputTransportFactory() { |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 124 | return inputTransportFactory_; |
| 125 | } |
| 126 | |
Mark Slee | 5ea15f9 | 2007-03-05 22:55:59 +0000 | [diff] [blame] | 127 | boost::shared_ptr<TTransportFactory> getOutputTransportFactory() { |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 128 | return outputTransportFactory_; |
Aditya Agarwal | 1ea9052 | 2007-01-19 02:02:12 +0000 | [diff] [blame] | 129 | } |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 130 | |
Mark Slee | 5ea15f9 | 2007-03-05 22:55:59 +0000 | [diff] [blame] | 131 | boost::shared_ptr<TProtocolFactory> getInputProtocolFactory() { |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 132 | return inputProtocolFactory_; |
Mark Slee | 4af6ed7 | 2006-10-25 19:02:49 +0000 | [diff] [blame] | 133 | } |
| 134 | |
Mark Slee | 5ea15f9 | 2007-03-05 22:55:59 +0000 | [diff] [blame] | 135 | boost::shared_ptr<TProtocolFactory> getOutputProtocolFactory() { |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 136 | return outputProtocolFactory_; |
| 137 | } |
Aditya Agarwal | 1ea9052 | 2007-01-19 02:02:12 +0000 | [diff] [blame] | 138 | |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 139 | boost::shared_ptr<TServerEventHandler> getEventHandler() { |
| 140 | return eventHandler_; |
| 141 | } |
| 142 | |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 143 | protected: |
Bryan Duxbury | 7a9fb81 | 2011-09-01 18:31:53 +0000 | [diff] [blame^] | 144 | template<typename ProcessorFactory> |
| 145 | TServer(const boost::shared_ptr<TProcessorFactory>& processorFactory, |
| 146 | THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)): |
| 147 | processorFactory_(processorFactory_) { |
| 148 | setInputTransportFactory(boost::shared_ptr<TTransportFactory>( |
| 149 | new TTransportFactory())); |
| 150 | setOutputTransportFactory(boost::shared_ptr<TTransportFactory>( |
| 151 | new TTransportFactory())); |
| 152 | setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>( |
| 153 | new TBinaryProtocolFactory())); |
| 154 | setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>( |
| 155 | new TBinaryProtocolFactory())); |
| 156 | } |
| 157 | |
| 158 | template<typename Processor> |
| 159 | TServer(const boost::shared_ptr<Processor>& processor, |
| 160 | THRIFT_OVERLOAD_IF(Processor, TProcessor)): |
Bryan Duxbury | 6dd9cd0 | 2011-09-01 18:06:20 +0000 | [diff] [blame] | 161 | processorFactory_(new TSingletonProcessorFactory(processor)) { |
Mark Slee | 5ea15f9 | 2007-03-05 22:55:59 +0000 | [diff] [blame] | 162 | setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory())); |
| 163 | setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory())); |
| 164 | setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); |
| 165 | setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 166 | } |
| 167 | |
Bryan Duxbury | 7a9fb81 | 2011-09-01 18:31:53 +0000 | [diff] [blame^] | 168 | template<typename ProcessorFactory> |
| 169 | TServer(const boost::shared_ptr<TProcessorFactory>& processorFactory, |
| 170 | const boost::shared_ptr<TServerTransport>& serverTransport, |
| 171 | THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)): |
| 172 | processorFactory_(processorFactory), |
| 173 | serverTransport_(serverTransport) { |
| 174 | setInputTransportFactory(boost::shared_ptr<TTransportFactory>( |
| 175 | new TTransportFactory())); |
| 176 | setOutputTransportFactory(boost::shared_ptr<TTransportFactory>( |
| 177 | new TTransportFactory())); |
| 178 | setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>( |
| 179 | new TBinaryProtocolFactory())); |
| 180 | setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>( |
| 181 | new TBinaryProtocolFactory())); |
| 182 | } |
| 183 | |
| 184 | template<typename Processor> |
| 185 | TServer(const boost::shared_ptr<Processor>& processor, |
| 186 | const boost::shared_ptr<TServerTransport>& serverTransport, |
| 187 | THRIFT_OVERLOAD_IF(Processor, TProcessor)): |
Bryan Duxbury | 6dd9cd0 | 2011-09-01 18:06:20 +0000 | [diff] [blame] | 188 | processorFactory_(new TSingletonProcessorFactory(processor)), |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 189 | serverTransport_(serverTransport) { |
Mark Slee | 5ea15f9 | 2007-03-05 22:55:59 +0000 | [diff] [blame] | 190 | setInputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory())); |
| 191 | setOutputTransportFactory(boost::shared_ptr<TTransportFactory>(new TTransportFactory())); |
| 192 | setInputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); |
| 193 | setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 194 | } |
| 195 | |
Bryan Duxbury | 7a9fb81 | 2011-09-01 18:31:53 +0000 | [diff] [blame^] | 196 | template<typename ProcessorFactory> |
| 197 | TServer(const boost::shared_ptr<ProcessorFactory>& processorFactory, |
| 198 | const boost::shared_ptr<TServerTransport>& serverTransport, |
| 199 | const boost::shared_ptr<TTransportFactory>& transportFactory, |
| 200 | const boost::shared_ptr<TProtocolFactory>& protocolFactory, |
| 201 | THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)): |
| 202 | processorFactory_(processorFactory), |
| 203 | serverTransport_(serverTransport), |
| 204 | inputTransportFactory_(transportFactory), |
| 205 | outputTransportFactory_(transportFactory), |
| 206 | inputProtocolFactory_(protocolFactory), |
| 207 | outputProtocolFactory_(protocolFactory) {} |
| 208 | |
| 209 | template<typename Processor> |
| 210 | TServer(const boost::shared_ptr<Processor>& processor, |
| 211 | const boost::shared_ptr<TServerTransport>& serverTransport, |
| 212 | const boost::shared_ptr<TTransportFactory>& transportFactory, |
| 213 | const boost::shared_ptr<TProtocolFactory>& protocolFactory, |
| 214 | THRIFT_OVERLOAD_IF(Processor, TProcessor)): |
Bryan Duxbury | 6dd9cd0 | 2011-09-01 18:06:20 +0000 | [diff] [blame] | 215 | processorFactory_(new TSingletonProcessorFactory(processor)), |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 216 | serverTransport_(serverTransport), |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 217 | inputTransportFactory_(transportFactory), |
| 218 | outputTransportFactory_(transportFactory), |
| 219 | inputProtocolFactory_(protocolFactory), |
| 220 | outputProtocolFactory_(protocolFactory) {} |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 221 | |
Bryan Duxbury | 7a9fb81 | 2011-09-01 18:31:53 +0000 | [diff] [blame^] | 222 | template<typename ProcessorFactory> |
| 223 | TServer(const boost::shared_ptr<ProcessorFactory>& processorFactory, |
| 224 | const boost::shared_ptr<TServerTransport>& serverTransport, |
| 225 | const boost::shared_ptr<TTransportFactory>& inputTransportFactory, |
| 226 | const boost::shared_ptr<TTransportFactory>& outputTransportFactory, |
| 227 | const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory, |
| 228 | const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory, |
| 229 | THRIFT_OVERLOAD_IF(ProcessorFactory, TProcessorFactory)): |
| 230 | processorFactory_(processorFactory_), |
| 231 | serverTransport_(serverTransport), |
| 232 | inputTransportFactory_(inputTransportFactory), |
| 233 | outputTransportFactory_(outputTransportFactory), |
| 234 | inputProtocolFactory_(inputProtocolFactory), |
| 235 | outputProtocolFactory_(outputProtocolFactory) {} |
| 236 | |
| 237 | template<typename Processor> |
| 238 | TServer(const boost::shared_ptr<Processor>& processor, |
| 239 | const boost::shared_ptr<TServerTransport>& serverTransport, |
| 240 | const boost::shared_ptr<TTransportFactory>& inputTransportFactory, |
| 241 | const boost::shared_ptr<TTransportFactory>& outputTransportFactory, |
| 242 | const boost::shared_ptr<TProtocolFactory>& inputProtocolFactory, |
| 243 | const boost::shared_ptr<TProtocolFactory>& outputProtocolFactory, |
| 244 | THRIFT_OVERLOAD_IF(Processor, TProcessor)): |
Bryan Duxbury | 6dd9cd0 | 2011-09-01 18:06:20 +0000 | [diff] [blame] | 245 | processorFactory_(new TSingletonProcessorFactory(processor)), |
Mark Slee | 4af6ed7 | 2006-10-25 19:02:49 +0000 | [diff] [blame] | 246 | serverTransport_(serverTransport), |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 247 | inputTransportFactory_(inputTransportFactory), |
| 248 | outputTransportFactory_(outputTransportFactory), |
| 249 | inputProtocolFactory_(inputProtocolFactory), |
| 250 | outputProtocolFactory_(outputProtocolFactory) {} |
Mark Slee | 4af6ed7 | 2006-10-25 19:02:49 +0000 | [diff] [blame] | 251 | |
Bryan Duxbury | 6dd9cd0 | 2011-09-01 18:06:20 +0000 | [diff] [blame] | 252 | /** |
| 253 | * Get a TProcessor to handle calls on a particular connection. |
| 254 | * |
| 255 | * This method should only be called once per connection (never once per |
| 256 | * call). This allows the TProcessorFactory to return a different processor |
| 257 | * for each connection if it desires. |
| 258 | */ |
| 259 | boost::shared_ptr<TProcessor> getProcessor( |
| 260 | boost::shared_ptr<TProtocol> inputProtocol, |
| 261 | boost::shared_ptr<TProtocol> outputProtocol, |
| 262 | boost::shared_ptr<TTransport> transport) { |
| 263 | TConnectionInfo connInfo; |
| 264 | connInfo.input = inputProtocol; |
| 265 | connInfo.output = outputProtocol; |
| 266 | connInfo.transport = transport; |
| 267 | return processorFactory_->getProcessor(connInfo); |
| 268 | } |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 269 | |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 270 | // Class variables |
Bryan Duxbury | 6dd9cd0 | 2011-09-01 18:06:20 +0000 | [diff] [blame] | 271 | boost::shared_ptr<TProcessorFactory> processorFactory_; |
Mark Slee | 5ea15f9 | 2007-03-05 22:55:59 +0000 | [diff] [blame] | 272 | boost::shared_ptr<TServerTransport> serverTransport_; |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 273 | |
Mark Slee | 5ea15f9 | 2007-03-05 22:55:59 +0000 | [diff] [blame] | 274 | boost::shared_ptr<TTransportFactory> inputTransportFactory_; |
| 275 | boost::shared_ptr<TTransportFactory> outputTransportFactory_; |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 276 | |
Mark Slee | 5ea15f9 | 2007-03-05 22:55:59 +0000 | [diff] [blame] | 277 | boost::shared_ptr<TProtocolFactory> inputProtocolFactory_; |
| 278 | boost::shared_ptr<TProtocolFactory> outputProtocolFactory_; |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 279 | |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 280 | boost::shared_ptr<TServerEventHandler> eventHandler_; |
| 281 | |
David Reiss | ef22dc6 | 2007-11-30 20:38:49 +0000 | [diff] [blame] | 282 | public: |
Mark Slee | 5ea15f9 | 2007-03-05 22:55:59 +0000 | [diff] [blame] | 283 | void setInputTransportFactory(boost::shared_ptr<TTransportFactory> inputTransportFactory) { |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 284 | inputTransportFactory_ = inputTransportFactory; |
| 285 | } |
| 286 | |
Mark Slee | 5ea15f9 | 2007-03-05 22:55:59 +0000 | [diff] [blame] | 287 | void setOutputTransportFactory(boost::shared_ptr<TTransportFactory> outputTransportFactory) { |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 288 | outputTransportFactory_ = outputTransportFactory; |
| 289 | } |
| 290 | |
Mark Slee | 5ea15f9 | 2007-03-05 22:55:59 +0000 | [diff] [blame] | 291 | void setInputProtocolFactory(boost::shared_ptr<TProtocolFactory> inputProtocolFactory) { |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 292 | inputProtocolFactory_ = inputProtocolFactory; |
| 293 | } |
| 294 | |
Mark Slee | 5ea15f9 | 2007-03-05 22:55:59 +0000 | [diff] [blame] | 295 | void setOutputProtocolFactory(boost::shared_ptr<TProtocolFactory> outputProtocolFactory) { |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 296 | outputProtocolFactory_ = outputProtocolFactory; |
| 297 | } |
| 298 | |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 299 | void setServerEventHandler(boost::shared_ptr<TServerEventHandler> eventHandler) { |
| 300 | eventHandler_ = eventHandler; |
| 301 | } |
| 302 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 303 | }; |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 304 | |
veeve | 01d187c | 2008-02-26 05:12:08 +0000 | [diff] [blame] | 305 | /** |
| 306 | * Helper function to increase the max file descriptors limit |
| 307 | * for the current process and all of its children. |
| 308 | * By default, tries to increase it to as much as 2^24. |
| 309 | */ |
| 310 | int increase_max_fds(int max_fds=(1<<24)); |
| 311 | |
| 312 | |
T Jake Luciani | b5e6221 | 2009-01-31 22:36:20 +0000 | [diff] [blame] | 313 | }}} // apache::thrift::server |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 314 | |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 315 | #endif // #ifndef _THRIFT_SERVER_TSERVER_H_ |