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


Java TThreadPoolServer.Args方法代碼示例

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


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

示例1: poolServer

import org.apache.thrift.server.TThreadPoolServer; //導入方法依賴的package包/類
@Bean(name = "pool-server")
public TServer poolServer() throws Exception {
	TServerTransport transport = new TServerSocket(this.port());

	TThreadPoolServer.Args args = new TThreadPoolServer.Args(transport);
	args.transportFactory(new TTransportFactory());
	args.protocolFactory(new TBinaryProtocol.Factory());

	args.processor(this.processor());
	args.executorService(new ThreadPoolExecutor(env.getProperty(
			"rpc.server.min.worker.threads", Integer.class, 512), env
			.getProperty("rpc.server.max.worker.threads", Integer.class,
					65535), env.getProperty(
			"rpc.server.thread.keep.alive.time", Long.class, 600l),
			TimeUnit.SECONDS, new SynchronousQueue<Runnable>()));

	return new TThreadPoolServer(args);
}
 
開發者ID:jigsaw-projects,項目名稱:jigsaw-payment,代碼行數:19,代碼來源:HelloServerConfig.java

示例2: ServerThread

import org.apache.thrift.server.TThreadPoolServer; //導入方法依賴的package包/類
ServerThread() throws TTransportException {
   TMultiplexedProcessor processor = new TMultiplexedProcessor();
   for (String beanName : serviceMap.keySet()) {
      IThriftServerService serverService = (IThriftServerService) serviceMap.getService(beanName);
      String processorName = serverService.getName();
      TProcessor tProcessor = serverService.getProcessor(serverService);
      processor.registerProcessor(processorName, tProcessor);
      logger.info("Register a processorName {} processorImpl {}", processorName, tProcessor);
   }

   logger.info("init default TServerTransport in addr {} port {}", applicationProperties.getAddr(), applicationProperties.getPort());
   TServerTransport tServerTransport = new TServerSocket(new InetSocketAddress(applicationProperties.getAddr(),
           applicationProperties.getPort()));
   TThreadPoolServer.Args args = new TThreadPoolServer.Args(tServerTransport);
   args.processor(processor);
   args.protocolFactory(tProtocolFactory);
   server = new TThreadPoolServer(args);
}
 
開發者ID:somewhereMrli,項目名稱:albedo-thrift,代碼行數:19,代碼來源:ThriftServer.java

示例3: getTThreadPoolServer

