Example usage for io.netty.handler.codec.http2 Http2Connection newKey

List of usage examples for io.netty.handler.codec.http2 Http2Connection newKey

Introduction

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

Prototype

PropertyKey newKey();

Source Link

Document

Creates a new key that is unique within this Http2Connection .

Usage

From source file:com.linkedin.r2.transport.http.client.Http2ClientPipelineInitializer.java

License:Apache License

@Override
protected void initChannel(NioSocketChannel channel) throws Exception {
    Http2Connection connection = new DefaultHttp2Connection(false /* not server */);
    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);
}

From source file:com.linkedin.r2.transport.http.client.Http2FrameListener.java

License:Apache License

public Http2FrameListener(ScheduledExecutorService scheduler, Http2Connection connection,
        Http2LifecycleManager lifecycleManager, long maxContentLength, long streamingTimeout) {
    _scheduler = scheduler;//www . j  av a2 s  . c o  m
    _connection = connection;
    _writerKey = connection.newKey();
    _lifecycleManager = lifecycleManager;
    _maxContentLength = maxContentLength;
    _streamingTimeout = streamingTimeout;
}

From source file:io.gatling.http.client.impl.Http2AppHandler.java

License:Apache License

Http2AppHandler(Http2Connection connection, Http2ConnectionHandler http2ConnectionHandler,
        ChannelPool channelPool, HttpClientConfig config) {
    this.connection = connection;
    this.propertyKey = connection.newKey();
    this.http2ConnectionHandler = http2ConnectionHandler;
    this.channelPool = channelPool;
    this.config = config;
}

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

License:Apache License

private NettyClientHandler(Http2ConnectionDecoder decoder, StreamBufferingEncoder encoder,
        Http2Settings settings, ClientTransportLifecycleManager lifecycleManager,
        KeepAliveManager keepAliveManager, Supplier<Stopwatch> stopwatchFactory,
        final Runnable tooManyPingsRunnable, TransportTracer transportTracer, Attributes eagAttributes,
        String authority) {// ww  w .ja  va 2 s  .  c  o  m
    super(/* channelUnused= */ null, decoder, encoder, settings);
    this.lifecycleManager = lifecycleManager;
    this.keepAliveManager = keepAliveManager;
    this.stopwatchFactory = stopwatchFactory;
    this.transportTracer = Preconditions.checkNotNull(transportTracer);
    this.eagAttributes = eagAttributes;
    this.authority = authority;
    this.attributes = Attributes.newBuilder().set(GrpcAttributes.ATTR_CLIENT_EAG_ATTRS, eagAttributes).build();

    // Set the frame listener on the decoder.
    decoder().frameListener(new FrameListener());

    Http2Connection connection = encoder.connection();
    streamKey = connection.newKey();

    connection.addListener(new Http2ConnectionAdapter() {
        @Override
        public void onGoAwayReceived(int lastStreamId, long errorCode, ByteBuf debugData) {
            byte[] debugDataBytes = ByteBufUtil.getBytes(debugData);
            goingAway(statusFromGoAway(errorCode, debugDataBytes));
            if (errorCode == Http2Error.ENHANCE_YOUR_CALM.code()) {
                String data = new String(debugDataBytes, UTF_8);
                logger.log(Level.WARNING, "Received GOAWAY with ENHANCE_YOUR_CALM. Debug data: {1}", data);
                if ("too_many_pings".equals(data)) {
                    tooManyPingsRunnable.run();
                }
            }
        }

        @Override
        public void onStreamActive(Http2Stream stream) {
            if (connection().numActiveStreams() == 1 && NettyClientHandler.this.keepAliveManager != null) {
                NettyClientHandler.this.keepAliveManager.onTransportActive();
            }
        }

        @Override
        public void onStreamClosed(Http2Stream stream) {
            // Although streams with CALL_OPTIONS_RPC_OWNED_BY_BALANCER are not marked as "in-use" in
            // the first place, we don't propagate that option here, and it's safe to reset the in-use
            // state for them, which will be a cheap no-op.
            inUseState.updateObjectInUse(stream, false);
            if (connection().numActiveStreams() == 0 && NettyClientHandler.this.keepAliveManager != null) {
                NettyClientHandler.this.keepAliveManager.onTransportIdle();
            }
        }
    });
}

From source file:org.jboss.aerogear.webpush.netty.WebPushFrameListener.java

License:Apache License

public void encoder(Http2ConnectionEncoder encoder) {
    this.encoder = encoder;
    Http2Connection connection = encoder.connection();
    pathPropertyKey = connection.newKey();
    resourcePropertyKey = connection.newKey();
    pushReceiptPropertyKey = connection.newKey();
    ttlPropertyKey = connection.newKey();
}