当前位置: 首页>>代码示例>>Java>>正文


Java TThreadedSelectorServer.Args方法代码示例

本文整理汇总了Java中org.apache.thrift.server.TThreadedSelectorServer.Args方法的典型用法代码示例。如果您正苦于以下问题:Java TThreadedSelectorServer.Args方法的具体用法?Java TThreadedSelectorServer.Args怎么用?Java TThreadedSelectorServer.Args使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.thrift.server.TThreadedSelectorServer的用法示例。


在下文中一共展示了TThreadedSelectorServer.Args方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTThreadedSelectorServer

import org.apache.thrift.server.TThreadedSelectorServer; //导入方法依赖的package包/类
private static TServer getTThreadedSelectorServer(TProtocolFactory protocolFactory,
    TProcessor processor, TTransportFactory transportFactory,
    int workerThreads, int selectorThreads, int maxCallQueueSize,
    InetSocketAddress inetSocketAddress, ThriftMetrics metrics)
    throws TTransportException {
  TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
  log.info("starting HBase ThreadedSelector Thrift server on " + inetSocketAddress.toString());
  TThreadedSelectorServer.Args serverArgs = new TThreadedSelectorServer.Args(serverTransport);
  if (workerThreads > 0) {
    serverArgs.workerThreads(workerThreads);
  }
  if (selectorThreads > 0) {
    serverArgs.selectorThreads(selectorThreads);
  }

  ExecutorService executorService = createExecutor(
      workerThreads, maxCallQueueSize, metrics);
  serverArgs.executorService(executorService);
  serverArgs.processor(processor);
  serverArgs.transportFactory(transportFactory);
  serverArgs.protocolFactory(protocolFactory);
  return new TThreadedSelectorServer(serverArgs);
}
 
开发者ID:apache,项目名称:hbase,代码行数:24,代码来源:ThriftServer.java

示例2: createThreadedSelectorServer

import org.apache.thrift.server.TThreadedSelectorServer; //导入方法依赖的package包/类
public static TServer createThreadedSelectorServer(TProcessorFactory processorFactory,
        int port, int clientTimeoutMillisecs, int maxFrameSize, long maxReadBufferSize)
        throws TTransportException {
    int numThreads = Math.max(2, Runtime.getRuntime().availableProcessors());
    int selectorThreads = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
    TNonblockingServerTransport transport = new TNonblockingServerSocket(port,
            clientTimeoutMillisecs);
    TProtocolFactory protocolFactory = new TBinaryProtocol.Factory();
    TTransportFactory transportFactory = new TFramedTransport.Factory(maxFrameSize);
    TThreadedSelectorServer.Args args = new TThreadedSelectorServer.Args(transport)
            .processorFactory(processorFactory).protocolFactory(protocolFactory)
            .transportFactory(transportFactory).workerThreads(numThreads)
            .acceptPolicy(AcceptPolicy.FAIR_ACCEPT).acceptQueueSizePerThread(10000)
            .selectorThreads(selectorThreads);
    args.maxReadBufferBytes = maxReadBufferSize;
    TThreadedSelectorServer server = new TThreadedSelectorServer(args);
    return server;
}
 
开发者ID:DDTH,项目名称:osgi-bundle-frontapi,代码行数:19,代码来源:ThriftUtils.java

示例3: main

import org.apache.thrift.server.TThreadedSelectorServer; //导入方法依赖的package包/类
public static void main(String [] args) 
		throws TTransportException, IOException, InterruptedException {	
	Properties port_cfg = new Properties();
	InputStream input = new FileInputStream("../config.properties");
	port_cfg.load(input);
	String port_str = port_cfg.getProperty("CA_PORT");
	Integer port = Integer.valueOf(port_str);
	TProcessor proc = new LucidaService.AsyncProcessor(
			new CAServiceHandler.AsyncCAServiceHandler());
	TNonblockingServerTransport transport = new TNonblockingServerSocket(port);
	TThreadedSelectorServer.Args arguments = new TThreadedSelectorServer.Args(transport)
	.processor(proc)	
	.protocolFactory(new TBinaryProtocol.Factory())
	.transportFactory(new TFramedTransport.Factory());
	final TThreadedSelectorServer server = new TThreadedSelectorServer(arguments);
	System.out.println("CA at port " + port_str);
	server.serve();
}
 
