Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't use TSimpleServer. Not recommended for production. Use TThreadP…

…oolServer instead since it is transport-compatible with our existing code.
  • Loading branch information...
commit e2c219e9d271ef1af5cb5da37fcccb5977da0fc9 1 parent 8ecb520
@fakeholz fakeholz authored
View
19 opentripplanner-api-thrift/src/main/java/org/opentripplanner/api/thrift/OTPServerTask.java
@@ -15,8 +15,12 @@
import lombok.Data;
+import org.apache.thrift.protocol.TBinaryProtocol;
+import org.apache.thrift.protocol.TProtocolFactory;
import org.apache.thrift.server.TServer;
-import org.apache.thrift.server.TSimpleServer;
+import org.apache.thrift.server.TThreadPoolServer;
+import org.apache.thrift.transport.TNonblockingServerSocket;
+import org.apache.thrift.transport.TNonblockingServerTransport;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TServerTransport;
import org.apache.thrift.transport.TTransportException;
@@ -46,12 +50,13 @@ public void run() {
OTPService.Processor<OTPServiceImpl> processor = new OTPService.Processor<OTPServiceImpl>(
otpServiceImpl);
- // TODO(flamholz): make the transport and server type be configurable?
- TServerTransport serverTransport;
- serverTransport = new TServerSocket(port);
-
- TSimpleServer.Args args = new TSimpleServer.Args(serverTransport).processor(processor);
- TServer server = new TSimpleServer(args);
+ // TODO(flamholz): make the transport, protocol and server type be configurable?
+ TServerTransport serverTransport = new TServerSocket(port);
+ TProtocolFactory protocolFactory = new TBinaryProtocol.Factory(true, true);
+ TThreadPoolServer.Args args = new TThreadPoolServer.Args(serverTransport)
+ .processor(processor)
+ .protocolFactory(protocolFactory);
+ TServer server = new TThreadPoolServer(args);
LOG.info("Starting the OTPService on port {}", port);
server.serve();
View
2  opentripplanner-api-thrift/src/main/resources/scripts/tickle_server.py
@@ -24,7 +24,7 @@ def Connect(host, port):
transport = TTransport.TBufferedTransport(transport)
# Wrap in a protocol
- protocol = TBinaryProtocol.TBinaryProtocolAccelerated(transport)
+ protocol = TBinaryProtocol.TBinaryProtocol(transport)
# Create a client to use the protocol encoder
client = OTPService.Client(protocol)

0 comments on commit e2c219e

Please sign in to comment.
Something went wrong with that request. Please try again.