@Override public Channel register(SocketChannel socketChannel, boolean clientMode) throws IOException { NioChannel channel = new NioChannel( socketChannel, clientMode, channelInitializer, metricsRegistry, closeListenerExecutor); socketChannel.configureBlocking(false); NioInboundPipeline inboundPipeline = newInboundPipeline(channel); NioOutboundPipeline outboundPipeline = newOutboundPipeline(channel); channels.add(channel); channel.init(inboundPipeline, outboundPipeline); ioBalancer.channelAdded(inboundPipeline, outboundPipeline); channel.addCloseListener(channelCloseListener); return channel; }
protected void stopNetworking() { networking.shutdown(); }
protected void startNetworking() { networking.start(); }
@Override public void run(DiagnosticsLogWriter writer) { writer.startSection("NetworkingImbalance"); writer.startSection("InputThreads"); render(writer, networking.getInputThreads()); writer.endSection(); writer.startSection("OutputThreads"); render(writer, networking.getOutputThreads()); writer.endSection(); writer.endSection(); }
private Networking createNetworking(Node node, NodeIOService ioService) { ChannelInitializer initializer = node.getNodeExtension().createChannelInitializer(ioService); LoggingServiceImpl loggingService = node.loggingService; ChannelErrorHandler errorHandler = new TcpIpConnectionChannelErrorHandler(loggingService.getLogger(TcpIpConnectionChannelErrorHandler.class)); HazelcastProperties props = node.getProperties(); return new NioNetworking( new NioNetworking.Context() .loggingService(loggingService) .metricsRegistry(node.nodeEngine.getMetricsRegistry()) .threadNamePrefix(node.hazelcastInstance.getName()) .errorHandler(errorHandler) .inputThreadCount(props.getInteger(IO_INPUT_THREAD_COUNT)) .outputThreadCount(props.getInteger(IO_OUTPUT_THREAD_COUNT)) .balancerIntervalSeconds(props.getInteger(IO_BALANCER_INTERVAL_SECONDS)) .channelInitializer(initializer)); } }
protected ClientConnection createSocketConnection(final Address remoteAddress) throws IOException { SocketChannel socketChannel = null; try { socketChannel = SocketChannel.open(); Socket socket = socketChannel.socket(); bindSocketToPort(socket); Channel channel = networking.register(socketChannel, true); channel.connect(inetSocketAddressCache.get(remoteAddress), connectionTimeoutMillis); ClientConnection connection = new ClientConnection(client, connectionIdGen.incrementAndGet(), channel); socketChannel.configureBlocking(true); if (socketInterceptor != null) { socketInterceptor.onConnect(socket); } channel.start(); return connection; } catch (Exception e) { closeResource(socketChannel); throw rethrow(e, IOException.class); } }
@Override public void run(DiagnosticsLogWriter writer) { writer.startSection("NetworkingImbalance"); writer.startSection("InputThreads"); render(writer, networking.getInputThreads()); writer.endSection(); writer.startSection("OutputThreads"); render(writer, networking.getOutputThreads()); writer.endSection(); writer.endSection(); }
private Networking createNetworking(Node node, NodeIOService ioService) { ChannelInitializer initializer = node.getNodeExtension().createChannelInitializer(ioService); LoggingServiceImpl loggingService = node.loggingService; ChannelErrorHandler errorHandler = new TcpIpConnectionChannelErrorHandler(loggingService.getLogger(TcpIpConnectionChannelErrorHandler.class)); HazelcastProperties props = node.getProperties(); return new NioNetworking( new NioNetworking.Context() .loggingService(loggingService) .metricsRegistry(node.nodeEngine.getMetricsRegistry()) .threadNamePrefix(node.hazelcastInstance.getName()) .errorHandler(errorHandler) .inputThreadCount(props.getInteger(IO_INPUT_THREAD_COUNT)) .outputThreadCount(props.getInteger(IO_OUTPUT_THREAD_COUNT)) .balancerIntervalSeconds(props.getInteger(IO_BALANCER_INTERVAL_SECONDS)) .channelInitializer(initializer)); } }
protected ClientConnection createSocketConnection(final Address remoteAddress) throws IOException { SocketChannel socketChannel = null; try { socketChannel = SocketChannel.open(); Socket socket = socketChannel.socket(); bindSocketToPort(socket); Channel channel = networking.register(socketChannel, true); channel.connect(remoteAddress.getInetSocketAddress(), connectionTimeoutMillis); ClientConnection connection = new ClientConnection(client, connectionIdGen.incrementAndGet(), channel); socketChannel.configureBlocking(true); if (socketInterceptor != null) { socketInterceptor.onConnect(socket); } channel.start(); return connection; } catch (Exception e) { closeResource(socketChannel); throw rethrow(e, IOException.class); } }
@Override public Channel register(SocketChannel socketChannel, boolean clientMode) throws IOException { NioChannel channel = new NioChannel( socketChannel, clientMode, channelInitializer, metricsRegistry, closeListenerExecutor); socketChannel.configureBlocking(false); NioInboundPipeline inboundPipeline = newInboundPipeline(channel); NioOutboundPipeline outboundPipeline = newOutboundPipeline(channel); channels.add(channel); channel.init(inboundPipeline, outboundPipeline); ioBalancer.channelAdded(inboundPipeline, outboundPipeline); channel.addCloseListener(channelCloseListener); return channel; }
protected void stopNetworking() { networking.shutdown(); }
protected NioNetworking initNetworking(HazelcastClientInstanceImpl client) { HazelcastProperties properties = client.getProperties(); SSLConfig sslConfig = client.getClientConfig().getNetworkConfig().getSSLConfig(); boolean sslEnabled = sslConfig != null && sslConfig.isEnabled(); int configuredInputThreads = properties.getInteger(IO_INPUT_THREAD_COUNT); int configuredOutputThreads = properties.getInteger(IO_OUTPUT_THREAD_COUNT); int inputThreads; if (configuredInputThreads == -1) { inputThreads = sslEnabled ? DEFAULT_SSL_THREAD_COUNT : 1; } else { inputThreads = configuredInputThreads; } int outputThreads; if (configuredOutputThreads == -1) { outputThreads = sslEnabled ? DEFAULT_SSL_THREAD_COUNT : 1; } else { outputThreads = configuredOutputThreads; } return new NioNetworking( new NioNetworking.Context() .loggingService(client.getLoggingService()) .metricsRegistry(client.getMetricsRegistry()) .threadNamePrefix(client.getName()) .errorHandler(new ClientConnectionChannelErrorHandler()) .inputThreadCount(inputThreads) .outputThreadCount(outputThreads) .balancerIntervalSeconds(properties.getInteger(IO_BALANCER_INTERVAL_SECONDS)) .channelInitializer(client.getClientExtension().createChannelInitializer())); }
protected void startNetworking() { networking.start(); }
@Override public void shutdown() { ioBalancer.stop(); if (logger.isFinestEnabled()) { logger.finest("Shutting down IO Threads... Total: " + (inputThreads.length + outputThreads.length)); } shutdown(inputThreads); inputThreads = null; shutdown(outputThreads); outputThreads = null; closeListenerExecutor.shutdown(); }
protected NioNetworking initNetworking(HazelcastClientInstanceImpl client) { HazelcastProperties properties = client.getProperties(); SSLConfig sslConfig = client.getClientConfig().getNetworkConfig().getSSLConfig(); boolean sslEnabled = sslConfig != null && sslConfig.isEnabled(); int configuredInputThreads = properties.getInteger(IO_INPUT_THREAD_COUNT); int configuredOutputThreads = properties.getInteger(IO_OUTPUT_THREAD_COUNT); int inputThreads; if (configuredInputThreads == -1) { inputThreads = sslEnabled ? DEFAULT_SSL_THREAD_COUNT : 1; } else { inputThreads = configuredInputThreads; } int outputThreads; if (configuredOutputThreads == -1) { outputThreads = sslEnabled ? DEFAULT_SSL_THREAD_COUNT : 1; } else { outputThreads = configuredOutputThreads; } return new NioNetworking( new NioNetworking.Context() .loggingService(client.getLoggingService()) .metricsRegistry(client.getMetricsRegistry()) .threadNamePrefix(client.getName()) .errorHandler(new ClientConnectionChannelErrorHandler()) .inputThreadCount(inputThreads) .outputThreadCount(outputThreads) .balancerIntervalSeconds(properties.getInteger(IO_BALANCER_INTERVAL_SECONDS)) .channelInitializer(client.getClientExtension().createChannelInitializer())); }
@Override public void shutdown() { ioBalancer.stop(); if (logger.isFinestEnabled()) { logger.finest("Shutting down IO Threads... Total: " + (inputThreads.length + outputThreads.length)); } shutdown(inputThreads); inputThreads = null; shutdown(outputThreads); outputThreads = null; closeListenerExecutor.shutdown(); }