本文整理汇总了Java中org.apache.thrift.server.TThreadPoolServer类的典型用法代码示例。如果您正苦于以下问题:Java TThreadPoolServer类的具体用法?Java TThreadPoolServer怎么用?Java TThreadPoolServer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TThreadPoolServer类属于org.apache.thrift.server包,在下文中一共展示了TThreadPoolServer类的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: start
import org.apache.thrift.server.TThreadPoolServer; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void start() {
try {
InetSocketAddress bindAddr = new InetSocketAddress(host, port);
serverTransport = new TServerSocket(bindAddr);
ThriftFlumeEventServer.Processor processor =
new ThriftFlumeEventServer.Processor(new ThriftFlumeEventServerImpl());
server = new TThreadPoolServer(
new TThreadPoolServer.Args(serverTransport).processor(processor));
} catch (TTransportException e) {
throw new FlumeException("Failed starting source", e);
}
ThriftHandler thriftHandler = new ThriftHandler(server);
thriftHandlerThread = new Thread(thriftHandler);
thriftHandlerThread.start();
super.start();
}
示例3: startSchedulerThriftService
import org.apache.thrift.server.TThreadPoolServer; //导入依赖的package包/类
/**
* @Title: startSchedulerThriftService
* @Description: 开启scheduler 同步、异步调用服务
* @return void 返回类型
*/
private static void startSchedulerThriftService() {
LOG.info("start scheduler thrift service....");
new Thread() {
@Override
public void run(){
try {
SchedulerServiceImpl schedulerServiceImpl = SpringUtil.getBean(SchedulerServiceImpl.class);
TProcessor tprocessor = new SchedulerService.Processor<SchedulerService.Iface>(schedulerServiceImpl);
TServerSocket serverTransport = new TServerSocket(PropertyLoader.THRIFT_SCHEDULER_PORT);
TThreadPoolServer.Args ttpsArgs = new TThreadPoolServer.Args(serverTransport);
ttpsArgs.processor(tprocessor);
ttpsArgs.protocolFactory(new TBinaryProtocol.Factory());
//线程池服务模型,使用标准的阻塞式IO,预先创建一组线程处理请求。
TServer server = new TThreadPoolServer(ttpsArgs);
server.serve();
} catch (Exception e) {
LOG.error("start scheduler thrift service error,msg:"+ExceptionUtil.getStackTraceAsString(e));
}
}
}.start();
LOG.info("start scheduler thrift server success!");
}
示例4: 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);
}
示例5: 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);
}
示例6: start
import org.apache.thrift.server.TThreadPoolServer; //导入依赖的package包/类
public void start() throws TTransportException, UnknownHostException {
InetAddress inetAddress = InetAddress.getByName(hostName);
TSSLTransportFactory.TSSLTransportParameters params =
new TSSLTransportFactory.TSSLTransportParameters();
params.setKeyStore(keyStore, keyStorePassword);
TServerSocket serverTransport;
serverTransport = TSSLTransportFactory.getServerSocket(port, clientTimeout, inetAddress, params);
AuthenticatorService.Processor<AuthenticatorServiceImpl> processor =
new AuthenticatorService.Processor<AuthenticatorServiceImpl>(
new AuthenticatorServiceImpl(thriftAuthenticatorService));
authenticationServer = new TThreadPoolServer(
new TThreadPoolServer.Args(serverTransport).processor(processor));
Thread thread = new Thread(new ServerRunnable(authenticationServer));
if (log.isDebugEnabled()) {
log.debug("Thrift Authentication Service started at ssl://" + hostName + ":" + port);
}
thread.start();
}
示例7: testDefaultServiceImpl
import org.apache.thrift.server.TThreadPoolServer; //导入依赖的package包/类
@Test
public void testDefaultServiceImpl() {
int serverPort = 49000;
ThriftServerConfiguration thriftServerConfiguration = new ThriftServerConfiguration();
thriftServerConfiguration.setServerArgsAspect(new ServerArgsAspect() {
@Override
public TThreadPoolServer.Args TThreadPoolServerArgsAspect(TThreadPoolServer.Args args) {
args.stopTimeoutVal = 1;
return args;
}
});
Factory factory = new GeneralFactory(thriftServerConfiguration);
ThriftServer thriftServer = factory.getThriftServer(serverPort, new TestService());
thriftServer.run();
ThriftClient thriftClient = factory.getThriftClient("localhost", serverPort);
try {
Thread.sleep(500);
Service service = factory.getService(thriftClient);
assertEquals(service.get(testString), testString);
} catch (Exception e) {
fail();
} finally {
thriftServer.stop();
}
}
示例8: main
import org.apache.thrift.server.TThreadPoolServer; //导入依赖的package包/类
public static void main(String[] args) {
try {
userProfileServerHandler = new UserProfileServerHandler();
userProfileProcessor = new UserProfileService.Processor(userProfileServerHandler);
TMultiplexedProcessor airavataServerProcessor = new TMultiplexedProcessor();
airavataServerProcessor.registerProcessor("UserProfileService", userProfileProcessor);
TServerTransport serverTransport = new TServerSocket(9190);
TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(airavataServerProcessor));
System.out.println("Starting User Profile server...");
server.serve();
} catch (Exception x) {
x.printStackTrace();
}
}
示例9: 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());
}
示例10: 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();
}
}
示例11: 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;
}
示例12: 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;
}
示例13: 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);
}
示例14: main
import org.apache.thrift.server.TThreadPoolServer; //导入依赖的package包/类
public static void main(String[] args) {
try {
handler = new CalculatorHandler();
processor = new Calculator.Processor(handler);
try {
TServerTransport serverTransport = new TServerSocket(9090);
TServer server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));
System.out.println("Starting the server...");
server.serve();
} catch (TTransportException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (Exception x) {
x.printStackTrace();
}
}
示例15: 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);
}