private static List<DriftServer> startThriftServers(int thriftServers, boolean enableIndexJoin) { List<DriftServer> servers = new ArrayList<>(thriftServers); for (int i = 0; i < thriftServers; i++) { ThriftTpchService service = enableIndexJoin ? new ThriftIndexedTpchService() : new ThriftTpchService(); DriftServer server = new DriftServer( new DriftNettyServerTransportFactory(new DriftNettyServerConfig()), CODEC_MANAGER, new NullMethodInvocationStatsFactory(), ImmutableSet.of(new DriftService(service)), ImmutableSet.of()); server.start(); servers.add(server); } return servers; }
.build(); DriftNettyServerConfig expected = new DriftNettyServerConfig() .setPort(99) .setAcceptBacklog(101) .setIoThreadCount(202) .setWorkerThreadCount(303) .setRequestTimeout(new Duration(33, MINUTES)) .setMaxFrameSize(new DataSize(55, MEGABYTE)) .setSslContextRefreshTime(new Duration(33, MINUTES)) .setAllowPlaintext(false) .setSslEnabled(true) .setTrustCertificate(new File("trust")) .setKey(new File("key")) .setKeyPassword("key_password") .setSessionCacheSize(678) .setSessionTimeout(new Duration(78, HOURS)) .setCiphers("some_cipher") .setAssumeClientsSupportOutOfOrderResponses(false);
this.port = config.getPort(); ioGroup = new NioEventLoopGroup(config.getIoThreadCount(), threadsNamed("drift-server-io-%s")); workerGroup = new NioEventLoopGroup(config.getWorkerThreadCount(), threadsNamed("drift-server-worker-%s")); if (config.isSslEnabled()) { SslContextFactory sslContextFactory = createSslContextFactory(false, config.getSslContextRefreshTime(), workerGroup); sslContext = Optional.of(sslContextFactory.get( config.getTrustCertificate(), Optional.ofNullable(config.getKey()), Optional.ofNullable(config.getKey()), Optional.ofNullable(config.getKeyPassword()), config.getSessionCacheSize(), config.getSessionTimeout(), config.getCiphers())); config.getMaxFrameSize(), config.getRequestTimeout(), sslContext, config.isAllowPlaintext(), config.isAssumeClientsSupportOutOfOrderResponses(), workerGroup); .channel(NioServerSocketChannel.class) .childHandler(serverInitializer) .option(SO_BACKLOG, config.getAcceptBacklog()) .option(ALLOCATOR, allocator) .childOption(SO_KEEPALIVE, true)
private static int testDriftServer(ServerMethodInvoker methodInvoker, List<ToIntFunction<HostAndPort>> clients) { DriftNettyServerConfig config = new DriftNettyServerConfig() .setSslEnabled(true) .setTrustCertificate(ClientTestUtils.getCertificateChainFile()) .setKey(ClientTestUtils.getPrivateKeyFile()); TestingPooledByteBufAllocator testingAllocator = new TestingPooledByteBufAllocator(); ServerTransport serverTransport = new DriftNettyServerTransportFactory(config, testingAllocator).createServerTransport(methodInvoker); try { serverTransport.start(); HostAndPort address = HostAndPort.fromParts("localhost", ((DriftNettyServerTransport) serverTransport).getPort()); int sum = 0; for (ToIntFunction<HostAndPort> client : clients) { sum += client.applyAsInt(address); } return sum; } finally { serverTransport.shutdown(); testingAllocator.close(); } }
private static int testServerMethodInvoker(ServerMethodInvoker methodInvoker, boolean assumeClientsSupportOutOfOrderResponses, List<ToIntFunction<HostAndPort>> clients) { DriftNettyServerConfig config = new DriftNettyServerConfig() .setAssumeClientsSupportOutOfOrderResponses(assumeClientsSupportOutOfOrderResponses); TestingPooledByteBufAllocator testingAllocator = new TestingPooledByteBufAllocator(); ServerTransport serverTransport = new DriftNettyServerTransportFactory(config, testingAllocator).createServerTransport(methodInvoker); try { serverTransport.start(); HostAndPort address = HostAndPort.fromParts("localhost", ((DriftNettyServerTransport) serverTransport).getPort()); int sum = 0; for (ToIntFunction<HostAndPort> client : clients) { sum += client.applyAsInt(address); } return sum; } finally { serverTransport.shutdown(); testingAllocator.close(); } }
.build(); DriftNettyServerConfig expected = new DriftNettyServerConfig() .setPort(99) .setAcceptBacklog(101) .setIoThreadCount(202) .setWorkerThreadCount(303) .setRequestTimeout(new Duration(33, MINUTES)) .setMaxFrameSize(new DataSize(55, MEGABYTE)) .setSslContextRefreshTime(new Duration(33, MINUTES)) .setAllowPlaintext(false) .setSslEnabled(true) .setTrustCertificate(new File("trust")) .setKey(new File("key")) .setKeyPassword("key_password") .setSessionCacheSize(678) .setSessionTimeout(new Duration(78, HOURS)) .setCiphers("some_cipher") .setAssumeClientsSupportOutOfOrderResponses(false);
this.port = config.getPort(); ioGroup = new NioEventLoopGroup(config.getIoThreadCount(), threadsNamed("drift-server-io-%s")); workerGroup = new NioEventLoopGroup(config.getWorkerThreadCount(), threadsNamed("drift-server-worker-%s")); if (config.isSslEnabled()) { SslContextFactory sslContextFactory = createSslContextFactory(false, config.getSslContextRefreshTime(), workerGroup); sslContext = Optional.of(sslContextFactory.get( config.getTrustCertificate(), Optional.ofNullable(config.getKey()), Optional.ofNullable(config.getKey()), Optional.ofNullable(config.getKeyPassword()), config.getSessionCacheSize(), config.getSessionTimeout(), config.getCiphers())); config.getMaxFrameSize(), config.getRequestTimeout(), sslContext, config.isAllowPlaintext(), config.isAssumeClientsSupportOutOfOrderResponses(), workerGroup); .channel(NioServerSocketChannel.class) .childHandler(serverInitializer) .option(SO_BACKLOG, config.getAcceptBacklog()) .option(ALLOCATOR, allocator) .childOption(SO_KEEPALIVE, true)
private static void testDriftServer(DriftService service, Consumer<HostAndPort> task) { DriftNettyServerConfig config = new DriftNettyServerConfig() .setSslEnabled(true) .setTrustCertificate(ClientTestUtils.getCertificateChainFile()) .setKey(ClientTestUtils.getPrivateKeyFile()); TestingPooledByteBufAllocator testingAllocator = new TestingPooledByteBufAllocator(); DriftServer driftServer = new DriftServer( new DriftNettyServerTransportFactory(config, testingAllocator), CODEC_MANAGER, new NullMethodInvocationStatsFactory(), ImmutableSet.of(service), ImmutableSet.of()); try { driftServer.start(); HostAndPort address = HostAndPort.fromParts("localhost", ((DriftNettyServerTransport) driftServer.getServerTransport()).getPort()); task.accept(address); } finally { driftServer.shutdown(); testingAllocator.close(); } } }
private static int testServerMethodInvoker(ServerMethodInvoker methodInvoker, boolean assumeClientsSupportOutOfOrderResponses, List<ToIntFunction<HostAndPort>> clients) { DriftNettyServerConfig config = new DriftNettyServerConfig() .setAssumeClientsSupportOutOfOrderResponses(assumeClientsSupportOutOfOrderResponses); TestingPooledByteBufAllocator testingAllocator = new TestingPooledByteBufAllocator(); ServerTransport serverTransport = new DriftNettyServerTransportFactory(config, testingAllocator).createServerTransport(methodInvoker); try { serverTransport.start(); HostAndPort address = HostAndPort.fromParts("localhost", ((DriftNettyServerTransport) serverTransport).getPort()); int sum = 0; for (ToIntFunction<HostAndPort> client : clients) { sum += client.applyAsInt(address); } return sum; } finally { serverTransport.shutdown(); testingAllocator.close(); } }
private static List<DriftServer> startThriftServers(int thriftServers, boolean enableIndexJoin) { List<DriftServer> servers = new ArrayList<>(thriftServers); for (int i = 0; i < thriftServers; i++) { ThriftTpchService service = enableIndexJoin ? new ThriftIndexedTpchService() : new ThriftTpchService(); DriftServer server = new DriftServer( new DriftNettyServerTransportFactory(new DriftNettyServerConfig()), CODEC_MANAGER, new NullMethodInvocationStatsFactory(), ImmutableSet.of(new DriftService(service)), ImmutableSet.of()); server.start(); servers.add(server); } return servers; }
private static int testMethodInvoker(ServerMethodInvoker methodInvoker, List<ToIntFunction<HostAndPort>> clients) { TestingPooledByteBufAllocator testingAllocator = new TestingPooledByteBufAllocator(); ServerTransport serverTransport = new DriftNettyServerTransportFactory(new DriftNettyServerConfig(), testingAllocator).createServerTransport(methodInvoker); try { serverTransport.start(); HostAndPort address = HostAndPort.fromParts("localhost", ((DriftNettyServerTransport) serverTransport).getPort()); int sum = 0; for (ToIntFunction<HostAndPort> client : clients) { sum += client.applyAsInt(address); } return sum; } finally { serverTransport.shutdown(); testingAllocator.close(); } }
private static int testMethodInvoker(ServerMethodInvoker methodInvoker, List<ToIntFunction<HostAndPort>> clients) { TestingPooledByteBufAllocator testingAllocator = new TestingPooledByteBufAllocator(); ServerTransport serverTransport = new DriftNettyServerTransportFactory(new DriftNettyServerConfig(), testingAllocator).createServerTransport(methodInvoker); try { serverTransport.start(); HostAndPort address = HostAndPort.fromParts("localhost", ((DriftNettyServerTransport) serverTransport).getPort()); int sum = 0; for (ToIntFunction<HostAndPort> client : clients) { sum += client.applyAsInt(address); } return sum; } finally { serverTransport.shutdown(); testingAllocator.close(); } }