本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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());
}
示例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();
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
}
示例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());
}
示例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);
}
示例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--------------");
}
示例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);
}