Search in sources :

Example 1 with Http2FrameReader

use of io.netty.handler.codec.http2.Http2FrameReader in project grpc-java by grpc.

the class NettyServerHandler method newHandler.

static NettyServerHandler newHandler(ServerTransportListener transportListener, int maxStreams, int flowControlWindow, int maxHeaderListSize, int maxMessageSize) {
    Preconditions.checkArgument(maxHeaderListSize > 0, "maxHeaderListSize must be positive");
    Http2FrameLogger frameLogger = new Http2FrameLogger(LogLevel.DEBUG, NettyServerHandler.class);
    Http2HeadersDecoder headersDecoder = new GrpcHttp2ServerHeadersDecoder(maxHeaderListSize);
    Http2FrameReader frameReader = new Http2InboundFrameLogger(new DefaultHttp2FrameReader(headersDecoder), frameLogger);
    Http2FrameWriter frameWriter = new Http2OutboundFrameLogger(new DefaultHttp2FrameWriter(), frameLogger);
    return newHandler(frameReader, frameWriter, transportListener, maxStreams, flowControlWindow, maxHeaderListSize, maxMessageSize);
}
Also used : Http2InboundFrameLogger(io.netty.handler.codec.http2.Http2InboundFrameLogger) DefaultHttp2FrameWriter(io.netty.handler.codec.http2.DefaultHttp2FrameWriter) Http2FrameWriter(io.netty.handler.codec.http2.Http2FrameWriter) Http2FrameReader(io.netty.handler.codec.http2.Http2FrameReader) DefaultHttp2FrameReader(io.netty.handler.codec.http2.DefaultHttp2FrameReader) Http2FrameLogger(io.netty.handler.codec.http2.Http2FrameLogger) GrpcHttp2ServerHeadersDecoder(io.grpc.netty.GrpcHttp2HeadersDecoder.GrpcHttp2ServerHeadersDecoder) Http2OutboundFrameLogger(io.netty.handler.codec.http2.Http2OutboundFrameLogger) Http2HeadersDecoder(io.netty.handler.codec.http2.Http2HeadersDecoder) DefaultHttp2FrameWriter(io.netty.handler.codec.http2.DefaultHttp2FrameWriter) DefaultHttp2FrameReader(io.netty.handler.codec.http2.DefaultHttp2FrameReader)

Example 2 with Http2FrameReader

use of io.netty.handler.codec.http2.Http2FrameReader in project grpc-java by grpc.

the class NettyServerHandler method newHandler.

@VisibleForTesting
static NettyServerHandler newHandler(Http2FrameReader frameReader, Http2FrameWriter frameWriter, ServerTransportListener transportListener, int maxStreams, int flowControlWindow, int maxHeaderListSize, int maxMessageSize) {
    Preconditions.checkArgument(maxStreams > 0, "maxStreams must be positive");
    Preconditions.checkArgument(flowControlWindow > 0, "flowControlWindow must be positive");
    Preconditions.checkArgument(maxHeaderListSize > 0, "maxHeaderListSize must be positive");
    Preconditions.checkArgument(maxMessageSize > 0, "maxMessageSize must be positive");
    Http2Connection connection = new DefaultHttp2Connection(true);
    // Create the local flow controller configured to auto-refill the connection window.
    connection.local().flowController(new DefaultHttp2LocalFlowController(connection, DEFAULT_WINDOW_UPDATE_RATIO, true));
    Http2ConnectionEncoder encoder = new DefaultHttp2ConnectionEncoder(connection, frameWriter);
    // TODO(ejona): swap back to DefaultHttp2Connection with Netty-4.1.9
    Http2ConnectionDecoder decoder = new FixedHttp2ConnectionDecoder(connection, encoder, frameReader);
    Http2Settings settings = new Http2Settings();
    settings.initialWindowSize(flowControlWindow);
    settings.maxConcurrentStreams(maxStreams);
    settings.maxHeaderListSize(maxHeaderListSize);
    return new NettyServerHandler(transportListener, decoder, encoder, settings, maxMessageSize);
}
Also used : Http2ConnectionDecoder(io.netty.handler.codec.http2.Http2ConnectionDecoder) DefaultHttp2Connection(io.netty.handler.codec.http2.DefaultHttp2Connection) DefaultHttp2Connection(io.netty.handler.codec.http2.DefaultHttp2Connection) Http2Connection(io.netty.handler.codec.http2.Http2Connection) DefaultHttp2LocalFlowController(io.netty.handler.codec.http2.DefaultHttp2LocalFlowController) Http2ConnectionEncoder(io.netty.handler.codec.http2.Http2ConnectionEncoder) DefaultHttp2ConnectionEncoder(io.netty.handler.codec.http2.DefaultHttp2ConnectionEncoder) Http2Settings(io.netty.handler.codec.http2.Http2Settings) DefaultHttp2ConnectionEncoder(io.netty.handler.codec.http2.DefaultHttp2ConnectionEncoder) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 3 with Http2FrameReader

