blob: ba7a183db038d44f853eea5e797f168a081dd977 [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +00001/*
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 Slee9f0c6512007-02-28 23:58:26 +000019
Roger Meier49ff8b12012-04-13 09:12:31 +000020#include <thrift/server/TSimpleServer.h>
Mark Sleee8540632006-05-30 09:24:40 +000021
Konrad Grochowski16a23a62014-11-13 15:33:38 +010022namespace apache {
23namespace thrift {
24namespace server {
Marc Slemko6f038a72006-08-03 18:58:09 +000025
Jim King21b68522015-04-26 18:30:26 -040026using apache::thrift::protocol::TProtocol;
27using apache::thrift::protocol::TProtocolFactory;
28using apache::thrift::transport::TServerTransport;
29using apache::thrift::transport::TTransport;
30using apache::thrift::transport::TTransportException;
31using apache::thrift::transport::TTransportFactory;
cyy316723a2019-01-05 16:35:14 +080032using std::shared_ptr;
Jim King21b68522015-04-26 18:30:26 -040033using std::string;
34
Konrad Grochowski1f6e3802015-05-18 18:10:06 +020035TSimpleServer::TSimpleServer(const shared_ptr<TProcessorFactory>& processorFactory,
36 const shared_ptr<TServerTransport>& serverTransport,
37 const shared_ptr<TTransportFactory>& transportFactory,
38 const shared_ptr<TProtocolFactory>& protocolFactory)
39 : TServerFramework(processorFactory, serverTransport, transportFactory, protocolFactory) {
Jim King79c99112015-04-30 07:10:08 -040040 TServerFramework::setConcurrentClientLimit(1);
41}
Jim King21b68522015-04-26 18:30:26 -040042
Konrad Grochowski1f6e3802015-05-18 18:10:06 +020043TSimpleServer::TSimpleServer(const shared_ptr<TProcessor>& processor,
44 const shared_ptr<TServerTransport>& serverTransport,
45 const shared_ptr<TTransportFactory>& transportFactory,
46 const shared_ptr<TProtocolFactory>& protocolFactory)
47 : TServerFramework(processor, serverTransport, transportFactory, protocolFactory) {
Jim King79c99112015-04-30 07:10:08 -040048 TServerFramework::setConcurrentClientLimit(1);
49}
Jim King21b68522015-04-26 18:30:26 -040050
Konrad Grochowski1f6e3802015-05-18 18:10:06 +020051TSimpleServer::TSimpleServer(const shared_ptr<TProcessorFactory>& processorFactory,
52 const shared_ptr<TServerTransport>& serverTransport,
53 const shared_ptr<TTransportFactory>& inputTransportFactory,
54 const shared_ptr<TTransportFactory>& outputTransportFactory,
55 const shared_ptr<TProtocolFactory>& inputProtocolFactory,
56 const shared_ptr<TProtocolFactory>& outputProtocolFactory)
57 : TServerFramework(processorFactory,
58 serverTransport,
59 inputTransportFactory,
60 outputTransportFactory,
61 inputProtocolFactory,
62 outputProtocolFactory) {
Jim King79c99112015-04-30 07:10:08 -040063 TServerFramework::setConcurrentClientLimit(1);
64}
Jim King21b68522015-04-26 18:30:26 -040065
Konrad Grochowski1f6e3802015-05-18 18:10:06 +020066TSimpleServer::TSimpleServer(const shared_ptr<TProcessor>& processor,
67 const shared_ptr<TServerTransport>& serverTransport,
68 const shared_ptr<TTransportFactory>& inputTransportFactory,
69 const shared_ptr<TTransportFactory>& outputTransportFactory,
70 const shared_ptr<TProtocolFactory>& inputProtocolFactory,
71 const shared_ptr<TProtocolFactory>& outputProtocolFactory)
72 : TServerFramework(processor,
73 serverTransport,
74 inputTransportFactory,
75 outputTransportFactory,
76 inputProtocolFactory,
77 outputProtocolFactory) {
Jim King79c99112015-04-30 07:10:08 -040078 TServerFramework::setConcurrentClientLimit(1);
79}
Jim King21b68522015-04-26 18:30:26 -040080
Sebastian Zenker042580f2019-01-29 15:48:12 +010081TSimpleServer::~TSimpleServer() = default;
Mark Slee5ea15f92007-03-05 22:55:59 +000082
Mark Slee8d7e1f62006-06-07 06:48:56 +000083/**
Jim King21b68522015-04-26 18:30:26 -040084 * The main body of customized implementation for TSimpleServer is quite simple:
85 * When a client connects, use the serve() thread to drive it to completion thus
86 * blocking new connections.
Mark Slee8d7e1f62006-06-07 06:48:56 +000087 */
Jim King21b68522015-04-26 18:30:26 -040088void TSimpleServer::onClientConnected(const shared_ptr<TConnectedClient>& pClient) {
89 pClient->run();
Mark Sleee8540632006-05-30 09:24:40 +000090}
Ben Craig1684c422015-04-24 08:52:44 -050091
Jim King21b68522015-04-26 18:30:26 -040092/**
93 * TSimpleServer does not track clients so there is nothing to do here.
94 */
Konrad Grochowski1f6e3802015-05-18 18:10:06 +020095void TSimpleServer::onClientDisconnected(TConnectedClient*) {
96}
Ben Craig1684c422015-04-24 08:52:44 -050097
Jim King79c99112015-04-30 07:10:08 -040098/**
99 * This makes little sense to the simple server because it is not capable
100 * of having more than one client at a time, so we hide it.
101 */
Konrad Grochowski1f6e3802015-05-18 18:10:06 +0200102void TSimpleServer::setConcurrentClientLimit(int64_t) {
103}
Konrad Grochowski16a23a62014-11-13 15:33:38 +0100104}
105}
106} // apache::thrift::server