io.netty.channel.socket.SocketChannelConfig Java Examples
The following examples show how to use
io.netty.channel.socket.SocketChannelConfig.
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: NettyClientTransportTest.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
@Test public void setSoLingerChannelOption() throws IOException { startServer(); Map<ChannelOption<?>, Object> channelOptions = new HashMap<ChannelOption<?>, Object>(); // set SO_LINGER option int soLinger = 123; channelOptions.put(ChannelOption.SO_LINGER, soLinger); NettyClientTransport transport = new NettyClientTransport( address, NioSocketChannel.class, channelOptions, group, newNegotiator(), DEFAULT_WINDOW_SIZE, DEFAULT_MAX_MESSAGE_SIZE, GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE, KEEPALIVE_TIME_NANOS_DISABLED, 1L, false, authority, null /* user agent */, tooManyPingsRunnable, new TransportTracer(), Attributes.EMPTY, new SocketPicker()); transports.add(transport); callMeMaybe(transport.start(clientTransportListener)); // verify SO_LINGER has been set ChannelConfig config = transport.channel().config(); assertTrue(config instanceof SocketChannelConfig); assertEquals(soLinger, ((SocketChannelConfig) config).getSoLinger()); }
Example #2
Source File: NettyClientTransportTest.java From grpc-java with Apache License 2.0 | 6 votes |
@Test public void setSoLingerChannelOption() throws IOException { startServer(); Map<ChannelOption<?>, Object> channelOptions = new HashMap<>(); // set SO_LINGER option int soLinger = 123; channelOptions.put(ChannelOption.SO_LINGER, soLinger); NettyClientTransport transport = new NettyClientTransport( address, new ReflectiveChannelFactory<>(NioSocketChannel.class), channelOptions, group, newNegotiator(), false, DEFAULT_WINDOW_SIZE, DEFAULT_MAX_MESSAGE_SIZE, GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE, KEEPALIVE_TIME_NANOS_DISABLED, 1L, false, authority, null /* user agent */, tooManyPingsRunnable, new TransportTracer(), Attributes.EMPTY, new SocketPicker(), new FakeChannelLogger(), false); transports.add(transport); callMeMaybe(transport.start(clientTransportListener)); // verify SO_LINGER has been set ChannelConfig config = transport.channel().config(); assertTrue(config instanceof SocketChannelConfig); assertEquals(soLinger, ((SocketChannelConfig) config).getSoLinger()); }
Example #3
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setWriteSpinCount(int writeSpinCount) { super.setWriteSpinCount(writeSpinCount); return this; }
Example #4
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setTrafficClass(int trafficClass) { channel.setOption(Options.IP_TRAFFIC_CLASS, trafficClass); return this; }
Example #5
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setReuseAddress(boolean reuseAddress) { channel.setOption(Options.REUSE_ADDRESSES, reuseAddress); return this; }
Example #6
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setPerformancePreferences(int connectionTime, int latency, int bandwidth) { throw new UnsupportedOperationException(); }
Example #7
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setAllowHalfClosure(boolean allowHalfClosure) { throw new UnsupportedOperationException(); }
Example #8
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis) { super.setConnectTimeoutMillis(connectTimeoutMillis); return this; }
Example #9
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead) { super.setMaxMessagesPerRead(maxMessagesPerRead); return this; }
Example #10
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setReceiveBufferSize(int receiveBufferSize) { channel.setOption(Options.RECEIVE_BUFFER, receiveBufferSize); return this; }
Example #11
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setAllocator(ByteBufAllocator allocator) { super.setAllocator(allocator); return this; }
Example #12
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator) { super.setRecvByteBufAllocator(allocator); return this; }
Example #13
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setAutoRead(boolean autoRead) { super.setAutoRead(autoRead); return this; }
Example #14
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setWriteBufferHighWaterMark(int writeBufferHighWaterMark) { super.setWriteBufferHighWaterMark(writeBufferHighWaterMark); return this; }
Example #15
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator) { super.setMessageSizeEstimator(estimator); return this; }
Example #16
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setWriteBufferLowWaterMark(int writeBufferLowWaterMark) { super.setWriteBufferLowWaterMark(writeBufferLowWaterMark); return this; }
Example #17
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setAutoClose(boolean autoClose) { super.setAutoClose(autoClose); return this; }
Example #18
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setKeepAlive(boolean keepAlive) { channel.setOption(Options.KEEP_ALIVE, keepAlive); return this; }
Example #19
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setSendBufferSize(int sendBufferSize) { channel.setOption(Options.SEND_BUFFER, sendBufferSize); return this; }
Example #20
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setSoLinger(int soLinger) { throw new UnsupportedOperationException(); }
Example #21
Source File: XnioSocketChannelConfig.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig setTcpNoDelay(boolean tcpNoDelay) { channel.setOption(Options.TCP_NODELAY, tcpNoDelay); return this; }
Example #22
Source File: AbstractXnioSocketChannel.java From netty-xnio-transport with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig config() { return config; }
Example #23
Source File: NioSocketChannel.java From netty4.0.27Learn with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig config() { return config; }
Example #24
Source File: NettyRequestFactory.java From haven-platform with Apache License 2.0 | 4 votes |
/** * Template method for changing properties on the given {@link SocketChannelConfig}. * <p>The default implementation sets the connect timeout based on the set property. * @param config the channel configuration */ protected void configureChannel(SocketChannelConfig config) { if (this.connectTimeout >= 0) { config.setConnectTimeoutMillis(this.connectTimeout); } }
Example #25
Source File: Netty4ClientHttpRequestFactory.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Template method for changing properties on the given {@link SocketChannelConfig}. * <p>The default implementation sets the connect timeout based on the set property. * @param config the channel configuration */ protected void configureChannel(SocketChannelConfig config) { if (this.connectTimeout >= 0) { config.setConnectTimeoutMillis(this.connectTimeout); } }
Example #26
Source File: Netty4ClientHttpRequestFactory.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Template method for changing properties on the given {@link SocketChannelConfig}. * <p>The default implementation sets the connect timeout based on the set property. * @param config the channel configuration */ protected void configureChannel(SocketChannelConfig config) { if (this.connectTimeout >= 0) { config.setConnectTimeoutMillis(this.connectTimeout); } }
Example #27
Source File: RequestResponseCloseHandlerTest.java From servicetalk with Apache License 2.0 | 4 votes |
/** * Simulates netty channel behavior, behavior verified by {@link ChannelBehavior} below. */ @Before public void setup() { // A description prefixed with "IGNORE " will not fail the suite! assumeThat(desc, desc, not(startsWith("IGNORE "))); ctx = mock(ChannelHandlerContext.class); channel = mock(SocketChannel.class, ""); when(ctx.channel()).thenReturn(channel); // Asserts EventExecutor exec = mock(EventExecutor.class); when(ctx.executor()).thenReturn(exec); when(exec.inEventLoop()).thenReturn(true); scc = mock(SocketChannelConfig.class); when(channel.config()).thenReturn(scc); EventLoop loop = mock(EventLoop.class); when(channel.eventLoop()).thenReturn(loop); when(loop.inEventLoop()).thenReturn(true); when(scc.isAllowHalfClosure()).thenReturn(true); when(channel.isOutputShutdown()).then(__ -> outputShutdown.get()); when(channel.isInputShutdown()).then(__ -> inputShutdown.get()); when(channel.isOpen()).then(__ -> !closed.get()); ChannelFuture future = mock(ChannelFuture.class); when(channel.shutdownInput()).then(__ -> { inputShutdown.set(true); LOGGER.debug("channel.shutdownInput()"); h.channelClosedInbound(ctx); // OutputShutDownEvent observed from transport return future; }); when(channel.shutdownOutput()).then(__ -> { outputShutdown.set(true); LOGGER.debug("channel.shutdownOutput()"); h.channelClosedOutbound(ctx); // InputShutDownReadComplete observed from transport return future; }); when(channel.close()).then(__ -> { closed.set(true); LOGGER.debug("channel.close()"); return future; }); when(scc.setSoLinger(0)).then(__ -> { LOGGER.debug("channel.config().setSoLinger(0)"); if (inputShutdown.get() && outputShutdown.get()) { fail("mock => setsockopt() failed - output already shutdown!"); } return scc; }); h = (RequestResponseCloseHandler) spy(mode == Mode.C ? forPipelinedRequestResponse(true, channel.config()) : forPipelinedRequestResponse(false, channel.config())); h.registerEventHandler(channel, e -> { if (observedEvent == null) { LOGGER.debug("Emitted: {}", e); observedEvent = e; } }); }
Example #28
Source File: Netty4ClientHttpRequestFactory.java From java-technology-stack with MIT License | 4 votes |
/** * Template method for changing properties on the given {@link SocketChannelConfig}. * <p>The default implementation sets the connect timeout based on the set property. * @param config the channel configuration */ protected void configureChannel(SocketChannelConfig config) { if (this.connectTimeout >= 0) { config.setConnectTimeoutMillis(this.connectTimeout); } }
Example #29
Source File: NioSocketChannel.java From netty-4.1.22 with Apache License 2.0 | 4 votes |
@Override public SocketChannelConfig config() { return config; }
Example #30
Source File: Netty4ClientHttpRequestFactory.java From spring-analysis-note with MIT License | 4 votes |
/** * Template method for changing properties on the given {@link SocketChannelConfig}. * <p>The default implementation sets the connect timeout based on the set property. * @param config the channel configuration */ protected void configureChannel(SocketChannelConfig config) { if (this.connectTimeout >= 0) { config.setConnectTimeoutMillis(this.connectTimeout); } }