Search in sources :

Example 6 with KeyMapper

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

the class TestScatterGather method testScatterGatherEntityLoadBalancerIntegration.

@Test(dataProvider = "requestBuilderDataProvider")
public static void testScatterGatherEntityLoadBalancerIntegration(RootBuilderWrapper<Long, Greeting> builders) throws Exception {
    SimpleLoadBalancer loadBalancer = MockLBFactory.createLoadBalancer();
    KeyMapper keyMapper = new ConsistentHashKeyMapper(loadBalancer, new TestPartitionInfoProvider());
    try {
        keyMapper.mapKeysV2(URI.create("http://badurischeme/"), new HashSet<String>());
        Assert.fail("keyMapper should reject non-D2 URI scheme");
    } catch (IllegalArgumentException e) {
    // expected
    }
    ScatterGatherBuilder<Greeting> sg = new ScatterGatherBuilder<>(keyMapper);
    final int NUM_IDS = 20;
    Long[] requestIds = generateIds(NUM_IDS);
    Collection<ScatterGatherBuilder.KVRequestInfo<Long, EntityResponse<Greeting>>> scatterGatherRequests = buildScatterGatherGetEntityRequests(sg, requestIds);
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) SimpleLoadBalancer(com.linkedin.d2.balancer.simple.SimpleLoadBalancer) HostToKeyMapper(com.linkedin.d2.balancer.util.HostToKeyMapper) KeyMapper(com.linkedin.d2.balancer.KeyMapper) ConsistentHashKeyMapper(com.linkedin.d2.balancer.util.hashing.ConsistentHashKeyMapper) ConsistentHashKeyMapper(com.linkedin.d2.balancer.util.hashing.ConsistentHashKeyMapper) Test(org.testng.annotations.Test) RestLiIntegrationTest(com.linkedin.restli.examples.RestLiIntegrationTest)

Aggregations

Test (org.testng.annotations.Test)5 KeyMapper (com.linkedin.d2.balancer.KeyMapper)4 PartitionData (com.linkedin.d2.balancer.properties.PartitionData)3 SimpleLoadBalancer (com.linkedin.d2.balancer.simple.SimpleLoadBalancer)3 HostToKeyMapper (com.linkedin.d2.balancer.util.HostToKeyMapper)3 ConsistentHashKeyMapper (com.linkedin.d2.balancer.util.hashing.ConsistentHashKeyMapper)3 RestLiIntegrationTest (com.linkedin.restli.examples.RestLiIntegrationTest)3 Greeting (com.linkedin.restli.examples.greetings.api.Greeting)3 URI (java.net.URI)3 FutureCallback (com.linkedin.common.callback.FutureCallback)2 None (com.linkedin.common.util.None)2 ClusterProperties (com.linkedin.d2.balancer.properties.ClusterProperties)2 ServiceProperties (com.linkedin.d2.balancer.properties.ServiceProperties)2 UriProperties (com.linkedin.d2.balancer.properties.UriProperties)2 LoadBalancerStrategy (com.linkedin.d2.balancer.strategies.LoadBalancerStrategy)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 DarkClusterConfigMap (com.linkedin.d2.DarkClusterConfigMap)1