开发者ID:claritylab,项目名称:lucida,代码行数:19,代码来源:CalendarDaemon.java

示例4: main

import org.apache.thrift.server.TThreadedSelectorServer; //导入方法依赖的package包/类
/** 
 * Entry point for question-answer.
 * @param args the argument list. Provide port numbers
 * for both sirius and qa.
 */
public static void main(String [] args) 
		throws TTransportException, IOException, InterruptedException {	
	Properties port_cfg = new Properties();
	InputStream input = new FileInputStream("../../config.properties");
	port_cfg.load(input);
	String port_str = port_cfg.getProperty("QA_PORT");
	Integer port = Integer.valueOf(port_str);
	TProcessor proc = new LucidaService.AsyncProcessor(
			new QAServiceHandler.AsyncQAServiceHandler());
	TNonblockingServerTransport transport = new TNonblockingServerSocket(port);
	TThreadedSelectorServer.Args arguments = new TThreadedSelectorServer.Args(transport)
	.processor(proc)	
	.protocolFactory(new TBinaryProtocol.Factory())
	.transportFactory(new TFramedTransport.Factory());
	final TThreadedSelectorServer server = new TThreadedSelectorServer(arguments);
	System.out.println("QA at port " + port_str);
	server.serve();
}
 
开发者ID:claritylab,项目名称:lucida,代码行数:24,代码来源:QADaemon.java

示例5: initServer

import org.apache.thrift.server.TThreadedSelectorServer; //导入方法依赖的package包/类
/**
 * 初始化Thrift服务
 * 
 * @param serverTransport
 *            服务传输类型
 */
@Override
protected void initServer(TServerTransport serverTransport) {
	ThriftServerConfiguration configuration = getThriftServerConfiguration();
	// 使用多线程半同步半异步方式
	TThreadedSelectorServer.Args args = new TThreadedSelectorServer.Args((TNonblockingServerSocket) serverTransport)
			.transportFactory(configuration.getTransportFactory())
			.protocolFactory(configuration.getProtocolFactory());
	if (configuration.getExecutorService() != null)
		args.executorService(configuration.getExecutorService());
	server = new TThreadedSelectorServer(
			configuration.getServerArgsAspect().TThreadedSelectorServerArgsAspect(args).processor(getProcessor()));
	if (configuration.getServerEventHandler() != null)
		server.setServerEventHandler(configuration.getServerEventHandler());
}
 
开发者ID:venwyhk,项目名称:ikasoa,代码行数:21,代码来源:NonblockingThriftServerImpl.java

示例6: setup

import org.apache.thrift.server.TThreadedSelectorServer; //导入方法依赖的package包/类
/** 
 * Entry point for ensemble.
 */
public static void setup(Controller controller)
        throws TTransportException, IOException, InterruptedException { 
    connectToCMD();
    TProcessor proc = new LucidaService.AsyncProcessor(
            new ThriftHandler.AsyncThriftHandler(controller));
    TNonblockingServerTransport transport = new TNonblockingServerSocket(9090);
    TThreadedSelectorServer.Args arguments = new TThreadedSelectorServer.Args(transport)
    .processor(proc)    
    .protocolFactory(new TBinaryProtocol.Factory())
    .transportFactory(new TFramedTransport.Factory());
    final TThreadedSelectorServer server = new TThreadedSelectorServer(arguments);
    System.out.println("ensemble at port 9090");
    server.serve();
}
 
开发者ID:k0105,项目名称:ensemble,代码行数:18,代码来源:ThriftServer.java

示例7: runService