use of io.netty.handler.codec.http2.Http2FrameReader in project grpc-java by grpc.

the class NettyClientHandler method newHandler.

@VisibleForTesting
static NettyClientHandler newHandler(Http2Connection connection, Http2FrameReader frameReader, Http2FrameWriter frameWriter, ClientTransportLifecycleManager lifecycleManager, KeepAliveManager keepAliveManager, int flowControlWindow, int maxHeaderListSize, Ticker ticker) {
    Preconditions.checkNotNull(connection, "connection");
    Preconditions.checkNotNull(frameReader, "frameReader");
    Preconditions.checkNotNull(lifecycleManager, "lifecycleManager");
    Preconditions.checkArgument(flowControlWindow > 0, "flowControlWindow must be positive");
    Preconditions.checkArgument(maxHeaderListSize > 0, "maxHeaderListSize must be positive");
    Preconditions.checkNotNull(ticker, "ticker");
    Http2FrameLogger frameLogger = new Http2FrameLogger(LogLevel.DEBUG, NettyClientHandler.class);
    frameReader = new Http2InboundFrameLogger(frameReader, frameLogger);
    frameWriter = new Http2OutboundFrameLogger(frameWriter, frameLogger);
    StreamBufferingEncoder encoder = new StreamBufferingEncoder(new DefaultHttp2ConnectionEncoder(connection, frameWriter));
    // Create the local flow controller configured to auto-refill the connection window.
    connection.local().flowController(new DefaultHttp2LocalFlowController(connection, DEFAULT_WINDOW_UPDATE_RATIO, true));
    // TODO(ejona): swap back to DefaultHttp2Connection with Netty-4.1.9
    Http2ConnectionDecoder decoder = new FixedHttp2ConnectionDecoder(connection, encoder, frameReader);
    Http2Settings settings = new Http2Settings();
    settings.pushEnabled(false);
    settings.initialWindowSize(flowControlWindow);
    settings.maxConcurrentStreams(0);
    settings.maxHeaderListSize(maxHeaderListSize);
    return new NettyClientHandler(decoder, encoder, settings, lifecycleManager, keepAliveManager, ticker);
}
Also used : Http2ConnectionDecoder(io.netty.handler.codec.http2.Http2ConnectionDecoder) Http2InboundFrameLogger(io.netty.handler.codec.http2.Http2InboundFrameLogger) StreamBufferingEncoder(io.netty.handler.codec.http2.StreamBufferingEncoder) Http2FrameLogger(io.netty.handler.codec.http2.Http2FrameLogger) DefaultHttp2LocalFlowController(io.netty.handler.codec.http2.DefaultHttp2LocalFlowController) Http2OutboundFrameLogger(io.netty.handler.codec.http2.Http2OutboundFrameLogger) Http2Settings(io.netty.handler.codec.http2.Http2Settings) DefaultHttp2ConnectionEncoder(io.netty.handler.codec.http2.DefaultHttp2ConnectionEncoder) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 4 with Http2FrameReader

