protected ExecutorService createExecutor(BlockingQueue<Runnable> callQueue, int minWorkers, int maxWorkers) { ThreadFactoryBuilder tfb = new ThreadFactoryBuilder(); tfb.setDaemon(true); tfb.setNameFormat("thrift-worker-%d"); ThreadPoolExecutor threadPool = new THBaseThreadPoolExecutor(minWorkers, maxWorkers, Long.MAX_VALUE, TimeUnit.SECONDS, callQueue, tfb.build(), metrics); threadPool.allowCoreThreadTimeOut(true); return threadPool; }
public TBoundedThreadPoolServer(Args options, ThriftMetrics metrics) { super(options); int minWorkerThreads = options.minWorkerThreads; int maxWorkerThreads = options.maxWorkerThreads; if (options.maxQueuedRequests > 0) { this.callQueue = new CallQueue( new LinkedBlockingQueue<>(options.maxQueuedRequests), metrics); minWorkerThreads = maxWorkerThreads; } else { this.callQueue = new CallQueue(new SynchronousQueue<>(), metrics); } ThreadFactoryBuilder tfb = new ThreadFactoryBuilder(); tfb.setDaemon(true); tfb.setNameFormat("thrift-worker-%d"); executorService = new THBaseThreadPoolExecutor(minWorkerThreads, maxWorkerThreads, options.threadKeepAliveTimeSec, TimeUnit.SECONDS, this.callQueue, tfb.build(), metrics); executorService.allowCoreThreadTimeOut(true); serverOptions = options; }
ExecutorService createExecutor(BlockingQueue<Runnable> callQueue, int minWorkers, int maxWorkers) { ThreadFactoryBuilder tfb = new ThreadFactoryBuilder(); tfb.setDaemon(true); tfb.setNameFormat("thrift-worker-%d"); ThreadPoolExecutor threadPool = new THBaseThreadPoolExecutor(minWorkers, maxWorkers, Long.MAX_VALUE, TimeUnit.SECONDS, callQueue, tfb.build(), metrics); threadPool.allowCoreThreadTimeOut(true); return threadPool; }
ExecutorService createExecutor(BlockingQueue<Runnable> callQueue, int minWorkers, int maxWorkers) { ThreadFactoryBuilder tfb = new ThreadFactoryBuilder(); tfb.setDaemon(true); tfb.setNameFormat("thrift-worker-%d"); ThreadPoolExecutor threadPool = new THBaseThreadPoolExecutor(minWorkers, maxWorkers, Long.MAX_VALUE, TimeUnit.SECONDS, callQueue, tfb.build(), metrics); threadPool.allowCoreThreadTimeOut(true); return threadPool; }
public TBoundedThreadPoolServer(Args options, ThriftMetrics metrics) { super(options); int minWorkerThreads = options.minWorkerThreads; int maxWorkerThreads = options.maxWorkerThreads; if (options.maxQueuedRequests > 0) { this.callQueue = new CallQueue( new LinkedBlockingQueue<>(options.maxQueuedRequests), metrics); minWorkerThreads = maxWorkerThreads; } else { this.callQueue = new CallQueue(new SynchronousQueue<>(), metrics); } ThreadFactoryBuilder tfb = new ThreadFactoryBuilder(); tfb.setDaemon(true); tfb.setNameFormat("thrift-worker-%d"); executorService = new THBaseThreadPoolExecutor(minWorkerThreads, maxWorkerThreads, options.threadKeepAliveTimeSec, TimeUnit.SECONDS, this.callQueue, tfb.build(), metrics); executorService.allowCoreThreadTimeOut(true); serverOptions = options; }
private static ExecutorService createExecutor( int workerThreads, int maxCallQueueSize, ThriftMetrics metrics) { CallQueue callQueue; if (maxCallQueueSize > 0) { callQueue = new CallQueue(new LinkedBlockingQueue<>(maxCallQueueSize), metrics); } else { callQueue = new CallQueue(new LinkedBlockingQueue<>(), metrics); } ThreadFactoryBuilder tfb = new ThreadFactoryBuilder(); tfb.setDaemon(true); tfb.setNameFormat("thrift2-worker-%d"); ThreadPoolExecutor pool = new THBaseThreadPoolExecutor(workerThreads, workerThreads, Long.MAX_VALUE, TimeUnit.SECONDS, callQueue, tfb.build(), metrics); pool.prestartAllCoreThreads(); return pool; }
public TBoundedThreadPoolServer(Args options, ThriftMetrics metrics) { super(options); int minWorkerThreads = options.minWorkerThreads; int maxWorkerThreads = options.maxWorkerThreads; if (options.maxQueuedRequests > 0) { this.callQueue = new CallQueue( new LinkedBlockingQueue<>(options.maxQueuedRequests), metrics); minWorkerThreads = maxWorkerThreads; } else { this.callQueue = new CallQueue(new SynchronousQueue<>(), metrics); } ThreadFactoryBuilder tfb = new ThreadFactoryBuilder(); tfb.setDaemon(true); tfb.setNameFormat("thrift-worker-%d"); executorService = new THBaseThreadPoolExecutor(minWorkerThreads, maxWorkerThreads, options.threadKeepAliveTimeSec, TimeUnit.SECONDS, this.callQueue, tfb.build(), metrics); executorService.allowCoreThreadTimeOut(true); serverOptions = options; }
private static ExecutorService createExecutor( int workerThreads, int maxCallQueueSize, ThriftMetrics metrics) { CallQueue callQueue; if (maxCallQueueSize > 0) { callQueue = new CallQueue(new LinkedBlockingQueue<>(maxCallQueueSize), metrics); } else { callQueue = new CallQueue(new LinkedBlockingQueue<>(), metrics); } ThreadFactoryBuilder tfb = new ThreadFactoryBuilder(); tfb.setDaemon(true); tfb.setNameFormat("thrift2-worker-%d"); ThreadPoolExecutor pool = new THBaseThreadPoolExecutor(workerThreads, workerThreads, Long.MAX_VALUE, TimeUnit.SECONDS, callQueue, tfb.build(), metrics); pool.prestartAllCoreThreads(); return pool; }
private static TServer getTThreadPoolServer(TProtocolFactory protocolFactory, TProcessor processor, TTransportFactory transportFactory, int workerThreads, InetSocketAddress inetSocketAddress, int backlog, int clientTimeout, ThriftMetrics metrics) 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); } ThreadPoolExecutor executor = new THBaseThreadPoolExecutor(serverArgs.minWorkerThreads, serverArgs.maxWorkerThreads, serverArgs.stopTimeoutVal, TimeUnit.SECONDS, new SynchronousQueue<>(), metrics); serverArgs.executorService(executor); return new TThreadPoolServer(serverArgs); }
private static TServer getTThreadPoolServer(TProtocolFactory protocolFactory, TProcessor processor, TTransportFactory transportFactory, int workerThreads, InetSocketAddress inetSocketAddress, int backlog, int clientTimeout, ThriftMetrics metrics) 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); } ThreadPoolExecutor executor = new THBaseThreadPoolExecutor(serverArgs.minWorkerThreads, serverArgs.maxWorkerThreads, serverArgs.stopTimeoutVal, TimeUnit.SECONDS, new SynchronousQueue<>(), metrics); serverArgs.executorService(executor); return new TThreadPoolServer(serverArgs); }