import org.apache.thrift.server.TThreadedSelectorServer; //导入方法依赖的package包/类
public static void runService(GalenApiRemoteService.Processor processor, int serverPort) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(serverPort);
        TThreadedSelectorServer.Args args = new TThreadedSelectorServer.Args(serverTransport);
        TServer server = new TThreadedSelectorServer(args.processor(processor));
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:valermor,项目名称:galen-api-ports,代码行数:11,代码来源:GalenApiServer.java

示例8: serve

import org.apache.thrift.server.TThreadedSelectorServer; //导入方法依赖的package包/类
public void serve() {
  TThreadedSelectorServer.Args serverArgs = createServerArgs();

  if (serverArgs == null)
    return;

  server = new ThriftServer(serverArgs, "server-selector-%d", servingListeners);

  // Make sure we at least try to clean up a little bit when the VM is shut down.
  Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
    @Override
    public void run() {
      logger.info("Shutting down server...");
      if (gracefulShutdownListeners != null) {
        logger.debug("Executing graceful shutdown listeners...");
        new ShutdownUtil(applicationContext).callShutdownListeners();
      }
      logger.debug("Stopping all local beans...");
      applicationContext.close();
      logger.debug("Stopping thrift server...");
      server.stop();
      logger.debug("Shutting down everything of remaining queries...");
      executorManager.shutdownEverythingOfAllQueries();
      logger.info("Shutdown complete.");
    }
  }, "shutdown-thread"));

  if ("".equals(bind))
    logger.info("Listening for incoming requests on port {}...", port);
  else
    logger.info("Listening for incoming requests on port {} (bound to {})...", port, bind);
  server.serve();
}
 
开发者ID:diqube,项目名称:diqube,代码行数:34,代码来源:ServerImplementation.java

示例9: getServer

import org.apache.thrift.server.TThreadedSelectorServer; //导入方法依赖的package包/类
@Override
protected TServer getServer(TProcessor processor) throws TTransportException {
    LOGGER.debug("Setting Server with {} selector threads and {} worker threads", numSelectorThreads, numWorkerThreads);

    TNonblockingServerSocket transport = new TNonblockingServerSocket(remotePort);

    TThreadedSelectorServer.Args args = new TThreadedSelectorServer.Args(transport);
    args.transportFactory(new TFramedTransport.Factory());
    args.protocolFactory(new TBinaryProtocol.Factory());
    args.processor(processor);
    args.selectorThreads(numSelectorThreads);
    args.workerThreads(numWorkerThreads);

    return new TThreadedSelectorServer(args);
}
 
开发者ID:sergypv,项目名称:spring-thrift-service-manager,代码行数:16,代码来源:ServiceThreadPoolWrapper.java

示例10: TThreadedSelectorServerArgsAspect

import org.apache.thrift.server.TThreadedSelectorServer; //导入方法依赖的package包/类
public TThreadedSelectorServer.Args TThreadedSelectorServerArgsAspect(TThreadedSelectorServer.Args args) {
	return args;
}
 
开发者ID:venwyhk,项目名称:ikasoa,代码行数:4,代码来源:ServerArgsAspect.java

示例11: createThreadedSelectorServer

import org.apache.thrift.server.TThreadedSelectorServer; //导入方法依赖的package包/类
/**
 * Helper method to create a new framed-transport, threaded-selector
 * {@link TServer}.
 * 
 * <p>
 * Note: if {@code numSelectorThreads < 1}, the {@link TServer} is created
 * with 2 selector threads.
 * </p>
 * 
 * <p>
 * Note: if {@code numWorkerThreads < 1}, the {@link TServer} is created
 * with 8 worker threads.
 * </p>
 * 
 * @param processorFactory
 * @param protocolFactory
 * @param port
 * @param numSelectorThreads
 * @param numWorkerThreads
 * @param clientTimeoutMillisecs
 * @param maxFrameSize
 * @param maxReadBufferSize
 * @return
 * @throws TTransportException
 */
