/** * Server initialization. * * @throws Exception error */ public void start() throws Exception { log.info("initializing thrift server {}", getServerName()); final ThreadFactory threadFactory = new ThreadFactoryBuilder() .setNameFormat(threadPoolNameFormat) .setUncaughtExceptionHandler((t, e) -> log.error("Uncaught exception in thread: {}", t.getName(), e)) .build(); final ExecutorService executorService = new ThreadPoolExecutor( Math.min(2, config.getThriftServerMaxWorkerThreads()), config.getThriftServerMaxWorkerThreads(), 60L, TimeUnit.SECONDS, new SynchronousQueue<>(), threadFactory ); RegistryUtil.registerThreadPool(registry, threadPoolNameFormat, (ThreadPoolExecutor) executorService); final int timeout = config.getThriftServerSocketClientTimeoutInSeconds() * 1000; final TServerTransport serverTransport = new TServerSocket(portNumber, timeout); startServing(executorService, serverTransport); }
/** * Server initialization. * * @throws Exception error */ public void start() throws Exception { log.info("initializing thrift server {}", getServerName()); final ThreadFactory threadFactory = new ThreadFactoryBuilder() .setNameFormat(threadPoolNameFormat) .setUncaughtExceptionHandler((t, e) -> log.error("Uncaught exception in thread: {}", t.getName(), e)) .build(); final ExecutorService executorService = new ThreadPoolExecutor( Math.min(2, config.getThriftServerMaxWorkerThreads()), config.getThriftServerMaxWorkerThreads(), 60L, TimeUnit.SECONDS, new SynchronousQueue<>(), threadFactory ); RegistryUtil.registerThreadPool(registry, threadPoolNameFormat, (ThreadPoolExecutor) executorService); final int timeout = config.getThriftServerSocketClientTimeoutInSeconds() * 1000; final TServerTransport serverTransport = new TServerSocket(portNumber, timeout); startServing(executorService, serverTransport); }