use of io.netty.handler.codec.http2.Http2FrameReader in project grpc-java by grpc.

the class NettyClientHandler method newHandler.

static NettyClientHandler newHandler(ClientTransportLifecycleManager lifecycleManager, @Nullable KeepAliveManager keepAliveManager, int flowControlWindow, int maxHeaderListSize, Ticker ticker) {
    Preconditions.checkArgument(maxHeaderListSize > 0, "maxHeaderListSize must be positive");
    Http2HeadersDecoder headersDecoder = new GrpcHttp2ClientHeadersDecoder(maxHeaderListSize);
    Http2FrameReader frameReader = new DefaultHttp2FrameReader(headersDecoder);
    Http2FrameWriter frameWriter = new DefaultHttp2FrameWriter();
    Http2Connection connection = new DefaultHttp2Connection(false);
    return newHandler(connection, frameReader, frameWriter, lifecycleManager, keepAliveManager, flowControlWindow, maxHeaderListSize, ticker);
}
Also used : DefaultHttp2Connection(io.netty.handler.codec.http2.DefaultHttp2Connection) DefaultHttp2FrameWriter(io.netty.handler.codec.http2.DefaultHttp2FrameWriter) Http2FrameWriter(io.netty.handler.codec.http2.Http2FrameWriter) Http2FrameReader(io.netty.handler.codec.http2.Http2FrameReader) DefaultHttp2FrameReader(io.netty.handler.codec.http2.DefaultHttp2FrameReader) DefaultHttp2Connection(io.netty.handler.codec.http2.DefaultHttp2Connection) Http2Connection(io.netty.handler.codec.http2.Http2Connection) GrpcHttp2ClientHeadersDecoder(io.grpc.netty.GrpcHttp2HeadersDecoder.GrpcHttp2ClientHeadersDecoder) Http2HeadersDecoder(io.netty.handler.codec.http2.Http2HeadersDecoder) DefaultHttp2FrameWriter(io.netty.handler.codec.http2.DefaultHttp2FrameWriter) DefaultHttp2FrameReader(io.netty.handler.codec.http2.DefaultHttp2FrameReader)

Example 5 with Http2FrameReader

use of io.netty.handler.codec.http2.Http2FrameReader in project rest.li by linkedin.

the class Http2StreamCodecBuilder method build.

