Example usage for io.netty.handler.codec.http2 Http2LocalFlowController initialWindowSize

List of usage examples for io.netty.handler.codec.http2 Http2LocalFlowController initialWindowSize

Introduction

In this page you can find the example usage for io.netty.handler.codec.http2 Http2LocalFlowController initialWindowSize.

Prototype

int initialWindowSize(Http2Stream stream);

Source Link

Document

Get the initial flow control window size for the given stream.

Usage

From source file:io.grpc.netty.NettyClientHandlerTest.java

License:Apache License

@Test
public void connectionWindowShouldBeOverridden() throws Exception {
    flowControlWindow = 1048576; // 1MiB
    setUp();//from w w  w.j a  va 2s  .com

    Http2Stream connectionStream = connection().connectionStream();
    Http2LocalFlowController localFlowController = connection().local().flowController();
    int actualInitialWindowSize = localFlowController.initialWindowSize(connectionStream);
    int actualWindowSize = localFlowController.windowSize(connectionStream);
    assertEquals(flowControlWindow, actualWindowSize);
    assertEquals(flowControlWindow, actualInitialWindowSize);
    assertEquals(1048576, actualWindowSize);
}

From source file:io.grpc.netty.NettyHandlerTestBase.java

License:Apache License

@Test
public void windowUpdateMatchesTarget() throws Exception {
    manualSetUp();// w ww .j  a va  2 s . co m
    Http2Stream connectionStream = connection().connectionStream();
    Http2LocalFlowController localFlowController = connection().local().flowController();
    makeStream();
    AbstractNettyHandler handler = (AbstractNettyHandler) handler();
    handler.setAutoTuneFlowControl(true);

    ByteBuf data = ctx().alloc().buffer(1024);
    while (data.isWritable()) {
        data.writeLong(1111);
    }
    int length = data.readableBytes();
    ByteBuf frame = dataFrame(3, false, data.copy());
    channelRead(frame);
    int accumulator = length;
    // 40 is arbitrary, any number large enough to trigger a window update would work
    for (int i = 0; i < 40; i++) {
        channelRead(dataFrame(3, false, data.copy()));
        accumulator += length;
    }
    long pingData = handler.flowControlPing().payload();
    channelRead(pingFrame(true, pingData));

    assertEquals(accumulator, handler.flowControlPing().getDataSincePing());
    assertEquals(2 * accumulator, localFlowController.initialWindowSize(connectionStream));
}

From source file:io.grpc.netty.NettyHandlerTestBase.java

License:Apache License

@Test
public void windowShouldNotExceedMaxWindowSize() throws Exception {
    manualSetUp();/*from w w  w . j  av a  2  s . c  o  m*/
    makeStream();
    AbstractNettyHandler handler = (AbstractNettyHandler) handler();
    handler.setAutoTuneFlowControl(true);
    Http2Stream connectionStream = connection().connectionStream();
    Http2LocalFlowController localFlowController = connection().local().flowController();
    int maxWindow = handler.flowControlPing().maxWindow();

    handler.flowControlPing().setDataSizeAndSincePing(maxWindow);
    long payload = handler.flowControlPing().payload();
    channelRead(pingFrame(true, payload));

    assertEquals(maxWindow, localFlowController.initialWindowSize(connectionStream));
}

From source file:io.grpc.netty.NettyServerHandlerTest.java

License:Apache License

@Test
public void connectionWindowShouldBeOverridden() throws Exception {
    flowControlWindow = 1048576; // 1MiB
    manualSetUp();/* w  ww.ja va2s. com*/

    Http2Stream connectionStream = connection().connectionStream();
    Http2LocalFlowController localFlowController = connection().local().flowController();
    int actualInitialWindowSize = localFlowController.initialWindowSize(connectionStream);
    int actualWindowSize = localFlowController.windowSize(connectionStream);
    assertEquals(flowControlWindow, actualWindowSize);
    assertEquals(flowControlWindow, actualInitialWindowSize);
}