List of usage examples for org.apache.thrift.server TNonblockingServer serve
public void serve()
From source file:org.diqube.itest.util.ClusterFlattenServiceTestUtil.java
License:Open Source License
public static TestClusterFlattenService createClusterFlattenService(byte[] serverMacKey) { short port = 5200; // TODO find port dynamically. TMultiplexedProcessor multiProcessor = new TMultiplexedProcessor(); TestClusterFlattenService res = new TestClusterFlattenService(new ServerAddr("127.0.0.1", port)); ClusterFlattenServiceImpl serviceImpl = new ClusterFlattenServiceImpl(res); multiProcessor.registerProcessor(ClusterFlattenServiceConstants.SERVICE_NAME, new ClusterFlattenService.Processor<ClusterFlattenService.Iface>(serviceImpl)); multiProcessor.registerProcessor(KeepAliveServiceConstants.SERVICE_NAME, // no integrity check for keep alives. new IntegrityCheckingProtocol.IntegrityCheckDisablingProcessor( new KeepAliveService.Processor<KeepAliveService.Iface>(new KeepAliveService.Iface() { @Override public void ping() throws TException { // noop. }/* www . j a v a2s . c o m*/ }))); TNonblockingServerSocket transport; try { transport = new TNonblockingServerSocket(new InetSocketAddress("127.0.0.1", port)); } catch (TTransportException e) { throw new RuntimeException("Could not open transport for result service", e); } TNonblockingServer.Args args = new TNonblockingServer.Args(transport); args.processor(multiProcessor); args.transportFactory(new RememberingTransport.Factory(new TFramedTransport.Factory())); args.protocolFactory(new IntegrityCheckingProtocol.Factory(new TCompactProtocol.Factory(), serverMacKey)); TNonblockingServer thriftServer = new TNonblockingServer(args); Thread serverThread = new Thread(() -> thriftServer.serve(), "Test-ClusterFlattenService-serverthread"); res.setThriftServer(thriftServer); res.setServerThread(serverThread); serverThread.start(); return res; }
From source file:org.diqube.itest.util.IdentityCallbackServiceTestUtil.java
License:Open Source License
public static TestIdentityCallbackService createIdentityCallbackService() { short port = 5200; // TODO find port dynamically. TMultiplexedProcessor multiProcessor = new TMultiplexedProcessor(); TestIdentityCallbackService res = new TestIdentityCallbackService(new ServerAddr("127.0.0.1", port)); IdentityCallbackServiceImpl serviceImpl = new IdentityCallbackServiceImpl(res); multiProcessor.registerProcessor(IdentityCallbackServiceConstants.SERVICE_NAME, new IdentityCallbackService.Processor<IdentityCallbackService.Iface>(serviceImpl)); multiProcessor.registerProcessor(KeepAliveServiceConstants.SERVICE_NAME, // no integrity check for keep alives. new IntegrityCheckingProtocol.IntegrityCheckDisablingProcessor( new KeepAliveService.Processor<KeepAliveService.Iface>(new KeepAliveService.Iface() { @Override public void ping() throws TException { // noop. }/*from w w w . ja va 2 s . c om*/ }))); TNonblockingServerSocket transport; try { transport = new TNonblockingServerSocket(new InetSocketAddress("127.0.0.1", port)); } catch (TTransportException e) { throw new RuntimeException("Could not open transport for result service", e); } TNonblockingServer.Args args = new TNonblockingServer.Args(transport); args.processor(multiProcessor); args.transportFactory(new RememberingTransport.Factory(new TFramedTransport.Factory())); args.protocolFactory(new TCompactProtocol.Factory()); TNonblockingServer thriftServer = new TNonblockingServer(args); Thread serverThread = new Thread(() -> thriftServer.serve(), "Test-IdentityCallbackService-serverthread"); res.setThriftServer(thriftServer); res.setServerThread(serverThread); serverThread.start(); return res; }
From source file:org.diqube.itest.util.QueryResultServiceTestUtil.java
License:Open Source License
public static TestQueryResultService createQueryResultService() { short port = 5200; // TODO find port dynamically. TMultiplexedProcessor multiProcessor = new TMultiplexedProcessor(); TestQueryResultService res = new TestQueryResultService(new ServerAddr("127.0.0.1", port)); QueryResultServiceImpl serviceImpl = new QueryResultServiceImpl(res); multiProcessor.registerProcessor(QueryResultServiceConstants.SERVICE_NAME, new QueryResultService.Processor<QueryResultService.Iface>(serviceImpl)); multiProcessor.registerProcessor(KeepAliveServiceConstants.SERVICE_NAME, new KeepAliveService.Processor<KeepAliveService.Iface>(new KeepAliveService.Iface() { @Override// w w w . jav a2 s. c o m public void ping() throws TException { // noop. } })); TNonblockingServerSocket transport; try { transport = new TNonblockingServerSocket(new InetSocketAddress("127.0.0.1", port)); } catch (TTransportException e) { throw new RuntimeException("Could not open transport for result service", e); } TNonblockingServer.Args args = new TNonblockingServer.Args(transport); args.processor(multiProcessor); args.transportFactory(new TFramedTransport.Factory()); // no integrity check for everything. args.protocolFactory(new TCompactProtocol.Factory()); TNonblockingServer thriftServer = new TNonblockingServer(args); Thread serverThread = new Thread(() -> thriftServer.serve(), "Test-QueryResultService-serverthread"); res.setThriftServer(thriftServer); res.setServerThread(serverThread); serverThread.start(); return res; }
From source file:thrift.demo.userservice.rpc.async.AsyncServer.java
License:Apache License
public static void main(String[] args) { UserService.AsyncProcessor<AsyncUserServiceHandler> processor = new UserService.AsyncProcessor<AsyncUserServiceHandler>( new AsyncUserServiceHandler()); try {/* w w w.j ava 2 s .com*/ TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(9090); TNonblockingServer server = new TNonblockingServer( new TNonblockingServer.Args(serverTransport).processor(processor)); System.out.println("Starting the async/noblocking server..."); server.serve(); } catch (Exception e) { e.printStackTrace(); } }