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 | |
Roger Meier | 49ff8b1 | 2012-04-13 09:12:31 +0000 | [diff] [blame] | 23 | #include <thrift/TProcessor.h> |
| 24 | #include <thrift/transport/TServerTransport.h> |
| 25 | #include <thrift/protocol/TBinaryProtocol.h> |
| 26 | #include <thrift/concurrency/Thread.h> |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 27 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 28 | #include <memory> |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 29 | |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 30 | namespace apache { |
| 31 | namespace thrift { |
| 32 | namespace server { |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 33 | |
T Jake Luciani | b5e6221 | 2009-01-31 22:36:20 +0000 | [diff] [blame] | 34 | using apache::thrift::TProcessor; |
| 35 | using apache::thrift::protocol::TBinaryProtocolFactory; |
| 36 | using apache::thrift::protocol::TProtocol; |
| 37 | using apache::thrift::protocol::TProtocolFactory; |
| 38 | using apache::thrift::transport::TServerTransport; |
| 39 | using apache::thrift::transport::TTransport; |
| 40 | using apache::thrift::transport::TTransportFactory; |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 41 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 42 | /** |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 43 | * Virtual interface class that can handle events from the server core. To |
| 44 | * use this you should subclass it and implement the methods that you care |
| 45 | * about. Your subclass can also store local data that you may care about, |
| 46 | * such as additional "arguments" to these methods (stored in the object |
| 47 | * instance's state). |
| 48 | */ |
| 49 | class TServerEventHandler { |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 50 | public: |
Sebastian Zenker | 042580f | 2019-01-29 15:48:12 +0100 | [diff] [blame] | 51 | virtual ~TServerEventHandler() = default; |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 52 | |
| 53 | /** |
| 54 | * Called before the server begins. |
| 55 | */ |
| 56 | virtual void preServe() {} |
| 57 | |
| 58 | /** |
| 59 | * Called when a new client has connected and is about to being processing. |
| 60 | */ |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 61 | virtual void* createContext(std::shared_ptr<TProtocol> input, |
| 62 | std::shared_ptr<TProtocol> output) { |
David Reiss | 2324871 | 2010-10-06 17:10:08 +0000 | [diff] [blame] | 63 | (void)input; |
| 64 | (void)output; |
Sebastian Zenker | 042580f | 2019-01-29 15:48:12 +0100 | [diff] [blame] | 65 | return nullptr; |
David Reiss | 2324871 | 2010-10-06 17:10:08 +0000 | [diff] [blame] | 66 | } |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 67 | |
| 68 | /** |
David Reiss | 2324871 | 2010-10-06 17:10:08 +0000 | [diff] [blame] | 69 | * Called when a client has finished request-handling to delete server |
| 70 | * context. |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 71 | */ |
David Reiss | 2324871 | 2010-10-06 17:10:08 +0000 | [diff] [blame] | 72 | virtual void deleteContext(void* serverContext, |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 73 | std::shared_ptr<TProtocol> input, |
| 74 | std::shared_ptr<TProtocol> output) { |
David Reiss | 2324871 | 2010-10-06 17:10:08 +0000 | [diff] [blame] | 75 | (void)serverContext; |
| 76 | (void)input; |
| 77 | (void)output; |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * Called when a client is about to call the processor. |
| 82 | */ |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 83 | virtual void processContext(void* serverContext, std::shared_ptr<TTransport> transport) { |
David Reiss | 2324871 | 2010-10-06 17:10:08 +0000 | [diff] [blame] | 84 | (void)serverContext; |
| 85 | (void)transport; |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 86 | } |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 87 | |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 88 | protected: |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 89 | /** |
| 90 | * Prevent direct instantiation. |
| 91 | */ |
Sebastian Zenker | 042580f | 2019-01-29 15:48:12 +0100 | [diff] [blame] | 92 | TServerEventHandler() = default; |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | /** |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 96 | * Thrift server. |
| 97 | * |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 98 | */ |
Aditya Agarwal | d622e96 | 2006-10-11 02:42:49 +0000 | [diff] [blame] | 99 | class TServer : public concurrency::Runnable { |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 100 | public: |
Sebastian Zenker | 042580f | 2019-01-29 15:48:12 +0100 | [diff] [blame] | 101 | ~TServer() override = default; |
Mark Slee | 4af6ed7 | 2006-10-25 19:02:49 +0000 | [diff] [blame] | 102 | |
Mark Slee | 794993d | 2006-09-20 01:56:10 +0000 | [diff] [blame] | 103 | virtual void serve() = 0; |
Aditya Agarwal | d622e96 | 2006-10-11 02:42:49 +0000 | [diff] [blame] | 104 | |
Mark Slee | 6e3f637 | 2007-03-01 22:05:46 +0000 | [diff] [blame] | 105 | virtual void stop() {} |
| 106 | |
Aditya Agarwal | d622e96 | 2006-10-11 02:42:49 +0000 | [diff] [blame] | 107 | // Allows running the server as a Runnable thread |
Sebastian Zenker | 042580f | 2019-01-29 15:48:12 +0100 | [diff] [blame] | 108 | void run() override { serve(); } |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 109 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 110 | std::shared_ptr<TProcessorFactory> getProcessorFactory() { return processorFactory_; } |
Aditya Agarwal | 1ea9052 | 2007-01-19 02:02:12 +0000 | [diff] [blame] | 111 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 112 | std::shared_ptr<TServerTransport> getServerTransport() { return serverTransport_; } |
Aditya Agarwal | 1ea9052 | 2007-01-19 02:02:12 +0000 | [diff] [blame] | 113 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 114 | std::shared_ptr<TTransportFactory> getInputTransportFactory() { return inputTransportFactory_; } |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 115 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 116 | std::shared_ptr<TTransportFactory> getOutputTransportFactory() { |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 117 | return outputTransportFactory_; |
Aditya Agarwal | 1ea9052 | 2007-01-19 02:02:12 +0000 | [diff] [blame] | 118 | } |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 119 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 120 | std::shared_ptr<TProtocolFactory> getInputProtocolFactory() { return inputProtocolFactory_; } |
Mark Slee | 4af6ed7 | 2006-10-25 19:02:49 +0000 | [diff] [blame] | 121 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 122 | std::shared_ptr<TProtocolFactory> getOutputProtocolFactory() { return outputProtocolFactory_; } |
Aditya Agarwal | 1ea9052 | 2007-01-19 02:02:12 +0000 | [diff] [blame] | 123 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 124 | std::shared_ptr<TServerEventHandler> getEventHandler() { return eventHandler_; } |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 125 | |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 126 | protected: |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 127 | TServer(const std::shared_ptr<TProcessorFactory>& processorFactory) |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 128 | : processorFactory_(processorFactory) { |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 129 | setInputTransportFactory(std::shared_ptr<TTransportFactory>(new TTransportFactory())); |
| 130 | setOutputTransportFactory(std::shared_ptr<TTransportFactory>(new TTransportFactory())); |
| 131 | setInputProtocolFactory(std::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); |
| 132 | setOutputProtocolFactory(std::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 133 | } |
| 134 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 135 | TServer(const std::shared_ptr<TProcessor>& processor) |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 136 | : processorFactory_(new TSingletonProcessorFactory(processor)) { |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 137 | setInputTransportFactory(std::shared_ptr<TTransportFactory>(new TTransportFactory())); |
| 138 | setOutputTransportFactory(std::shared_ptr<TTransportFactory>(new TTransportFactory())); |
| 139 | setInputProtocolFactory(std::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); |
| 140 | setOutputProtocolFactory(std::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); |
Konrad Grochowski | 74260aa | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 141 | } |
| 142 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 143 | TServer(const std::shared_ptr<TProcessorFactory>& processorFactory, |
| 144 | const std::shared_ptr<TServerTransport>& serverTransport) |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 145 | : processorFactory_(processorFactory), serverTransport_(serverTransport) { |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 146 | setInputTransportFactory(std::shared_ptr<TTransportFactory>(new TTransportFactory())); |
| 147 | setOutputTransportFactory(std::shared_ptr<TTransportFactory>(new TTransportFactory())); |
| 148 | setInputProtocolFactory(std::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); |
| 149 | setOutputProtocolFactory(std::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 150 | } |
| 151 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 152 | TServer(const std::shared_ptr<TProcessor>& processor, |
| 153 | const std::shared_ptr<TServerTransport>& serverTransport) |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 154 | : processorFactory_(new TSingletonProcessorFactory(processor)), |
| 155 | serverTransport_(serverTransport) { |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 156 | setInputTransportFactory(std::shared_ptr<TTransportFactory>(new TTransportFactory())); |
| 157 | setOutputTransportFactory(std::shared_ptr<TTransportFactory>(new TTransportFactory())); |
| 158 | setInputProtocolFactory(std::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); |
| 159 | setOutputProtocolFactory(std::shared_ptr<TProtocolFactory>(new TBinaryProtocolFactory())); |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 160 | } |
| 161 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 162 | TServer(const std::shared_ptr<TProcessorFactory>& processorFactory, |
| 163 | const std::shared_ptr<TServerTransport>& serverTransport, |
| 164 | const std::shared_ptr<TTransportFactory>& transportFactory, |
| 165 | const std::shared_ptr<TProtocolFactory>& protocolFactory) |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 166 | : processorFactory_(processorFactory), |
| 167 | serverTransport_(serverTransport), |
| 168 | inputTransportFactory_(transportFactory), |
| 169 | outputTransportFactory_(transportFactory), |
| 170 | inputProtocolFactory_(protocolFactory), |
| 171 | outputProtocolFactory_(protocolFactory) {} |
Bryan Duxbury | 7a9fb81 | 2011-09-01 18:31:53 +0000 | [diff] [blame] | 172 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 173 | TServer(const std::shared_ptr<TProcessor>& processor, |
| 174 | const std::shared_ptr<TServerTransport>& serverTransport, |
| 175 | const std::shared_ptr<TTransportFactory>& transportFactory, |
| 176 | const std::shared_ptr<TProtocolFactory>& protocolFactory) |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 177 | : processorFactory_(new TSingletonProcessorFactory(processor)), |
| 178 | serverTransport_(serverTransport), |
| 179 | inputTransportFactory_(transportFactory), |
| 180 | outputTransportFactory_(transportFactory), |
| 181 | inputProtocolFactory_(protocolFactory), |
| 182 | outputProtocolFactory_(protocolFactory) {} |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 183 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 184 | TServer(const std::shared_ptr<TProcessorFactory>& processorFactory, |
| 185 | const std::shared_ptr<TServerTransport>& serverTransport, |
| 186 | const std::shared_ptr<TTransportFactory>& inputTransportFactory, |
| 187 | const std::shared_ptr<TTransportFactory>& outputTransportFactory, |
| 188 | const std::shared_ptr<TProtocolFactory>& inputProtocolFactory, |
| 189 | const std::shared_ptr<TProtocolFactory>& outputProtocolFactory) |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 190 | : processorFactory_(processorFactory), |
| 191 | serverTransport_(serverTransport), |
| 192 | inputTransportFactory_(inputTransportFactory), |
| 193 | outputTransportFactory_(outputTransportFactory), |
| 194 | inputProtocolFactory_(inputProtocolFactory), |
| 195 | outputProtocolFactory_(outputProtocolFactory) {} |
Bryan Duxbury | 7a9fb81 | 2011-09-01 18:31:53 +0000 | [diff] [blame] | 196 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 197 | TServer(const std::shared_ptr<TProcessor>& processor, |
| 198 | const std::shared_ptr<TServerTransport>& serverTransport, |
| 199 | const std::shared_ptr<TTransportFactory>& inputTransportFactory, |
| 200 | const std::shared_ptr<TTransportFactory>& outputTransportFactory, |
| 201 | const std::shared_ptr<TProtocolFactory>& inputProtocolFactory, |
| 202 | const std::shared_ptr<TProtocolFactory>& outputProtocolFactory) |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 203 | : processorFactory_(new TSingletonProcessorFactory(processor)), |
| 204 | serverTransport_(serverTransport), |
| 205 | inputTransportFactory_(inputTransportFactory), |
| 206 | outputTransportFactory_(outputTransportFactory), |
| 207 | inputProtocolFactory_(inputProtocolFactory), |
| 208 | outputProtocolFactory_(outputProtocolFactory) {} |
Mark Slee | 4af6ed7 | 2006-10-25 19:02:49 +0000 | [diff] [blame] | 209 | |
Bryan Duxbury | 6dd9cd0 | 2011-09-01 18:06:20 +0000 | [diff] [blame] | 210 | /** |
| 211 | * Get a TProcessor to handle calls on a particular connection. |
| 212 | * |
| 213 | * This method should only be called once per connection (never once per |
| 214 | * call). This allows the TProcessorFactory to return a different processor |
| 215 | * for each connection if it desires. |
| 216 | */ |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 217 | std::shared_ptr<TProcessor> getProcessor(std::shared_ptr<TProtocol> inputProtocol, |
| 218 | std::shared_ptr<TProtocol> outputProtocol, |
| 219 | std::shared_ptr<TTransport> transport) { |
Bryan Duxbury | 6dd9cd0 | 2011-09-01 18:06:20 +0000 | [diff] [blame] | 220 | TConnectionInfo connInfo; |
| 221 | connInfo.input = inputProtocol; |
| 222 | connInfo.output = outputProtocol; |
| 223 | connInfo.transport = transport; |
| 224 | return processorFactory_->getProcessor(connInfo); |
| 225 | } |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 226 | |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 227 | // Class variables |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 228 | std::shared_ptr<TProcessorFactory> processorFactory_; |
| 229 | std::shared_ptr<TServerTransport> serverTransport_; |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 230 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 231 | std::shared_ptr<TTransportFactory> inputTransportFactory_; |
| 232 | std::shared_ptr<TTransportFactory> outputTransportFactory_; |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 233 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 234 | std::shared_ptr<TProtocolFactory> inputProtocolFactory_; |
| 235 | std::shared_ptr<TProtocolFactory> outputProtocolFactory_; |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 236 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 237 | std::shared_ptr<TServerEventHandler> eventHandler_; |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 238 | |
David Reiss | ef22dc6 | 2007-11-30 20:38:49 +0000 | [diff] [blame] | 239 | public: |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 240 | void setInputTransportFactory(std::shared_ptr<TTransportFactory> inputTransportFactory) { |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 241 | inputTransportFactory_ = inputTransportFactory; |
| 242 | } |
| 243 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 244 | void setOutputTransportFactory(std::shared_ptr<TTransportFactory> outputTransportFactory) { |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 245 | outputTransportFactory_ = outputTransportFactory; |
| 246 | } |
| 247 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 248 | void setInputProtocolFactory(std::shared_ptr<TProtocolFactory> inputProtocolFactory) { |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 249 | inputProtocolFactory_ = inputProtocolFactory; |
| 250 | } |
| 251 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 252 | void setOutputProtocolFactory(std::shared_ptr<TProtocolFactory> outputProtocolFactory) { |
Aditya Agarwal | 9abb0d6 | 2007-01-24 22:53:54 +0000 | [diff] [blame] | 253 | outputProtocolFactory_ = outputProtocolFactory; |
| 254 | } |
| 255 | |
cyy | 316723a | 2019-01-05 16:35:14 +0800 | [diff] [blame] | 256 | void setServerEventHandler(std::shared_ptr<TServerEventHandler> eventHandler) { |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 257 | eventHandler_ = eventHandler; |
| 258 | } |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 259 | }; |
Mark Slee | b4d3e7b | 2007-11-28 01:51:43 +0000 | [diff] [blame] | 260 | |
veeve | 01d187c | 2008-02-26 05:12:08 +0000 | [diff] [blame] | 261 | /** |
| 262 | * Helper function to increase the max file descriptors limit |
| 263 | * for the current process and all of its children. |
| 264 | * By default, tries to increase it to as much as 2^24. |
| 265 | */ |
Ben Craig | 96ea9da | 2013-10-09 15:23:49 -0500 | [diff] [blame] | 266 | #ifdef HAVE_SYS_RESOURCE_H |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 267 | int increase_max_fds(int max_fds = (1 << 24)); |
Ben Craig | 96ea9da | 2013-10-09 15:23:49 -0500 | [diff] [blame] | 268 | #endif |
Konrad Grochowski | 16a23a6 | 2014-11-13 15:33:38 +0100 | [diff] [blame] | 269 | } |
| 270 | } |
| 271 | } // apache::thrift::server |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 272 | |
Mark Slee | d788b2e | 2006-09-07 01:26:35 +0000 | [diff] [blame] | 273 | #endif // #ifndef _THRIFT_SERVER_TSERVER_H_ |