use of com.linkedin.d2.balancer.PartitionedLoadBalancerTestState in project rest.li by linkedin.
the class TestAllPartitionsRequestBuilder method getKeyToHostMapper.
private ConsistentHashKeyMapper getKeyToHostMapper(int partitionNum, List<URI> expectedUris, RingFactory<URI> ringFactory) throws URISyntaxException {
Map<URI, Map<Integer, PartitionData>> partitionDescriptions = new HashMap<URI, Map<Integer, PartitionData>>();
for (int i = 0; i < partitionNum; i++) {
final URI foo = new URI("http://foo" + i + ".com");
expectedUris.add(foo);
Map<Integer, PartitionData> foo1Data = new HashMap<Integer, PartitionData>();
foo1Data.put(i, new PartitionData(1.0));
partitionDescriptions.put(foo, foo1Data);
}
List<LoadBalancerState.SchemeStrategyPair> orderedStrategies = new ArrayList<LoadBalancerState.SchemeStrategyPair>();
LoadBalancerStrategy strategy = new ConsistentHashKeyMapperTest.TestLoadBalancerStrategy(partitionDescriptions, ringFactory);
orderedStrategies.add(new LoadBalancerState.SchemeStrategyPair("http", strategy));
PartitionAccessor accessor = new ConsistentHashKeyMapperTest.TestPartitionAccessor();
SimpleLoadBalancer balancer = new SimpleLoadBalancer(new PartitionedLoadBalancerTestState("clusterName", "serviceName", "path", "strategyName", partitionDescriptions, orderedStrategies, accessor));
return new ConsistentHashKeyMapper(balancer, balancer);
}
Aggregations