@Test public void shouldSetWriteBufferWatermarkOnChannelConfigWhenInstalled() { // given TransportThrottle throttle = newThrottle(); // when throttle.install( channel ); // expect ArgumentCaptor<WriteBufferWaterMark> argument = ArgumentCaptor.forClass( WriteBufferWaterMark.class ); verify( config, times( 1 ) ).setWriteBufferWaterMark( argument.capture() ); assertEquals( 64, argument.getValue().low() ); assertEquals( 256, argument.getValue().high() ); }
@Override public void initChannel( SocketChannel ch ) throws Exception { try { ch.config().setOption( ChannelOption.IP_TOS, 0x18 ); } catch ( ChannelException e ) { // Ignore } ch.config().setAllocator( PooledByteBufAllocator.DEFAULT ); ch.config().setWriteBufferWaterMark( MARK ); Pipeline.prepare( ch.pipeline(), connectionHandler ); } }
@Override public void initChannel( SocketChannel ch ) throws Exception { final ConnectionHandler connectionHandler = new ConnectionHandler(); try { ch.config().setOption( ChannelOption.IP_TOS, 0x18 ); } catch ( ChannelException ex ) { // Ignored } ch.config().setAllocator( PooledByteBufAllocator.DEFAULT ); ch.config().setWriteBufferWaterMark( MARK ); Pipeline.prepare( ch.pipeline(), connectionHandler ); connectionHandler.whenConnected( aVoid -> newConnection.accept( connectionHandler ) ); } }