import org.apache.thrift.server.TThreadPoolServer; //導入方法依賴的package包/類
private static TServer getTThreadPoolServer(TProtocolFactory protocolFactory,
                                            TProcessor processor,
                                            TTransportFactory transportFactory,
                                            int workerThreads,
                                            InetSocketAddress inetSocketAddress,
                                            int backlog,
                                            int clientTimeout)
    throws TTransportException {
  TServerTransport serverTransport = new TServerSocket(
                                         new TServerSocket.ServerSocketTransportArgs().
                                             bindAddr(inetSocketAddress).backlog(backlog).
                                             clientTimeout(clientTimeout));
  log.info("starting HBase ThreadPool Thrift server on " + inetSocketAddress.toString());
  TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(serverTransport);
  serverArgs.processor(processor);
  serverArgs.transportFactory(transportFactory);
  serverArgs.protocolFactory(protocolFactory);
  if (workerThreads > 0) {
    serverArgs.maxWorkerThreads(workerThreads);
  }
  return new TThreadPoolServer(serverArgs);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:23,代碼來源:ThriftServer.java

示例4: initializeClusterManagerCallbackServer

import org.apache.thrift.server.TThreadPoolServer; //導入方法依賴的package包/類
private synchronized void initializeClusterManagerCallbackServer()
    throws IOException {
  // Create thrift RPC to serve ClusterManager
  int soTimeout = fConf.getInt(
      CORONA_TASK_TRACKER_SERVER_CLIENTTIMEOUT_KEY, 30 * 1000);
  ServerSocket serverSocket = new ServerSocket();
  serverSocket.setReuseAddress(true);
  serverSocket.bind(new InetSocketAddress(0));
  TServerSocket tSocket = new TServerSocket(serverSocket, soTimeout);
  CoronaTaskTrackerService.Processor proc =
      new CoronaTaskTrackerService.Processor(this);
  TBinaryProtocol.Factory protocolFactory =
      new TBinaryProtocol.Factory(true, true);
  TThreadPoolServer.Args args = new TThreadPoolServer.Args(tSocket);
  args.processor(proc);
  args.protocolFactory(protocolFactory);
  clusterManagerCallbackServer = new TThreadPoolServer(args);
  clusterManagerCallbackServerThread =
      new TServerThread(clusterManagerCallbackServer);
  clusterManagerCallbackServerThread.start();
  clusterManagerCallbackServerAddr = new InetAddress(
      getLocalHostname(), serverSocket.getLocalPort());
  LOG.info("SessionServer up at " + serverSocket.getLocalSocketAddress());
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:25,代碼來源:CoronaTaskTracker.java

示例5: HadoopThriftServer

import org.apache.thrift.server.TThreadPoolServer; //導入方法依賴的package包/類
/**
 * Constrcts a server object
 */
public HadoopThriftServer(String [] args) {

  if (args.length > 0) {
    serverPort = new Integer(args[0]);
  }
  try {
    ServerSocket ssock = createServerSocket(serverPort);
    TServerTransport serverTransport = new TServerSocket(ssock);
    Iface handler = new HadoopThriftHandler("hdfs-thrift-dhruba");
    ThriftHadoopFileSystem.Processor processor = new ThriftHadoopFileSystem.Processor(handler);
    TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(serverTransport);
    serverArgs.minWorkerThreads = 10;
    serverArgs.processor(processor);
    serverArgs.transportFactory(new TTransportFactory());
    serverArgs.protocolFactory(new TBinaryProtocol.Factory());
    server = new TThreadPoolServer(serverArgs);
    System.out.println("Starting the hadoop thrift server on port [" + serverPort + "]...");
    HadoopThriftHandler.LOG.info("Starting the hadoop thrift server on port [" +serverPort + "]...");
    System.out.flush();

  } catch (Exception x) {
    x.printStackTrace();
  }
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:28,代碼來源:HadoopThriftServer.java

示例6: startThreadedPoolServer

import org.apache.thrift.server.TThreadPoolServer; //導入方法依賴的package包/類
private static TServer startThreadedPoolServer(final TServerTransport transport, final TProcessor processor,
        Properties properties) throws Exception {

    TThreadPoolServer.Args serverArgs;
    if (properties == null) {
        serverArgs = new TThreadPoolServer.Args(transport).processor(processor);
    } else {
        serverArgs =
                (TThreadPoolServer.Args) ThriftUtils.getServerArgs(transport, properties).processor(
                        processor);
    }

    final TServer server = new TThreadPoolServer(serverArgs);
    new Thread(new Runnable() {
        @Override
        public void run() {
            server.serve();
        }
    }).start();
    return server;
}
 
開發者ID:ezbake,項目名稱:ezbake-common-java,代碼行數:22,代碼來源:ThriftUtils.java

示例7: getServerArgs

import org.apache.thrift.server.TThreadPoolServer; //導入方法依賴的package包/類
@SuppressWarnings("null")
public static TServer.AbstractServerArgs<?> getServerArgs(TServerTransport transport, Properties properties) {
    TServer.AbstractServerArgs<?> args = null;
    ThriftConfigurationHelper thriftConfiguration = new ThriftConfigurationHelper(properties);
    switch (thriftConfiguration.getServerMode()) {
        case Simple:
            args = new TServer.Args(transport);
            break;
        case ThreadedPool:
            args = new TThreadPoolServer.Args(transport);
            break;
        case HsHa:
            throw new IllegalArgumentException("Unable to create an HsHa Server Args at this time");
    }

    // Use the EzSecureTransport (exposes peer ssl certs) if using SSL
    if (thriftConfiguration.useSSL()) {
        args.inputTransportFactory(new EzSecureServerTransport.Factory(properties));
    }

    return args;
}
 
開發者ID:ezbake,項目名稱:ezbake-common-java,代碼行數:23,代碼來源:ThriftUtils.java

示例8: getServer

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

    TThreadPoolServer.Args server_args =
            new TThreadPoolServer.Args(serverTransport).processor(new TUGIWrapProcessor(processor)).minWorkerThreads(numWorkerThreads)
                    .maxWorkerThreads(numWorkerThreads).protocolFactory(new TBinaryProtocol.Factory(false, true));

    if (serverTransportFactory != null) {
        server_args.transportFactory(serverTransportFactory);
    }
    BlockingQueue workQueue = new SynchronousQueue();
    if (queueSize != null) {
        workQueue = new ArrayBlockingQueue(queueSize);
    }
    ThreadPoolExecutor executorService = new ExtendedThreadPoolExecutor(numWorkerThreads, numWorkerThreads, 60, TimeUnit.SECONDS, workQueue);
    server_args.executorService(executorService);
    return new TThreadPoolServer(server_args);
}
 
開發者ID:kkllwww007,項目名稱:jstrom,代碼行數:24,代碼來源:SaslTransportPlugin.java

示例9: getServer

import org.apache.thrift.server.TThreadPoolServer; //導入方法依賴的package包/類
public TServer getServer(int port, TProcessor processor) throws IOException, TTransportException {
    TTransportFactory serverTransportFactory = getServerTransportFactory();

    //define THsHaServer args 
    //original: THsHaServer + TNonblockingServerSocket
    //option: TThreadPoolServer + TServerSocket
    TServerSocket serverTransport = new TServerSocket(port);
    TThreadPoolServer.Args server_args = new TThreadPoolServer.Args(serverTransport).
            processor(new TUGIWrapProcessor(processor)).
            minWorkerThreads(64).
            maxWorkerThreads(64).
            protocolFactory(new TBinaryProtocol.Factory());            
    if (serverTransportFactory != null) 
        server_args.transportFactory(serverTransportFactory);

    //construct THsHaServer
    return new TThreadPoolServer(server_args);
}
 
開發者ID:metamx,項目名稱:incubator-storm,代碼行數:19,代碼來源:SaslTransportPlugin.java

示例10: getTThreadPoolServer

import org.apache.thrift.server.TThreadPoolServer; //導入方法依賴的package包/類
private TServer getTThreadPoolServer() {
  TServerTransport serverTransport;
  if (enableSsl) {
    serverTransport = getSSLServerTransport();
  } else {
    serverTransport = getTServerTransport();
  }
  TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(serverTransport);
  serverArgs.maxWorkerThreads(maxThreads);
  populateServerParams(serverArgs);
  return new TThreadPoolServer(serverArgs);
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:13,代碼來源:ThriftSource.java

示例11: startServing

import org.apache.thrift.server.TThreadPoolServer; //導入方法依賴的package包/類
private void startServing(final ExecutorService executorService, final TServerTransport serverTransport) {
    if (!stopping.get()) {
        final TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(serverTransport)
            .processor(getProcessor())
            .executorService(executorService);
        server = new TThreadPoolServer(serverArgs);
        if (hasServerEventHandler()) {
            server.setServerEventHandler(getServerEventHandler());
        }

        final String threadName = getServerName() + "-thread-#" + serverThreadCount.incrementAndGet();
        new Thread(threadName) {
            @Override
            public void run() {
                log.debug("starting serving");
                try {
                    server.serve();
                } catch (Throwable t) {
                    if (!stopping.get()) {
                        log.error("Unexpected exception in {}. This probably "
                            + "means that the worker pool was exhausted. "
                            + "Increase 'metacat.thrift.server_max_worker_threads' "
                            + "from {} or throttle the number of requests. "
                            + "This server thread is not in a bad state so starting a new one.",
                            getServerName(), config.getThriftServerMaxWorkerThreads(), t);
                        startServing(executorService, serverTransport);
                    } else {
                        log.debug("stopping serving");
                    }
                }
                log.debug("started serving");
            }
        }.start();
    }
}
 
開發者ID:Netflix,項目名稱:metacat,代碼行數:36,代碼來源:AbstractThriftServer.java

示例12: initServer

import org.apache.thrift.server.TThreadPoolServer; //導入方法依賴的package包/類
/**
 * 初始化Thrift服務
 * <p>
 * 啟動Thrift服務之前必須要進行初始化.
 * 
 * @param serverTransport
 *            服務傳輸類型
 */
protected void initServer(TServerTransport serverTransport) {
	ThriftServerConfiguration configuration = getThriftServerConfiguration();
	// 默認使用TThreadPoolServer方式啟動Thrift服務器,對每個連接都會單獨建立一個線程.
	TThreadPoolServer.Args args = new TThreadPoolServer.Args(serverTransport)
			.transportFactory(configuration.getTransportFactory())
			.protocolFactory(configuration.getProtocolFactory());
	// 如果不設置ExecutorService,則默認使用ThreadPoolExecutor實現.
	if (configuration.getExecutorService() != null)
		args.executorService(configuration.getExecutorService());
	server = new TThreadPoolServer(
			configuration.getServerArgsAspect().TThreadPoolServerArgsAspect(args).processor(getProcessor()));
	if (configuration.getServerEventHandler() != null)
		server.setServerEventHandler(configuration.getServerEventHandler());
}
 
開發者ID:venwyhk,項目名稱:ikasoa,代碼行數:23,代碼來源:DefaultThriftServerImpl.java

示例13: startBlockingServer

import org.apache.thrift.server.TThreadPoolServer; //導入方法依賴的package包/類
private TServer startBlockingServer(TProcessor processor, TProtocolFactory protocolFactory) {
    TThreadPoolServer.Args args = new TThreadPoolServer.Args(serverTransport)
            .processor(processor)
            .protocolFactory(protocolFactory);

    return new TThreadPoolServer(args);
}
 
開發者ID:Microsoft,項目名稱:thrifty,代碼行數:8,代碼來源:TestServer.java

示例14: startServer

import org.apache.thrift.server.TThreadPoolServer; //導入方法依賴的package包/類
/**
 * 啟動thrift server,如果存在server容器或者多個service,則一些需要設置為daemon模式
 */
private void startServer() throws Exception {

    TServerSocket serverTransport = new TServerSocket(serverConfig.getPort());
    TThreadPoolServer.Args args = new TThreadPoolServer.Args(serverTransport);
    args.maxWorkerThreads = serverConfig.getMaxWorkerThreads();
    args.minWorkerThreads = serverConfig.getMinWorkerThreads();
    args.protocolFactory(new TBinaryProtocol.Factory());

    TProcessor tProcessor = getProcessorIface(getIfaceClass());
    args.processor(tProcessor);
    final TServer server = new TThreadPoolServer(args);
    server.setServerEventHandler(serverConfig.getServerEventHandler());
    Thread thread = new Thread(new Runnable() {
        @Override
        public void run() {
            server.serve();
        }
    });
    thread.setDaemon(serverConfig.isDaemonRun());
    thread.start();
    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
        @Override public void run() {
            if (!serverConfig.isDirectInvoke()) {
                unZkRegister(providerInfo, serviceInfo);
            }
            server.stop();
        }
    }));

    LOGGER.info("----------------start thrift server--------------");
}
 
開發者ID:ketao1989,項目名稱:ourea,代碼行數:35,代碼來源:ServiceProvider.java

示例15: getTThreadPoolServer

import org.apache.thrift.server.TThreadPoolServer; //導入方法依賴的package包/類
private static TServer getTThreadPoolServer(TProtocolFactory protocolFactory, THBaseService.Processor processor,
    TTransportFactory transportFactory, InetSocketAddress inetSocketAddress) throws TTransportException {
  TServerTransport serverTransport = new TServerSocket(inetSocketAddress);
  log.info("starting HBase ThreadPool Thrift server on " + inetSocketAddress.toString());
  TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(serverTransport);
  serverArgs.processor(processor);
  serverArgs.transportFactory(transportFactory);
  serverArgs.protocolFactory(protocolFactory);
  return new TThreadPoolServer(serverArgs);
}
 
開發者ID:fengchen8086,項目名稱:LCIndex-HBase-0.94.16,代碼行數:11,代碼來源:ThriftServer.java


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