org.apache.thrift.server.TNonblockingServer Java Examples
The following examples show how to use
org.apache.thrift.server.TNonblockingServer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ThriftServerTest2.java From ThriftJ with Apache License 2.0 | 6 votes |
public static void main(String[] args){ ExecutorService es = Executors.newFixedThreadPool(2); for(int i=0; i<ports.length; i++){ final int index = i; es.execute(new Runnable() { @Override public void run() { try{ TNonblockingServerSocket socket = new TNonblockingServerSocket(ports[index]); TestThriftJ.Processor processor = new TestThriftJ.Processor(new QueryImp()); TNonblockingServer.Args arg = new TNonblockingServer.Args(socket); arg.protocolFactory(new TBinaryProtocol.Factory()); arg.transportFactory(new TFramedTransport.Factory()); arg.processorFactory(new TProcessorFactory(processor)); TServer server = new TNonblockingServer (arg); logger.info("127.0.0.1:" + ports[index] + " start"); server.serve(); }catch(Exception e){ logger.error("127.0.0.1:" + ports[index] + " error"); } } }); } }
Example #2
Source File: ThriftServerTest.java From ThriftJ with Apache License 2.0 | 6 votes |
public static void main(String[] args){ ExecutorService es = Executors.newFixedThreadPool(2); for(int i=0; i<ports.length; i++){ final int index = i; es.execute(new Runnable() { @Override public void run() { try{ TNonblockingServerSocket socket = new TNonblockingServerSocket(ports[index]); TestThriftJ.Processor processor = new TestThriftJ.Processor(new QueryImp()); TNonblockingServer.Args arg = new TNonblockingServer.Args(socket); arg.protocolFactory(new TBinaryProtocol.Factory()); arg.transportFactory(new TFramedTransport.Factory()); arg.processorFactory(new TProcessorFactory(processor)); TServer server = new TNonblockingServer(arg); logger.info("127.0.0.1:" + ports[index] + " start"); server.serve(); }catch(Exception e){ logger.error("127.0.0.1:" + ports[index] + " error"); } } }); } }
Example #3
Source File: CustomTNonBlockingServer.java From stratio-cassandra with Apache License 2.0 | 6 votes |
public TServer buildTServer(Args args) { if (DatabaseDescriptor.getClientEncryptionOptions().enabled) throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration."); final InetSocketAddress addr = args.addr; TNonblockingServerTransport serverTransport; try { serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize); } catch (TTransportException e) { throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e); } // This is single threaded hence the invocation will be all // in one thread. TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory) .outputTransportFactory(args.outTransportFactory) .inputProtocolFactory(args.tProtocolFactory) .outputProtocolFactory(args.tProtocolFactory) .processor(args.processor); return new CustomTNonBlockingServer(serverArgs); }
Example #4
Source File: AsyncEchoTestServer.java From pinpoint with Apache License 2.0 | 6 votes |
public static AsyncEchoTestServer<TNonblockingServer> nonblockingServer(final TestEnvironment environment) throws TTransportException { TNonblockingServer server = new TNonblockingServer(new TNonblockingServer.Args( new TNonblockingServerSocket(environment.getPort())).processor(getAsyncProcessor()) .inputProtocolFactory(environment.getProtocolFactory()) .outputProtocolFactory(environment.getProtocolFactory())); return new AsyncEchoTestServer<TNonblockingServer>(server, environment) { @Override public SyncEchoTestClient getSynchronousClient() throws TTransportException { return new SyncEchoTestClient.ClientForNonblockingServer(environment); } @Override public AsyncEchoTestClient getAsynchronousClient() throws IOException { return new AsyncEchoTestClient.Client(environment); } }; }
Example #5
Source File: SyncEchoTestServer.java From pinpoint with Apache License 2.0 | 6 votes |
public static SyncEchoTestServer<TNonblockingServer> nonblockingServer(final TestEnvironment environment) throws TTransportException { TNonblockingServer server = new TNonblockingServer(new TNonblockingServer.Args( new TNonblockingServerSocket(environment.getPort())).processor(getProcessor()) .inputProtocolFactory(environment.getProtocolFactory()) .outputProtocolFactory(environment.getProtocolFactory())); return new SyncEchoTestServer<TNonblockingServer>(server, environment) { @Override public SyncEchoTestClient getSynchronousClient() throws TTransportException { return new SyncEchoTestClient.ClientForNonblockingServer(environment); } @Override public AsyncEchoTestClient getAsynchronousClient() throws IOException { return new AsyncEchoTestClient.Client(environment); } }; }
Example #6
Source File: ThriftServer.java From luxun with Apache License 2.0 | 6 votes |
public ThriftServer(QueueService.Iface queueService, ServerConfig serverConfig, ThriftServerStats stats) throws TTransportException { this.queueService = queueService; this.serverConfig = serverConfig; this.stats = stats; // assemble thrift server TProcessor tprocessor = new QueueService.Processor(this.queueService); TNonblockingServerSocket tnbSocketTransport = new TNonblockingServerSocket(serverConfig.getPort()); TNonblockingServer.Args tnbArgs = new TNonblockingServer.Args(tnbSocketTransport); tnbArgs.processor(tprocessor); // Nonblocking server mode must use TFramedTransport tnbArgs.transportFactory(new TFramedTransport.Factory()); tnbArgs.protocolFactory(new TBinaryProtocol.Factory()); this.server = new TNonblockingServer(tnbArgs); // THsHaServer.Args thhArgs = new THsHaServer.Args(tnbSocketTransport); // thhArgs.processor(tprocessor); // // Nonblocking server mode must use TFramedTransport // thhArgs.transportFactory(new TFramedTransport.Factory()); // thhArgs.protocolFactory(new TBinaryProtocol.Factory()); // // this.server = new THsHaServer(thhArgs); this.serverThread = new ServerThread(this.server); }
Example #7
Source File: ThriftQueueServer.java From bigqueue with Apache License 2.0 | 6 votes |
public void start() { try { System.out.println("Thrift queue server start ..."); BigQueueService.Iface bigQueueSerivce = new ThriftQueueServiceImpl(QUEUE_DIR); TProcessor tprocessor = new BigQueueService.Processor(bigQueueSerivce); TNonblockingServerSocket tnbSocketTransport = new TNonblockingServerSocket(SERVER_PORT); TNonblockingServer.Args tnbArgs = new TNonblockingServer.Args(tnbSocketTransport); tnbArgs.processor(tprocessor); // Nonblocking server mode needs TFramedTransport tnbArgs.transportFactory(new TFramedTransport.Factory()); tnbArgs.protocolFactory(new TBinaryProtocol.Factory()); TServer server = new TNonblockingServer(tnbArgs); System.out.println("Thrift queue server started on port " + SERVER_PORT); server.serve(); } catch (Exception e) { System.err.println("Server start error!!!"); e.printStackTrace(); } }
Example #8
Source File: ThriftTest.java From java-specialagent with Apache License 2.0 | 5 votes |
private void startAsyncServer() throws Exception { final CustomHandler customHandler = new CustomHandler(); final TProcessor customProcessor = new CustomService.Processor<CustomService.Iface>(customHandler); final TNonblockingServerSocket tnbSocketTransport = new TNonblockingServerSocket(port, 30000); final TNonblockingServer.Args tnbArgs = new TNonblockingServer.Args(tnbSocketTransport); tnbArgs.processor(customProcessor); server = new TNonblockingServer(tnbArgs); new Thread(new Runnable() { @Override public void run() { server.serve(); } }).start(); }
Example #9
Source File: ThriftServer.java From hbase with Apache License 2.0 | 5 votes |
protected TServer getTNonBlockingServer(TNonblockingServerTransport serverTransport, TProtocolFactory protocolFactory, TProcessor processor, TTransportFactory transportFactory, InetSocketAddress inetSocketAddress) { LOG.info("starting HBase Nonblocking Thrift server on " + inetSocketAddress.toString()); TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport); serverArgs.processor(processor); serverArgs.transportFactory(transportFactory); serverArgs.protocolFactory(protocolFactory); return new TNonblockingServer(serverArgs); }
Example #10
Source File: ServerArgsAspect.java From ikasoa with MIT License | 4 votes |
public TNonblockingServer.Args tNonblockingServerArgsAspect(TNonblockingServer.Args args) { return args; }
Example #11
Source File: ThriftNonblockingServerAsyncIT.java From pinpoint with Apache License 2.0 | 4 votes |
@Override protected ThriftEchoTestServer<TNonblockingServer> createEchoServer(TestEnvironment environment) throws TTransportException { return AsyncEchoTestServerFactory.nonblockingServer(environment); }
Example #12
Source File: ThriftNonblockingServerIT.java From pinpoint with Apache License 2.0 | 4 votes |
@Override protected ThriftEchoTestServer<TNonblockingServer> createEchoServer(TestEnvironment environment) throws TTransportException { return SyncEchoTestServerFactory.nonblockingServer(environment); }
Example #13
Source File: ThriftServer.java From luxun with Apache License 2.0 | 4 votes |
ServerThread(TNonblockingServer server) { this.server = server; }