當前位置: 首頁>>代碼示例>>Java>>正文


Java TServer.stop方法代碼示例

本文整理匯總了Java中org.apache.thrift.server.TServer.stop方法的典型用法代碼示例。如果您正苦於以下問題:Java TServer.stop方法的具體用法?Java TServer.stop怎麽用?Java TServer.stop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.thrift.server.TServer的用法示例。


在下文中一共展示了TServer.stop方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import org.apache.thrift.server.TServer; //導入方法依賴的package包/類
public static void main(String[] args) throws TTransportException, IOException, InterruptedException {
    TNonblockingServerSocket trans_svr = new TNonblockingServerSocket(9090);
    TMultiplexedProcessor proc = new TMultiplexedProcessor();
    proc.registerProcessor("Message", new Message.Processor<>(new MessageHandler()));
    proc.registerProcessor("ServerTime", new ServerTime.Processor<>(new ServerTimeHandler()));

    TServer server = new TThreadedSelectorServer(
            new TThreadedSelectorServer.Args(trans_svr)
            .processor(proc)
            .protocolFactory(new TJSONProtocol.Factory())
            .workerThreads(6)
            .selectorThreads(3));
    Thread server_thread = new Thread(new RunnableServer(server), "server_thread");
    server_thread.start();

    System.out.println("[Server] press enter to shutdown> ");
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    br.readLine();
    System.out.println("[Server] shutting down...");
    server.stop();
    server_thread.join();
    System.out.println("[Server] down, exiting");
}
 
開發者ID:RandyAbernethy,項目名稱:ThriftBook,代碼行數:24,代碼來源:MultiServiceServer.java

示例2: stop

import org.apache.thrift.server.TServer; //導入方法依賴的package包/類
public synchronized void stop() {
  final TServer thriftServer = this.thriftServer;
  if (thriftServer != null) {
    this.service.stop();
    thriftServer.stop();
    final ThreadPoolExecutor connExecutor = this.thriftThreadPerConnExecutor;
    if (connExecutor != null) {
      connExecutor.shutdown();
    }
    this.thriftExecutor.shutdown();
    try {
      this.thriftMainThread.join(5000L);
      // force stop the executor if required
      if (this.thriftMainThread.isAlive()) {
        if (connExecutor != null) {
          connExecutor.shutdownNow();
        }
        this.thriftExecutor.shutdownNow();
        this.thriftMainThread.join();
      }
    } catch (InterruptedException ie) {
      Thread.currentThread().interrupt();
    }
  }
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:26,代碼來源:GfxdThriftServer.java

示例3: testProcessor

import org.apache.thrift.server.TServer; //導入方法依賴的package包/類
private static int testProcessor(TProcessor processor, List<ToIntFunction<HostAndPort>> clients)
        throws Exception
{
    try (TServerSocket serverTransport = new TServerSocket(0)) {
        TProtocolFactory protocolFactory = new Factory();
        TTransportFactory transportFactory = new TFramedTransport.Factory();
        TServer server = new TSimpleServer(new Args(serverTransport)
                .protocolFactory(protocolFactory)
                .transportFactory(transportFactory)
                .processor(processor));

        Thread serverThread = new Thread(server::serve);
        try {
            serverThread.start();

            int localPort = serverTransport.getServerSocket().getLocalPort();
            HostAndPort address = HostAndPort.fromParts("localhost", localPort);

            int sum = 0;
            for (ToIntFunction<HostAndPort> client : clients) {
                sum += client.applyAsInt(address);
            }
            return sum;
        }
        finally {
            server.stop();
            serverThread.interrupt();
        }
    }
}
 
開發者ID:airlift,項目名稱:drift,代碼行數:31,代碼來源:TestApacheThriftMethodInvoker.java

示例4: testProcessor

import org.apache.thrift.server.TServer; //導入方法依賴的package包/類
private static int testProcessor(TProcessor processor, List<ToIntFunction<HostAndPort>> clients)
        throws Exception
{
    try (TServerSocket serverTransport = new TServerSocket(0)) {
        TProtocolFactory protocolFactory = new TBinaryProtocol.Factory();
        TTransportFactory transportFactory = new TFramedTransport.Factory();
        TServer server = new TSimpleServer(new Args(serverTransport)
                .protocolFactory(protocolFactory)
                .transportFactory(transportFactory)
                .processor(processor));

        Thread serverThread = new Thread(server::serve);
        try {
            serverThread.start();

            int localPort = serverTransport.getServerSocket().getLocalPort();
            HostAndPort address = HostAndPort.fromParts("localhost", localPort);

            int sum = 0;
            for (ToIntFunction<HostAndPort> client : clients) {
                sum += client.applyAsInt(address);
            }
            return sum;
        }
        finally {
            server.stop();
            serverThread.interrupt();
        }
    }
}
 
開發者ID:airlift,項目名稱:drift,代碼行數:31,代碼來源:TestDriftNettyMethodInvoker.java

示例5: shutdown

import org.apache.thrift.server.TServer; //導入方法依賴的package包/類
/**
 * Shutdown all the running servers
 */
public void shutdown() {
    for (TServer server : thriftServers) {
        server.stop();
    }
    try {
        zookeeper.shutdown();
        discovery.close();
    } catch (IOException ex) {
        //don't care
    }
}
 
開發者ID:ezbake,項目名稱:ezbake-common-java,代碼行數:15,代碼來源:ThriftServerPool.java

示例6: stopAllServers

import org.apache.thrift.server.TServer; //導入方法依賴的package包/類
/**
 * 關閉所有thrift服務的方法
 */
protected void stopAllServers() {
	for (TServer tServer : servers) {
		tServer.stop();
	}
}
 
開發者ID:wmz7year,項目名稱:Thrift-Connection-Pool,代碼行數:9,代碼來源:BasicAbstractTest.java


注:本文中的org.apache.thrift.server.TServer.stop方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。