use of com.netflix.client.ClientException in project ribbon by Netflix.
the class NettyClientTest method testLoadBalancerThrottle.
@Test
public void testLoadBalancerThrottle() throws Exception {
HttpClientRequest<ByteBuf> request = HttpClientRequest.createGet("/testAsync/throttle");
IClientConfig config = DefaultClientConfigImpl.getClientConfigWithDefaultValues().set(IClientConfigKey.Keys.MaxAutoRetriesNextServer, 1).set(IClientConfigKey.Keys.OkToRetryOnAllOperations, true);
BaseLoadBalancer lb = new BaseLoadBalancer(new DummyPing(), new AvailabilityFilteringRule());
LoadBalancingHttpClient<ByteBuf, ByteBuf> lbObservables = RibbonTransport.newHttpClient(lb, config);
Server server = new Server(host, port);
lb.setServersList(Lists.newArrayList(server, server, server));
Observable<HttpClientResponse<ByteBuf>> response = lbObservables.submit(request);
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<Throwable> error = new AtomicReference<Throwable>();
response.subscribe(new Action1<HttpClientResponse<ByteBuf>>() {
@Override
public void call(HttpClientResponse<ByteBuf> t1) {
System.err.println("Get response: " + t1.getStatus().code());
latch.countDown();
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable t1) {
error.set(t1);
latch.countDown();
}
}, new Action0() {
@Override
public void call() {
Thread.dumpStack();
latch.countDown();
}
});
latch.await();
assertTrue(error.get() instanceof ClientException);
ClientException ce = (ClientException) error.get();
assertTrue(ce.toString(), ce.getErrorType() == ClientException.ErrorType.NUMBEROF_RETRIES_NEXTSERVER_EXCEEDED);
assertEquals(2, lbObservables.getServerStats(server).getSuccessiveConnectionFailureCount());
}
use of com.netflix.client.ClientException in project feign by OpenFeign.
the class RibbonClient method execute.
@Override
public Response execute(Request request, Request.Options options) throws IOException {
try {
URI asUri = URI.create(request.url());
String clientName = asUri.getHost();
URI uriWithoutHost = cleanUrl(request.url(), clientName);
LBClient.RibbonRequest ribbonRequest = new LBClient.RibbonRequest(delegate, request, uriWithoutHost);
return lbClient(clientName).executeWithLoadBalancer(ribbonRequest, new FeignOptionsClientConfig(options)).toResponse();
} catch (ClientException e) {
propagateFirstIOException(e);
throw new RuntimeException(e);
}
}
use of com.netflix.client.ClientException in project feign by OpenFeign.
the class PropagateFirstIOExceptionTest method propagatesDoubleNestedIOE.
/**
* Happened in practice; a blocking observable wrapped the connect exception in a runtime
* exception
*/
@Test
public void propagatesDoubleNestedIOE() throws IOException {
thrown.expect(ConnectException.class);
RibbonClient.propagateFirstIOException(new ClientException(new RuntimeException(new ConnectException())));
}
use of com.netflix.client.ClientException in project feign by OpenFeign.
the class PropagateFirstIOExceptionTest method propagatesNestedIOE.
@Test
public void propagatesNestedIOE() throws IOException {
thrown.expect(IOException.class);
RibbonClient.propagateFirstIOException(new ClientException(new IOException()));
}
Aggregations