Search in sources :

Example 16 with Http2Connection

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

the class Http2ClientPipelineInitializer method initChannel.

@Override
protected void initChannel(NioSocketChannel channel) throws Exception {
    Http2Connection connection = new DefaultHttp2Connection(false);
    channel.attr(HTTP2_CONNECTION_ATTR_KEY).set(connection);
    channel.attr(CALLBACK_ATTR_KEY).set(connection.newKey());
    channel.attr(CHANNEL_POOL_HANDLE_ATTR_KEY).set(connection.newKey());
    Http2InitializerHandler initializerHandler = new Http2InitializerHandler(_maxHeaderSize, _maxChunkSize, _maxResponseSize, _streamingTimeout, _scheduler, connection, _sslContext, _sslParameters);
    channel.pipeline().addLast("initializerHandler", initializerHandler);
}
Also used : DefaultHttp2Connection(io.netty.handler.codec.http2.DefaultHttp2Connection) DefaultHttp2Connection(io.netty.handler.codec.http2.DefaultHttp2Connection) Http2Connection(io.netty.handler.codec.http2.Http2Connection)

Example 17 with Http2Connection

use of io.netty.handler.codec.http2.Http2Connection 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 18 with Http2Connection

use of io.netty.handler.codec.http2.Http2Connection 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 19 with Http2Connection

use of io.netty.handler.codec.http2.Http2Connection 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 20 with Http2Connection

use of io.netty.handler.codec.http2.Http2Connection in project vert.x by eclipse.

the class Http2ConnectionBase method checkShutdown.

// Private
private void checkShutdown() {
    Handler<Void> shutdownHandler;
    synchronized (this) {
        if (shutdown) {
            return;
        }
        Http2Connection conn = handler.connection();
        if ((!conn.goAwayReceived() && !conn.goAwaySent()) || conn.numActiveStreams() > 0) {
            return;
        }
        shutdown = true;
        shutdownHandler = this.shutdownHandler;
    }
    doShutdown(shutdownHandler);
}
Also used : Http2Connection(io.netty.handler.codec.http2.Http2Connection)

Aggregations

Http2Connection (io.netty.handler.codec.http2.Http2Connection)19 DefaultHttp2Connection (io.netty.handler.codec.http2.DefaultHttp2Connection)14 Http2ConnectionDecoder (io.netty.handler.codec.http2.Http2ConnectionDecoder)8 Http2Settings (io.netty.handler.codec.http2.Http2Settings)8 DefaultHttp2ConnectionEncoder (io.netty.handler.codec.http2.DefaultHttp2ConnectionEncoder)7 Http2ConnectionEncoder (io.netty.handler.codec.http2.Http2ConnectionEncoder)6 DefaultHttp2ConnectionDecoder (io.netty.handler.codec.http2.DefaultHttp2ConnectionDecoder)5 DefaultHttp2FrameReader (io.netty.handler.codec.http2.DefaultHttp2FrameReader)5 Http2Stream (io.netty.handler.codec.http2.Http2Stream)5 Bootstrap (io.netty.bootstrap.Bootstrap)4 Channel (io.netty.channel.Channel)4 ChannelFuture (io.netty.channel.ChannelFuture)4 ChannelPipeline (io.netty.channel.ChannelPipeline)4 DefaultHttp2FrameWriter (io.netty.handler.codec.http2.DefaultHttp2FrameWriter)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)3 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)3 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)3 DefaultHttp2LocalFlowController (io.netty.handler.codec.http2.DefaultHttp2LocalFlowController)3 Http2ConnectionHandler (io.netty.handler.codec.http2.Http2ConnectionHandler)3