Search in sources :

Example 1 with ChannelDiagnostics

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

the class MultiplexedChannelRecord method acquireClaimedStream.

void acquireClaimedStream(Promise<Channel> promise) {
    doInEventLoop(connection.eventLoop(), () -> {
        if (state != RecordState.OPEN) {
            String message;
            // GOAWAY
            if (state == RecordState.CLOSED_TO_NEW) {
                message = String.format("Connection %s received GOAWAY with Last Stream ID %d. Unable to open new " + "streams on this connection.", connection, lastStreamId);
            } else {
                message = String.format("Connection %s was closed while acquiring new stream.", connection);
            }
            log.warn(connection, () -> message);
            promise.setFailure(new IOException(message));
            return;
        }
        Future<Http2StreamChannel> streamFuture = new Http2StreamChannelBootstrap(connection).open();
        streamFuture.addListener((GenericFutureListener<Future<Http2StreamChannel>>) future -> {
            warnIfNotInEventLoop(connection.eventLoop());
            if (!future.isSuccess()) {
                promise.setFailure(future.cause());
                return;
            }
            Http2StreamChannel channel = future.getNow();
            channel.pipeline().addLast(UnusedChannelExceptionHandler.getInstance());
            channel.attr(ChannelAttributeKey.HTTP2_FRAME_STREAM).set(channel.stream());
            channel.attr(ChannelAttributeKey.CHANNEL_DIAGNOSTICS).set(new ChannelDiagnostics(channel));
            childChannels.put(channel.id(), channel);
            promise.setSuccess(channel);
            if (closeIfIdleTask == null && allowedIdleConnectionTimeMillis != null) {
                enableCloseIfIdleTask();
            }
        });
    }, promise);
}
Also used : ScheduledFuture(io.netty.util.concurrent.ScheduledFuture) ChannelAttributeKey(software.amazon.awssdk.http.nio.netty.internal.ChannelAttributeKey) ChannelId(io.netty.channel.ChannelId) NettyUtils.warnIfNotInEventLoop(software.amazon.awssdk.http.nio.netty.internal.utils.NettyUtils.warnIfNotInEventLoop) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) NettyUtils.doInEventLoop(software.amazon.awssdk.http.nio.netty.internal.utils.NettyUtils.doInEventLoop) Http2GoAwayFrame(io.netty.handler.codec.http2.Http2GoAwayFrame) ArrayList(java.util.ArrayList) Http2StreamChannelBootstrap(io.netty.handler.codec.http2.Http2StreamChannelBootstrap) Duration(java.time.Duration) Map(java.util.Map) ChannelDiagnostics(software.amazon.awssdk.http.nio.netty.internal.ChannelDiagnostics) Promise(io.netty.util.concurrent.Promise) GenericFutureListener(io.netty.util.concurrent.GenericFutureListener) IOException(java.io.IOException) UnusedChannelExceptionHandler(software.amazon.awssdk.http.nio.netty.internal.UnusedChannelExceptionHandler) NettyClientLogger(software.amazon.awssdk.http.nio.netty.internal.utils.NettyClientLogger) Channel(io.netty.channel.Channel) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) AtomicLong(java.util.concurrent.atomic.AtomicLong) List(java.util.List) ChannelOutboundInvoker(io.netty.channel.ChannelOutboundInvoker) SdkInternalApi(software.amazon.awssdk.annotations.SdkInternalApi) Http2StreamChannel(io.netty.handler.codec.http2.Http2StreamChannel) Future(io.netty.util.concurrent.Future) Http2StreamChannelBootstrap(io.netty.handler.codec.http2.Http2StreamChannelBootstrap) ScheduledFuture(io.netty.util.concurrent.ScheduledFuture) CompletableFuture(java.util.concurrent.CompletableFuture) Future(io.netty.util.concurrent.Future) IOException(java.io.IOException) ChannelDiagnostics(software.amazon.awssdk.http.nio.netty.internal.ChannelDiagnostics) Http2StreamChannel(io.netty.handler.codec.http2.Http2StreamChannel)

Example 2 with ChannelDiagnostics

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

the class NettyUtils method closedChannelMessage.

public static String closedChannelMessage(Channel channel) {
    ChannelDiagnostics channelDiagnostics = channel.attr(CHANNEL_DIAGNOSTICS).get();
    ChannelDiagnostics parentChannelDiagnostics = channel.parent() != null ? channel.parent().attr(CHANNEL_DIAGNOSTICS).get() : null;
    StringBuilder error = new StringBuilder();
    error.append("The connection was closed during the request. The request will usually succeed on a retry, but if it does" + " not: consider disabling any proxies you have configured, enabling debug logging, or performing a TCP" + " dump to identify the root cause. If this is a streaming operation, validate that data is being read or" + " written in a timely manner.");
    if (channelDiagnostics != null) {
        error.append(" Channel Information: ").append(channelDiagnostics);
        if (parentChannelDiagnostics != null) {
            error.append(" Parent Channel Information: ").append(parentChannelDiagnostics);
        }
    }
    return error.toString();
}
Also used : ChannelDiagnostics(software.amazon.awssdk.http.nio.netty.internal.ChannelDiagnostics)

Aggregations

ChannelDiagnostics (software.amazon.awssdk.http.nio.netty.internal.ChannelDiagnostics)2 Channel (io.netty.channel.Channel)1 ChannelId (io.netty.channel.ChannelId)1 ChannelOutboundInvoker (io.netty.channel.ChannelOutboundInvoker)1 Http2GoAwayFrame (io.netty.handler.codec.http2.Http2GoAwayFrame)1 Http2StreamChannel (io.netty.handler.codec.http2.Http2StreamChannel)1 Http2StreamChannelBootstrap (io.netty.handler.codec.http2.Http2StreamChannelBootstrap)1 Future (io.netty.util.concurrent.Future)1 GenericFutureListener (io.netty.util.concurrent.GenericFutureListener)1 Promise (io.netty.util.concurrent.Promise)1 ScheduledFuture (io.netty.util.concurrent.ScheduledFuture)1 IOException (java.io.IOException)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 TimeUnit (java.util.concurrent.TimeUnit)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1