Search in sources :

Example 11 with DynamicClient

use of com.linkedin.d2.balancer.clients.DynamicClient in project rest.li by linkedin.

the class RetryClientTest method testRetry.

@Test
public void testRetry() throws Exception {
    SimpleLoadBalancer balancer = prepareLoadBalancer(Arrays.asList("http://test.linkedin.com/retry1", "http://test.linkedin.com/good"));
    DynamicClient dynamicClient = new DynamicClient(balancer, null);
    RetryClient client = new RetryClient(dynamicClient, 3);
    URI uri = URI.create("d2://retryService?arg1arg2");
    RestRequest restRequest = new RestRequestBuilder(uri).build();
    TrackerClientTest.TestCallback<RestResponse> restCallback = new TrackerClientTest.TestCallback<RestResponse>();
    client.restRequest(restRequest, restCallback);
    assertNull(restCallback.e);
    assertNotNull(restCallback.t);
}
Also used : RestRequest(com.linkedin.r2.message.rest.RestRequest) SimpleLoadBalancer(com.linkedin.d2.balancer.simple.SimpleLoadBalancer) RestResponse(com.linkedin.r2.message.rest.RestResponse) RestRequestBuilder(com.linkedin.r2.message.rest.RestRequestBuilder) URI(java.net.URI) Test(org.testng.annotations.Test)

Aggregations

RestRequest (com.linkedin.r2.message.rest.RestRequest)8 RestRequestBuilder (com.linkedin.r2.message.rest.RestRequestBuilder)8 RestResponse (com.linkedin.r2.message.rest.RestResponse)8 URI (java.net.URI)8 Test (org.testng.annotations.Test)6 DynamicClient (com.linkedin.d2.balancer.clients.DynamicClient)4 SimpleLoadBalancer (com.linkedin.d2.balancer.simple.SimpleLoadBalancer)4 Facilities (com.linkedin.d2.balancer.Facilities)2 TestCallback (com.linkedin.d2.balancer.clients.TrackerClientTest.TestCallback)2 DelegatingFacilities (com.linkedin.d2.balancer.util.DelegatingFacilities)2 RequestContext (com.linkedin.r2.message.RequestContext)2 ServiceUnavailableException (com.linkedin.d2.balancer.ServiceUnavailableException)1 RetryClient (com.linkedin.d2.balancer.clients.RetryClient)1 ClientFactoryProvider (com.linkedin.d2.balancer.util.ClientFactoryProvider)1 DirectoryProvider (com.linkedin.d2.balancer.util.DirectoryProvider)1 KeyMapperProvider (com.linkedin.d2.balancer.util.KeyMapperProvider)1 PropertyStoreException (com.linkedin.d2.discovery.stores.PropertyStoreException)1 TransportClientFactory (com.linkedin.r2.transport.common.TransportClientFactory)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1