new NettyConfig(LOCAL_ADDRESS, 0, segmentSize, slots, config));
@Override public String toString() { String format = "NettyConfig [" + "server address: %s, " + "server port: %d, " + "ssl enabled: %s, " + "memory segment size (bytes): %d, " + "transport type: %s, " + "number of server threads: %d (%s), " + "number of client threads: %d (%s), " + "server connect backlog: %d (%s), " + "client connect timeout (sec): %d, " + "send/receive buffer size (bytes): %d (%s)]"; String def = "use Netty's default"; String man = "manual"; return String.format(format, serverAddress, serverPort, getSSLEnabled() ? "true" : "false", memorySegmentSize, getTransportType(), getServerNumThreads(), getServerNumThreads() == 0 ? def : man, getClientNumThreads(), getClientNumThreads() == 0 ? def : man, getServerConnectBacklog(), getServerConnectBacklog() == 0 ? def : man, getClientConnectTimeoutSeconds(), getSendAndReceiveBufferSize(), getSendAndReceiveBufferSize() == 0 ? def : man); } }
private void initNioBootstrap() { // Add the server port number to the name in order to distinguish // multiple servers running on the same host. String name = NettyConfig.SERVER_THREAD_GROUP_NAME + " (" + config.getServerPort() + ")"; NioEventLoopGroup nioGroup = new NioEventLoopGroup(config.getServerNumThreads(), getNamedThreadFactory(name)); bootstrap.group(nioGroup).channel(NioServerSocketChannel.class); }
private void initNioBootstrap() { // Add the server port number to the name in order to distinguish // multiple clients running on the same host. String name = NettyConfig.CLIENT_THREAD_GROUP_NAME + " (" + config.getServerPort() + ")"; NioEventLoopGroup nioGroup = new NioEventLoopGroup(config.getClientNumThreads(), NettyServer.getNamedThreadFactory(name)); bootstrap.group(nioGroup).channel(NioSocketChannel.class); }
switch (config.getTransportType()) { case NIO: initNioBootstrap(); bootstrap.localAddress(config.getServerAddress(), config.getServerPort()); bootstrap.childOption(ChannelOption.ALLOCATOR, nettyBufferPool); if (config.getServerConnectBacklog() > 0) { bootstrap.option(ChannelOption.SO_BACKLOG, config.getServerConnectBacklog()); int receiveAndSendBufferSize = config.getSendAndReceiveBufferSize(); if (receiveAndSendBufferSize > 0) { bootstrap.childOption(ChannelOption.SO_SNDBUF, receiveAndSendBufferSize); bootstrap.childOption(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, 2 * config.getMemorySegmentSize()); bootstrap.childOption(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, config.getMemorySegmentSize() + 1); serverSSLContext = config.createServerSSLContext(); } catch (Exception e) { throw new IOException("Failed to initialize SSL Context for the Netty Server", e);
switch (config.getTransportType()) { case NIO: initNioBootstrap(); bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, config.getClientConnectTimeoutSeconds() * 1000); int receiveAndSendBufferSize = config.getSendAndReceiveBufferSize(); if (receiveAndSendBufferSize > 0) { bootstrap.option(ChannelOption.SO_SNDBUF, receiveAndSendBufferSize); clientSSLContext = config.createClientSSLContext(); } catch (Exception e) { throw new IOException("Failed to initialize SSL Context for the Netty client", e);
long maxNettyMemorySizeInBytes = (nettyConfigWithoutTotalMemory.getServerNumThreads() + 1) * (long) nettyConfigWithoutTotalMemory.getChunkSize(); checkArgument(nettyConfig.getNumberOfArenas() >= 1, "Direct memory left for netty (" + nettyDirectMemorySizeInMB + "MB) is not enough " + "at least one arena, please increase the total direct memory size or both the total direct memory size" +
public SSLContext createClientSSLContext() throws Exception { // Create SSL Context from config SSLContext clientSSLContext = null; if (getSSLEnabled()) { clientSSLContext = SSLUtils.createSSLClientContext(config); } return clientSSLContext; }
public NettyConnectionManager(NettyConfig nettyConfig) { this.server = new NettyServer(nettyConfig); this.client = new NettyClient(nettyConfig); this.bufferPool = new NettyBufferPool(nettyConfig.getNumberOfArenas(), nettyConfig.getMaxOrder(), nettyConfig.getChunkSize()); this.partitionRequestClientFactory = new PartitionRequestClientFactory(client); }
public NettyConnectionManager(NettyConfig nettyConfig) { this.server = new NettyServer(nettyConfig); this.client = new NettyClient(nettyConfig); this.bufferPool = new NettyBufferPool(nettyConfig.getNumberOfArenas()); this.partitionRequestClientFactory = new PartitionRequestClientFactory(client); }
switch (config.getTransportType()) { case NIO: initNioBootstrap(); bootstrap.localAddress(config.getServerAddress(), config.getServerPort()); bootstrap.childOption(ChannelOption.ALLOCATOR, nettyBufferPool); if (config.getServerConnectBacklog() > 0) { bootstrap.option(ChannelOption.SO_BACKLOG, config.getServerConnectBacklog()); int receiveAndSendBufferSize = config.getSendAndReceiveBufferSize(); if (receiveAndSendBufferSize > 0) { bootstrap.childOption(ChannelOption.SO_SNDBUF, receiveAndSendBufferSize); final int newLowWaterMark = config.getMemorySegmentSize() + 1; final int newHighWaterMark = 2 * config.getMemorySegmentSize(); if (newLowWaterMark > defaultHighWaterMark) { bootstrap.childOption(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, newHighWaterMark); serverSSLContext = config.createServerSSLContext(); } catch (Exception e) { throw new IOException("Failed to initialize SSL Context for the Netty Server", e);
private void initEpollBootstrap() { // Add the server port number to the name in order to distinguish // multiple clients running on the same host. String name = NettyConfig.CLIENT_THREAD_GROUP_NAME + " (" + config.getServerPort() + ")"; EpollEventLoopGroup epollGroup = new EpollEventLoopGroup(config.getClientNumThreads(), NettyServer.getNamedThreadFactory(name)); bootstrap.group(epollGroup).channel(EpollSocketChannel.class); }
switch (config.getTransportType()) { case NIO: initNioBootstrap(); bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, config.getClientConnectTimeoutSeconds() * 1000); int receiveAndSendBufferSize = config.getSendAndReceiveBufferSize(); if (receiveAndSendBufferSize > 0) { bootstrap.option(ChannelOption.SO_SNDBUF, receiveAndSendBufferSize); clientSSLContext = config.createClientSSLContext(); } catch (Exception e) { throw new IOException("Failed to initialize SSL Context for the Netty client", e);
public SSLContext createServerSSLContext() throws Exception { // Create SSL Context from config SSLContext serverSSLContext = null; if (getSSLEnabled()) { serverSSLContext = SSLUtils.createSSLServerContext(config); } return serverSSLContext; }
public ExternalBlockShuffleService(Configuration configuration) throws Exception { this.shuffleServiceConfiguration = ExternalBlockShuffleServiceConfiguration.fromConfiguration(configuration); this.partitionProvider = new ExternalBlockResultPartitionManager(shuffleServiceConfiguration); NettyConfig nettyConfig = shuffleServiceConfiguration.getNettyConfig(); bufferPool = new NettyBufferPool(nettyConfig.getNumberOfArenas(), nettyConfig.getMaxOrder(), nettyConfig.getChunkSize()); server = new NettyServer(nettyConfig); }
public NettyConnectionManager(NettyConfig nettyConfig) { this.server = new NettyServer(nettyConfig); this.client = new NettyClient(nettyConfig); this.bufferPool = new NettyBufferPool(nettyConfig.getNumberOfArenas()); this.partitionRequestClientFactory = new PartitionRequestClientFactory(client); }
@Override public String toString() { String format = "NettyConfig [" + "server address: %s, " + "server port: %d, " + "ssl enabled: %s, " + "memory segment size (bytes): %d, " + "transport type: %s, " + "number of server threads: %d (%s), " + "number of client threads: %d (%s), " + "server connect backlog: %d (%s), " + "client connect timeout (sec): %d, " + "send/receive buffer size (bytes): %d (%s)]"; String def = "use Netty's default"; String man = "manual"; return String.format(format, serverAddress, serverPort, getSSLEnabled() ? "true":"false", memorySegmentSize, getTransportType(), getServerNumThreads(), getServerNumThreads() == 0 ? def : man, getClientNumThreads(), getClientNumThreads() == 0 ? def : man, getServerConnectBacklog(), getServerConnectBacklog() == 0 ? def : man, getClientConnectTimeoutSeconds(), getSendAndReceiveBufferSize(), getSendAndReceiveBufferSize() == 0 ? def : man); }
private void initEpollBootstrap() { // Add the server port number to the name in order to distinguish // multiple servers running on the same host. String name = NettyConfig.SERVER_THREAD_GROUP_NAME + " (" + config.getServerPort() + ")"; EpollEventLoopGroup epollGroup = new EpollEventLoopGroup(config.getServerNumThreads(), getNamedThreadFactory(name)); bootstrap.group(epollGroup).channel(EpollServerSocketChannel.class); }
private void initNioBootstrap() { // Add the server port number to the name in order to distinguish // multiple clients running on the same host. String name = NettyConfig.CLIENT_THREAD_GROUP_NAME + " (" + config.getServerPort() + ")"; NioEventLoopGroup nioGroup = new NioEventLoopGroup(config.getClientNumThreads(), NettyServer.getNamedThreadFactory(name)); bootstrap.group(nioGroup).channel(NioSocketChannel.class); }
private static NettyConfig createNettyConfig(Configuration configuration) { final Integer port = configuration.getInteger(ExternalBlockShuffleServiceOptions.FLINK_SHUFFLE_SERVICE_PORT_KEY); checkArgument(port != null && port > 0 && port < 65536, "Invalid port number for ExternalBlockShuffleService: " + port); final InetSocketAddress shuffleServiceInetSocketAddress = new InetSocketAddress(port); final int memorySizePerBufferInBytes = configuration.getInteger( ExternalBlockShuffleServiceOptions.MEMORY_SIZE_PER_BUFFER_IN_BYTES); return new NettyConfig( shuffleServiceInetSocketAddress.getAddress(), shuffleServiceInetSocketAddress.getPort(), memorySizePerBufferInBytes, Integer.MAX_VALUE, configuration); }