use of org.apache.storm.thrift.server.TThreadPoolServer in project storm by apache.
the class SaslTransportPlugin method getServer.
@Override
public TServer getServer(TProcessor processor) throws IOException, TTransportException {
int configuredPort = type.getPort(conf);
Integer socketTimeout = type.getSocketTimeOut(conf);
TTransportFactory serverTransportFactory = getServerTransportFactory(type.isImpersonationAllowed());
TServerSocket serverTransport = null;
if (socketTimeout != null) {
serverTransport = new TServerSocket(configuredPort, socketTimeout);
} else {
serverTransport = new TServerSocket(configuredPort);
}
this.port = serverTransport.getServerSocket().getLocalPort();
int numWorkerThreads = type.getNumThreads(conf);
Integer queueSize = type.getQueueSize(conf);
TThreadPoolServer.Args serverArgs = new TThreadPoolServer.Args(serverTransport).processor(new TUGIWrapProcessor(processor)).minWorkerThreads(numWorkerThreads).maxWorkerThreads(numWorkerThreads).protocolFactory(new TBinaryProtocol.Factory(false, true));
if (serverTransportFactory != null) {
serverArgs.transportFactory(serverTransportFactory);
}
BlockingQueue<Runnable> workQueue = new SynchronousQueue<>();
if (queueSize != null) {
workQueue = new ArrayBlockingQueue<>(queueSize);
}
ThreadPoolExecutor executorService = new ExtendedThreadPoolExecutor(numWorkerThreads, numWorkerThreads, 60, TimeUnit.SECONDS, workQueue);
serverArgs.executorService(executorService);
return new TThreadPoolServer(serverArgs);
}
Aggregations