@Override
public Http2StreamCodec build() {
    ObjectUtil.checkNotNull(_connection, "connection");
    ObjectUtil.checkPositive(_maxHeaderSize, "maxHeaderSize");
    Http2HeadersDecoder headerDecoder = new DefaultHttp2HeadersDecoder(_maxHeaderSize, Http2CodecUtil.DEFAULT_HEADER_TABLE_SIZE, isValidateHeaders(), INITIAL_HUFFMAN_DECODE_CAPACITY);
    Http2FrameReader reader = new DefaultHttp2FrameReader(headerDecoder);
    Http2FrameWriter writer = new DefaultHttp2FrameWriter(headerSensitivityDetector());
    if (frameLogger() != null) {
        reader = new Http2InboundFrameLogger(reader, frameLogger());
        writer = new Http2OutboundFrameLogger(writer, frameLogger());
    }
    Http2ConnectionEncoder encoder = new DefaultHttp2ConnectionEncoder(_connection, writer);
    boolean encoderEnforceMaxConcurrentStreams = encoderEnforceMaxConcurrentStreams();
    if (encoderEnforceMaxConcurrentStreams) {
        if (_connection.isServer()) {
            encoder.close();
            reader.close();
            throw new IllegalArgumentException("encoderEnforceMaxConcurrentStreams: " + encoderEnforceMaxConcurrentStreams + " not supported for server");
        }
        encoder = new StreamBufferingEncoder(encoder);
    }
    Http2ConnectionDecoder decoder = new DefaultHttp2ConnectionDecoder(_connection, encoder, reader);
    super.codec(decoder, encoder);
    return super.build();
}
Also used : Http2InboundFrameLogger(io.netty.handler.codec.http2.Http2InboundFrameLogger) Http2FrameReader(io.netty.handler.codec.http2.Http2FrameReader) DefaultHttp2FrameReader(io.netty.handler.codec.http2.DefaultHttp2FrameReader) StreamBufferingEncoder(io.netty.handler.codec.http2.StreamBufferingEncoder) DefaultHttp2ConnectionDecoder(io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder) Http2OutboundFrameLogger(io.netty.handler.codec.http2.Http2OutboundFrameLogger) Http2HeadersDecoder(io.netty.handler.codec.http2.Http2HeadersDecoder) DefaultHttp2HeadersDecoder(io.netty.handler.codec.http2.DefaultHttp2HeadersDecoder) DefaultHttp2FrameWriter(io.netty.handler.codec.http2.DefaultHttp2FrameWriter) DefaultHttp2ConnectionEncoder(io.netty.handler.codec.http2.DefaultHttp2ConnectionEncoder) Http2ConnectionDecoder(io.netty.handler.codec.http2.Http2ConnectionDecoder) DefaultHttp2ConnectionDecoder(io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder) Http2FrameWriter(io.netty.handler.codec.http2.Http2FrameWriter) DefaultHttp2FrameWriter(io.netty.handler.codec.http2.DefaultHttp2FrameWriter) DefaultHttp2HeadersDecoder(io.netty.handler.codec.http2.DefaultHttp2HeadersDecoder) Http2ConnectionEncoder(io.netty.handler.codec.http2.Http2ConnectionEncoder) DefaultHttp2ConnectionEncoder(io.netty.handler.codec.http2.DefaultHttp2ConnectionEncoder) DefaultHttp2FrameReader(io.netty.handler.codec.http2.DefaultHttp2FrameReader)

Aggregations

DefaultHttp2ConnectionEncoder (io.netty.handler.codec.http2.DefaultHttp2ConnectionEncoder)3 DefaultHttp2FrameReader (io.netty.handler.codec.http2.DefaultHttp2FrameReader)3 DefaultHttp2FrameWriter (io.netty.handler.codec.http2.DefaultHttp2FrameWriter)3 Http2ConnectionDecoder (io.netty.handler.codec.http2.Http2ConnectionDecoder)3 Http2FrameReader (io.netty.handler.codec.http2.Http2FrameReader)3 Http2FrameWriter (io.netty.handler.codec.http2.Http2FrameWriter)3 Http2HeadersDecoder (io.netty.handler.codec.http2.Http2HeadersDecoder)3 Http2InboundFrameLogger (io.netty.handler.codec.http2.Http2InboundFrameLogger)3 Http2OutboundFrameLogger (io.netty.handler.codec.http2.Http2OutboundFrameLogger)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 DefaultHttp2Connection (io.netty.handler.codec.http2.DefaultHttp2Connection)2 DefaultHttp2LocalFlowController (io.netty.handler.codec.http2.DefaultHttp2LocalFlowController)2 Http2Connection (io.netty.handler.codec.http2.Http2Connection)2 Http2ConnectionEncoder (io.netty.handler.codec.http2.Http2ConnectionEncoder)2 Http2FrameLogger (io.netty.handler.codec.http2.Http2FrameLogger)2 Http2Settings (io.netty.handler.codec.http2.Http2Settings)2 StreamBufferingEncoder (io.netty.handler.codec.http2.StreamBufferingEncoder)2 GrpcHttp2ClientHeadersDecoder (io.grpc.netty.GrpcHttp2HeadersDecoder.GrpcHttp2ClientHeadersDecoder)1 GrpcHttp2ServerHeadersDecoder (io.grpc.netty.GrpcHttp2HeadersDecoder.GrpcHttp2ServerHeadersDecoder)1 DefaultHttp2ConnectionDecoder (io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder)1