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);
}
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());
}
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();
}
}
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);
}
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);
}
}
}
Aggregations