use of org.apache.thrift.transport.TServerTransport in project rubix by qubole.
the class TestPoolingClient method startServer.
private static void startServer(final Configuration conf) throws TTransportException {
if (server != null) {
return;
}
Processor processor = new Processor();
TServerTransport serverTransport = new TServerSocket(new TServerSocket.ServerSocketTransportArgs().bindAddr(new InetSocketAddress(PORT)).backlog(Integer.MAX_VALUE));
server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(new TestingService.Processor(processor)).maxWorkerThreads(getServerMaxThreads(conf)));
server.serve();
}
use of org.apache.thrift.transport.TServerTransport in project rubix by qubole.
the class BookKeeperServer method createThriftServer.
private void createThriftServer(Configuration conf, BookKeeper bookKeeper) {
processor = new BookKeeperService.Processor(bookKeeper);
log.info("Starting BookKeeperServer on port " + getBookKeeperServerPort(conf));
try {
TServerTransport serverTransport = new TServerSocket(new TServerSocket.ServerSocketTransportArgs().bindAddr(new InetSocketAddress(getBookKeeperServerPort(conf))).backlog(Integer.MAX_VALUE));
server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor).maxWorkerThreads(getServerMaxThreads(conf)));
} catch (TTransportException e) {
throw new RuntimeException("Error starting BookKeeperServer", e);
}
}
use of org.apache.thrift.transport.TServerTransport in project dubbo by alibaba.
the class ServiceMethodNotFoundTest method init.
protected void init() throws Exception {
TServerTransport serverTransport = new TServerSocket(PORT);
DubboDemoImpl impl = new DubboDemoImpl();
$__DemoStub.Processor processor = new $__DemoStub.Processor(impl);
// for test
Field field = processor.getClass().getSuperclass().getDeclaredField("processMap");
ReflectUtils.makeAccessible(field);
Object obj = field.get(processor);
if (obj instanceof Map) {
((Map) obj).remove("echoString");
}
// ~
TBinaryProtocol.Factory bFactory = new TBinaryProtocol.Factory();
MultiServiceProcessor wrapper = new MultiServiceProcessor();
wrapper.addProcessor(Demo.class, processor);
server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).inputProtocolFactory(bFactory).outputProtocolFactory(bFactory).inputTransportFactory(getTransportFactory()).outputTransportFactory(getTransportFactory()).processor(wrapper));
Thread startTread = new Thread() {
@Override
public void run() {
server.serve();
}
};
startTread.start();
while (!server.isServing()) {
Thread.sleep(100);
}
}
use of org.apache.thrift.transport.TServerTransport in project yyl_example by Relucent.
the class HelloServer method getSimpleServer.
/**
* 简单的单线程服务模型,一般用于测试
*/
public static TServer getSimpleServer(int port, HelloService.Processor<HelloServiceHandler> processor) throws TTransportException {
TServerTransport transport = new TServerSocket(port);
TServer server = new TSimpleServer(new TServer.Args(transport).processor(processor));
return server;
}
use of org.apache.thrift.transport.TServerTransport in project tech by ffyyhh995511.
the class Test1 method main.
/**
* 编写服务端,发布(阻塞式IO + 多线程处理)服务
*
* @param args
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void main(String[] args) {
try {
// 设置传输通道,普通通道
TServerTransport serverTransport = new TServerSocket(7911);
// 使用高密度二进制协议
TProtocolFactory proFactory = new TCompactProtocol.Factory();
// 设置处理器HelloImpl
TProcessor processor = new Hello.Processor(new HelloImpl());
// 创建服务器
Args args2 = new Args(serverTransport);
args2.protocolFactory(proFactory);
args2.processor(processor);
TServer server = new TThreadPoolServer(args2);
System.out.println("Start server on port 7911...");
server.serve();
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations