/** * @see #transportFactory(int) */ public static synchronized TTransportFactory transportFactory(long maxFrameSize) { if (maxFrameSize > Integer.MAX_VALUE || maxFrameSize < 1) throw new RuntimeException("Thrift transport frames are limited to " + Integer.MAX_VALUE); return transportFactory((int) maxFrameSize); }
/** * Creates a TThreadPoolServer for normal unsecure operation. Useful for comparing performance * against SSL or SASL transports. * * @param address * Address to bind to * @param processor * TProcessor for the server * @param maxMessageSize * Maximum size of a Thrift message allowed * @return A configured TThreadPoolServer and its bound address information */ public static ServerAddress createBlockingServer(HostAndPort address, TProcessor processor, TProtocolFactory protocolFactory, long maxMessageSize, String serverName, int numThreads, int numSimpleTimerThreads, long timeBetweenThreadChecks) throws TTransportException { InetSocketAddress isa = new InetSocketAddress(address.getHost(), address.getPort()); // Must use an ISA, providing only a port would ignore the hostname given TServerSocket transport = new TServerSocket(isa); ThreadPoolExecutor pool = createSelfResizingThreadPool(serverName, numThreads, numSimpleTimerThreads, timeBetweenThreadChecks); TThreadPoolServer server = createTThreadPoolServer(transport, processor, ThriftUtil.transportFactory(maxMessageSize), protocolFactory, pool); if (address.getPort() == 0) { address = HostAndPort.fromParts(address.getHost(), transport.getServerSocket().getLocalPort()); log.info("Blocking Server bound on {}", address); } return new ServerAddress(server, address); }
ThriftUtil.transportFactory(), protocolFactory, pool), address);
transport = ThriftUtil.transportFactory().getTransport(transport); } else if (saslParams != null) { if (!UserGroupInformation.isSecurityEnabled()) { transport = ThriftUtil.transportFactory().getTransport(transport);
/** * Create a NonBlockingServer with a custom thread pool that can dynamically resize itself. */ public static ServerAddress createNonBlockingServer(HostAndPort address, TProcessor processor, TProtocolFactory protocolFactory, final String serverName, final int numThreads, final int numSTThreads, long timeBetweenThreadChecks, long maxMessageSize) throws TTransportException { final TNonblockingServerSocket transport = new TNonblockingServerSocket( new InetSocketAddress(address.getHost(), address.getPort())); final CustomNonBlockingServer.Args options = new CustomNonBlockingServer.Args(transport); options.protocolFactory(protocolFactory); options.transportFactory(ThriftUtil.transportFactory(maxMessageSize)); options.maxReadBufferBytes = maxMessageSize; options.stopTimeoutVal(5); // Create our own very special thread pool. ThreadPoolExecutor pool = createSelfResizingThreadPool(serverName, numThreads, numSTThreads, timeBetweenThreadChecks); options.executorService(pool); options.processorFactory(new TProcessorFactory(processor)); if (address.getPort() == 0) { address = HostAndPort.fromParts(address.getHost(), transport.getPort()); } return new ServerAddress(new CustomNonBlockingServer(options), address); }
/** * @see #transportFactory(int) */ public static synchronized TTransportFactory transportFactory(long maxFrameSize) { if (maxFrameSize > Integer.MAX_VALUE || maxFrameSize < 1) throw new RuntimeException("Thrift transport frames are limited to " + Integer.MAX_VALUE); return transportFactory((int) maxFrameSize); }
/** * Creates a TTheadPoolServer for normal unsecure operation. Useful for comparing performance * against SSL or SASL transports. * * @param address * Address to bind to * @param processor * TProcessor for the server * @param maxMessageSize * Maximum size of a Thrift message allowed * @return A configured TThreadPoolServer and its bound address information */ public static ServerAddress createBlockingServer(HostAndPort address, TProcessor processor, TProtocolFactory protocolFactory, long maxMessageSize, String serverName, int numThreads, int numSimpleTimerThreads, long timeBetweenThreadChecks) throws TTransportException { TServerSocket transport = new TServerSocket(address.getPort()); ThreadPoolExecutor pool = createSelfResizingThreadPool(serverName, numThreads, numSimpleTimerThreads, timeBetweenThreadChecks); TThreadPoolServer server = createTThreadPoolServer(transport, processor, ThriftUtil.transportFactory(maxMessageSize), protocolFactory, pool); if (address.getPort() == 0) { address = HostAndPort.fromParts(address.getHost(), transport.getServerSocket().getLocalPort()); log.info("Blocking Server bound on {}", address); } return new ServerAddress(server, address); }
ThriftUtil.transportFactory(), protocolFactory, pool), address);
transport = ThriftUtil.transportFactory().getTransport(transport); } else if (null != saslParams) { if (!UserGroupInformation.isSecurityEnabled()) { transport = ThriftUtil.transportFactory().getTransport(transport);
/** * Create a NonBlockingServer with a custom thread pool that can dynamically resize itself. */ public static ServerAddress createNonBlockingServer(HostAndPort address, TProcessor processor, TProtocolFactory protocolFactory, final String serverName, String threadName, final int numThreads, final int numSTThreads, long timeBetweenThreadChecks, long maxMessageSize) throws TTransportException { final TNonblockingServerSocket transport = new TNonblockingServerSocket( new InetSocketAddress(address.getHost(), address.getPort())); final CustomNonBlockingServer.Args options = new CustomNonBlockingServer.Args(transport); options.protocolFactory(protocolFactory); options.transportFactory(ThriftUtil.transportFactory(maxMessageSize)); options.maxReadBufferBytes = maxMessageSize; options.stopTimeoutVal(5); // Create our own very special thread pool. ThreadPoolExecutor pool = createSelfResizingThreadPool(serverName, numThreads, numSTThreads, timeBetweenThreadChecks); options.executorService(pool); options.processorFactory(new TProcessorFactory(processor)); if (address.getPort() == 0) { address = HostAndPort.fromParts(address.getHost(), transport.getPort()); } return new ServerAddress(new CustomNonBlockingServer(options), address); }