org.apache.thrift.server.TThreadPoolServer Java Examples
The following examples show how to use
org.apache.thrift.server.TThreadPoolServer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SyncEchoTestServer.java From pinpoint with Apache License 2.0 | 6 votes |
public static SyncEchoTestServer<TThreadPoolServer> threadedPoolServer(final TestEnvironment environment) throws TTransportException { TThreadPoolServer server = new TThreadPoolServer(new TThreadPoolServer.Args(new TServerSocket( environment.getPort())).processor(getProcessor()) .inputProtocolFactory(environment.getProtocolFactory()) .outputProtocolFactory(environment.getProtocolFactory())); return new SyncEchoTestServer<TThreadPoolServer>(server, environment) { @Override public SyncEchoTestClient getSynchronousClient() throws TTransportException { return new SyncEchoTestClient.Client(environment); } @Override public AsyncEchoTestClient getAsynchronousClient() throws IOException { return new AsyncEchoTestClient.Client(environment); } }; }
Example #2
Source File: TestThriftClientPool.java From thrift-client-pool-java with Artistic License 2.0 | 6 votes |
@BeforeClass public static void setUp() { int port = 9090; try { TServerTransport serverTransport = new TServerSocket(port); Args processor = new TThreadPoolServer.Args(serverTransport) .inputTransportFactory(new TFramedTransport.Factory()) .outputTransportFactory(new TFramedTransport.Factory()) .processor(new Processor<>(new TestThriftServiceHandler())); // processor.maxWorkerThreads = 20; TThreadPoolServer server = new TThreadPoolServer(processor); logger.info("Starting test server..."); new Thread(server::serve).start(); Thread.sleep(1000); // waiting server init } catch (Exception e) { e.printStackTrace(); } }
Example #3
Source File: HiveTableBaseTest.java From iceberg with Apache License 2.0 | 6 votes |
private TServer thriftServer() throws IOException, TTransportException, MetaException, InvocationTargetException, NoSuchMethodException, IllegalAccessException, NoSuchFieldException { final TServerSocketKeepAlive socket = new TServerSocketKeepAlive(new TServerSocket(0)); this.hiveConf = hiveConf(new Configuration(), socket.getServerSocket().getLocalPort()); HiveMetaStore.HMSHandler baseHandler = new HiveMetaStore.HMSHandler("new db based metaserver", hiveConf); IHMSHandler handler = RetryingHMSHandler.getProxy(hiveConf, baseHandler, true); final TTransportFactory transportFactory = new TTransportFactory(); final TSetIpAddressProcessor<IHMSHandler> processor = new TSetIpAddressProcessor<>(handler); TThreadPoolServer.Args args = new TThreadPoolServer.Args(socket) .processor(processor) .transportFactory(transportFactory) .protocolFactory(new TBinaryProtocol.Factory()) .minWorkerThreads(3) .maxWorkerThreads(5); return new TThreadPoolServer(args); }
Example #4
Source File: HelloServerConfig.java From jigsaw-payment with Apache License 2.0 | 6 votes |
@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); }
Example #5
Source File: TestThriftServiceStarter.java From thrift-client-pool-java with Artistic License 2.0 | 6 votes |
public static void main(String[] args) { int port = 9090; try { TServerTransport serverTransport = new TServerSocket(port); Args processor = new TThreadPoolServer.Args(serverTransport) .inputTransportFactory(new TFramedTransport.Factory()) .outputTransportFactory(new TFramedTransport.Factory()) .processor(new Processor<>(new TestThriftServiceHandler())); // processor.maxWorkerThreads = 20; TThreadPoolServer server = new TThreadPoolServer(processor); System.out.println("Starting the server..."); server.serve(); } catch (Exception e) { e.printStackTrace(); } }
Example #6
Source File: ThriftITest.java From java-specialagent with Apache License 2.0 | 6 votes |
private static TServer startNewThreadPoolServer(final TServerTransport transport) { final TProtocolFactory protocolFactory = new TBinaryProtocol.Factory(); final CustomHandler customHandler = new CustomHandler(); final CustomService.Processor<CustomService.Iface> customProcessor = new CustomService.Processor<CustomService.Iface>(customHandler); final TThreadPoolServer.Args args = new TThreadPoolServer .Args(transport) .processorFactory(new TProcessorFactory(customProcessor)) .protocolFactory(protocolFactory) .minWorkerThreads(5) .maxWorkerThreads(10); final TServer server = new TThreadPoolServer(args); new Thread(new Runnable() { @Override public void run() { server.serve(); } }).start(); return server; }
Example #7
Source File: ThriftTest.java From java-specialagent with Apache License 2.0 | 6 votes |
private void startNewThreadPoolServer() throws Exception { final TServerTransport transport = new TServerSocket(port); final TProtocolFactory protocolFactory = new TBinaryProtocol.Factory(); // TTransportFactory transportFactory = new TFramedTransport.Factory(); final CustomHandler customHandler = new CustomHandler(); final TProcessor customProcessor = new CustomService.Processor<CustomService.Iface>(customHandler); final TThreadPoolServer.Args args = new TThreadPoolServer.Args(transport) .processorFactory(new TProcessorFactory(customProcessor)) .protocolFactory(protocolFactory) // .transportFactory(transportFactory) .minWorkerThreads(5) // .executorService(Executors.newCachedThreadPool()) .maxWorkerThreads(10); server = new TThreadPoolServer(args); new Thread(new Runnable() { @Override public void run() { server.serve(); } }).start(); }
Example #8
Source File: IoTDBThreadPoolFactoryTest.java From incubator-iotdb with Apache License 2.0 | 6 votes |
@Test public void testCreateJDBCClientThreadPool() throws InterruptedException { String reason = "(can be ignored in Tests) CreateJDBCClientThreadPool"; TThreadPoolServer.Args args = new Args(null); args.maxWorkerThreads = 4; args.minWorkerThreads = 2; args.stopTimeoutVal = 10; args.stopTimeoutUnit = TimeUnit.SECONDS; Thread.UncaughtExceptionHandler handler = new TestExceptionHandler(reason); int threadCount = 4; latch = new CountDownLatch(threadCount); ExecutorService exec = IoTDBThreadPoolFactory .createThriftRpcClientThreadPool(args, POOL_NAME, handler); for (int i = 0; i < threadCount; i++) { Runnable task = new TestThread(reason); exec.execute(task); } try { latch.await(); assertEquals(count.get(), threadCount); } catch (InterruptedException E) { fail(); } }
Example #9
Source File: ServiceTest.java From ikasoa with MIT License | 6 votes |
@Test public void testServiceImpl() { int serverPort = ServerUtil.getNewPort(); 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(); waiting(); try (ThriftClient thriftClient = factory.getThriftClient(TestConstants.LOCAL_HOST, serverPort)) { assertEquals(factory.getService(thriftClient).get(TestConstants.TEST_STRING), TestConstants.TEST_STRING); } catch (Exception e) { fail(); } finally { thriftServer.stop(); } }
Example #10
Source File: ThriftLegacySource.java From mt-flume with Apache License 2.0 | 6 votes |
@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(); }
Example #11
Source File: DKSearchService.java From dk-fitting with Apache License 2.0 | 6 votes |
/** * 线程池服务模型,使用标准的阻塞式IO,预先创建一组线程处理请求。 */ public void startTThreadPoolServer() { try { System.out.println("UserInfoServiceDemo TThreadPoolServer start ...."); TMultiplexedProcessor processor = new TMultiplexedProcessor(); processor.registerProcessor( "DKSearchOutput",new DKSearchOutput.Processor<DKSearchOutput.Iface>( new DKSearchOutputImpl() ) ); processor.registerProcessor( "DKSearchInput",new DKSearchInput.Processor<DKSearchInput.Iface>(new DKSearchInputImpl() ) ); processor.registerProcessor( "DKSearchService",new SearchService.Processor<SearchService.Iface>(new SearchServiceImpl() ) ); //TProcessor tprocessor = new UserInfoService.Processor<UserInfoService.Iface>(new UserInfoServiceImpl()); TServerSocket serverTransport = new TServerSocket( Integer.valueOf(prop.get("dkSearch.port"))); TThreadPoolServer.Args ttpsArgs = new TThreadPoolServer.Args(serverTransport); ttpsArgs.processor(processor); ttpsArgs.protocolFactory(new TBinaryProtocol.Factory()); // 线程池服务模型,使用标准的阻塞式IO,预先创建一组线程处理请求。 TServer server = new TThreadPoolServer(ttpsArgs); server.serve(); } catch (Exception e) { System.out.println("Server start error!!!"); e.printStackTrace(); } }
Example #12
Source File: DKMLServer.java From dk-fitting with Apache License 2.0 | 6 votes |
/** * 阻塞式、多线程处理 * * @param args */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static void main(String[] args) { try { int port = Integer.valueOf(prop.get("dkml.port")); //设置传输通道,普通通道 TServerTransport serverTransport = new TServerSocket(port); //使用高密度二进制协议 TProtocolFactory proFactory = new TCompactProtocol.Factory(); //设置处理器 TProcessor processor = new DKML.Processor(new DKMLImpl()); //创建服务器 TServer server = new TThreadPoolServer( new TThreadPoolServer.Args(serverTransport) .protocolFactory(proFactory) .processor(processor) ); System.out.println("Start server on port "+ port +"..."); server.serve(); } catch (Exception e) { e.printStackTrace(); } }
Example #13
Source File: TCPThriftAuthenticationService.java From carbon-identity with Apache License 2.0 | 6 votes |
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(); }
Example #14
Source File: CoronaTaskTracker.java From RDFS with Apache License 2.0 | 6 votes |
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()); }
Example #15
Source File: TestExampleService.java From ikasoa with MIT License | 5 votes |
@Before public void setUp() { // configurator.setClientInvocationHandler(new // LoggerClientInvocationHandlerImpl()); thriftServerConfiguration.setServerArgsAspect(new ServerArgsAspect() { @Override public TThreadPoolServer.Args tThreadPoolServerArgsAspect(TThreadPoolServer.Args args) { args.stopTimeoutVal = 1; return args; } }); }
Example #16
Source File: ThreadPoolThriftServerImpl.java From ikasoa with MIT License | 5 votes |
/** * 初始化Thrift服务 * <p> * 启动Thrift服务之前必须要进行初始化. * * @param serverTransport * 服务传输类型 */ protected void initServer(TServerTransport serverTransport) { ThriftServerConfiguration configuration = getServerConfiguration(); // 使用TThreadPoolServer方式启动Thrift服务器,对每个连接都会单独建立一个线程. TThreadPoolServer.Args args = new TThreadPoolServer.Args(serverTransport) .transportFactory(configuration.getTransportFactory()) .protocolFactory(configuration.getProtocolFactory()); // 如果不设置ExecutorService,则默认使用ThreadPoolExecutor实现. if (ObjectUtil.isNotNull(configuration.getExecutorService())) args.executorService(configuration.getExecutorService()); server = new TThreadPoolServer( configuration.getServerArgsAspect().tThreadPoolServerArgsAspect(args).processor(getProcessor())); if (ObjectUtil.isNotNull(configuration.getServerEventHandler())) server.setServerEventHandler(configuration.getServerEventHandler()); }
Example #17
Source File: ThriftServer.java From ThriftBook with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws TTransportException, IOException { TradeHistory.Processor proc = new TradeHistory.Processor(new TradeHistoryHandler()); TServerSocket trans_svr = new TServerSocket(9090); TThreadPoolServer server = new TThreadPoolServer(new TThreadPoolServer.Args(trans_svr).processor(proc)); System.out.println("[Server] listening of port 9090"); server.serve(); }
Example #18
Source File: AysncServiceTest.java From ikasoa with MIT License | 5 votes |
@Before public void setUp() { thriftServerConfiguration.setProtocolFactory(new TCompactProtocol.Factory()); thriftServerConfiguration.setServerArgsAspect(new ServerArgsAspect() { @Override public TThreadPoolServer.Args tThreadPoolServerArgsAspect(TThreadPoolServer.Args args) { args.stopTimeoutVal = 1; return args; } }); }
Example #19
Source File: AbstractTest.java From dubbox-hystrix with Apache License 2.0 | 5 votes |
protected void init() throws Exception { TServerTransport serverTransport = new TServerSocket( PORT ); TBinaryProtocol.Factory bFactory = new TBinaryProtocol.Factory(); server = new TThreadPoolServer( new TThreadPoolServer.Args( serverTransport ) .inputProtocolFactory( bFactory ) .outputProtocolFactory( bFactory ) .inputTransportFactory( getTransportFactory() ) .outputTransportFactory( getTransportFactory() ) .processor( getProcessor() ) ); Thread startTread = new Thread() { @Override public void run() { server.serve(); } }; startTread.setName( "thrift-server" ); startTread.start(); while( !server.isServing() ) { Thread.sleep( 100 ); } protocol = ExtensionLoader.getExtensionLoader(Protocol.class) .getExtension( ThriftProtocol.NAME ); invoker = protocol.refer( getInterface(), getUrl() ); }
Example #20
Source File: ServerTest.java From ikasoa with MIT License | 5 votes |
@Test public void testAysncThriftServerImpl() { int serverPort = ServerUtil.getNewPort(); ThriftServerConfiguration thriftServerConfiguration = new ThriftServerConfiguration(); thriftServerConfiguration.setProtocolFactory(new TCompactProtocol.Factory()); thriftServerConfiguration.setProcessorFactory(new TProcessorFactory(processor)); 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(serverName, serverPort, processor); thriftServer.run(); waiting(); try { ThriftSimpleService.AsyncClient thriftClient = new ThriftSimpleService.AsyncClient( new TCompactProtocol.Factory(), new TAsyncClientManager(), new TNonblockingSocket(TestConstants.LOCAL_HOST, serverPort)); thriftClient.get(TestConstants.TEST_STRING, new TestCallback()); waiting(); } catch (Exception e) { fail(); } finally { thriftServer.stop(); } }
Example #21
Source File: AbstractTest.java From dubbox with Apache License 2.0 | 5 votes |
protected void init() throws Exception { TServerTransport serverTransport = new TServerSocket( PORT ); TBinaryProtocol.Factory bFactory = new TBinaryProtocol.Factory(); server = new TThreadPoolServer( new TThreadPoolServer.Args( serverTransport ) .inputProtocolFactory( bFactory ) .outputProtocolFactory( bFactory ) .inputTransportFactory( getTransportFactory() ) .outputTransportFactory( getTransportFactory() ) .processor( getProcessor() ) ); Thread startTread = new Thread() { @Override public void run() { server.serve(); } }; startTread.setName( "thrift-server" ); startTread.start(); while( !server.isServing() ) { Thread.sleep( 100 ); } protocol = ExtensionLoader.getExtensionLoader(Protocol.class) .getExtension( ThriftProtocol.NAME ); invoker = protocol.refer( getInterface(), getUrl() ); }
Example #22
Source File: ThriftServer.java From ThriftBook with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws TTransportException, IOException { TradeHistory.Processor proc = new TradeHistory.Processor(new TradeHistoryHandler()); TServerSocket trans_svr = new TServerSocket(9090); TThreadPoolServer server = new TThreadPoolServer(new TThreadPoolServer.Args(trans_svr) .protocolFactory(new TJSONProtocol.Factory()) .processor(proc)); System.out.println("[Server] listening of port 9090"); server.serve(); }
Example #23
Source File: FactoryServer.java From ThriftBook with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws TTransportException { TServerSocket trans_svr = new TServerSocket(9090); TProcessor proc = new Message.Processor<>(new MessageHandler()); TServer server = new TThreadPoolServer( new TThreadPoolServer.Args(trans_svr) .processor(proc) .protocolFactory(new TJSONProtocol.Factory()) .inputTransportFactory(new TFramedTransport.Factory()) .outputTransportFactory(new TWritelogTransportFactory(100))); server.serve(); }
Example #24
Source File: ServiceProvider.java From ourea with Apache License 2.0 | 5 votes |
/** * 启动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--------------"); }
Example #25
Source File: ExampleServer.java From Thrift-Connection-Pool with Apache License 2.0 | 5 votes |
public static void main(String[] args) { try { int port = 9119; TServerTransport serverTransport = new TServerSocket(port); Factory proFactory = new TBinaryProtocol.Factory(); Processor<Iface> processor = new Example.Processor<Example.Iface>(new Example.Iface() { @Override public void pong() throws TException { System.out.println("pong"); } @Override public void ping() throws TException { System.out.println("ping"); } }); Args thriftArgs = new Args(serverTransport); thriftArgs.processor(processor); thriftArgs.protocolFactory(proFactory); TServer tserver = new TThreadPoolServer(thriftArgs); System.out.println("启动监听:" + port); tserver.serve(); } catch (TTransportException e) { e.printStackTrace(); } }
Example #26
Source File: AbstractTest.java From dubbox with Apache License 2.0 | 5 votes |
protected void init() throws Exception { TServerTransport serverTransport = new TServerSocket( PORT ); TBinaryProtocol.Factory bFactory = new TBinaryProtocol.Factory(); server = new TThreadPoolServer( new TThreadPoolServer.Args( serverTransport ) .inputProtocolFactory( bFactory ) .outputProtocolFactory( bFactory ) .inputTransportFactory( getTransportFactory() ) .outputTransportFactory( getTransportFactory() ) .processor( getProcessor() ) ); Thread startTread = new Thread() { @Override public void run() { server.serve(); } }; startTread.setName( "thrift-server" ); startTread.start(); while( !server.isServing() ) { Thread.sleep( 100 ); } protocol = ExtensionLoader.getExtensionLoader(Protocol.class) .getExtension( ThriftProtocol.NAME ); invoker = protocol.refer( getInterface(), getUrl() ); }
Example #27
Source File: TestBookKeeperFactory.java From rubix with Apache License 2.0 | 5 votes |
void startServer(Configuration conf) throws TException { BookKeeperService.Iface bookKeeper = mock(BookKeeperService.Iface.class); when(bookKeeper.isBookKeeperAlive()).then(new GetBookKeeperAliveStatus()); try { TServerTransport serverTransport = new TServerSocket(CacheConfig.getBookKeeperServerPort(conf)); BookKeeperService.Processor processor = new BookKeeperService.Processor<>(bookKeeper); server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor)); server.serve(); } catch (TException e) { log.error("Error starting MockBookKeeperServer", e); } }
Example #28
Source File: AbstractThriftServer.java From metacat with Apache License 2.0 | 5 votes |
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(); } }
Example #29
Source File: AbstractTest.java From dubbox with Apache License 2.0 | 5 votes |
protected void init() throws Exception { TServerTransport serverTransport = new TServerSocket( PORT ); TBinaryProtocol.Factory bFactory = new TBinaryProtocol.Factory(); server = new TThreadPoolServer( new TThreadPoolServer.Args( serverTransport ) .inputProtocolFactory( bFactory ) .outputProtocolFactory( bFactory ) .inputTransportFactory( getTransportFactory() ) .outputTransportFactory( getTransportFactory() ) .processor( getProcessor() ) ); Thread startTread = new Thread() { @Override public void run() { server.serve(); } }; startTread.setName( "thrift-server" ); startTread.start(); while( !server.isServing() ) { Thread.sleep( 100 ); } protocol = ExtensionLoader.getExtensionLoader(Protocol.class) .getExtension( ThriftProtocol.NAME ); invoker = protocol.refer( getInterface(), getUrl() ); }
Example #30
Source File: TestHiveMetastore.java From iceberg with Apache License 2.0 | 5 votes |
private TServer newThriftServer(TServerSocket socket, HiveConf conf) throws Exception { HiveConf serverConf = new HiveConf(conf); serverConf.set(HiveConf.ConfVars.METASTORECONNECTURLKEY.varname, "jdbc:derby:" + getDerbyPath() + ";create=true"); HiveMetaStore.HMSHandler baseHandler = new HiveMetaStore.HMSHandler("new db based metaserver", serverConf); IHMSHandler handler = RetryingHMSHandler.getProxy(serverConf, baseHandler, false); TThreadPoolServer.Args args = new TThreadPoolServer.Args(socket) .processor(new TSetIpAddressProcessor<>(handler)) .transportFactory(new TTransportFactory()) .protocolFactory(new TBinaryProtocol.Factory()) .minWorkerThreads(3) .maxWorkerThreads(5); return new TThreadPoolServer(args); }