public static void runServer(TProcessor processor, int port, int threads) { TNonblockingServerTransport serverTransport; TServer server; try { serverTransport = new TNonblockingServerSocket(port); if (threads == 1) { server = new TNonblockingServer(processor, serverTransport); } else { THsHaServer.Options serverOptions = new THsHaServer.Options(); serverOptions.workerThreads = threads; server = new THsHaServer( new TProcessorFactory(processor), serverTransport, new TFramedTransport.Factory(), new TBinaryProtocol.Factory(), serverOptions); } Runtime.getRuntime() .addShutdownHook( new Thread( new ShutdownListener(server, serverTransport), "Server Shutdown Listener")); logger.info("Starting the server on port {} with {} threads", port, threads); server.serve(); } catch (TTransportException e) { logger.error("Thrift Transport error"); logger.error(e.toString()); System.exit(1); } }
/** Start the data server thread and heartbeat thread of this TachyonWorker. */ public void start() throws IOException { login(); mHeartbeatThread.start(); LOG.info("The worker server started @ " + mWorkerAddress); mServer.serve(); LOG.info("The worker server ends @ " + mWorkerAddress); }
public static void simple(SimpleIrcService.Processor processor) { try { TServerTransport serverTransport = new TServerSocket(9090); TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor)); System.out.println("Starting the simple server..."); server.serve(); } catch (Exception e) { e.printStackTrace(); } }
public static void StartsimpleServer( AdditionService.Processor<AdditionServiceHandler> processor) { try { TServerTransport serverTransport = new TServerSocket(9090); TServer server = new TSimpleServer(new TServer.Args(serverTransport).processor(processor)); // log.info("Starting the simple server......."); System.out.println("Starting the simple server......"); server.serve(); } catch (TTransportException e) { e.printStackTrace(); } }
public void run() throws Exception { SimpleTimer.getInstance() .schedule( new Runnable() { @Override public void run() { flush(); } }, 1000, 1000); server.serve(); }
public static void main(String args[]) { try { TServerSocket serverTransport = new TServerSocket(7777); Factory proFactory = new TBinaryProtocol.Factory(); TProcessor processor = new RFIDService.Processor(new RFIDServiceImpl()); TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor)); System.out.println("Start server on port 7777..."); server.serve(); } catch (TTransportException e) { e.printStackTrace(); } }
public void start() { try { TServerSocket serverTransport = new TServerSocket(7911); BGService.Processor<BGService.Iface> processor = new BGService.Processor<BGService.Iface>(new BGVerticalServiceImpl(options)); TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor)); System.out.println("Starting Server on port 7911.."); server.serve(); } catch (TTransportException e) { e.printStackTrace(); } }
public void run() { try { int port = 9090; TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port); VicDataService.Processor<VicDataServiceImpl> processor = new VicDataService.Processor<VicDataServiceImpl>(new VicDataServiceImpl()); TServer server = new TNonblockingServer(new TNonblockingServer.Args(serverTransport).processor(processor)); System.out.println("Starting server on port " + port + " ..."); server.serve(); } catch (TTransportException e) { e.printStackTrace(); } }
/** * start serving the thrift server. doesn't return. * * @throws IOException * @throws TException */ private void serve() throws IOException, TException { // set up the service handler HankSmartClient handler; try { handler = new HankSmartClient(coord, ringGroupName); } catch (DataNotFoundException e) { throw new RuntimeException(e); } // launch the thrift server TNonblockingServerSocket serverSocket = new TNonblockingServerSocket(configurator.getPortNumber()); Args options = new THsHaServer.Args(serverSocket); options.processor(new SmartClient.Processor(handler)); options.workerThreads(configurator.getNumThreads()); options.protocolFactory(new TCompactProtocol.Factory()); server = new THsHaServer(options); server.serve(); }
/** * 启动 Thrift 服务器 * * @param args */ public static void main(String[] args) { try { // hello 协议的处理类 TProcessor hello = new Hello.Processor(new HelloServiceImpl()); TProcessor world = new World.Processor(new WorldServiceImpl()); TMultiplexedProcessor processor = new TMultiplexedProcessor(); processor.registerProcessor("HelloService", hello); processor.registerProcessor("WorldService", world); // 服务传输层 TServerTransport serverTransport = new TServerSocket(9090); TServer server = new TSimpleServer(new TThreadPoolServer.Args(serverTransport).processor(processor)); System.out.println("Start server on port 9090..."); server.serve(); } catch (TTransportException e) { e.printStackTrace(); } }
// @Test public void testCompactServerStart() { try { TServerTransport serverTransport = new TServerSocket(port); // TThreadPoolServer.Args processor = new TThreadPoolServer.Args(serverTransport) // .inputTransportFactory(new TFramedTransport.Factory()) // .outputTransportFactory(new TFramedTransport.Factory()) // .protocolFactory(new TCompactProtocol.Factory()) // .processor(new PingPongService.Processor<>(pingPongService)); // TThreadPoolServer server = new TThreadPoolServer(processor); System.out.println("Starting the server..."); // server.serve(); TServer server = new TSimpleServer(new TSimpleServer.Args(serverTransport)); server.serve(); } catch (Exception e) { e.printStackTrace(); } }
// @Test public void start() { log.info("start thrift test server......."); try { TMultiplexedProcessor processor = new TMultiplexedProcessor(); processor.registerProcessor( "pingPongService", new PingPongService.Processor<>(pingPongService)); TCompactProtocol.Factory protocolFactory = new TCompactProtocol.Factory(); TServerSocket socket = new TServerSocket(port); TServer server = new TThreadPoolServer( new TThreadPoolServer.Args(socket) .processor(processor) .protocolFactory(protocolFactory)); server.serve(); } catch (TException e) { e.printStackTrace(); } }
public static void main(String[] args) { try { int port = 10000; if (args.length >= 1) { port = Integer.parseInt(args[0]); } TServerTransport serverTransport = new TServerSocket(port); ThriftHiveProcessorFactory hfactory = new ThriftHiveProcessorFactory(null); TThreadPoolServer.Options options = new TThreadPoolServer.Options(); TServer server = new TThreadPoolServer( hfactory, serverTransport, new TTransportFactory(), new TTransportFactory(), new TBinaryProtocol.Factory(), new TBinaryProtocol.Factory(), options); HiveServerHandler.LOG.info("Starting hive server on port " + port); server.serve(); } catch (Exception x) { x.printStackTrace(); } }
@Override public void run() { server.serve(); }
@Override public void run() { mMasterServiceServer.serve(); }