public static TServer createThreadedSelectorServer(TProcessorFactory processorFactory,
        TProtocolFactory protocolFactory, int port, int numSelectorThreads,
        int numWorkerThreads, int clientTimeoutMillisecs, int maxFrameSize,
        long maxReadBufferSize) throws TTransportException {
    if (numSelectorThreads < 1) {
        numSelectorThreads = 2;
    }
    if (numWorkerThreads < 1) {
        numWorkerThreads = 8;
    }
    TNonblockingServerTransport transport = new TNonblockingServerSocket(port,
            clientTimeoutMillisecs);
    TTransportFactory transportFactory = new TFramedTransport.Factory(maxFrameSize);
    TThreadedSelectorServer.Args args = new TThreadedSelectorServer.Args(transport)
            .processorFactory(processorFactory).protocolFactory(protocolFactory)
            .transportFactory(transportFactory).workerThreads(numWorkerThreads)
            .acceptPolicy(AcceptPolicy.FAIR_ACCEPT).acceptQueueSizePerThread(10000)
            .selectorThreads(numSelectorThreads);
    args.maxReadBufferBytes = maxReadBufferSize;
    TThreadedSelectorServer server = new TThreadedSelectorServer(args);
    return server;
}
 
开发者ID:DDTH,项目名称:ddth-commons,代码行数:48,代码来源:ThriftUtils.java

示例12: createThreadedSelectorServer

import org.apache.thrift.server.TThreadedSelectorServer; //导入方法依赖的package包/类
/**
 * Creates a {@link TThreadedSelectorServer} server.
 * 
 * <p>
 * Similar to {@link THsHaServer} but its use 2 thread pools: one for
 * handling network I/O (e.g. accepting client connections), one for
 * handling message such like {@link THsHaServer}.
 * </p>
 * 
 * @param processorFactory
 * @param protocolFactory
 * @param port
 *            port number on which the Thrift server will listen
 * @param clientTimeoutMillisecs
 * @param maxFrameSize
 *            max size (in bytes) of a transport frame, supply {@code <=0}
 *            value to let the method choose a default {@code maxFrameSize}
 *            value (which is 1Mb)
 * @param maxReadBufferSize
 *            max size (in bytes) of read buffer, supply {@code <=0} value
 *            to let the method choose a default {@code maxReadBufferSize}
 *            value (which is 16Mb)
 * @param numSelectorThreads
 *            number of selector threads, supply {@code <=0} value to let
 *            the method choose a default {@code numSelectorThreads} value
 *            (which is {@code 2} )
 * @param numWorkerThreads
 *            number of worker threads, supply {@code <=0} value to let the
 *            method choose a default {@code numWorkerThreads} value (which
 *            is
 *            {@code Math.max(4, Runtime.getRuntime().availableProcessors())}
 *            )
 * @return
 * @throws TTransportException
 */
public static TThreadedSelectorServer createThreadedSelectorServer(
        TProcessorFactory processorFactory, TProtocolFactory protocolFactory, int port,
        int clientTimeoutMillisecs, int maxFrameSize, long maxReadBufferSize,
        int numSelectorThreads, int numWorkerThreads) throws TTransportException {
    if (clientTimeoutMillisecs <= 0) {
        clientTimeoutMillisecs = DEFAULT_CLIENT_TIMEOUT_MS;
    }
    if (maxFrameSize <= 0) {
        maxFrameSize = DEFAULT_MAX_FRAMESIZE;
    }
    if (maxReadBufferSize <= 0) {
        maxReadBufferSize = DEFAULT_TOTAL_MAX_READ_BUFFERSIZE;
    }
    if (numSelectorThreads <= 0) {
        numSelectorThreads = DEFAULT_NUM_SELECTOR_THREADS;
    }
    if (numWorkerThreads <= 0) {
        numWorkerThreads = DEFAULT_NUM_WORKER_THREADS;
    }

    TNonblockingServerTransport transport = new TNonblockingServerSocket(port,
            clientTimeoutMillisecs);
    TTransportFactory transportFactory = new TFramedTransport.Factory(maxFrameSize);
    TThreadedSelectorServer.Args args = new TThreadedSelectorServer.Args(transport)
            .processorFactory(processorFactory).protocolFactory(protocolFactory)
            .transportFactory(transportFactory).workerThreads(numWorkerThreads)
            .acceptPolicy(AcceptPolicy.FAIR_ACCEPT).acceptQueueSizePerThread(100000)
            .selectorThreads(numSelectorThreads);
    args.maxReadBufferBytes = maxReadBufferSize;
    TThreadedSelectorServer server = new TThreadedSelectorServer(args);
    return server;
}
 
