Search in sources :

Example 1 with ReadTimeoutException

use of io.netty.handler.timeout.ReadTimeoutException in project iep by Netflix.

the class RxHttpTest method readTimeoutDoesntRetry.

@Test
public void readTimeoutDoesntRetry() throws Exception {
    // set(client + ".niws.client.ReadTimeout", "100");
    set(client + ".niws.client.RetryReadTimeouts", "false");
    int code = 200;
    statusCode.set(code);
    AtomicIntegerArray expected = copy(statusCounts);
    expected.addAndGet(code, 1);
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicReference<Throwable> throwable = new AtomicReference<>();
    rxHttp.get(uri("/readTimeout")).subscribe(Actions.empty(), t -> {
        throwable.set(t);
        latch.countDown();
    }, latch::countDown);
    latch.await();
    Assert.assertTrue(throwable.get() instanceof ReadTimeoutException);
    assertEquals(expected, statusCounts);
}
Also used : AtomicIntegerArray(java.util.concurrent.atomic.AtomicIntegerArray) ReadTimeoutException(io.netty.handler.timeout.ReadTimeoutException) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 2 with ReadTimeoutException

use of io.netty.handler.timeout.ReadTimeoutException in project flink by apache.

the class FanOutRecordPublisherTest method testSubscribeToShardIgnoresReadTimeoutInRetryPolicy.

@Test
public void testSubscribeToShardIgnoresReadTimeoutInRetryPolicy() throws Exception {
    Properties efoProperties = createEfoProperties();
    efoProperties.setProperty(SUBSCRIBE_TO_SHARD_RETRIES, String.valueOf(EXPECTED_SUBSCRIBE_TO_SHARD_RETRIES));
    FanOutRecordPublisherConfiguration configuration = new FanOutRecordPublisherConfiguration(efoProperties, emptyList());
    ReadTimeoutException retryableError = ReadTimeoutException.INSTANCE;
    FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2 kinesis = FakeKinesisFanOutBehavioursFactory.errorDuringSubscription(retryableError);
    FullJitterBackoff backoff = mock(FullJitterBackoff.class);
    FanOutRecordPublisher recordPublisher = new FanOutRecordPublisher(latest(), "arn", createDummyStreamShardHandle(), kinesis, configuration, backoff);
    int count = 0;
    while (recordPublisher.run(new TestConsumer()) == RecordPublisherRunResult.INCOMPLETE) {
        if (++count > EXPECTED_SUBSCRIBE_TO_SHARD_RETRIES) {
            break;
        }
    }
    // No exception is thrown, but we still backoff.
    verify(backoff, times(EXPECTED_SUBSCRIBE_TO_SHARD_RETRIES + 1)).calculateFullJitterBackoff(anyLong(), anyLong(), anyDouble(), anyInt());
}
Also used : ReadTimeoutException(io.netty.handler.timeout.ReadTimeoutException) FakeKinesisFanOutBehavioursFactory(org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory) Properties(java.util.Properties) SubscriptionErrorKinesisV2(org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2) FullJitterBackoff(org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff) TestConsumer(org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer) Test(org.junit.Test)

Example 3 with ReadTimeoutException

use of io.netty.handler.timeout.ReadTimeoutException in project zuul by Netflix.

the class ClientResponseWriter method exceptionCaught.

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
    int status = 500;
    final String errorMsg = "ClientResponseWriter caught exception in client connection pipeline: " + ChannelUtils.channelInfoForLogging(ctx.channel());
    if (cause instanceof ZuulException) {
        final ZuulException ze = (ZuulException) cause;
        status = ze.getStatusCode();
        LOG.error(errorMsg, cause);
    } else if (cause instanceof ReadTimeoutException) {
        LOG.error(errorMsg + ", Read timeout fired");
        status = 504;
    } else {
        LOG.error(errorMsg, cause);
    }
    if (isHandlingRequest && !startedSendingResponseToClient && ctx.channel().isActive()) {
        final HttpResponse httpResponse = new DefaultFullHttpResponse(HTTP_1_1, HttpResponseStatus.valueOf(status));
        ctx.writeAndFlush(httpResponse).addListener(ChannelFutureListener.CLOSE);
        startedSendingResponseToClient = true;
    } else {
        ctx.close();
    }
}
Also used : DefaultFullHttpResponse(io.netty.handler.codec.http.DefaultFullHttpResponse) ReadTimeoutException(io.netty.handler.timeout.ReadTimeoutException) ZuulException(com.netflix.zuul.exception.ZuulException) DefaultHttpResponse(io.netty.handler.codec.http.DefaultHttpResponse) DefaultFullHttpResponse(io.netty.handler.codec.http.DefaultFullHttpResponse) HttpResponse(io.netty.handler.codec.http.HttpResponse)

