Search in sources :

Example 36 with ServiceUnavailableException

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

the class TestScatterGather method testBuildSGEntityRequests.

public static void testBuildSGEntityRequests(int endPointsNum, int partitionNum, RootBuilderWrapper<Long, Greeting> builders) throws URISyntaxException, RestException, ServiceUnavailableException {
    final int NUM_ENDPOINTS = endPointsNum;
    ConsistentHashKeyMapper mapper;
    if (partitionNum > 0) {
        mapper = getKeyToHostMapper(endPointsNum, partitionNum);
    } else {
        mapper = getKeyToHostMapper(endPointsNum);
    }
    ScatterGatherBuilder<Greeting> sg = new ScatterGatherBuilder<Greeting>(mapper);
    final int NUM_IDS = 100;
    Long[] ids = generateIds(NUM_IDS);
    Map<Long, Greeting> updates = generateUpdates(ids);
    testBuildSGGetEntityRequests(NUM_ENDPOINTS, sg, ids);
    testBuildSGDeleteRequests(NUM_ENDPOINTS, sg, ids, builders);
    testBuildSGUpdateRequests(NUM_ENDPOINTS, sg, updates, builders);
}
Also used : Greeting(com.linkedin.restli.examples.greetings.api.Greeting) ConsistentHashKeyMapper(com.linkedin.d2.balancer.util.hashing.ConsistentHashKeyMapper)

Aggregations

URI (java.net.URI)16 ServiceProperties (com.linkedin.d2.balancer.properties.ServiceProperties)15 Test (org.testng.annotations.Test)14 ClusterProperties (com.linkedin.d2.balancer.properties.ClusterProperties)12 UriProperties (com.linkedin.d2.balancer.properties.UriProperties)12 ServiceUnavailableException (com.linkedin.d2.balancer.ServiceUnavailableException)11 HashMap (java.util.HashMap)11 ArrayList (java.util.ArrayList)10 CountDownLatch (java.util.concurrent.CountDownLatch)10 DegraderLoadBalancerStrategyFactoryV3 (com.linkedin.d2.balancer.strategies.degrader.DegraderLoadBalancerStrategyFactoryV3)9 RequestContext (com.linkedin.r2.message.RequestContext)9 URIRequest (com.linkedin.d2.balancer.util.URIRequest)7 PropertyEventShutdownCallback (com.linkedin.d2.discovery.event.PropertyEventThread.PropertyEventShutdownCallback)7 Map (java.util.Map)7 None (com.linkedin.common.util.None)6 SimpleLoadBalancerSimulation (com.linkedin.d2.balancer.simulator.SimpleLoadBalancerSimulation)6 LoadBalancerStrategy (com.linkedin.d2.balancer.strategies.LoadBalancerStrategy)6 RandomLoadBalancerStrategyFactory (com.linkedin.d2.balancer.strategies.random.RandomLoadBalancerStrategyFactory)6 TransportClientFactory (com.linkedin.r2.transport.common.TransportClientFactory)6 HashSet (java.util.HashSet)6