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


Java THsHaServer.Args方法代碼示例

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


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

示例1: nonBlockMode

import org.apache.thrift.server.THsHaServer; //導入方法依賴的package包/類
private void nonBlockMode() {
        AskerHandler handler = new AskerHandler();
        Asker.Processor processor = new Asker.Processor(handler);
        try {
            TNonblockingServerTransport transport = new TNonblockingServerSocket(port);
            THsHaServer.Args arg = new THsHaServer.Args(transport);
            arg.protocolFactory(new TCompactProtocol.Factory());
//            arg.transportFactory(new TFramedTransport.Factory());
//            arg.processorFactory(new TProcessorFactory(processor));
            arg.processor(processor);
            server = new THsHaServer(arg);
            start.countDown();

            System.out.println("Starting the nonBlock server...");
            server.serve();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
開發者ID:altiplanogao,項目名稱:rpc-comparison,代碼行數:20,代碼來源:AskerServer.java

示例2: run

import org.apache.thrift.server.THsHaServer; //導入方法依賴的package包/類
public void run() {
  try {
    Scribe.Processor processor = new Scribe.Processor(new Receiver());
    TNonblockingServerTransport transport = new TNonblockingServerSocket(port);
    THsHaServer.Args args = new THsHaServer.Args(transport);

    args.workerThreads(workers);
    args.processor(processor);
    args.transportFactory(new TFramedTransport.Factory(maxReadBufferBytes));
    args.protocolFactory(new TBinaryProtocol.Factory(false, false));
    args.maxReadBufferBytes = maxReadBufferBytes;

    server = new THsHaServer(args);

    LOG.info("Starting Scribe Source on port " + port);

    server.serve();
  } catch (Exception e) {
    LOG.warn("Scribe failed", e);
  }
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:22,代碼來源:ScribeSource.java

示例3: hshaServer

import org.apache.thrift.server.THsHaServer; //導入方法依賴的package包/類
/** 
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:20,代碼來源:PacketStreamerServer.java

示例4: hshaServer

import org.apache.thrift.server.THsHaServer; //導入方法依賴的package包/類
/**
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:zhenshengcai,項目名稱:floodlight-hardware,代碼行數:20,代碼來源:PacketStreamerServer.java

示例5: startHshaServer

import org.apache.thrift.server.THsHaServer; //導入方法依賴的package包/類
@VisibleForTesting
public static TServer startHshaServer(TProcessor processor, int portNumber) throws Exception {

    final TNonblockingServerSocket socket = new TNonblockingServerSocket(portNumber);
    final THsHaServer.Args serverArgs = new THsHaServer.Args(socket);
    serverArgs.processor(processor);
    serverArgs.inputProtocolFactory(new TCompactProtocol.Factory());
    serverArgs.outputProtocolFactory(new TCompactProtocol.Factory());
    final TServer server = new THsHaServer(serverArgs);
    final Thread t = new Thread(new Runnable() {
        @Override
        public void run() {
            server.serve();
        }
    });
    t.start();
    return server;
}
 
開發者ID:ezbake,項目名稱:ezbake-common-java,代碼行數:19,代碼來源:ThriftUtils.java

示例6: initHandlerServer

import org.apache.thrift.server.THsHaServer; //導入方法依賴的package包/類
private THsHaServer initHandlerServer(Map conf, final Drpc service) throws Exception {
    int port = JStormUtils.parseInt(conf.get(Config.DRPC_PORT));
    int workerThreadNum = JStormUtils.parseInt(conf.get(Config.DRPC_WORKER_THREADS));
    int queueSize = JStormUtils.parseInt(conf.get(Config.DRPC_QUEUE_SIZE));

    TNonblockingServerSocket socket = new TNonblockingServerSocket(port);
    THsHaServer.Args targs = new THsHaServer.Args(socket);
    targs.workerThreads(64);
    targs.protocolFactory(new TBinaryProtocol.Factory());
    targs.processor(new DistributedRPC.Processor<DistributedRPC.Iface>(service));

    ThreadPoolExecutor executor = new ThreadPoolExecutor(workerThreadNum, workerThreadNum, 60, TimeUnit.SECONDS, new ArrayBlockingQueue(queueSize));
    targs.executorService(executor);

    THsHaServer handlerServer = new THsHaServer(targs);
    LOG.info("Successfully init Handler Server " + port);

    return handlerServer;
}
 
開發者ID:kkllwww007,項目名稱:jstrom,代碼行數:20,代碼來源:Drpc.java

示例7: initThrift

import org.apache.thrift.server.THsHaServer; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
private void initThrift(Map conf) throws TTransportException {
    Integer thrift_port = JStormUtils.parseInt(conf.get(Config.NIMBUS_THRIFT_PORT));
    TNonblockingServerSocket socket = new TNonblockingServerSocket(thrift_port);

    Integer maxReadBufSize = JStormUtils.parseInt(conf.get(Config.NIMBUS_THRIFT_MAX_BUFFER_SIZE));

    THsHaServer.Args args = new THsHaServer.Args(socket);
    args.workerThreads(ServiceHandler.THREAD_NUM);
    args.protocolFactory(new TBinaryProtocol.Factory(false, true, maxReadBufSize, -1));

    args.processor(new Nimbus.Processor<Iface>(serviceHandler));
    args.maxReadBufferBytes = maxReadBufSize;

    thriftServer = new THsHaServer(args);

    LOG.info("Successfully started nimbus: started Thrift server...");
    thriftServer.serve();
}
 
開發者ID:kkllwww007,項目名稱:jstrom,代碼行數:20,代碼來源:NimbusServer.java

示例8: getServer

import org.apache.thrift.server.THsHaServer; //導入方法依賴的package包/類
@Override
public TServer getServer(TProcessor processor) throws IOException, TTransportException {
    int port = type.getPort(storm_conf);
    TNonblockingServerSocket serverTransport = new TNonblockingServerSocket(port);
    int numWorkerThreads = type.getNumThreads(storm_conf);
    int maxBufferSize = type.getMaxBufferSize(storm_conf);
    Integer queueSize = type.getQueueSize(storm_conf);

    THsHaServer.Args server_args =
            new THsHaServer.Args(serverTransport).processor(new SimpleWrapProcessor(processor)).workerThreads(numWorkerThreads)
                    .protocolFactory(new TBinaryProtocol.Factory(false, true, maxBufferSize, -1));

    if (queueSize != null) {
        server_args.executorService(new ThreadPoolExecutor(numWorkerThreads, numWorkerThreads, 60, TimeUnit.SECONDS, new ArrayBlockingQueue(queueSize)));
    }

    // construct THsHaServer
    return new THsHaServer(server_args);
}
 
開發者ID:kkllwww007,項目名稱:jstrom,代碼行數:20,代碼來源:SimpleTransportPlugin.java

示例9: getTHsHaServer

import org.apache.thrift.server.THsHaServer; //導入方法依賴的package包/類
private static TServer getTHsHaServer(TProtocolFactory protocolFactory,
    TProcessor processor, TTransportFactory transportFactory,
    int workerThreads, int maxCallQueueSize,
    InetSocketAddress inetSocketAddress, ThriftMetrics metrics)
    throws TTransportException {
  TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
  log.info("starting HBase HsHA Thrift server on " + inetSocketAddress.toString());
  THsHaServer.Args serverArgs = new THsHaServer.Args(serverTransport);
  if (workerThreads > 0) {
    // Could support the min & max threads, avoiding to preserve existing functionality.
    serverArgs.minWorkerThreads(workerThreads).maxWorkerThreads(workerThreads);
  }
  ExecutorService executorService = createExecutor(
      workerThreads, maxCallQueueSize, metrics);
  serverArgs.executorService(executorService);
  serverArgs.processor(processor);
  serverArgs.transportFactory(transportFactory);
  serverArgs.protocolFactory(protocolFactory);
  return new THsHaServer(serverArgs);
}
 
開發者ID:apache,項目名稱:hbase,代碼行數:21,代碼來源:ThriftServer.java

示例10: start

import org.apache.thrift.server.THsHaServer; //導入方法依賴的package包/類
public  void start() throws Exception {
    transport = new TNonblockingServerSocket(port);
    processor =  new SuroServer.Processor(this);

    THsHaServer.Args serverArgs = new THsHaServer.Args(transport);
    serverArgs.processor(processor);
    serverArgs.workerThreads(2);

    server = new THsHaServer(serverArgs);
    System.out.println("Server started on port:" + port);

    Thread t = new Thread() {

        @Override
        public void run() {
            server.serve();
        }

    };
    t.start();

    Field serverSocketField = TNonblockingServerSocket.class.getDeclaredField("serverSocket_");
    serverSocketField.setAccessible(true);
    ServerSocket serverSocket = (ServerSocket) serverSocketField.get(transport);
    port = serverSocket.getLocalPort();
}
 
開發者ID:Netflix,項目名稱:suro,代碼行數:27,代碼來源:SuroServer4Test.java

示例11: startTHsHaServer

import org.apache.thrift.server.THsHaServer; //導入方法依賴的package包/類
/**
 * 啟動thrift的server端的服務
 */
public void startTHsHaServer() {
	try {
		TNonblockingServerSocket tnbSocketTransport = new TNonblockingServerSocket(
				SERVER_PORT);
		THsHaServer.Args thhsArgs = new THsHaServer.Args(tnbSocketTransport);

		// 設置處理邏輯
		thhsArgs.processor(tprocessor);

		// 傳輸方式
		thhsArgs.transportFactory(new TFramedTransport.Factory());

		// 數據協議
		thhsArgs.protocolFactory(new TCompactProtocol.Factory());

		// 半同步半異步的服務模型
		server = new THsHaServer(thhsArgs);
		server.serve();

	} catch (Exception e) {
		System.out.println("Server start error!!!");
		e.printStackTrace();
	}
}
 
開發者ID:suhuanzheng7784877,項目名稱:ParallelExecute,代碼行數:28,代碼來源:DistributedParalleExecuteTHsHaServer.java

示例12: initHandlerServer

import org.apache.thrift.server.THsHaServer; //導入方法依賴的package包/類
private THsHaServer initHandlerServer(Map conf, final Drpc service) throws Exception {
    int port = JStormUtils.parseInt(conf.get(Config.DRPC_PORT));
    int workerThreadNum = JStormUtils.parseInt(conf.get(Config.DRPC_WORKER_THREADS));
    int queueSize = JStormUtils.parseInt(conf.get(Config.DRPC_QUEUE_SIZE));

    LOG.info("Begin to init DRPC handler server at port: " + port);

    TNonblockingServerSocket socket = new TNonblockingServerSocket(port);
    THsHaServer.Args targs = new THsHaServer.Args(socket);
    targs.workerThreads(64);
    targs.protocolFactory(new TBinaryProtocol.Factory());
    targs.processor(new DistributedRPC.Processor<DistributedRPC.Iface>(service));

    ThreadPoolExecutor executor = new ThreadPoolExecutor(
            workerThreadNum, workerThreadNum, 60, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(queueSize));
    targs.executorService(executor);

    THsHaServer handlerServer = new THsHaServer(targs);
    LOG.info("Successfully inited DRPC handler server at port: " + port);

    return handlerServer;
}
 
開發者ID:alibaba,項目名稱:jstorm,代碼行數:23,代碼來源:Drpc.java

示例13: initInvokeServer

import org.apache.thrift.server.THsHaServer; //導入方法依賴的package包/類
private THsHaServer initInvokeServer(Map conf, final Drpc service) throws Exception {
    int port = JStormUtils.parseInt(conf.get(Config.DRPC_INVOCATIONS_PORT));

    LOG.info("Begin to init DRPC invoke server at port: " + port);

    TNonblockingServerSocket socket = new TNonblockingServerSocket(port);
    THsHaServer.Args targsInvoke = new THsHaServer.Args(socket);
    targsInvoke.workerThreads(64);
    targsInvoke.protocolFactory(new TBinaryProtocol.Factory());
    targsInvoke.processor(new DistributedRPCInvocations.Processor<DistributedRPCInvocations.Iface>(service));

    THsHaServer invokeServer = new THsHaServer(targsInvoke);

    LOG.info("Successfully inited DRPC invoke server at port: " + port);
    return invokeServer;
}
 
開發者ID:alibaba,項目名稱:jstorm,代碼行數:17,代碼來源:Drpc.java

示例14: apply

import org.apache.thrift.server.THsHaServer; //導入方法依賴的package包/類
@Override
public TServer apply(ServerSetup setup) throws TTransportException {

    TNonblockingServerSocket socket = setup.getSocketTimeout() == null
            ? new TNonblockingServerSocket(new InetSocketAddress("0.0.0.0", setup.getPort()))
            : new TNonblockingServerSocket(new InetSocketAddress("0.0.0.0", setup.getPort()),
            setup.getSocketTimeout().as(Time.MILLISECONDS));

    setup.setSocket(getServerSocketFor(socket));
    THsHaServer.Args options = new THsHaServer.Args(socket);
    options.processor(setup.getProcessor());
    if (setup.getNumThreads() > 0) {
        options.workerThreads(setup.getNumThreads());
    }
    // default queue size to num threads:  max response time becomes double avg service time
    final BlockingQueue<Runnable> queue =
            new ArrayBlockingQueue<Runnable>(setup.getQueueSize() > 0 ? setup.getQueueSize()
                    : options.getWorkerThreads());
    final ThreadPoolExecutor invoker = new ThreadPoolExecutor(options.getWorkerThreads(),
            options.getWorkerThreads(), options.getStopTimeoutVal(), options.getStopTimeoutUnit(), queue);

    final String serverName = (setup.getName() != null ? setup.getName() : "no-name");
    return new THsHaServer(options);
}
 
開發者ID:houdejun214,項目名稱:lakeside-java,代碼行數:25,代碼來源:ThriftServer.java

示例15: getTHsHaServer

import org.apache.thrift.server.THsHaServer; //導入方法依賴的package包/類
private static TServer getTHsHaServer(TProtocolFactory protocolFactory,
    TProcessor processor, TTransportFactory transportFactory,
    int workerThreads,
    InetSocketAddress inetSocketAddress, ThriftMetrics metrics)
    throws TTransportException {
  TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
  log.info("starting HBase HsHA Thrift server on " + inetSocketAddress.toString());
  THsHaServer.Args serverArgs = new THsHaServer.Args(serverTransport);
  if (workerThreads > 0) {
    // Could support the min & max threads, avoiding to preserve existing functionality.
    serverArgs.minWorkerThreads(workerThreads).maxWorkerThreads(workerThreads);
  }
  ExecutorService executorService = createExecutor(
      workerThreads, metrics);
  serverArgs.executorService(executorService);
  serverArgs.processor(processor);
  serverArgs.transportFactory(transportFactory);
  serverArgs.protocolFactory(protocolFactory);
  return new THsHaServer(serverArgs);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:21,代碼來源:ThriftServer.java


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