Example 4 with ReadTimeoutException

use of io.netty.handler.timeout.ReadTimeoutException in project iep by Netflix.

the class RxHttpTest method readTimeout.

@Test
public void readTimeout() throws Exception {
    // set(client + ".niws.client.ReadTimeout", "100");
    int code = 200;
    statusCode.set(code);
    AtomicIntegerArray expected = copy(statusCounts);
    expected.addAndGet(code, 3);
    final CountDownLatch latch = new CountDownLatch(1);
    final AtomicReference<Throwable> throwable = new AtomicReference<>();
    rxHttp.get(uri("/readTimeout")).subscribe(Actions.empty(), t -> {
        throwable.set(t);
        latch.countDown();
    }, latch::countDown);
    latch.await();
    Assert.assertTrue(throwable.get() instanceof ReadTimeoutException);
    assertEquals(expected, statusCounts);
}
Also used : AtomicIntegerArray(java.util.concurrent.atomic.AtomicIntegerArray) ReadTimeoutException(io.netty.handler.timeout.ReadTimeoutException) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 5 with ReadTimeoutException

use of io.netty.handler.timeout.ReadTimeoutException in project zuul by Netflix.

the class RequestAttempt method setException.

public void setException(Throwable t) {
    if (t != null) {
        if (t instanceof ReadTimeoutException) {
            error = "READ_TIMEOUT";
            exceptionType = t.getClass().getSimpleName();
        } else if (t instanceof OriginConnectException) {
            OriginConnectException oce = (OriginConnectException) t;
            if (oce.getErrorType() != null) {
                error = oce.getErrorType().toString();
            } else {
                error = "ORIGIN_CONNECT_ERROR";
            }
            final Throwable cause = t.getCause();
            if (cause != null) {
                exceptionType = t.getCause().getClass().getSimpleName();
            } else {
                exceptionType = t.getClass().getSimpleName();
            }
        } else if (t instanceof OutboundException) {
            OutboundException obe = (OutboundException) t;
            error = obe.getOutboundErrorType().toString();
            exceptionType = OutboundException.class.getSimpleName();
        } else if (t instanceof SSLHandshakeException) {
            error = t.getMessage();
            exceptionType = t.getClass().getSimpleName();
            cause = t.getCause().getMessage();
        } else {
            error = t.getMessage();
            exceptionType = t.getClass().getSimpleName();
            cause = Throwables.getStackTraceAsString(t);
        }
    }
}
Also used : ReadTimeoutException(io.netty.handler.timeout.ReadTimeoutException) OriginConnectException(com.netflix.zuul.netty.connectionpool.OriginConnectException) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) OutboundException(com.netflix.zuul.exception.OutboundException)

Aggregations

ReadTimeoutException (io.netty.handler.timeout.ReadTimeoutException)6 Test (org.junit.Test)3 CountDownLatch (java.util.concurrent.CountDownLatch)2 AtomicIntegerArray (java.util.concurrent.atomic.AtomicIntegerArray)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 OutboundException (com.netflix.zuul.exception.OutboundException)1 ZuulException (com.netflix.zuul.exception.ZuulException)1 OriginConnectException (com.netflix.zuul.netty.connectionpool.OriginConnectException)1 DefaultFullHttpResponse (io.netty.handler.codec.http.DefaultFullHttpResponse)1 DefaultHttpResponse (io.netty.handler.codec.http.DefaultHttpResponse)1 HttpResponse (io.netty.handler.codec.http.HttpResponse)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 SSLHandshakeException (javax.net.ssl.SSLHandshakeException)1 FullJitterBackoff (org.apache.flink.streaming.connectors.kinesis.proxy.FullJitterBackoff)1 FakeKinesisFanOutBehavioursFactory (org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory)1 SubscriptionErrorKinesisV2 (org.apache.flink.streaming.connectors.kinesis.testutils.FakeKinesisFanOutBehavioursFactory.SubscriptionErrorKinesisV2)1 TestConsumer (org.apache.flink.streaming.connectors.kinesis.testutils.TestUtils.TestConsumer)1