List of usage examples for io.netty.channel WriteBufferWaterMark high
int high
To view the source code for io.netty.channel WriteBufferWaterMark high.
Click Source Link
From source file:io.grpc.netty.NettyServerTest.java
License:Apache License
@Test(timeout = 60000) public void childChannelOptions() throws Exception { final int originalLowWaterMark = 2097169; final int originalHighWaterMark = 2097211; Map<ChannelOption<?>, Object> channelOptions = new HashMap<>(); channelOptions.put(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(originalLowWaterMark, originalHighWaterMark)); final AtomicInteger lowWaterMark = new AtomicInteger(0); final AtomicInteger highWaterMark = new AtomicInteger(0); final CountDownLatch countDownLatch = new CountDownLatch(1); InetSocketAddress addr = new InetSocketAddress(0); NettyServer ns = new NettyServer(addr, Utils.DEFAULT_SERVER_CHANNEL_FACTORY, channelOptions, SharedResourcePool.forResource(Utils.DEFAULT_BOSS_EVENT_LOOP_GROUP), SharedResourcePool.forResource(Utils.DEFAULT_WORKER_EVENT_LOOP_GROUP), ProtocolNegotiators.plaintext(), Collections.<ServerStreamTracer.Factory>emptyList(), TransportTracer.getDefaultFactory(), 1, // ignore 1, // ignore 1, // ignore 1, // ignore 1, // ignore 1, 1, // ignore 1, 1, // ignore true, 0, // ignore channelz);//from ww w .j a v a 2 s .c o m ns.start(new ServerListener() { @Override public ServerTransportListener transportCreated(ServerTransport transport) { Channel channel = ((NettyServerTransport) transport).channel(); WriteBufferWaterMark writeBufferWaterMark = channel.config() .getOption(ChannelOption.WRITE_BUFFER_WATER_MARK); lowWaterMark.set(writeBufferWaterMark.low()); highWaterMark.set(writeBufferWaterMark.high()); countDownLatch.countDown(); return new NoopServerTransportListener(); } @Override public void serverShutdown() { } }); Socket socket = new Socket(); socket.connect(ns.getListenSocketAddress(), /* timeout= */ 8000); countDownLatch.await(); socket.close(); assertThat(lowWaterMark.get()).isEqualTo(originalLowWaterMark); assertThat(highWaterMark.get()).isEqualTo(originalHighWaterMark); ns.shutdown(); }