List of usage examples for org.apache.thrift.server TThreadedSelectorServer.Args TThreadedSelectorServer.Args
public Args(TNonblockingServerTransport transport)
From source file:StubServer.java
License:Apache License
public static void main(String argv[]) { try {/*from w ww . ja va 2s . 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()); } }