Search in sources :

Example 16 with RewriteLoadBalancerClient

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

the class RewriteLoadBalancerClientTestStreamRequest method testPathAppend.

@Test
public void testPathAppend() {
    URI uri = URI.create("http://test.linkedin.com:9876/test");
    String serviceName = "HistoryService";
    TestClient wrappedClient = new TestClient();
    RewriteLoadBalancerClient client = new RewriteLoadBalancerClient(serviceName, uri, wrappedClient);
    assertEquals(client.getUri(), uri);
    assertEquals(client.getServiceName(), serviceName);
    StreamRequest streamRequest;
    Map<String, String> restWireAttrs = new HashMap<>();
    TestTransportCallback<StreamResponse> restCallback = new TestTransportCallback<>();
    streamRequest = getRequest("d2://HistoryService");
    client.streamRequest(streamRequest, new RequestContext(), restWireAttrs, restCallback);
    checkRewrite(wrappedClient, streamRequest, restCallback, "http://test.linkedin.com:9876/test");
    streamRequest = getRequest("d2://HistoryService/");
    client.streamRequest(streamRequest, new RequestContext(), restWireAttrs, restCallback);
    checkRewrite(wrappedClient, streamRequest, restCallback, "http://test.linkedin.com:9876/test/");
    streamRequest = getRequest("d2://HistoryService//");
    client.streamRequest(streamRequest, new RequestContext(), restWireAttrs, restCallback);
    checkRewrite(wrappedClient, streamRequest, restCallback, "http://test.linkedin.com:9876/test//");
    streamRequest = getRequest("d2://HistoryService/foo");
    client.streamRequest(streamRequest, new RequestContext(), restWireAttrs, restCallback);
    checkRewrite(wrappedClient, streamRequest, restCallback, "http://test.linkedin.com:9876/test/foo");
    streamRequest = getRequest("d2://HistoryService/foo/");
    client.streamRequest(streamRequest, new RequestContext(), restWireAttrs, restCallback);
    checkRewrite(wrappedClient, streamRequest, restCallback, "http://test.linkedin.com:9876/test/foo/");
}
Also used : HashMap(java.util.HashMap) StreamResponse(com.linkedin.r2.message.stream.StreamResponse) TestTransportCallback(com.linkedin.d2.balancer.clients.DegraderTrackerClientTest.TestTransportCallback) RequestContext(com.linkedin.r2.message.RequestContext) URI(java.net.URI) StreamRequest(com.linkedin.r2.message.stream.StreamRequest) Test(org.testng.annotations.Test)

Aggregations

RequestContext (com.linkedin.r2.message.RequestContext)16 URI (java.net.URI)16 HashMap (java.util.HashMap)16 Test (org.testng.annotations.Test)13 TestTransportCallback (com.linkedin.d2.balancer.clients.DegraderTrackerClientTest.TestTransportCallback)10 FutureCallback (com.linkedin.common.callback.FutureCallback)6 None (com.linkedin.common.util.None)6 DarkClusterConfigMap (com.linkedin.d2.DarkClusterConfigMap)6 ClusterProperties (com.linkedin.d2.balancer.properties.ClusterProperties)6 PartitionData (com.linkedin.d2.balancer.properties.PartitionData)6 ServiceProperties (com.linkedin.d2.balancer.properties.ServiceProperties)6 UriProperties (com.linkedin.d2.balancer.properties.UriProperties)6 LoadBalancerStrategy (com.linkedin.d2.balancer.strategies.LoadBalancerStrategy)6 TransportClientFactory (com.linkedin.r2.transport.common.TransportClientFactory)6 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6 Map (java.util.Map)6 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)6 RewriteLoadBalancerClient (com.linkedin.d2.balancer.clients.RewriteLoadBalancerClient)5 LoadBalancerStrategyFactory (com.linkedin.d2.balancer.strategies.LoadBalancerStrategyFactory)5