开发者ID:btnguyen2k,项目名称:queue-server,代码行数:68,代码来源:ThriftServerUtils.java

示例13: createThreadedSelectorServer

import org.apache.thrift.server.TThreadedSelectorServer; //导入方法依赖的package包/类
/**
 * Creates a {@link TThreadedSelectorServer} server.
 * 
 * <p>
 * Similar to {@link THsHaServer} but its use 2 thread pools: one for
 * handling network I/O (e.g. accepting client connections), one for
 * handling message such like {@link THsHaServer}.
 * </p>
 * 
 * @param processorFactory
 * @param protocolFactory
 * @param port
 *            port number on which the Thrift server will listen
 * @param clientTimeoutMillisecs
 * @param maxFrameSize
 *            max size (in bytes) of a transport frame, supply {@code <=0}
 *            value to let the method choose a default {@code maxFrameSize}
 *            value (which is 1Mb)
 * @param maxReadBufferSize
 *            max size (in bytes) of read buffer, supply {@code <=0} value
 *            to let the method choose a default {@code maxReadBufferSize}
 *            value (which is 16Mb)
 * @param numSelectorThreads
 *            number of selector threads, supply {@code <=0} value to let
 *            the method choose a default {@code numSelectorThreads} value
 *            (which is {@code 2} )
 * @param numWorkerThreads
 *            number of worker threads, supply {@code <=0} value to let the
 *            method choose a default {@code numWorkerThreads} value (which
 *            is
 *            {@code Math.max(2, Runtime.getRuntime().availableProcessors())}
 *            )
 * @return
 * @throws TTransportException
 */
public static TThreadedSelectorServer createThreadedSelectorServer(
        TProcessorFactory processorFactory, TProtocolFactory protocolFactory, int port,
        int clientTimeoutMillisecs, int maxFrameSize, long maxReadBufferSize,
        int numSelectorThreads, int numWorkerThreads) throws TTransportException {
    if (clientTimeoutMillisecs <= 0) {
        clientTimeoutMillisecs = DEFAULT_CLIENT_TIMEOUT_MS;
    }
    if (maxFrameSize <= 0) {
        maxFrameSize = DEFAULT_MAX_FRAMESIZE;
    }
    if (maxReadBufferSize <= 0) {
        maxReadBufferSize = DEFAULT_TOTAL_MAX_READ_BUFFERSIZE;
    }
    if (numSelectorThreads <= 0) {
        numSelectorThreads = DEFAULT_NUM_SELECTOR_THREADS;
    }
    if (numWorkerThreads <= 0) {
        numWorkerThreads = DEFAULT_NUM_WORKER_THREADS;
    }

    TNonblockingServerTransport transport = new TNonblockingServerSocket(port,
            clientTimeoutMillisecs);
    TTransportFactory transportFactory = new TFramedTransport.Factory(maxFrameSize);
    TThreadedSelectorServer.Args args = new TThreadedSelectorServer.Args(transport)
            .processorFactory(processorFactory).protocolFactory(protocolFactory)
            .transportFactory(transportFactory).workerThreads(numWorkerThreads)
            .acceptPolicy(AcceptPolicy.FAIR_ACCEPT).acceptQueueSizePerThread(100000)
            .selectorThreads(numSelectorThreads);
    args.maxReadBufferBytes = maxReadBufferSize;
    TThreadedSelectorServer server = new TThreadedSelectorServer(args);
    return server;
}
 
开发者ID:btnguyen2k,项目名称:id-server,代码行数:68,代码来源:ThriftServerUtils.java


注:本文中的org.apache.thrift.server.TThreadedSelectorServer.Args方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。