Search in sources :

Example 1 with HTTP2_MULTIPLEXED_CHANNEL_POOL

use of software.amazon.awssdk.http.nio.netty.internal.ChannelAttributeKey.HTTP2_MULTIPLEXED_CHANNEL_POOL in project aws-sdk-java-v2 by aws.

the class Http2MultiplexedChannelPool method acquireStreamOnNewConnection.

private void acquireStreamOnNewConnection(Promise<Channel> promise) {
    Future<Channel> newConnectionAcquire = connectionPool.acquire();
    newConnectionAcquire.addListener(f -> {
        if (!newConnectionAcquire.isSuccess()) {
            promise.setFailure(newConnectionAcquire.cause());
            return;
        }
        Channel parentChannel = newConnectionAcquire.getNow();
        try {
            parentChannel.attr(HTTP2_MULTIPLEXED_CHANNEL_POOL).set(this);
            // When the protocol future is completed on the new connection, we're ready for new streams to be added to it.
            parentChannel.attr(PROTOCOL_FUTURE).get().thenAccept(protocol -> acquireStreamOnFreshConnection(promise, parentChannel, protocol)).exceptionally(throwable -> failAndCloseParent(promise, parentChannel, throwable));
        } catch (Throwable e) {
            failAndCloseParent(promise, parentChannel, e);
        }
    });
}
Also used : AttributeKey(io.netty.util.AttributeKey) HTTP2_MULTIPLEXED_CHANNEL_POOL(software.amazon.awssdk.http.nio.netty.internal.ChannelAttributeKey.HTTP2_MULTIPLEXED_CHANNEL_POOL) Protocol(software.amazon.awssdk.http.Protocol) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CompletableFuture(java.util.concurrent.CompletableFuture) BetterFixedChannelPool(software.amazon.awssdk.http.nio.netty.internal.utils.BetterFixedChannelPool) NettyUtils.doInEventLoop(software.amazon.awssdk.http.nio.netty.internal.utils.NettyUtils.doInEventLoop) MAX_CONCURRENT_STREAMS(software.amazon.awssdk.http.nio.netty.internal.ChannelAttributeKey.MAX_CONCURRENT_STREAMS) Sharable(io.netty.channel.ChannelHandler.Sharable) ArrayList(java.util.ArrayList) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) HTTP2_INITIAL_WINDOW_SIZE(software.amazon.awssdk.http.nio.netty.internal.ChannelAttributeKey.HTTP2_INITIAL_WINDOW_SIZE) Http2StreamChannelBootstrap(io.netty.handler.codec.http2.Http2StreamChannelBootstrap) Http2Exception(io.netty.handler.codec.http2.Http2Exception) Duration(java.time.Duration) Http2Stream(io.netty.handler.codec.http2.Http2Stream) SdkTestInternalApi(software.amazon.awssdk.annotations.SdkTestInternalApi) SdkChannelPool(software.amazon.awssdk.http.nio.netty.internal.SdkChannelPool) ChannelDuplexHandler(io.netty.channel.ChannelDuplexHandler) Validate(software.amazon.awssdk.utils.Validate) EventLoopGroup(io.netty.channel.EventLoopGroup) Promise(io.netty.util.concurrent.Promise) MetricCollector(software.amazon.awssdk.metrics.MetricCollector) ClosedChannelException(java.nio.channels.ClosedChannelException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HttpMetric(software.amazon.awssdk.http.HttpMetric) NettyUtils(software.amazon.awssdk.http.nio.netty.internal.utils.NettyUtils) Set(java.util.Set) IOException(java.io.IOException) PromiseCombiner(io.netty.util.concurrent.PromiseCombiner) EventLoop(io.netty.channel.EventLoop) HTTP2_CONNECTION(software.amazon.awssdk.http.nio.netty.internal.ChannelAttributeKey.HTTP2_CONNECTION) NettyClientLogger(software.amazon.awssdk.http.nio.netty.internal.utils.NettyClientLogger) Channel(io.netty.channel.Channel) TimeUnit(java.util.concurrent.TimeUnit) PROTOCOL_FUTURE(software.amazon.awssdk.http.nio.netty.internal.ChannelAttributeKey.PROTOCOL_FUTURE) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Http2Connection(io.netty.handler.codec.http2.Http2Connection) ChannelPool(io.netty.channel.pool.ChannelPool) Http2LocalFlowController(io.netty.handler.codec.http2.Http2LocalFlowController) SdkInternalApi(software.amazon.awssdk.annotations.SdkInternalApi) Future(io.netty.util.concurrent.Future) Channel(io.netty.channel.Channel)

Aggregations

Channel (io.netty.channel.Channel)1 ChannelDuplexHandler (io.netty.channel.ChannelDuplexHandler)1 Sharable (io.netty.channel.ChannelHandler.Sharable)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 EventLoop (io.netty.channel.EventLoop)1 EventLoopGroup (io.netty.channel.EventLoopGroup)1 ChannelPool (io.netty.channel.pool.ChannelPool)1 Http2Connection (io.netty.handler.codec.http2.Http2Connection)1 Http2Exception (io.netty.handler.codec.http2.Http2Exception)1 Http2LocalFlowController (io.netty.handler.codec.http2.Http2LocalFlowController)1 Http2Stream (io.netty.handler.codec.http2.Http2Stream)1 Http2StreamChannelBootstrap (io.netty.handler.codec.http2.Http2StreamChannelBootstrap)1 AttributeKey (io.netty.util.AttributeKey)1 Future (io.netty.util.concurrent.Future)1 Promise (io.netty.util.concurrent.Promise)1 PromiseCombiner (io.netty.util.concurrent.PromiseCombiner)1 IOException (java.io.IOException)1 ClosedChannelException (java.nio.channels.ClosedChannelException)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1