List of usage examples for org.apache.thrift.transport TFramedTransport.Factory TFramedTransport.Factory
TFramedTransport.Factory
From source file:JavaHsHaServer.java
License:Apache License
public static void main(String[] args) { try {/*w w w . j a v a 2s . c o m*/ handler = new MyserviceHandler(); processor = new Myservice.Processor(handler); TNonblockingServerSocket socket = new TNonblockingServerSocket(1357); THsHaServer.Args arg = new THsHaServer.Args(socket); arg.protocolFactory(new TBinaryProtocol.Factory()); arg.transportFactory(new TFramedTransport.Factory()); arg.processorFactory(new TProcessorFactory(processor)); arg.workerThreads(5); TServer server = new THsHaServer(arg); server.serve(); System.out.println("HsHa server started."); } catch (TTransportException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }
From source file:StubServer.java
License:Apache License
public static void main(String argv[]) { try {// w w w . ja v a 2 s . co m int port = 9090; int numThreads = 32; if (argv.length != 1) { usage(); } System.out.println(argv[0]); StubServer mapkeeper = new StubServer(); TServer server = null; if (argv[0].equals("hsha")) { TNonblockingServerTransport trans = new TNonblockingServerSocket(port); THsHaServer.Args args = new THsHaServer.Args(trans); args.transportFactory(new TFramedTransport.Factory()); args.protocolFactory(new TBinaryProtocol.Factory()); args.processor(new MapKeeper.Processor(mapkeeper)); args.workerThreads(numThreads); server = new THsHaServer(args); } else if (argv[0].equals("nonblocking")) { TNonblockingServerTransport trans = new TNonblockingServerSocket(port); TNonblockingServer.Args args = new TNonblockingServer.Args(trans); args.transportFactory(new TFramedTransport.Factory()); args.protocolFactory(new TBinaryProtocol.Factory()); args.processor(new MapKeeper.Processor(mapkeeper)); server = new TNonblockingServer(args); } else if (argv[0].equals("threadpool")) { TServerTransport trans = new TServerSocket(port); TThreadPoolServer.Args args = new TThreadPoolServer.Args(trans); args.transportFactory(new TFramedTransport.Factory()); args.protocolFactory(new TBinaryProtocol.Factory()); args.processor(new MapKeeper.Processor(mapkeeper)); server = new TThreadPoolServer(args); } else if (argv[0].equals("selector")) { TNonblockingServerTransport trans = new TNonblockingServerSocket(port); TThreadedSelectorServer.Args args = new TThreadedSelectorServer.Args(trans); args.transportFactory(new TFramedTransport.Factory()); args.protocolFactory(new TBinaryProtocol.Factory()); args.processor(new MapKeeper.Processor(mapkeeper)); args.selectorThreads(4); args.workerThreads(numThreads); server = new TThreadedSelectorServer(args); } else { usage(); } server.serve(); } catch (Exception x) { System.out.println(x.toString() + " " + x.getMessage()); } }
From source file:com.thinkaurelius.thrift.AbstractDisruptorTest.java
License:Apache License
public static void prepareTest(boolean onHeapBuffers, boolean shouldRellocateBuffers, int port) throws Exception { final TNonblockingServerTransport socket = new TNonblockingServerSocket(new InetSocketAddress(HOST, port)); final TBinaryProtocol.Factory protocol = new TBinaryProtocol.Factory(); TDisruptorServer.Args args = new TDisruptorServer.Args(socket) .inputTransportFactory(new TFramedTransport.Factory()) .outputTransportFactory(new TFramedTransport.Factory()).inputProtocolFactory(protocol) .outputProtocolFactory(protocol) .processor(new TestService.Processor<TestService.Iface>(new Service())) .useHeapBasedAllocation(onHeapBuffers).alwaysReallocateBuffers(shouldRellocateBuffers); TEST_SERVICE = new CustomTDisruptorServer(args); new Thread() { public void run() { TEST_SERVICE.serve();/* w ww . j a v a 2s .co m*/ } }.start(); }